summaryrefslogtreecommitdiff
path: root/libavcodec/h264_parse.c
diff options
context:
space:
mode:
authorJun Li <junli1026@gmail.com>2019-08-22 13:58:30 -0700
committerJames Almer <jamrial@gmail.com>2019-08-23 12:26:28 -0300
commit0b34cdf424d665d7d9b92aefdff49a5acc398a6d (patch)
tree77e8c6f96c5f4406f61228c555fa6d943d31ee96 /libavcodec/h264_parse.c
parent92c32b0f0c3e70d809e56be6c56cf1697cc259f9 (diff)
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: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/h264_parse.c')
-rw-r--r--libavcodec/h264_parse.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index ac31f54e07..32a8af88e5 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -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++) {
H2645NAL *nal = &pkt.nals[i];
switch (nal->type) {
- case H264_NAL_SPS:
- ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0);
+ case H264_NAL_SPS: {
+ 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)
goto fail;
break;
+ }
case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
nal->size_bits);