[FFmpeg-cvslog] idct: Convert IDCT permutation #defines to an enum

Diego Biurrun git at videolan.org
Fri Jul 18 22:14:14 CEST 2014


ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Tue Feb 18 11:30:55 2014 +0100| [b4987f72197e0c62cf2633bf835a9c32d2a445ae] | committer: Diego Biurrun

idct: Convert IDCT permutation #defines to an enum

Also rename the enum values to be consistent with other DCT permutations.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b4987f72197e0c62cf2633bf835a9c32d2a445ae
---

 libavcodec/arm/idctdsp_init_arm.c      |    4 ++--
 libavcodec/arm/idctdsp_init_armv5te.c  |    2 +-
 libavcodec/arm/idctdsp_init_armv6.c    |    2 +-
 libavcodec/arm/idctdsp_init_neon.c     |    2 +-
 libavcodec/cavsdsp.c                   |    2 +-
 libavcodec/eamad.c                     |    2 +-
 libavcodec/eatgq.c                     |    2 +-
 libavcodec/eatqi.c                     |    2 +-
 libavcodec/idctdsp.c                   |   24 ++++++++++++------------
 libavcodec/idctdsp.h                   |   21 ++++++++++++---------
 libavcodec/mpegvideo_enc.c             |    2 +-
 libavcodec/ppc/idctdsp.c               |    2 +-
 libavcodec/proresdsp.c                 |    2 +-
 libavcodec/wmv2.c                      |    2 +-
 libavcodec/wmv2dsp.c                   |    2 +-
 libavcodec/x86/cavsdsp.c               |    2 +-
 libavcodec/x86/idctdsp_init.c          |   12 ++++++------
 libavcodec/x86/mpegvideoenc_template.c |    2 +-
 libavcodec/x86/proresdsp_init.c        |    6 +++---
 19 files changed, 49 insertions(+), 46 deletions(-)

diff --git a/libavcodec/arm/idctdsp_init_arm.c b/libavcodec/arm/idctdsp_init_arm.c
index b4d1899..e61bf83 100644
--- a/libavcodec/arm/idctdsp_init_arm.c
+++ b/libavcodec/arm/idctdsp_init_arm.c
@@ -78,12 +78,12 @@ av_cold void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
             c->idct_put              = j_rev_dct_arm_put;
             c->idct_add              = j_rev_dct_arm_add;
             c->idct                  = ff_j_rev_dct_arm;
-            c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_LIBMPEG2;
         } else if (avctx->idct_algo == FF_IDCT_SIMPLEARM) {
             c->idct_put              = simple_idct_arm_put;
             c->idct_add              = simple_idct_arm_add;
             c->idct                  = ff_simple_idct_arm;
-            c->idct_permutation_type = FF_NO_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_NONE;
         }
     }
 
diff --git a/libavcodec/arm/idctdsp_init_armv5te.c b/libavcodec/arm/idctdsp_init_armv5te.c
index e2492a5..2037331 100644
--- a/libavcodec/arm/idctdsp_init_armv5te.c
+++ b/libavcodec/arm/idctdsp_init_armv5te.c
@@ -38,6 +38,6 @@ av_cold void ff_idctdsp_init_armv5te(IDCTDSPContext *c, AVCodecContext *avctx,
         c->idct_put              = ff_simple_idct_put_armv5te;
         c->idct_add              = ff_simple_idct_add_armv5te;
         c->idct                  = ff_simple_idct_armv5te;
-        c->idct_permutation_type = FF_NO_IDCT_PERM;
+        c->perm_type             = FF_IDCT_PERM_NONE;
     }
 }
