[FFmpeg-devel] [PATCH v1] avcodec/h264_parse: retry decoding SPS with complete NAL
Jun Li
junli1026 at gmail.com
Mon Aug 19 04:41:14 EEST 2019
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.
---
libavcodec/h264_parse.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index ac31f54e07..a2267a0610 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -376,8 +376,14 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
switch (nal->type) {
case H264_NAL_SPS:
ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0);
- if (ret < 0)
- goto fail;
+ if (ret < 0) {
+ GetBitContext tmp_gb = nal->gb;
+ av_log(logctx, AV_LOG_DEBUG,
+ "SPS decoding failure (maybe missing rbsp_stop_one_bit), trying again with the complete NAL\n");
+ init_get_bits8(&tmp_gb, nal->raw_data + 1, nal->raw_size - 1);
+ if ((ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0)) < 0)
+ goto fail;
+ }
break;
case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
--
2.17.1
More information about the ffmpeg-devel
mailing list