diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-15 17:23:39 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-03 18:24:36 +0100 |
commit | 54aa78adaa3b3c6863760cf1467c4a450dbdedce (patch) | |
tree | d7f43e507e2c1f7b72affdb7f743651a8804fb67 | |
parent | c575d63ac2dd3dd925d5e855fe36bf537264f138 (diff) | |
download | ffmpeg-54aa78adaa3b3c6863760cf1467c4a450dbdedce.tar.gz |
h264: fix midstream extardata handling with dump.f4v
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit a4755df5236551ab53a5bf4b970748809593adf6)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/h264.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index b1a9baae97..0e0b164330 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -4076,8 +4076,28 @@ static int decode_frame(AVCodecContext *avctx, return 0; } - if(h->is_avc && buf_size >= 9 && AV_RB32(buf)==0x0164001F && buf[5] && buf[8]==0x67) + if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){ + int cnt= buf[5]&0x1f; + uint8_t *p= buf+6; + while(cnt--){ + int nalsize= AV_RB16(p) + 2; + if(nalsize > buf_size - (p-buf) || p[2]!=0x67) + goto not_extra; + p += nalsize; + } + cnt = *(p++); + if(!cnt) + goto not_extra; + while(cnt--){ + int nalsize= AV_RB16(p) + 2; + if(nalsize > buf_size - (p-buf) || p[2]!=0x68) + goto not_extra; + p += nalsize; + } + return ff_h264_decode_extradata(h, buf, buf_size); + } +not_extra: buf_index=decode_nal_units(h, buf, buf_size); if(buf_index < 0) |