aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Foucu <tfoucu@gmail.com>2016-01-29 10:47:49 -0800
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-29 22:30:12 +0100
commit9a099526954962893f95d90ce202d07ea90d300c (patch)
treea791f3b67e194f8c82fdc46046c81946508b3d42
parent583a6431460ac62bd91328a8856fb07a445124ea (diff)
downloadffmpeg-9a099526954962893f95d90ce202d07ea90d300c.tar.gz
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 <michael@niedermayer.cc>
-rw-r--r--libavformat/flvdec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index e72bc81d90..5090ac2157 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);