[FFmpeg-devel] [PATCH] lavc/hevc_ps: fix process failed when SPS before VPS in hvcC
wangyaqiang
1035567130 at qq.com
Fri Sep 9 17:34:12 EEST 2022
> 2022年9月9日 下午9:55,James Almer <jamrial at gmail.com> 写道:
>
> On 9/9/2022 10:09 AM, 1035567130 at qq.com <mailto:1035567130 at qq.com> wrote:
>> From: Wang Yaqiang <wangyaqiang03 at kuaishou.com>
>> In some videos, SPS will be stored before VPS in hvcC box,
>> parse SPS does not depend on VPS, so the video is expected to be processed normally.
>> Added "parsed_vps" parameter to indicate whether VPS have been parsed.
>> Only VPS have been parsed can be verified during SPS parsing.
>> Signed-off-by: Wang Yaqiang <wangyaqiang03 at kuaishou.com>
>> ---
>> libavcodec/hevc_ps.c | 4 ++--
>> libavcodec/hevc_ps.h | 1 +
>> 2 files changed, 3 insertions(+), 2 deletions(-)
>> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
>> index f665d8053c..71835d0f36 100644
>> --- a/libavcodec/hevc_ps.c
>> +++ b/libavcodec/hevc_ps.c
>> @@ -464,7 +464,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
>> if (!vps_buf)
>> return AVERROR(ENOMEM);
>> vps = (HEVCVPS*)vps_buf->data;
>> -
>> + ps->parsed_vps = 1;
>
> This would need to be reset in ff_hevc_ps_uninit().
Thanks,I will fix it in the next commit.
>
>> av_log(avctx, AV_LOG_DEBUG, "Decoding VPS\n");
>> nal_size = gb->buffer_end - gb->buffer;
>> @@ -1272,7 +1272,7 @@ int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
>> ret = ff_hevc_parse_sps(sps, gb, &sps_id,
>> apply_defdispwin,
>> - ps->vps_list, avctx);
>> + ps->parsed_vps ? ps->vps_list : NULL, avctx);
>
> If VPS is not required to parse SPS, wouldn't it be better to just change the check in ff_hevc_parse_sps() to turn the log message into a warning and then not error out?
The SPS contains the vps_id,in the original logic,check the vps_id based on the vps_list param,so the original logic is preserved. i’m not sure which way is better.
>
>> if (ret < 0) {
>> av_buffer_unref(&sps_buf);
>> return ret;
>> diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
>> index 2a1bbf6489..e6b694e7f3 100644
>> --- a/libavcodec/hevc_ps.h
>> +++ b/libavcodec/hevc_ps.h
>> @@ -333,6 +333,7 @@ typedef struct HEVCParamSets {
>> const HEVCVPS *vps;
>> const HEVCSPS *sps;
>> const HEVCPPS *pps;
>> + int parsed_vps; // indicates VPS has been parsed
>> } HEVCParamSets;
>> /**
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org <mailto:ffmpeg-devel at ffmpeg.org>
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org <mailto:ffmpeg-devel-request at ffmpeg.org> with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list