mirror of https://github.com/jellyfin/jellyfin.git
feat: add hw scale filter for videotoolbox
Signed-off-by: gnattu <gnattuoc@me.com>
This commit is contained in:
parent
03ef9aebfd
commit
44cb9f5fdd
|
@ -2954,6 +2954,13 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
{
|
{
|
||||||
arg2 = (isSizeFixed ? ':' : '=') + arg2;
|
arg2 = (isSizeFixed ? ':' : '=') + arg2;
|
||||||
}
|
}
|
||||||
|
if (string.Equals(hwScaleSuffix, "vt", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// VideoToolBox scaling filter requires different syntax
|
||||||
|
arg1 = isSizeFixed ? ("=" + outWidth.Value + ":" + outHeight.Value) : string.Empty;
|
||||||
|
// VideoToolBox does format conversion automatically
|
||||||
|
arg2 = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(hwScaleSuffix) && (isSizeFixed || isFormatFixed))
|
if (!string.IsNullOrEmpty(hwScaleSuffix) && (isSizeFixed || isFormatFixed))
|
||||||
{
|
{
|
||||||
|
@ -4980,6 +4987,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
var newfilters = new List<string>();
|
var newfilters = new List<string>();
|
||||||
var noOverlay = swFilterChain.OverlayFilters.Count == 0;
|
var noOverlay = swFilterChain.OverlayFilters.Count == 0;
|
||||||
var supportsHwDeint = _mediaEncoder.SupportsFilter("yadif_videotoolbox");
|
var supportsHwDeint = _mediaEncoder.SupportsFilter("yadif_videotoolbox");
|
||||||
|
var supportsHwScale = _mediaEncoder.SupportsFilter("scale_vt");
|
||||||
// fallback to software filters if we are using filters not supported by hardware yet.
|
// fallback to software filters if we are using filters not supported by hardware yet.
|
||||||
var useHardwareFilters = noOverlay && (!doDeintH2645 || supportsHwDeint);
|
var useHardwareFilters = noOverlay && (!doDeintH2645 || supportsHwDeint);
|
||||||
|
|
||||||
|
@ -4988,14 +4996,20 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
return swFilterChain;
|
return swFilterChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ffmpeg cannot use videotoolbox to scale
|
if (!supportsHwScale)
|
||||||
|
{
|
||||||
var swScaleFilter = GetSwScaleFilter(state, options, vidEncoder, inW, inH, threeDFormat, reqW, reqH, reqMaxW, reqMaxH);
|
var swScaleFilter = GetSwScaleFilter(state, options, vidEncoder, inW, inH, threeDFormat, reqW, reqH, reqMaxW, reqMaxH);
|
||||||
newfilters.Add(swScaleFilter);
|
newfilters.Add(swScaleFilter);
|
||||||
|
}
|
||||||
// hwupload on videotoolbox encoders can automatically convert AVFrame into its CVPixelBuffer equivalent
|
// hwupload on videotoolbox encoders can automatically convert AVFrame into its CVPixelBuffer equivalent
|
||||||
// videotoolbox will automatically convert the CVPixelBuffer to a pixel format the encoder supports, so we don't have to set a pixel format explicitly here
|
// videotoolbox will automatically convert the CVPixelBuffer to a pixel format the encoder supports, so we don't have to set a pixel format explicitly here
|
||||||
// This will reduce CPU usage significantly on UHD videos with 10 bit colors because we bypassed the ffmpeg pixel format conversion
|
// This will reduce CPU usage significantly on UHD videos with 10 bit colors because we bypassed the ffmpeg pixel format conversion
|
||||||
newfilters.Add("hwupload");
|
newfilters.Add("hwupload");
|
||||||
|
if (supportsHwScale)
|
||||||
|
{
|
||||||
|
var hwScaleFilter = GetHwScaleFilter("vt", "", inW, inH, reqW, reqH, reqMaxW, reqMaxH);
|
||||||
|
newfilters.Add(hwScaleFilter);
|
||||||
|
}
|
||||||
|
|
||||||
if (doDeintH2645)
|
if (doDeintH2645)
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,6 +128,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
"overlay_vulkan",
|
"overlay_vulkan",
|
||||||
// videotoolbox
|
// videotoolbox
|
||||||
"yadif_videotoolbox",
|
"yadif_videotoolbox",
|
||||||
|
"scale_vt",
|
||||||
// rkrga
|
// rkrga
|
||||||
"scale_rkrga",
|
"scale_rkrga",
|
||||||
"vpp_rkrga",
|
"vpp_rkrga",
|
||||||
|
|
Loading…
Reference in New Issue