diff mbox series

[FFmpeg-devel,09/14] avcodec/mpegvideo_motion: Optimize check away

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

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Andreas Rheinhardt April 29, 2024, 12:35 a.m. UTC
When !CONFIG_SMALL, we create separate functions for FMT_MPEG1
(i.e. for MPEG-1/2); given that there are only three possibilities
for out_format (FMT_MPEG1, FMT_H263 and FMT_H261 -- MJPEG and SpeedHQ
are both intra-only and do not have motion vectors at all, ergo
they don't call this function), one can optimize MPEG-1/2-only code
away in mpeg_motion_internal().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_motion.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index 5b72196395..ccda20c0f1 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -114,13 +114,16 @@  void mpeg_motion_internal(MpegEncContext *s,
             uvsrc_y = src_y >> 1;
         }
     // Even chroma mv's are full pel in H261
-    } else if (!is_mpeg12 && s->out_format == FMT_H261) {
+    } else if (!CONFIG_SMALL && !is_mpeg12 ||
+               CONFIG_SMALL && s->out_format == FMT_H261) {
+        av_assert2(s->out_format == FMT_H261);
         mx      = motion_x / 4;
         my      = motion_y / 4;
         uvdxy   = 0;
         uvsrc_x = s->mb_x * 8 + mx;
         uvsrc_y = mb_y * 8 + my;
     } else {
+        av_assert2(s->out_format == FMT_MPEG1);
         if (s->chroma_y_shift) {
             mx      = motion_x / 2;
             my      = motion_y / 2;
@@ -820,6 +823,9 @@  void ff_mpv_motion(MpegEncContext *s,
                    op_pixels_func (*pix_op)[4],
                    qpel_mc_func (*qpix_op)[16])
 {
+    av_assert2(s->out_format == FMT_MPEG1 ||
+               s->out_format == FMT_H263  ||
+               s->out_format == FMT_H261);
     prefetch_motion(s, ref_picture, dir);
 
 #if !CONFIG_SMALL