[vlc-devel] [PATCH 2/3] avcodec:video: only try the hardware accelerated if there's one
Steve Lhomme
robux4 at videolabs.io
Fri Aug 4 14:54:56 CEST 2017
Otherwise we keep trying them all.
---
modules/codec/avcodec/video.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 14668db0c4..6368896e3e 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1490,12 +1490,48 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
can_hwaccel = true;
}
+ enum PixelFormat fmts[3];
char * var = var_InheritString(p_dec, "avcodec-hw");
if (var == NULL || !strcmp( var, "none" ))
{
msg_Dbg( p_dec, "disable hardware decoders" );
can_hwaccel = false;
}
+ else
+ {
+ enum PixelFormat hwfmt = AV_PIX_FMT_NONE;
+ if (!strcmp( var, "d3d11va" ))
+ hwfmt = AV_PIX_FMT_D3D11VA_VLD;
+ else if (!strcmp( var, "dxva2" ))
+ hwfmt = AV_PIX_FMT_DXVA2_VLD;
+ else if (!strcmp( var, "vdpau" ))
+ hwfmt = AV_PIX_FMT_VDPAU;
+ else if (!strcmp( var, "vaapi" ))
+ hwfmt = AV_PIX_FMT_VAAPI_VLD;
+ else if (strcmp( var, "any" ))
+ {
+ msg_Dbg( p_dec, "Unknown hardware decoder %s", var );
+ }
+
+ if (hwfmt != AV_PIX_FMT_NONE)
+ {
+ size_t j;
+ for( j = 0; pi_fmt[j] != AV_PIX_FMT_NONE; j++ )
+ {
+ if (pi_fmt[j] == hwfmt)
+ {
+ fmts[0] = hwfmt;
+ fmts[1] = swfmt;
+ fmts[2] = AV_PIX_FMT_NONE;
+ break;
+ }
+ }
+ if (pi_fmt[j] == AV_PIX_FMT_NONE)
+ can_hwaccel = false; /* no hardware flavor possible anyway */
+ else
+ pi_fmt = (const enum PixelFormat *)&fmts;
+ }
+ }
free(var);
/* If the format did not actually change (e.g. seeking), try to reuse the
--
2.12.1
More information about the vlc-devel
mailing list