diff mbox series

[FFmpeg-devel,v2] avcodec/mpegvideo_motion: Improve check to remove dead code

Message ID 20210205072117.1305251-1-andreas.rheinhardt@gmail.com
State Accepted
Commit b681680d294a796c2270860e82564aa694675b05
Headers show
Series [FFmpeg-devel,v2] avcodec/mpegvideo_motion: Improve check to remove dead code | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 5, 2021, 7:21 a.m. UTC
Several compile-time checks can be improved because mcsel is not used
for MPEG-1/2 (it is only used for MPEG-4) and because MPEG-1/2 is the
only user of ff_mpv_motion that uses MV_TYPE_16X8 and MV_TYPE_DMV.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Fixed a precedence issue in the first hunk below.

 libavcodec/mpegvideo_motion.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index 58cdecf83b..79785df8f8 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -306,9 +306,9 @@  void mpeg_motion_internal(MpegEncContext *s,
 
     if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 15   , 0) ||
         (unsigned)src_y >= FFMAX(   v_edge_pos - (motion_y & 1) - h + 1, 0)) {
-        if (is_mpeg12 ||
-            s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
-            s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
+        if (is_mpeg12 || (CONFIG_SMALL &&
+                          (s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
+                           s->codec_id == AV_CODEC_ID_MPEG1VIDEO))) {
             av_log(s->avctx, AV_LOG_DEBUG,
                    "MPEG motion vector out of boundary (%d %d)\n", src_x,
                    src_y);
@@ -853,7 +853,7 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
 
     switch (s->mv_type) {
     case MV_TYPE_16X16:
-        if (s->mcsel) {
+        if (!is_mpeg12 && s->mcsel) {
             if (s->real_sprite_warping_points == 1) {
                 gmc1_motion(s, dest_y, dest_cb, dest_cr,
                             ref_picture);
@@ -915,6 +915,7 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
         }
         break;
     case MV_TYPE_16X8:
+        if (CONFIG_SMALL || is_mpeg12) {
         for (i = 0; i < 2; i++) {
             uint8_t **ref2picture;
 
@@ -936,7 +937,9 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
             dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
         }
         break;
+        }
     case MV_TYPE_DMV:
+        if (CONFIG_SMALL || is_mpeg12) {
         if (s->picture_structure == PICT_FRAME) {
             for (i = 0; i < 2; i++) {
                 int j;
@@ -969,6 +972,7 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
             }
         }
         break;
+        }
     default: av_assert2(0);
     }
 }