mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-31 23:59:34 +00:00
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.
This commit is contained in:
parent
2e7905eee8
commit
87eebb3454
@ -137,7 +137,10 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode){
|
|||||||
return 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;
|
int i, si, di;
|
||||||
uint8_t *dst;
|
uint8_t *dst;
|
||||||
int bufidx;
|
int bufidx;
|
||||||
@ -148,6 +151,9 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_l
|
|||||||
|
|
||||||
src++; length--;
|
src++; length--;
|
||||||
|
|
||||||
|
if (nalsize_known) {
|
||||||
|
i = length;
|
||||||
|
} else
|
||||||
#if HAVE_FAST_UNALIGNED
|
#if HAVE_FAST_UNALIGNED
|
||||||
# if HAVE_FAST_64BIT
|
# if HAVE_FAST_64BIT
|
||||||
# define RS 7
|
# 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];
|
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){
|
if (ptr==NULL || dst_length < 0){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -610,9 +610,12 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length);
|
|||||||
* @param consumed is the number of bytes used as input
|
* @param consumed is the number of bytes used as input
|
||||||
* @param length is the length of the array
|
* @param length is the length of the array
|
||||||
* @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing?
|
* @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing?
|
||||||
|
* @param nalsize_known skip start code search if the size of the nalu is known
|
||||||
* @return decoded bytes, might be src+1 if no escapes
|
* @return decoded bytes, might be src+1 if no escapes
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free any data that may have been allocated in the H264 context like SPS, PPS etc.
|
* Free any data that may have been allocated in the H264 context like SPS, PPS etc.
|
||||||
|
@ -144,7 +144,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
|
|||||||
src_length = 20;
|
src_length = 20;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ptr= ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);
|
ptr= ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length, 0);
|
||||||
if (ptr==NULL || dst_length < 0)
|
if (ptr==NULL || dst_length < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user