From d96a345ef1f9b25927518361b5ebcf9ab1767f51 Mon Sep 17 00:00:00 2001 From: ulmus-scott Date: Wed, 17 Nov 2021 15:56:23 -0500 Subject: [PATCH] libavcodec/h264_refs.c best source I could find: Cumulated changes from previous sync https://github.com/MythTV/mythtv/commit/52be9885d38cdaa7a70660c66245c20fa8f87008#diff-9429ce52c81bb46d0a3f09a77ec81d3170ecf438b3f0e5a956cbffafca40c429 --- mythtv/external/FFmpeg/libavcodec/h264_refs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mythtv/external/FFmpeg/libavcodec/h264_refs.c b/mythtv/external/FFmpeg/libavcodec/h264_refs.c index dae8bd278ad..488d283bde0 100644 --- a/mythtv/external/FFmpeg/libavcodec/h264_refs.c +++ b/mythtv/external/FFmpeg/libavcodec/h264_refs.c @@ -766,6 +766,14 @@ int ff_h264_execute_ref_pic_marking(H264Context *h) h->short_ref[0] = h->cur_pic_ptr; h->short_ref_count++; h->cur_pic_ptr->reference |= h->picture_structure; + + /* MythTV changes - begin */ + // do not add more reference frames than allowed after seeing frame num gap + if (!mmco_count && h->short_ref_count > h->ps.sps->ref_frame_count) { + pic = h->short_ref[h->short_ref_count - 1]; + remove_short(h, pic->frame_num, 0); + } + /* MythTV changes - end */ } }