diff --git a/libavcodec/arm/idctdsp_init_armv6.c b/libavcodec/arm/idctdsp_init_armv6.c
index e92f471..dbf3647 100644
--- a/libavcodec/arm/idctdsp_init_armv6.c
+++ b/libavcodec/arm/idctdsp_init_armv6.c
@@ -41,7 +41,7 @@ av_cold void ff_idctdsp_init_armv6(IDCTDSPContext *c, AVCodecContext *avctx,
             c->idct_put              = ff_simple_idct_put_armv6;
             c->idct_add              = ff_simple_idct_add_armv6;
             c->idct                  = ff_simple_idct_armv6;
-            c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_LIBMPEG2;
         }
     }
     c->add_pixels_clamped = ff_add_pixels_clamped_armv6;
diff --git a/libavcodec/arm/idctdsp_init_neon.c b/libavcodec/arm/idctdsp_init_neon.c
index 1790597..6dcda25 100644
--- a/libavcodec/arm/idctdsp_init_neon.c
+++ b/libavcodec/arm/idctdsp_init_neon.c
@@ -43,7 +43,7 @@ av_cold void ff_idctdsp_init_neon(IDCTDSPContext *c, AVCodecContext *avctx,
             c->idct_put              = ff_simple_idct_put_neon;
             c->idct_add              = ff_simple_idct_add_neon;
             c->idct                  = ff_simple_idct_neon;
-            c->idct_permutation_type = FF_PARTTRANS_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_PARTTRANS;
         }
     }
 
diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c
index 958e3c5..b0f94de 100644
--- a/libavcodec/cavsdsp.c
+++ b/libavcodec/cavsdsp.c
@@ -561,7 +561,7 @@ av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) {
     c->cavs_filter_cv = cavs_filter_cv_c;
     c->cavs_filter_ch = cavs_filter_ch_c;
     c->cavs_idct8_add = cavs_idct8_add_c;
-    c->idct_perm = FF_NO_IDCT_PERM;
+    c->idct_perm = FF_IDCT_PERM_NONE;
 
     if (ARCH_X86)
         ff_cavsdsp_init_x86(c, avctx);
diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
index 9edf344..19a6783 100644
--- a/libavcodec/eamad.c
+++ b/libavcodec/eamad.c
@@ -68,7 +68,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
     ff_blockdsp_init(&s->bdsp, avctx);
     ff_bswapdsp_init(&s->bbdsp);
     ff_idctdsp_init(&s->idsp, avctx);
-    ff_init_scantable_permutation(s->idsp.idct_permutation, FF_NO_IDCT_PERM);
+    ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE);
     ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_zigzag_direct);
     ff_mpeg12_init_vlcs();
 
diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index d8320c9..0e4ba2f 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -51,7 +51,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx)
     TgqContext *s = avctx->priv_data;
     uint8_t idct_permutation[64];
     s->avctx = avctx;
-    ff_init_scantable_permutation(idct_permutation, FF_NO_IDCT_PERM);
+    ff_init_scantable_permutation(idct_permutation, FF_IDCT_PERM_NONE);
     ff_init_scantable(idct_permutation, &s->scantable, ff_zigzag_direct);
     avctx->time_base = (AVRational){1, 15};
     avctx->pix_fmt   = AV_PIX_FMT_YUV420P;
diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c
index 60d80e9..25882da 100644
--- a/libavcodec/eatqi.c
+++ b/libavcodec/eatqi.c
@@ -53,7 +53,7 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx)
     ff_blockdsp_init(&s->bdsp, avctx);
     ff_bswapdsp_init(&t->bsdsp);
     ff_idctdsp_init(&s->idsp, avctx);
-    ff_init_scantable_permutation(s->idsp.idct_permutation, FF_NO_IDCT_PERM);
+    ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE);
     ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
     s->qscale = 1;
     avctx->time_base = (AVRational){1, 15};
diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c
index 8542ab3..9651c2c 100644
--- a/libavcodec/idctdsp.c
+++ b/libavcodec/idctdsp.c
@@ -47,29 +47,29 @@ av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
 }
 
 av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
