When a slice is encountered, the H.264 parser up until now always unreferenced and reset the currently active PPS; immediately afterwards, the currently active PPS is set again which includes referencing it. Given that it is typical for the active parameter sets to change only seldomly, most of the time the new active PPS will be the old one. Therefore this commit checks for this and only unreferences the PPS if it changed.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- New and much simplified version of [1]. This has been made possible by 5e316096fa9ba4493d9dbb48847ad8e0b0e188c3. [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248374.html libavcodec/h264_parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index d988484660..c6fd049f46 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -363,6 +363,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, goto fail; } + if (p->ps.pps != (const PPS*)p->ps.pps_list[pps_id]->data) { av_buffer_unref(&p->ps.pps_ref); p->ps.pps = NULL; p->ps.sps = NULL; @@ -371,6 +372,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, goto fail; p->ps.pps = (const PPS*)p->ps.pps_ref->data; p->ps.sps = p->ps.pps->sps; + } sps = p->ps.sps; // heuristic to detect non marked keyframes -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".