ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | 
Sun Apr 28 18:59:29 2024 +0200| [a13ca893cff54610f45e85109d10bd81a24f7a89] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo_dec, rv34: Simplify check for "does pic exist?"

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.rheinha...@outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a13ca893cff54610f45e85109d10bd81a24f7a89
---

 libavcodec/mpegvideo_dec.c | 10 +++++-----
 libavcodec/rv34.c          |  3 +--
 2 files changed, 6 insertions(+), 7 deletions(-)

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)
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index cf6a948065..728e117df4 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1657,8 +1657,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
         av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
         return AVERROR_INVALIDDATA;
     }
-    if ((!s->last_pic.ptr || !s->last_pic.ptr->f->data[0]) &&
-        si.type == AV_PICTURE_TYPE_B) {
+    if (!s->last_pic.ptr && si.type == AV_PICTURE_TYPE_B) {
         av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without "
                "reference data.\n");
         faulty_b = 1;

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to