-                                           int idct_permutation_type)
+                                           enum idct_permutation_type perm_type)
 {
     int i;
 
     if (ARCH_X86)
         if (ff_init_scantable_permutation_x86(idct_permutation,
-                                              idct_permutation_type))
+                                              perm_type))
             return;
 
-    switch (idct_permutation_type) {
-    case FF_NO_IDCT_PERM:
+    switch (perm_type) {
+    case FF_IDCT_PERM_NONE:
         for (i = 0; i < 64; i++)
             idct_permutation[i] = i;
         break;
-    case FF_LIBMPEG2_IDCT_PERM:
+    case FF_IDCT_PERM_LIBMPEG2:
         for (i = 0; i < 64; i++)
             idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
         break;
-    case FF_TRANSPOSE_IDCT_PERM:
+    case FF_IDCT_PERM_TRANSPOSE:
         for (i = 0; i < 64; i++)
             idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
         break;
-    case FF_PARTTRANS_IDCT_PERM:
+    case FF_IDCT_PERM_PARTTRANS:
         for (i = 0; i < 64; i++)
             idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
         break;
@@ -161,23 +161,23 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
         c->idct_put              = ff_simple_idct_put_10;
         c->idct_add              = ff_simple_idct_add_10;
         c->idct                  = ff_simple_idct_10;
-        c->idct_permutation_type = FF_NO_IDCT_PERM;
+        c->perm_type             = FF_IDCT_PERM_NONE;
     } else {
         if (avctx->idct_algo == FF_IDCT_INT) {
             c->idct_put              = jref_idct_put;
             c->idct_add              = jref_idct_add;
             c->idct                  = ff_j_rev_dct;
-            c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_LIBMPEG2;
         } else if (avctx->idct_algo == FF_IDCT_FAAN) {
             c->idct_put              = ff_faanidct_put;
             c->idct_add              = ff_faanidct_add;
             c->idct                  = ff_faanidct;
-            c->idct_permutation_type = FF_NO_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_NONE;
         } else { // accurate/default
             c->idct_put              = ff_simple_idct_put_8;
             c->idct_add              = ff_simple_idct_add_8;
             c->idct                  = ff_simple_idct_8;
-            c->idct_permutation_type = FF_NO_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_NONE;
         }
     }
 
@@ -193,5 +193,5 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
         ff_idctdsp_init_x86(c, avctx, high_bit_depth);
 
     ff_init_scantable_permutation(c->idct_permutation,
-                                  c->idct_permutation_type);
+                                  c->perm_type);
 }
diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h
index e3a2317..b88cc82 100644
--- a/libavcodec/idctdsp.h
+++ b/libavcodec/idctdsp.h
@@ -32,12 +32,21 @@ typedef struct ScanTable {
     uint8_t raster_end[64];
 } ScanTable;
 
+enum idct_permutation_type {
+    FF_IDCT_PERM_NONE,
+    FF_IDCT_PERM_LIBMPEG2,
+    FF_IDCT_PERM_SIMPLE,
+    FF_IDCT_PERM_TRANSPOSE,
+    FF_IDCT_PERM_PARTTRANS,
+    FF_IDCT_PERM_SSE2,
+};
+
 void ff_init_scantable(uint8_t *permutation, ScanTable *st,
                        const uint8_t *src_scantable);
 void ff_init_scantable_permutation(uint8_t *idct_permutation,
-                                   int idct_permutation_type);
+                                   enum idct_permutation_type perm_type);
 int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
