[FFmpeg-devel] [PATCH] flvdec: fix size desync when reading timestamp offsets
Timo Rothenpieler
timo at rothenpieler.org
Tue Jul 25 03:10:01 EEST 2023
On 25.07.2023 01:41, Hendrik Leppkes wrote:
> 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 ||
tested with both h264 and hevc input, works fine
More information about the ffmpeg-devel
mailing list