[FFmpeg-devel] [PATCH v2 3/3] avcodec/vvc/dsp: prefix TxType and TxSize with VVC

toqsxw at outlook.com toqsxw at outlook.com
Thu Aug 8 22:13:43 EEST 2024


From: Wu Jianhua <toqsxw at outlook.com>

See https://github.com/ffvvc/FFmpeg/issues/180

Signed-off-by: Wu Jianhua <toqsxw at outlook.com>
---
 libavcodec/vvc/dsp.h          | 28 ++++++++++++++--------------
 libavcodec/vvc/dsp_template.c |  2 +-
 libavcodec/vvc/intra.c        | 26 +++++++++++++-------------
 3 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/libavcodec/vvc/dsp.h b/libavcodec/vvc/dsp.h
index 0b49b97021..38ff492a23 100644
--- a/libavcodec/vvc/dsp.h
+++ b/libavcodec/vvc/dsp.h
@@ -27,21 +27,21 @@
 #include <stdint.h>
 #include <stddef.h>
 
-enum TxType {
-    DCT2,
-    DST7,
-    DCT8,
-    N_TX_TYPE,
+enum VVCTxType {
+    VVC_DCT2,
+    VVC_DST7,
+    VVC_DCT8,
+    VVC_N_TX_TYPE,
 };
 
-enum TxSize {
-    TX_SIZE_2,
-    TX_SIZE_4,
-    TX_SIZE_8,
-    TX_SIZE_16,
-    TX_SIZE_32,
-    TX_SIZE_64,
-    N_TX_SIZE,
+enum VVCTxSize {
+    VVC_TX_SIZE_2,
+    VVC_TX_SIZE_4,
+    VVC_TX_SIZE_8,
+    VVC_TX_SIZE_16,
+    VVC_TX_SIZE_32,
+    VVC_TX_SIZE_64,
+    VVC_N_TX_SIZE,
 };
 
 typedef struct VVCInterDSPContext {
@@ -127,7 +127,7 @@ typedef struct VVCItxDSPContext {
     void (*add_residual_joint)(uint8_t *dst, const int *res, int width, int height, ptrdiff_t stride, int c_sign, int shift);
     void (*pred_residual_joint)(int *buf, int width, int height, int c_sign, int shift);
 
-    void (*itx[N_TX_TYPE][N_TX_SIZE])(int *coeffs, ptrdiff_t step, size_t nz);
+    void (*itx[VVC_N_TX_TYPE][VVC_N_TX_SIZE])(int *coeffs, ptrdiff_t step, size_t nz);
     void (*transform_bdpcm)(int *coeffs, int width, int height, int vertical, int log2_transform_range);
 } VVCItxDSPContext;
 
diff --git a/libavcodec/vvc/dsp_template.c b/libavcodec/vvc/dsp_template.c
index 8130abbccf..1aa1e027bd 100644
--- a/libavcodec/vvc/dsp_template.c
+++ b/libavcodec/vvc/dsp_template.c
@@ -97,7 +97,7 @@ static void FUNC(transform_bdpcm)(int *coeffs, const int width, const int height
 static void FUNC(ff_vvc_itx_dsp_init)(VVCItxDSPContext *const itx)
 {
 #define VVC_ITX(TYPE, type, s)                                                  \
-        itx->itx[TYPE][TX_SIZE_##s]      = ff_vvc_inv_##type##_##s;             \
+        itx->itx[VVC_##TYPE][VVC_##TX_SIZE_##s]      = ff_vvc_inv_##type##_##s;             \
 
 #define VVC_ITX_COMMON(TYPE, type)                                              \
         VVC_ITX(TYPE, type, 4);                                                 \
diff --git a/libavcodec/vvc/intra.c b/libavcodec/vvc/intra.c
index f77a012f09..73dca6dc85 100644
--- a/libavcodec/vvc/intra.c
+++ b/libavcodec/vvc/intra.c
@@ -128,15 +128,15 @@ static void ilfnst_transform(const VVCLocalContext *lc, TransformBlock *tb)
 }
 
 //part of 8.7.4 Transformation process for scaled transform coefficients
-static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalContext *lc, const TransformBlock *tb, enum TxType *trh, enum TxType *trv)
+static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalContext *lc, const TransformBlock *tb, enum VVCTxType *trh, enum VVCTxType *trv)
 {
     const CodingUnit *cu = lc->cu;
-    static const enum TxType mts_to_trh[] = {DCT2, DST7, DCT8, DST7, DCT8};
-    static const enum TxType mts_to_trv[] = {DCT2, DST7, DST7, DCT8, DCT8};
+    static const enum VVCTxType mts_to_trh[] = { VVC_DCT2, VVC_DST7, VVC_DCT8, VVC_DST7, VVC_DCT8 };
+    static const enum VVCTxType mts_to_trv[] = { VVC_DCT2, VVC_DST7, VVC_DST7, VVC_DCT8, VVC_DCT8 };
     const VVCSPS *sps       = fc->ps.sps;
     int implicit_mts_enabled = 0;
     if (tb->c_idx || (cu->isp_split_type != ISP_NO_SPLIT && cu->lfnst_idx)) {
-        *trh = *trv = DCT2;
+        *trh = *trv = VVC_DCT2;
         return;
     }
 
@@ -152,11 +152,11 @@ static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalConte
         const int w = tb->tb_width;
         const int h = tb->tb_height;
         if (cu->sbt_flag) {
-            *trh = (cu->sbt_horizontal_flag  || cu->sbt_pos_flag) ? DST7 : DCT8;
-            *trv = (!cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? DST7 : DCT8;
+            *trh = (cu->sbt_horizontal_flag  || cu->sbt_pos_flag) ? VVC_DST7 : VVC_DCT8;
+            *trv = (!cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? VVC_DST7 : VVC_DCT8;
         } else {
-            *trh = (w >= 4 && w <= 16) ? DST7 : DCT2;
-            *trv = (h >= 4 && h <= 16) ? DST7 : DCT2;
+            *trh = (w >= 4 && w <= 16) ? VVC_DST7 : VVC_DCT2;
+            *trv = (h >= 4 && h <= 16) ? VVC_DST7 : VVC_DCT2;
         }
         return;
     }
@@ -447,7 +447,7 @@ static void dequant(const VVCLocalContext *lc, const TransformUnit *tu, Transfor
 
 //transmatrix[0][0]
 #define DCT_A 64
-static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxType trh, const enum TxType trv)
+static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
 {
     const VVCSPS *sps   = fc->ps.sps;
     const int w         = tb->tb_width;
@@ -456,7 +456,7 @@ static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxT
     const size_t nzh    = tb->max_scan_y + 1;
     const int shift[]   = { 7, 5 + sps->log2_transform_range - sps->bit_depth };
 
-    if (w == h && nzw == 1 && nzh == 1 && trh == DCT2 && trv == DCT2) {
+    if (w == h && nzw == 1 && nzh == 1 && trh == VVC_DCT2 && trv == VVC_DCT2) {
         const int add[] = { 1 << (shift[0] - 1), 1 << (shift[1] - 1) };
         const int t     = (tb->coeffs[0] * DCT_A + add[0]) >> shift[0];
         const int dc    = (t * DCT_A + add[1]) >> shift[1];
@@ -476,7 +476,7 @@ static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxT
     scale(tb->coeffs, tb->coeffs, w, h, shift[1]);
 }
 
-static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxType trh, const enum TxType trv)
+static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
 {
     const VVCSPS *sps   = fc->ps.sps;
     const int w         = tb->tb_width;
@@ -484,7 +484,7 @@ static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxT
     const size_t nzw    = tb->max_scan_x + 1;
     const size_t nzh    = tb->max_scan_y + 1;
 
-    if ((w > 1 && nzw == 1 && trh == DCT2) || (h > 1 && nzh == 1 && trv == DCT2)) {
+    if ((w > 1 && nzw == 1 && trh == VVC_DCT2) || (h > 1 && nzh == 1 && trv == VVC_DCT2)) {
         const int shift = 6 + sps->log2_transform_range - sps->bit_depth;
         const int add   = 1 << (shift - 1);
         const int dc    = (tb->coeffs[0] * DCT_A + add) >> shift;
@@ -542,7 +542,7 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx,
                 transform_bdpcm(tb, lc, cu);
             dequant(lc, tu, tb);
             if (!tb->ts) {
-                enum TxType trh, trv;
+                enum VVCTxType trh, trv;
 
                 if (cu->apply_lfnst_flag[c_idx])
                     ilfnst_transform(lc, tb);
-- 
2.44.0.windows.1



More information about the ffmpeg-devel mailing list