-                                      int idct_permutation_type);
+                                      enum idct_permutation_type perm_type);
 
 typedef struct IDCTDSPContext {
     /* pixel ops : interface with DCT */
@@ -83,13 +92,7 @@ typedef struct IDCTDSPContext {
      *    -> simple_idct_mmx -> ...)
      */
     uint8_t idct_permutation[64];
-    int idct_permutation_type;
-#define FF_NO_IDCT_PERM 1
-#define FF_LIBMPEG2_IDCT_PERM 2
-#define FF_SIMPLE_IDCT_PERM 3
-#define FF_TRANSPOSE_IDCT_PERM 4
-#define FF_PARTTRANS_IDCT_PERM 5
-#define FF_SSE2_IDCT_PERM 6
+    enum idct_permutation_type perm_type;
 } IDCTDSPContext;
 
 void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f0bf73e..ea24902 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -4223,7 +4223,7 @@ int ff_dct_quantize_c(MpegEncContext *s,
     *overflow= s->max_qcoeff < max; //overflow might have happened
 
     /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
-    if (s->idsp.idct_permutation_type != FF_NO_IDCT_PERM)
+    if (s->idsp.perm_type != FF_IDCT_PERM_NONE)
         ff_block_permute(block, s->idsp.idct_permutation,
                          scantable, last_non_zero);
 
diff --git a/libavcodec/ppc/idctdsp.c b/libavcodec/ppc/idctdsp.c
index 8a1d290..7dd3ab2 100644
--- a/libavcodec/ppc/idctdsp.c
+++ b/libavcodec/ppc/idctdsp.c
@@ -237,7 +237,7 @@ av_cold void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx,
                 (avctx->idct_algo == FF_IDCT_ALTIVEC)) {
                 c->idct_add              = idct_add_altivec;
                 c->idct_put              = idct_put_altivec;
-                c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+                c->perm_type             = FF_IDCT_PERM_TRANSPOSE;
             }
         }
     }
