From 6dd5f9509334f53a4217540d430360d49578ecee Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Tue, 25 Jul 2023 01:41:23 +0200 Subject: [PATCH] avformat/flvdec: fix size desync when reading timestamp offsets The size offset was previously being accounted for in flv_set_video_codec for h264 and mpeg4, instead of being directly accounted for in the spot where its read, which desynced on HEVC streams. For clarity, move the size offset directly to the parsing, similar to how its done for all other header fields. --- libavformat/flvdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index a6a94a4021..3fe21622f7 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -407,11 +407,9 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, case FLV_CODECID_H264: par->codec_id = AV_CODEC_ID_H264; vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; - ret = 3; // not 4, reading packet type will consume one byte break; case FLV_CODECID_MPEG4: par->codec_id = AV_CODEC_ID_MPEG4; - ret = 3; break; default: avpriv_request_sample(s, "Video codec (%x)", flv_codecid); @@ -1321,6 +1319,7 @@ retry_duration: "invalid timestamps %"PRId64" %"PRId64"\n", dts, pts); dts = pts = AV_NOPTS_VALUE; } + size -= 3; } if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC || st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC ||