ffmpeg | branch: master | Thierry Foucu <tfo...@gmail.com> | Fri Jan 29 
10:47:49 2016 -0800| [9a099526954962893f95d90ce202d07ea90d300c] | committer: 
Michael Niedermayer

lavf/flvdec: Allow files where the PreviousTagSize is not set according to the 
spec.

Some muxer use the FLV field PreviousTagSize to be the sum of tag
length. Without this change, the flv demuxer think the file is broken
and the re-sync will fail.

Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

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

 libavformat/flvdec.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index e72bc81..5090ac2 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -60,6 +60,7 @@ typedef struct FLVContext {
     uint8_t resync_buffer[2*RESYNC_BUFFER_SIZE];
 
     int broken_sizes;
+    int sum_flv_tag_size;
 } FLVContext;
 
 static int probe(AVProbeData *p, int live)
@@ -629,6 +630,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t 
next_pos)
 static int flv_read_header(AVFormatContext *s)
 {
     int offset, flags;
+    FLVContext *flv = s->priv_data;
 
     avio_skip(s->pb, 4);
     flags = avio_r8(s->pb);
@@ -649,6 +651,7 @@ static int flv_read_header(AVFormatContext *s)
     avio_skip(s->pb, 4);
 
     s->start_time = 0;
+    flv->sum_flv_tag_size = 0;
 
     return 0;
 }
@@ -857,6 +860,7 @@ retry:
         type = (avio_r8(s->pb) & 0x1F);
         orig_size =
         size = avio_rb24(s->pb);
+        flv->sum_flv_tag_size += size + 11;
         dts  = avio_rb24(s->pb);
         dts |= (unsigned)avio_r8(s->pb) << 24;
         av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" 
pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb));
@@ -1141,7 +1145,7 @@ retry_duration:
 leave:
     last = avio_rb32(s->pb);
     if (last != orig_size + 11 &&
-        (last != orig_size || !last) &&
+        (last != orig_size || !last) && last != flv->sum_flv_tag_size &&
         !flv->broken_sizes) {
         av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d\n", last, orig_size + 
11);
         avio_seek(s->pb, pos + 1, SEEK_SET);

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to