diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-10-01 19:41:28 +0400 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2012-03-13 03:31:52 +0400 |
commit | 3aa661ec561d7a20812b84b353b0d7855ac346c8 (patch) | |
tree | 0c97713f0ffa409754ddc099251ed19f82382749 /libavcodec/h264.c | |
parent | bd3e07c82ae558c2cc3616115161827630826ec1 (diff) |
h264: improve parsing of broken AVC SPS
Parsing the entire NAL as SPS fixes decoding of some AVC bitstreams
with broken escaping. Since the size of the NAL unit is known and
checked against the buffer end we can parse it entirely without buffer
overreads.
Fixes playback of
http://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 20aed27fd1..c3ef3f0110 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3925,7 +3925,14 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ break; case NAL_SPS: init_get_bits(&s->gb, ptr, bit_length); - ff_h264_decode_seq_parameter_set(h); + if (ff_h264_decode_seq_parameter_set(h) < 0 && + h->is_avc && (nalsize != consumed) && nalsize) { + av_log(h->s.avctx, AV_LOG_DEBUG, "SPS decoding failure, " + "try parsing the coomplete NAL\n"); + init_get_bits(&s->gb, buf + buf_index + 1 - consumed, + 8 * (nalsize - 1)); + ff_h264_decode_seq_parameter_set(h); + } if (s->flags& CODEC_FLAG_LOW_DELAY || (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames)) |