On 9/9/2022 10:09 AM, 1035567...@qq.com wrote:
From: Wang Yaqiang <wangyaqian...@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 <wangyaqian...@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().

      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?

      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@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to