Message ID | 20190819014114.4336-1-junli1026@gmail.com |
---|---|
State | Superseded |
Headers | show |
On 8/18/2019 10:41 PM, Jun Li wrote: > 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, Copy instead the code from decode_nal_units() in h264dec.c, which checks first with the complete NAL, and then calls ff_h264_decode_seq_parameter_set() with the ignore_truncation parameter set to 1 as a last resort.
On Mon, Aug 19, 2019 at 3:45 PM James Almer <jamrial@gmail.com> wrote: > On 8/18/2019 10:41 PM, Jun Li wrote: > > 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, > > Copy instead the code from decode_nal_units() in h264dec.c, which checks > first with the complete NAL, and then calls > ff_h264_decode_seq_parameter_set() with the ignore_truncation parameter > set to 1 as a last resort. > Hi James, My first try was set the ignore_truncation to 1 but then found that decode_nal_units is already handling this using a different approach. So I just copied the code here, but without last try ignore_truncation=1. Are you suggesting modifying the commit message or comment identifying the code is copied from decide_nal_units, or extract them to one function and reuse two places ? -Jun > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On 8/19/2019 10:39 PM, Jun Li wrote: > On Mon, Aug 19, 2019 at 3:45 PM James Almer <jamrial@gmail.com> wrote: > >> On 8/18/2019 10:41 PM, Jun Li wrote: >>> 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, >> >> Copy instead the code from decode_nal_units() in h264dec.c, which checks >> first with the complete NAL, and then calls >> ff_h264_decode_seq_parameter_set() with the ignore_truncation parameter >> set to 1 as a last resort. >> > > Hi James, > My first try was set the ignore_truncation to 1 but then found that > decode_nal_units is already handling this using a different approach. > So I just copied the code here, but without last try ignore_truncation=1. > > Are you suggesting modifying the commit message or comment identifying the > code is copied from decide_nal_units, or extract them to one function and > reuse two places ? My suggestion was to copy the decode_nal_units approach here including the last try ignore_truncation=1 call. > > -Jun > > >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
On Mon, Aug 19, 2019 at 6:55 PM James Almer <jamrial@gmail.com> wrote: > On 8/19/2019 10:39 PM, Jun Li wrote: > > On Mon, Aug 19, 2019 at 3:45 PM James Almer <jamrial@gmail.com> wrote: > > > >> On 8/18/2019 10:41 PM, Jun Li wrote: > >>> 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, > >> > >> Copy instead the code from decode_nal_units() in h264dec.c, which checks > >> first with the complete NAL, and then calls > >> ff_h264_decode_seq_parameter_set() with the ignore_truncation parameter > >> set to 1 as a last resort. > >> > > > > Hi James, > > My first try was set the ignore_truncation to 1 but then found that > > decode_nal_units is already handling this using a different approach. > > So I just copied the code here, but without last try ignore_truncation=1. > > > > Are you suggesting modifying the commit message or comment identifying > the > > code is copied from decide_nal_units, or extract them to one function and > > reuse two places ? > > My suggestion was to copy the decode_nal_units approach here including > the last try ignore_truncation=1 call. Thanks for the input, I updated version 2 accordingly. https://patchwork.ffmpeg.org/patch/14604/ > > > > -Jun > > > > > >> _______________________________________________ > >> ffmpeg-devel mailing list > >> ffmpeg-devel@ffmpeg.org > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > >> To unsubscribe, visit link above, or email > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
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,