[FFmpeg-cvslog] lavc/vvcdec: refact, set AVCodecContext->has_b_frames in sps_export_stream_params
Nuo Mi
git at videolan.org
Sat Feb 22 05:33:09 EET 2025
ffmpeg | branch: master | Nuo Mi <nuomi2021 at gmail.com> | Mon Feb 3 17:17:50 2025 +0800| [2d9433f25b2c1a1b02ffbc3b556d2ad1353e1e9b] | committer: Nuo Mi
lavc/vvcdec: refact, set AVCodecContext->has_b_frames in sps_export_stream_params
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d9433f25b2c1a1b02ffbc3b556d2ad1353e1e9b
---
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 572e904301..f860e116ab 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -810,7 +810,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;
More information about the ffmpeg-cvslog
mailing list