diff mbox series

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

Message ID GV1SPRMB0021EFDC66DCFA3D43FCA0568F1B2@GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM
State Superseded
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
Only MPEG-2 can have field motion vectors with coded fields.

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

Patch

diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index 01c8d82e98..5b72196395 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -719,7 +719,11 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
                       dir, ref_picture, qpix_op, pix_op);
         break;
     case MV_TYPE_FIELD:
-        if (s->picture_structure == PICT_FRAME) {
+        // Only MPEG-1/2 can have a picture_structure != PICT_FRAME here.
+        if (!CONFIG_SMALL)
+            av_assert2(is_mpeg12 || s->picture_structure == PICT_FRAME);
+        if ((!CONFIG_SMALL && !is_mpeg12) ||
+            s->picture_structure == PICT_FRAME) {
             if (!is_mpeg12 && s->quarter_sample) {
                 for (i = 0; i < 2; i++)
                     qpel_motion(s, dest_y, dest_cb, dest_cr,
@@ -739,6 +743,7 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
                                   s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
             }
         } else {
+            av_assert2(s->out_format == FMT_MPEG1);
             if (s->picture_structure != s->field_select[dir][0] + 1 &&
                 s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
                 ref_picture = s->current_picture_ptr->f->data;