From 93b89868e139e9b45dfc8a62b4f8e1832bbfd5d8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 27 Nov 2012 18:06:00 +0100 Subject: [PATCH] h264: support invalid annex B in mp4 Fixes Ticket1914 Signed-off-by: Michael Niedermayer --- libavcodec/h264.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 33803bfe86..14843cf24e 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3763,6 +3763,13 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) ff_h264_reset_sei(h); } + if (h->nal_length_size == 4) { + if (buf_size > 8 && AV_RB32(buf) == 1 && AV_RB32(buf+5) > (unsigned)buf_size) { + h->is_avc = 0; + }else if(buf_size > 3 && AV_RB32(buf) > 1 && AV_RB32(buf) <= (unsigned)buf_size) + h->is_avc = 1; + } + for (; pass <= 1; pass++) { buf_index = 0; context_count = 0;