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.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -994,11 +994,13 @@ static int send_next_delayed_frame(H264Context *h, AVFrame *dst_frame, · 993 unmodified lines | ||
| 994 | 994 | int *got_frame, int buf_index) |
| 995 | 995 | { |
| 996 | 996 | int ret, i, out_idx; |
| 997 | − H264Picture *out = h->delayed_pic[0]; | |
| 997 | + H264Picture *out; | |
| 998 | 998 | |
| 999 | 999 | h->cur_pic_ptr = NULL; |
| 1000 | 1000 | h->first_field = 0; |
| 1001 | 1001 | |
| 1002 | + while (h->delayed_pic[0]) { | |
| 1003 | + out = h->delayed_pic[0]; | |
| 1002 | 1004 | out_idx = 0; |
| 1003 | 1005 | for (i = 1; |
| 1004 | 1006 | h->delayed_pic[i] && |
| @@ -1021,6 +1023,9 @@ static int send_next_delayed_frame(H264Context *h, AVFrame *dst_frame, · 16 unmodified lines | ||
| 1021 | 1023 | ret = finalize_frame(h, dst_frame, out, got_frame); |
| 1022 | 1024 | if (ret < 0) |
| 1023 | 1025 | return ret; |
| 1026 | + if (*got_frame) | |
| 1027 | + break; | |
| 1028 | + } | |
| 1024 | 1029 | } |
| 1025 | 1030 | |
| 1026 | 1031 | return buf_index; |