[vlc-devel] [PATCH 2/3] avcodec:video: only try the hardware accelerated if there's one

Rémi Denis-Courmont remi at remlab.net
Fri Aug 4 16:32:40 CEST 2017


Le 4 août 2017 15:54:56 GMT+03:00, Steve Lhomme <robux4 at videolabs.io> a écrit :
>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
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

That's intended. Working/not-working is not quite a static setting.
-- 
Rémi Denis-Courmont
Typed on an inconvenient virtual keyboard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170804/1fa8d90d/attachment.html>


More information about the vlc-devel mailing list