aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarch1t3cht <arch1t3cht@gmail.com>2024-03-28 02:56:38 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2024-04-16 16:36:22 +0100
commit728ffe6ca6d46f55e2f63de9dec8ea11e096c314 (patch)
treeb91d3536ff5f8463227bef8f1cf7a8f2f6fbbd20
parent5a856ac6e6a627402c1ff57a92fc478efb601131 (diff)
downloadffmpeg-728ffe6ca6d46f55e2f63de9dec8ea11e096c314.tar.gz
avcodec/h264dec: Handle non-recovered frames when draining
When starting on a SEI recovery point close enough to the end of the stream that draining starts before the recovery point's frame is output, there can be non-recovered frames in the delayed picture buffer that would currently cause the decoder to fail to output a frame. This commit skips such frames and outputs the first recovered frame, if there exists one. Signed-off-by: arch1t3cht <arch1t3cht@gmail.com> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r--libavcodec/h264dec.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 567f0dfa6b..76447e5206 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -994,11 +994,13 @@ static int send_next_delayed_frame(H264Context *h, AVFrame *dst_frame,
int *got_frame, int buf_index)
{
int ret, i, out_idx;
- H264Picture *out = h->delayed_pic[0];
+ H264Picture *out;
h->cur_pic_ptr = NULL;
h->first_field = 0;
+ while (h->delayed_pic[0]) {
+ out = h->delayed_pic[0];
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
@@ -1021,6 +1023,9 @@ static int send_next_delayed_frame(H264Context *h, AVFrame *dst_frame,
ret = finalize_frame(h, dst_frame, out, got_frame);
if (ret < 0)
return ret;
+ if (*got_frame)
+ break;
+ }
}
return buf_index;