From: Nuo Mi <nuomi2021@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Nuo Mi <nuomi2021@gmail.com> Subject: [FFmpeg-devel] [PATCH 1/2] lavc/vvcdec: refact, set AVCodecContext->has_b_frames in sps_export_stream_params Date: Mon, 3 Feb 2025 17:17:50 +0800 Message-ID: <20250203091751.259888-1-nuomi2021@gmail.com> (raw) --- libavcodec/vvc/dec.c | 1 - libavcodec/vvc/ps.c | 29 +++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c index 51dd60ae92..68fb26352e 100644 --- a/libavcodec/vvc/dec.c +++ b/libavcodec/vvc/dec.c @@ -812,7 +812,6 @@ static int export_frame_params(VVCContext *s, const VVCFrameContext *fc) c->width = pps->width - ((pps->r->pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) << sps->hshift[CHROMA]); c->height = pps->height - ((pps->r->pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) << sps->vshift[CHROMA]); - c->has_b_frames = sps->r->sps_dpb_params.dpb_max_num_reorder_pics[sps->r->sps_max_sublayers_minus1]; return 0; } diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c index 01b4615eda..664e2c6376 100644 --- a/libavcodec/vvc/ps.c +++ b/libavcodec/vvc/ps.c @@ -23,6 +23,7 @@ #include <stdbool.h> #include "libavcodec/cbs_h266.h" +#include "libavcodec/decode.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" #include "libavutil/refstruct.h" @@ -180,12 +181,19 @@ static void sps_ladf(VVCSPS* sps) } } -static int sps_derive(VVCSPS *sps, void *log_ctx) +static void sps_export_stream_params(AVCodecContext *c, const VVCSPS *sps) +{ + const H266RawSPS *r = sps->r; + + c->has_b_frames = !!r->sps_dpb_params.dpb_max_num_reorder_pics[r->sps_max_sublayers_minus1]; +} + +static int sps_derive(VVCSPS *sps, AVCodecContext *c) { int ret; const H266RawSPS *r = sps->r; - ret = sps_bit_depth(sps, log_ctx); + ret = sps_bit_depth(sps, c); if (ret < 0) return ret; sps_poc(sps); @@ -197,6 +205,7 @@ static int sps_derive(VVCSPS *sps, void *log_ctx) if (ret < 0) return ret; } + sps_export_stream_params(c, sps); return 0; } @@ -207,7 +216,7 @@ static void sps_free(AVRefStructOpaque opaque, void *obj) av_refstruct_unref(&sps->r); } -static const VVCSPS *sps_alloc(const H266RawSPS *rsps, void *log_ctx) +static const VVCSPS *sps_alloc(const H266RawSPS *rsps, AVCodecContext *c) { int ret; VVCSPS *sps = av_refstruct_alloc_ext(sizeof(*sps), 0, NULL, sps_free); @@ -217,7 +226,7 @@ static const VVCSPS *sps_alloc(const H266RawSPS *rsps, void *log_ctx) av_refstruct_replace(&sps->r, rsps); - ret = sps_derive(sps, log_ctx); + ret = sps_derive(sps, c); if (ret < 0) goto fail; @@ -228,7 +237,7 @@ fail: return NULL; } -static int decode_sps(VVCParamSets *ps, const H266RawSPS *rsps, void *log_ctx, int is_clvss) +static int decode_sps(VVCParamSets *ps, AVCodecContext *c, const H266RawSPS *rsps, int is_clvss) { const int sps_id = rsps->sps_seq_parameter_set_id; const VVCSPS *old_sps = ps->sps_list[sps_id]; @@ -245,7 +254,7 @@ static int decode_sps(VVCParamSets *ps, const H266RawSPS *rsps, void *log_ctx, i return AVERROR_INVALIDDATA; } - sps = sps_alloc(rsps, log_ctx); + sps = sps_alloc(rsps, c); if (!sps) return AVERROR(ENOMEM); @@ -647,7 +656,7 @@ static int decode_pps(VVCParamSets *ps, const H266RawPPS *rpps) return ret; } -static int decode_ps(VVCParamSets *ps, const CodedBitstreamH266Context *h266, void *log_ctx, int is_clvss) +static int decode_ps(VVCParamSets *ps, AVCodecContext *c, const CodedBitstreamH266Context *h266, int is_clvss) { const H266RawPictureHeader *ph = h266->ph; const H266RawPPS *rpps; @@ -665,13 +674,13 @@ static int decode_ps(VVCParamSets *ps, const CodedBitstreamH266Context *h266, vo if (!rsps) return AVERROR_INVALIDDATA; - ret = decode_sps(ps, rsps, log_ctx, is_clvss); + ret = decode_sps(ps, c, rsps, is_clvss); if (ret < 0) return ret; if (rsps->sps_log2_ctu_size_minus5 > 2) { // CTU > 128 are reserved in vvc spec v3 - av_log(log_ctx, AV_LOG_ERROR, "CTU size > 128. \n"); + av_log(c, AV_LOG_ERROR, "CTU size > 128. \n"); return AVERROR_PATCHWELCOME; } @@ -960,7 +969,7 @@ int ff_vvc_decode_frame_ps(VVCFrameParamSets *fps, struct VVCContext *s) decode_recovery_flag(s); is_clvss = IS_CLVSS(s); - ret = decode_ps(ps, h266, s->avctx, is_clvss); + ret = decode_ps(ps, s->avctx, h266, is_clvss); if (ret < 0) return ret; -- 2.34.1 _______________________________________________ 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".
next reply other threads:[~2025-02-03 9:18 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-02-03 9:17 Nuo Mi [this message] 2025-02-03 9:17 ` [FFmpeg-devel] [PATCH 2/2] lavc/vvcdec: export stream level VUI information Nuo Mi
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250203091751.259888-1-nuomi2021@gmail.com \ --to=nuomi2021@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git