diff options
author | Janne Grunau <janne-libav@jannau.net> | 2011-12-18 22:42:36 +0100 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2011-12-18 23:52:53 +0100 |
commit | 87eebb3454ff0cd6af6ebf9e1d31bdfd1c3b601b (patch) | |
tree | c0640de45934f4262cca34dc6cfe009fd8a8a606 /libavcodec/h264.c | |
parent | 2e7905eee8d0f8813e703cacdd7b3ffdc4960656 (diff) | |
download | ffmpeg-87eebb3454ff0cd6af6ebf9e1d31bdfd1c3b601b.tar.gz |
h264: skip start code search if the size of the nal unit is known
Start code emulation prevention is only required in Annex B bytestream
packed NAL units. For other coding formats the size is already known.
Looking for a start code prefix can result in false positives like in
http://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4
which has a false positive in the SPS.
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 77acd7168f..5d4ce90cae 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -137,7 +137,10 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode){ return mode; } -const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){ +const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, + int *dst_length, int *consumed, int length, + int nalsize_known) +{ int i, si, di; uint8_t *dst; int bufidx; @@ -148,6 +151,9 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_l src++; length--; + if (nalsize_known) { + i = length; + } else #if HAVE_FAST_UNALIGNED # if HAVE_FAST_64BIT # define RS 7 @@ -3789,7 +3795,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ hx = h->thread_context[context_count]; - ptr= ff_h264_decode_nal(hx, buf + buf_index, &dst_length, &consumed, next_avc - buf_index); + ptr= ff_h264_decode_nal(hx, buf + buf_index, &dst_length, &consumed, + next_avc - buf_index, !!nalsize); if (ptr==NULL || dst_length < 0){ return -1; } |