diff --git a/libavcodec/proresdsp.c b/libavcodec/proresdsp.c
index 1d92d36..3af2f0b 100644
--- a/libavcodec/proresdsp.c
+++ b/libavcodec/proresdsp.c
@@ -58,7 +58,7 @@ static void prores_idct_put_c(uint16_t *out, int linesize, int16_t *block, const
 av_cold void ff_proresdsp_init(ProresDSPContext *dsp)
 {
     dsp->idct_put = prores_idct_put_c;
-    dsp->idct_permutation_type = FF_NO_IDCT_PERM;
+    dsp->idct_permutation_type = FF_IDCT_PERM_NONE;
 
     if (ARCH_X86)
         ff_proresdsp_init_x86(dsp);
diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c
index b6c7bc0..7b1ea57 100644
--- a/libavcodec/wmv2.c
+++ b/libavcodec/wmv2.c
@@ -31,7 +31,7 @@ av_cold void ff_wmv2_common_init(Wmv2Context * w){
 
     ff_blockdsp_init(&s->bdsp, s->avctx);
     ff_wmv2dsp_init(&w->wdsp);
-    s->idsp.idct_permutation_type = w->wdsp.idct_perm;
+    s->idsp.perm_type = w->wdsp.idct_perm;
     ff_init_scantable_permutation(s->idsp.idct_permutation,
                                   w->wdsp.idct_perm);
     ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0],
diff --git a/libavcodec/wmv2dsp.c b/libavcodec/wmv2dsp.c
index 49df436..8af71f4 100644
--- a/libavcodec/wmv2dsp.c
+++ b/libavcodec/wmv2dsp.c
@@ -252,7 +252,7 @@ av_cold void ff_wmv2dsp_init(WMV2DSPContext *c)
 {
     c->idct_add  = wmv2_idct_add_c;
     c->idct_put  = wmv2_idct_put_c;
-    c->idct_perm = FF_NO_IDCT_PERM;
+    c->idct_perm = FF_IDCT_PERM_NONE;
 
     c->put_mspel_pixels_tab[0] = ff_put_pixels8x8_c;
     c->put_mspel_pixels_tab[1] = put_mspel8_mc10_c;
diff --git a/libavcodec/x86/cavsdsp.c b/libavcodec/x86/cavsdsp.c
index f0e8cfc..b85912b 100644
--- a/libavcodec/x86/cavsdsp.c
+++ b/libavcodec/x86/cavsdsp.c
@@ -493,7 +493,7 @@ static av_cold void cavsdsp_init_mmx(CAVSDSPContext *c,
     c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmx;
 
     c->cavs_idct8_add = cavs_idct8_add_mmx;
-    c->idct_perm      = FF_TRANSPOSE_IDCT_PERM;
+    c->idct_perm      = FF_IDCT_PERM_TRANSPOSE;
 }
 #endif /* HAVE_MMX_INLINE */
 
diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
index 9b68497..5bd293f 100644
--- a/libavcodec/x86/idctdsp_init.c
+++ b/libavcodec/x86/idctdsp_init.c
@@ -41,16 +41,16 @@ static const uint8_t simple_mmx_permutation[64] = {
 static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
 
 av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
-                                              int idct_permutation_type)
+                                              enum idct_permutation_type perm_type)
 {
     int i;
 
-    switch (idct_permutation_type) {
-    case FF_SIMPLE_IDCT_PERM:
+    switch (perm_type) {
+    case FF_IDCT_PERM_SIMPLE:
         for (i = 0; i < 64; i++)
             idct_permutation[i] = simple_mmx_permutation[i];
         return 1;
-    case FF_SSE2_IDCT_PERM:
+    case FF_IDCT_PERM_SSE2:
         for (i = 0; i < 64; i++)
             idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
         return 1;
@@ -76,7 +76,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
                 c->idct_put              = ff_simple_idct_put_mmx;
                 c->idct_add              = ff_simple_idct_add_mmx;
                 c->idct                  = ff_simple_idct_mmx;
-                c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
+                c->perm_type             = FF_IDCT_PERM_SIMPLE;
                 break;
             case FF_IDCT_XVIDMMX:
                 c->idct_put              = ff_idct_xvid_mmx_put;
@@ -100,7 +100,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
             c->idct_put              = ff_idct_xvid_sse2_put;
             c->idct_add              = ff_idct_xvid_sse2_add;
             c->idct                  = ff_idct_xvid_sse2;
-            c->idct_permutation_type = FF_SSE2_IDCT_PERM;
+            c->perm_type             = FF_IDCT_PERM_SSE2;
         }
     }
 }
diff --git a/libavcodec/x86/mpegvideoenc_template.c b/libavcodec/x86/mpegvideoenc_template.c
index 4a17ff3..87965fe 100644
--- a/libavcodec/x86/mpegvideoenc_template.c
+++ b/libavcodec/x86/mpegvideoenc_template.c
@@ -229,7 +229,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
     if(s->mb_intra) block[0]= level;
     else            block[0]= temp_block[0];
 
-    if (s->idsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM) {
+    if (s->idsp.perm_type == FF_IDCT_PERM_SIMPLE) {
         if(last_non_zero_p1 <= 1) goto end;
         block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08];
         block[0x20] = temp_block[0x10];
diff --git a/libavcodec/x86/proresdsp_init.c b/libavcodec/x86/proresdsp_init.c
index a66fc70..e82dac0 100644
--- a/libavcodec/x86/proresdsp_init.c
+++ b/libavcodec/x86/proresdsp_init.c
@@ -38,17 +38,17 @@ av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp)
     int cpu_flags = av_get_cpu_flags();
 
     if (EXTERNAL_SSE2(cpu_flags)) {
-        dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+        dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
         dsp->idct_put = ff_prores_idct_put_10_sse2;
     }
 
     if (EXTERNAL_SSE4(cpu_flags)) {
-        dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+        dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
         dsp->idct_put = ff_prores_idct_put_10_sse4;
     }
 
     if (EXTERNAL_AVX(cpu_flags)) {
-        dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+        dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
         dsp->idct_put = ff_prores_idct_put_10_avx;
     }
 #endif /* ARCH_X86_64 */



More information about the ffmpeg-cvslog mailing list