[FFmpeg-cvslog] avformat/flvdec: fix size desync when reading timestamp offsets

Hendrik Leppkes git at videolan.org
Tue Jul 25 14:59:08 EEST 2023


ffmpeg | branch: master | Hendrik Leppkes <h.leppkes at gmail.com> | Tue Jul 25 01:41:23 2023 +0200| [6dd5f9509334f53a4217540d430360d49578ecee] | committer: Timo Rothenpieler

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6dd5f9509334f53a4217540d430360d49578ecee
---

 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 ||



More information about the ffmpeg-cvslog mailing list