diff options
author | Zhao Zhili <zhilizhao@tencent.com> | 2025-01-19 00:35:06 +0800 |
---|---|---|
committer | Nuo Mi <nuomi2021@gmail.com> | 2025-01-19 13:30:13 +0800 |
commit | ea381285e7d9c5fd3f74e19bc699ca98bd653ca5 (patch) | |
tree | 94b98336e9e02807a21e050ae8ee973e6243053a | |
parent | a328b219edc4ed7d836782e5e64f054bc968d9df (diff) | |
download | ffmpeg-ea381285e7d9c5fd3f74e19bc699ca98bd653ca5.tar.gz |
avcodec/vvc: Add support for output_corrupt/showall flags
-rw-r--r-- | libavcodec/vvc/refs.c | 20 | ||||
-rw-r--r-- | libavcodec/vvc/refs.h | 1 |
2 files changed, 20 insertions, 1 deletions
diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c index 79b692ac48..8d4b7bb35b 100644 --- a/libavcodec/vvc/refs.c +++ b/libavcodec/vvc/refs.c @@ -48,6 +48,8 @@ void ff_vvc_unref_frame(VVCFrameContext *fc, VVCFrame *frame, int flags) return; frame->flags &= ~flags; + if (!(frame->flags & ~VVC_FRAME_FLAG_CORRUPT)) + frame->flags = 0; if (!frame->flags) { av_frame_unref(frame->frame); av_refstruct_unref(&frame->sps); @@ -280,6 +282,9 @@ int ff_vvc_output_frame(VVCContext *s, VVCFrameContext *fc, AVFrame *out, const if (nb_output) { VVCFrame *frame = &fc->DPB[min_idx]; + if (frame->flags & VVC_FRAME_FLAG_CORRUPT) + frame->frame->flags |= AV_FRAME_FLAG_CORRUPT; + ret = av_frame_ref(out, frame->frame); if (frame->flags & VVC_FRAME_FLAG_BUMPING) ff_vvc_unref_frame(fc, frame, VVC_FRAME_FLAG_OUTPUT | VVC_FRAME_FLAG_BUMPING); @@ -389,7 +394,7 @@ static VVCFrame *generate_missing_ref(VVCContext *s, VVCFrameContext *fc, int po frame->poc = poc; frame->sequence = s->seq_decode; - frame->flags = 0; + frame->flags = VVC_FRAME_FLAG_CORRUPT; ff_vvc_report_frame_finished(frame); @@ -424,6 +429,19 @@ static int add_candidate_ref(VVCContext *s, VVCFrameContext *fc, RefPicList *lis if (ref == fc->ref || list->nb_refs >= VVC_MAX_REF_ENTRIES) return AVERROR_INVALIDDATA; + if (!IS_CVSS(s)) { + const bool ref_corrupt = !ref || (ref->flags & VVC_FRAME_FLAG_CORRUPT); + const bool recovering = s->no_output_before_recovery_flag && !GDR_IS_RECOVERED(s); + + if (ref_corrupt && !recovering) { + if (!(s->avctx->flags & AV_CODEC_FLAG_OUTPUT_CORRUPT) && + !(s->avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL)) + return AVERROR_INVALIDDATA; + + fc->ref->flags |= VVC_FRAME_FLAG_CORRUPT; + } + } + if (!ref) { ref = generate_missing_ref(s, fc, poc); if (!ref) diff --git a/libavcodec/vvc/refs.h b/libavcodec/vvc/refs.h index e2271ab381..a3081a76be 100644 --- a/libavcodec/vvc/refs.h +++ b/libavcodec/vvc/refs.h @@ -29,6 +29,7 @@ #define VVC_FRAME_FLAG_SHORT_REF (1 << 1) #define VVC_FRAME_FLAG_LONG_REF (1 << 2) #define VVC_FRAME_FLAG_BUMPING (1 << 3) +#define VVC_FRAME_FLAG_CORRUPT (1 << 4) int ff_vvc_output_frame(VVCContext *s, VVCFrameContext *fc, struct AVFrame *out, int no_output_of_prior_pics_flag, int flush); void ff_vvc_bump_frame(VVCContext *s, VVCFrameContext *fc); |