Commit 0b34cdf4 authored by Jun Li's avatar Jun Li Committed by James Almer

avcodec/h264_parse: retry decoding SPS with complete NAL

Fix #6591
The content has no rbsp_stop_one_bit for ending the SPS, that
causes the decoding SPS failure, results decoding frame failure as well.

The patch is just adding a retry with complete NALU, copied from the retry in decode_nal_unit()
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 92c32b0f
...@@ -374,11 +374,22 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps, ...@@ -374,11 +374,22 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
for (i = 0; i < pkt.nb_nals; i++) { for (i = 0; i < pkt.nb_nals; i++) {
H2645NAL *nal = &pkt.nals[i]; H2645NAL *nal = &pkt.nals[i];
switch (nal->type) { switch (nal->type) {
case H264_NAL_SPS: case H264_NAL_SPS: {
ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0); GetBitContext tmp_gb = nal->gb;
ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0);
if (ret >= 0)
break;
av_log(logctx, AV_LOG_DEBUG,
"SPS decoding failure, trying again with the complete NAL\n");
init_get_bits8(&tmp_gb, nal->raw_data + 1, nal->raw_size - 1);
ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0);
if (ret >= 0)
break;
ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 1);
if (ret < 0) if (ret < 0)
goto fail; goto fail;
break; break;
}
case H264_NAL_PPS: case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps, ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
nal->size_bits); nal->size_bits);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment