|
@@ -971,7 +971,8 @@ fail: |
|
|
return -1; // free_tables will clean up for us |
|
|
return -1; // free_tables will clean up for us |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size); |
|
|
|
|
|
|
|
|
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size, |
|
|
|
|
|
int parse_extradata); |
|
|
|
|
|
|
|
|
static av_cold void common_init(H264Context *h) |
|
|
static av_cold void common_init(H264Context *h) |
|
|
{ |
|
|
{ |
|
@@ -1027,7 +1028,7 @@ static int ff_h264_decode_extradata_internal(H264Context *h, const uint8_t *buf, |
|
|
nalsize = AV_RB16(p) + 2; |
|
|
nalsize = AV_RB16(p) + 2; |
|
|
if(nalsize > size - (p-buf)) |
|
|
if(nalsize > size - (p-buf)) |
|
|
return -1; |
|
|
return -1; |
|
|
if (decode_nal_units(h, p, nalsize) < 0) { |
|
|
|
|
|
|
|
|
if (decode_nal_units(h, p, nalsize, 1) < 0) { |
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
"Decoding sps %d from avcC failed\n", i); |
|
|
"Decoding sps %d from avcC failed\n", i); |
|
|
return -1; |
|
|
return -1; |
|
@@ -1040,7 +1041,7 @@ static int ff_h264_decode_extradata_internal(H264Context *h, const uint8_t *buf, |
|
|
nalsize = AV_RB16(p) + 2; |
|
|
nalsize = AV_RB16(p) + 2; |
|
|
if(nalsize > size - (p-buf)) |
|
|
if(nalsize > size - (p-buf)) |
|
|
return -1; |
|
|
return -1; |
|
|
if (decode_nal_units(h, p, nalsize) < 0) { |
|
|
|
|
|
|
|
|
if (decode_nal_units(h, p, nalsize, 1) < 0) { |
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
"Decoding pps %d from avcC failed\n", i); |
|
|
"Decoding pps %d from avcC failed\n", i); |
|
|
return -1; |
|
|
return -1; |
|
@@ -1051,7 +1052,7 @@ static int ff_h264_decode_extradata_internal(H264Context *h, const uint8_t *buf, |
|
|
h->nal_length_size = (buf[4] & 0x03) + 1; |
|
|
h->nal_length_size = (buf[4] & 0x03) + 1; |
|
|
} else { |
|
|
} else { |
|
|
h->is_avc = 0; |
|
|
h->is_avc = 0; |
|
|
if (decode_nal_units(h, buf, size) < 0) |
|
|
|
|
|
|
|
|
if (decode_nal_units(h, buf, size, 1) < 0) |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
return size; |
|
|
return size; |
|
@@ -3778,7 +3779,8 @@ static int execute_decode_slices(H264Context *h, int context_count) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) |
|
|
|
|
|
|
|
|
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size, |
|
|
|
|
|
int parse_extradata) |
|
|
{ |
|
|
{ |
|
|
MpegEncContext *const s = &h->s; |
|
|
MpegEncContext *const s = &h->s; |
|
|
AVCodecContext *const avctx = s->avctx; |
|
|
AVCodecContext *const avctx = s->avctx; |
|
@@ -3922,6 +3924,17 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
again: |
|
|
again: |
|
|
|
|
|
/* Ignore every NAL unit type except PPS and SPS during extradata |
|
|
|
|
|
* parsing. Decoding slices is not possible in codec init |
|
|
|
|
|
* with frame-mt */ |
|
|
|
|
|
if (parse_extradata && HAVE_THREADS && |
|
|
|
|
|
(s->avctx->active_thread_type & FF_THREAD_FRAME) && |
|
|
|
|
|
(hx->nal_unit_type != NAL_PPS && |
|
|
|
|
|
hx->nal_unit_type != NAL_SPS)) { |
|
|
|
|
|
av_log(avctx, AV_LOG_INFO, "Ignoring NAL unit %d during " |
|
|
|
|
|
"extradata parsing\n", hx->nal_unit_type); |
|
|
|
|
|
hx->nal_unit_type = NAL_FF_IGNORE; |
|
|
|
|
|
} |
|
|
err = 0; |
|
|
err = 0; |
|
|
|
|
|
|
|
|
if (h->decoding_extradata) { |
|
|
if (h->decoding_extradata) { |
|
@@ -4083,6 +4096,8 @@ again: |
|
|
case NAL_SPS_EXT: |
|
|
case NAL_SPS_EXT: |
|
|
case NAL_AUXILIARY_SLICE: |
|
|
case NAL_AUXILIARY_SLICE: |
|
|
break; |
|
|
break; |
|
|
|
|
|
case NAL_FF_IGNORE: |
|
|
|
|
|
break; |
|
|
default: |
|
|
default: |
|
|
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n", |
|
|
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n", |
|
|
hx->nal_unit_type, bit_length); |
|
|
hx->nal_unit_type, bit_length); |
|
@@ -4201,7 +4216,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, |
|
|
} |
|
|
} |
|
|
not_extra: |
|
|
not_extra: |
|
|
|
|
|
|
|
|
buf_index = decode_nal_units(h, buf, buf_size); |
|
|
|
|
|
|
|
|
buf_index = decode_nal_units(h, buf, buf_size, 0); |
|
|
if (buf_index < 0) |
|
|
if (buf_index < 0) |
|
|
return -1; |
|
|
return -1; |
|
|
|
|
|
|
|
|