vlc | branch: master | Steve Lhomme <rob...@videolabs.io> | Thu Aug 10 13:51:41 
2017 +0200| [47d63b2ecdf018d3cca21c293e296aa91a6bd473] | committer: 
Jean-Baptiste Kempf

avcodec: favor D3D11VA over DXVA2

The order in which the vout are tried depends on which is the best for the
first video acceleration. Since we want D3D11 when possible we need to have
the matching VA by default too. On systems where D3D11VA doesn't work it will
fallback normally to DXVA2 and will use D3D9 with it.

Signed-off-by: Jean-Baptiste Kempf <j...@videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=47d63b2ecdf018d3cca21c293e296aa91a6bd473
---

 modules/codec/avcodec/video.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 590aa9460f..676cf34d00 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1472,12 +1472,13 @@ static enum PixelFormat ffmpeg_GetFormat( 
AVCodecContext *p_context,
     decoder_t *p_dec = p_context->opaque;
     decoder_sys_t *p_sys = p_dec->p_sys;
     video_format_t fmt;
+    size_t i;
 
     /* Enumerate available formats */
     enum PixelFormat swfmt = avcodec_default_get_format(p_context, pi_fmt);
     bool can_hwaccel = false;
 
-    for( size_t i = 0; pi_fmt[i] != AV_PIX_FMT_NONE; i++ )
+    for( i = 0; pi_fmt[i] != AV_PIX_FMT_NONE; i++ )
     {
         const AVPixFmtDescriptor *dsc = av_pix_fmt_desc_get(pi_fmt[i]);
         if (dsc == NULL)
@@ -1489,6 +1490,18 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext 
*p_context,
         if (hwaccel)
             can_hwaccel = true;
     }
+#if defined(_WIN32) && LIBAVUTIL_VERSION_CHECK(54, 13, 1, 24, 100)
+    enum PixelFormat p_fmts[i+1];
+    if (i > 1 && pi_fmt[0] == AV_PIX_FMT_DXVA2_VLD && pi_fmt[1] == 
AV_PIX_FMT_D3D11VA_VLD)
+    {
+        /* favor D3D11VA over DXVA2 as the order will decide which vout will be
+         * used */
+        memcpy(p_fmts, pi_fmt, sizeof(p_fmts));
+        p_fmts[0] = AV_PIX_FMT_D3D11VA_VLD;
+        p_fmts[1] = AV_PIX_FMT_DXVA2_VLD;
+        pi_fmt = p_fmts;
+    }
+#endif
 
     /* If the format did not actually change (e.g. seeking), try to reuse the
      * existing output format, and if present, hardware acceleration back-end.

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to