ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | 
Thu May  1 21:51:07 2025 +0200| [c37fb99abbd77b4956cec8682f8649be70083171] | 
committer: Andreas Rheinhardt

avcodec/h263dec: Always output next, not current pic when flushing

It is the last picture in display order.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>

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

 libavcodec/h263dec.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index fd1e36b68a..9785d6e343 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -426,22 +426,19 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
     /* no supplementary picture */
     if (buf_size == 0) {
         /* special case for last picture */
-        if (s->low_delay == 0 && s->next_pic.ptr) {
+        if ((!s->low_delay || s->skipped_last_frame) && s->next_pic.ptr) {
             if ((ret = av_frame_ref(pict, s->next_pic.ptr->f)) < 0)
                 return ret;
-            ff_mpv_unref_picture(&s->next_pic);
+            if (s->skipped_last_frame) {
+                /* If the stream ended with an NVOP, we output the last frame
+                 * in display order, but with the props from the last input
+                 * packet so that the stream's end time is correct. */
+                ret = ff_decode_frame_props(avctx, pict);
+                if (ret < 0)
+                    return ret;
+            }
 
-            *got_frame = 1;
-        } else if (s->skipped_last_frame && s->cur_pic.ptr) {
-            /* Output the last picture we decoded again if the stream ended 
with
-             * an NVOP */
-            if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0)
-                return ret;
-            /* Copy props from the last input packet. Otherwise, props from 
the last
-             * returned picture would be reused */
-            if ((ret = ff_decode_frame_props(avctx, pict)) < 0)
-                return ret;
-            ff_mpv_unref_picture(&s->cur_pic);
+            ff_mpv_unref_picture(&s->next_pic);
 
             *got_frame = 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