diff mbox series

[FFmpeg-devel,46/57] avcodec/mpegpicture: Avoid loop and branch when setting motion_val

Message ID AS8P250MB0744199C5FD317DF091FD2388F1B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,01/14] avcodec/get_buffer: Remove redundant check | expand

Commit Message

Andreas Rheinhardt April 29, 2024, 9:14 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegpicture.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index d175bbc924..234bf45735 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -223,6 +223,7 @@  static int alloc_picture_tables(BufferPoolContext *pools, MPVPicture *pic,
         for (int i = 0; i < 2; i++) {
             GET_BUFFER(ref_index,, [i]);
             GET_BUFFER(motion_val, _base, [i]);
+            pic->motion_val[i] = pic->motion_val_base[i] + 4;
         }
     }
 #undef GET_BUFFER
@@ -231,6 +232,9 @@  static int alloc_picture_tables(BufferPoolContext *pools, MPVPicture *pic,
     pic->mb_height = mb_height;
     pic->mb_stride = pools->alloc_mb_stride;
 
+    pic->qscale_table = pic->qscale_table_base + 2 * pic->mb_stride + 1;
+    pic->mb_type      = pic->mb_type_base      + 2 * pic->mb_stride + 1;
+
     return 0;
 }
 
@@ -250,13 +254,6 @@  int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *wpic,
     if (ret < 0)
         goto fail;
 
-    pic->qscale_table = pic->qscale_table_base + 2 * pic->mb_stride + 1;
-    pic->mb_type      = pic->mb_type_base      + 2 * pic->mb_stride + 1;
-
-    if (pic->motion_val_base[0]) {
-        for (int i = 0; i < 2; i++)
-            pic->motion_val[i] = pic->motion_val_base[i] + 4;
-    }
     set_workpic_from_pic(wpic, pic);
 
     return 0;