idct: Convert IDCT permutation #defines to an enum
authorDiego Biurrun <diego@biurrun.de>
Tue, 18 Feb 2014 10:30:55 +0000 (11:30 +0100)
committerDiego Biurrun <diego@biurrun.de>
Fri, 18 Jul 2014 14:51:03 +0000 (07:51 -0700)
Also rename the enum values to be consistent with other DCT permutations.

19 files changed:
libavcodec/arm/idctdsp_init_arm.c
libavcodec/arm/idctdsp_init_armv5te.c
libavcodec/arm/idctdsp_init_armv6.c
libavcodec/arm/idctdsp_init_neon.c
libavcodec/cavsdsp.c
libavcodec/eamad.c
libavcodec/eatgq.c
libavcodec/eatqi.c
libavcodec/idctdsp.c
libavcodec/idctdsp.h
libavcodec/mpegvideo_enc.c
libavcodec/ppc/idctdsp.c
libavcodec/proresdsp.c
libavcodec/wmv2.c
libavcodec/wmv2dsp.c
libavcodec/x86/cavsdsp.c
libavcodec/x86/idctdsp_init.c
libavcodec/x86/mpegvideoenc_template.c
libavcodec/x86/proresdsp_init.c

index b4d1899..e61bf83 100644 (file)
@@ -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;
         }
     }
 
index e2492a5..2037331 100644 (file)
@@ -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;
     }
 }
index e92f471..dbf3647 100644 (file)
@@ -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;
index 1790597..6dcda25 100644 (file)
@@ -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;
         }
     }
 
index 958e3c5..b0f94de 100644 (file)
@@ -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);
index 9edf344..19a6783 100644 (file)
@@ -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();
 
index d8320c9..0e4ba2f 100644 (file)
@@ -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;
index 60d80e9..25882da 100644 (file)
@@ -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};
index 8542ab3..9651c2c 100644 (file)
@@ -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);
 }
index e3a2317..b88cc82 100644 (file)
@@ -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);
index f0bf73e..ea24902 100644 (file)
@@ -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);
 
index 8a1d290..7dd3ab2 100644 (file)
@@ -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;
             }
         }
     }
index 1d92d36..3af2f0b 100644 (file)
@@ -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);
index b6c7bc0..7b1ea57 100644 (file)
@@ -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],
index 49df436..8af71f4 100644 (file)
@@ -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;
index f0e8cfc..b85912b 100644 (file)
@@ -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 */
 
index 9b68497..5bd293f 100644 (file)
@@ -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;
         }
     }
 }
index 4a17ff3..87965fe 100644 (file)
@@ -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];
index a66fc70..e82dac0 100644 (file)
@@ -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 */