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

Submitted by Anton Fedchin on Jan. 12, 2019, 3:31 p.m.

Details

Message ID 20190112153136.2868-2-afedchin@weezlabs.com
State New
Headers show

Commit Message

Anton Fedchin Jan. 12, 2019, 3:31 p.m.
---
 libavcodec/dxva2.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

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