diff mbox series

[FFmpeg-devel,51/57] avcodec/mpegvideo_dec: Simplify check for "does pic exist?"

Message ID AS8P250MB0744596ABDCA06430C64D1798F1B2@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
The days in which an MPVPicture* is set with the corresponding frame
being blank are over; this allows to simplify some checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_dec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 9d2b7671e3..f840dc9ffc 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -312,9 +312,10 @@  int ff_mpv_alloc_dummy_frames(MpegEncContext *s)
     AVCodecContext *avctx = s->avctx;
     int ret;
 
-    if ((!s->last_pic.ptr || !s->last_pic.ptr->f->buf[0]) &&
-        (s->pict_type != AV_PICTURE_TYPE_I)) {
-        if (s->pict_type == AV_PICTURE_TYPE_B && s->next_pic.ptr && s->next_pic.ptr->f->buf[0])
+    av_assert1(!s->last_pic.ptr || s->last_pic.ptr->f->buf[0]);
+    av_assert1(!s->next_pic.ptr || s->next_pic.ptr->f->buf[0]);
+    if (!s->last_pic.ptr && s->pict_type != AV_PICTURE_TYPE_I) {
+        if (s->pict_type == AV_PICTURE_TYPE_B && s->next_pic.ptr)
             av_log(avctx, AV_LOG_DEBUG,
                    "allocating dummy last picture for B frame\n");
         else if (s->codec_id != AV_CODEC_ID_H261 /* H.261 has no keyframes */ &&
@@ -332,8 +333,7 @@  int ff_mpv_alloc_dummy_frames(MpegEncContext *s)
             color_frame(s->last_pic.ptr->f, luma_val);
         }
     }
-    if ((!s->next_pic.ptr || !s->next_pic.ptr->f->buf[0]) &&
-        s->pict_type == AV_PICTURE_TYPE_B) {
+    if (!s->next_pic.ptr && s->pict_type == AV_PICTURE_TYPE_B) {
         /* Allocate a dummy frame */
         ret = alloc_dummy_frame(s, &s->next_pic);
         if (ret < 0)