[FFmpeg-devel] [PATCH 2/2] avcodec/dxva2: check pix_fmt before the loop instead of checking it inside

Anton Fedchin afedchin at weezlabs.com
Sat Jan 12 17:31:36 EET 2019


---
 libavcodec/dxva2.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index e0919d0b1c..dfae500444 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -778,9 +778,11 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
     }
 #endif
 #if CONFIG_DXVA2
-    for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
-        if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface)
-            return i;
+    if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
+        for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
+            if (ctx->dxva2.surface[i] == surface)
+                return i;
+        }
     }
 #endif
 
-- 
2.17.1.windows.2



More information about the ffmpeg-devel mailing list