[FFmpeg-devel] [PATCH v1 09/23] avcodec/vvc/intra: add ff_vvc_palette_derive_scale
toqsxw at gmail.com
toqsxw at gmail.com
Thu May 1 17:43:07 EEST 2025
From: Wu Jianhua <toqsxw at outlook.com>
Signed-off-by: Wu Jianhua <toqsxw at outlook.com>
---
libavcodec/vvc/intra.c | 52 ++++++++++++++++++++++++++----------------
libavcodec/vvc/intra.h | 1 +
2 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/libavcodec/vvc/intra.c b/libavcodec/vvc/intra.c
index 2e6cb8f09e..2e1703e234 100644
--- a/libavcodec/vvc/intra.c
+++ b/libavcodec/vvc/intra.c
@@ -336,29 +336,30 @@ static void derive_qp(const VVCLocalContext *lc, const TransformUnit *tu, Transf
tb->bd_offset = (1 << tb->bd_shift) >> 1;
}
+static const uint8_t rem6[63 + 8 * 6 + 1] = {
+ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
+ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
+ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
+ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
+ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
+};
+
+static const uint8_t div6[63 + 8 * 6 + 1] = {
+ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
+ 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
+ 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
+ 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18,
+};
+
+const static int level_scale[2][6] = {
+ { 40, 45, 51, 57, 64, 72 },
+ { 57, 64, 72, 80, 90, 102 }
+};
+
//8.7.3 Scaling process for transform coefficients
static av_always_inline int derive_scale(const TransformBlock *tb, const int sh_dep_quant_used_flag)
{
- static const uint8_t rem6[63 + 8 * 6 + 1] = {
- 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
- 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
- 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
- 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
- 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
- };
-
- static const uint8_t div6[63 + 8 * 6 + 1] = {
- 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
- 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18,
- };
-
- const static int level_scale[2][6] = {
- { 40, 45, 51, 57, 64, 72 },
- { 57, 64, 72, 80, 90, 102 }
- };
const int addin = sh_dep_quant_used_flag && !tb->ts;
const int qp = tb->qp + addin;
@@ -658,6 +659,17 @@ static void ibc_fill_vir_buf(const VVCLocalContext *lc, const CodingUnit *cu)
}
}
+int ff_vvc_palette_derive_scale(VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
+{
+ const VVCSPS *sps = lc->fc->ps.sps;
+ const int qp_prime_ts_min = 4 + 6 * sps->r->sps_min_qp_prime_ts;
+ int qp;
+
+ derive_qp(lc, tu, tb);
+ qp = FFMAX(qp_prime_ts_min, tb->qp);
+ return level_scale[0][rem6[qp]] << div6[qp];
+}
+
int ff_vvc_reconstruct(VVCLocalContext *lc, const int rs, const int rx, const int ry)
{
const VVCFrameContext *fc = lc->fc;
diff --git a/libavcodec/vvc/intra.h b/libavcodec/vvc/intra.h
index 8a02699135..1201c70836 100644
--- a/libavcodec/vvc/intra.h
+++ b/libavcodec/vvc/intra.h
@@ -45,5 +45,6 @@ int ff_vvc_intra_pred_angle_derive(int pred_mode);
int ff_vvc_intra_inv_angle_derive(int pred_mode);
int ff_vvc_wide_angle_mode_mapping(const CodingUnit *cu,
int tb_width, int tb_height, int c_idx, int pred_mode_intra);
+int ff_vvc_palette_derive_scale(VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb);
#endif // AVCODEC_VVC_INTRA_H
--
2.44.0.windows.1
More information about the ffmpeg-devel
mailing list