Adding get_scan_{4x4, 8x8, 16x16} functions.
authorDmitry Kovalev <dkovalev@google.com>
Mon, 22 Apr 2013 21:08:41 +0000 (14:08 -0700)
committerDmitry Kovalev <dkovalev@google.com>
Mon, 22 Apr 2013 21:08:41 +0000 (14:08 -0700)
Change-Id: Id4306ef6d65d4a3984aed50b775bdf48d4f6c438

vp9/common/vp9_entropy.c
vp9/common/vp9_entropy.h
vp9/decoder/vp9_detokenize.c
vp9/encoder/vp9_encodemb.c
vp9/encoder/vp9_quantize.c
vp9/encoder/vp9_rdopt.c
vp9/encoder/vp9_tokenize.c

index a5437d8..16ef14f 100644 (file)
@@ -12,7 +12,6 @@
 #include <stdio.h>
 
 #include "vp9/common/vp9_entropy.h"
-#include "string.h"
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_onyxc_int.h"
 #include "vp9/common/vp9_entropymode.h"
index 123b5e2..07b07a7 100644 (file)
@@ -223,6 +223,39 @@ void vp9_adapt_zpc_probs(struct VP9Common *cm);
 
 #endif  // CONFIG_CODE_ZEROGROUP
 
+static INLINE const int* get_scan_4x4(TX_TYPE tx_type) {
+  switch (tx_type) {
+    case ADST_DCT:
+      return vp9_row_scan_4x4;
+    case DCT_ADST:
+      return vp9_col_scan_4x4;
+    default:
+      return vp9_default_zig_zag1d_4x4;
+  }
+}
+
+static INLINE const int* get_scan_8x8(TX_TYPE tx_type) {
+  switch (tx_type) {
+    case ADST_DCT:
+      return vp9_row_scan_8x8;
+    case DCT_ADST:
+      return vp9_col_scan_8x8;
+    default:
+      return vp9_default_zig_zag1d_8x8;
+  }
+}
+
+static INLINE const int* get_scan_16x16(TX_TYPE tx_type) {
+  switch (tx_type) {
+    case ADST_DCT:
+      return vp9_row_scan_16x16;
+    case DCT_ADST:
+      return vp9_col_scan_16x16;
+    default:
+      return vp9_default_zig_zag1d_16x16;
+  }
+}
+
 #include "vp9/common/vp9_coefupdateprobs.h"
 
 #endif  // VP9_COMMON_VP9_ENTROPY_H_
index 18ef51a..02ee7c3 100644 (file)
@@ -165,17 +165,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
     case TX_4X4: {
       tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
           get_tx_type_4x4(xd, block_idx) : DCT_DCT;
-      switch (tx_type) {
-        default:
-          scan = vp9_default_zig_zag1d_4x4;
-          break;
-        case ADST_DCT:
-          scan = vp9_row_scan_4x4;
-          break;
-        case DCT_ADST:
-          scan = vp9_col_scan_4x4;
-          break;
-      }
+      scan = get_scan_4x4(tx_type);
       above_ec = A0[aidx] != 0;
       left_ec = L0[lidx] != 0;
       coef_probs  = fc->coef_probs_4x4;
@@ -194,17 +184,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
       const int y = block_idx - x;
       tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
           get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
-      switch (tx_type) {
-        default:
-          scan = vp9_default_zig_zag1d_8x8;
-          break;
-        case ADST_DCT:
-          scan = vp9_row_scan_8x8;
-          break;
-        case DCT_ADST:
-          scan = vp9_col_scan_8x8;
-          break;
-      }
+      scan = get_scan_8x8(tx_type);
       coef_probs  = fc->coef_probs_8x8;
       coef_counts = fc->coef_counts_8x8;
       above_ec = (A0[aidx] + A0[aidx + 1]) != 0;
@@ -223,17 +203,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
       const int y = block_idx - x;
       tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
           get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
-      switch (tx_type) {
-        default:
-          scan = vp9_default_zig_zag1d_16x16;
-          break;
-        case ADST_DCT:
-          scan = vp9_row_scan_16x16;
-          break;
-        case DCT_ADST:
-          scan = vp9_col_scan_16x16;
-          break;
-      }
+      scan = get_scan_16x16(tx_type);
       coef_probs  = fc->coef_probs_16x16;
       coef_counts = fc->coef_counts_16x16;
       if (type == PLANE_TYPE_UV) {
index c841c28..8121f86 100644 (file)
@@ -335,13 +335,7 @@ static void optimize_b(VP9_COMMON *const cm,
     case TX_4X4: {
       const TX_TYPE tx_type = get_tx_type_4x4(xd, ib);
       default_eob = 16;
-      if (tx_type == DCT_ADST) {
-        scan = vp9_col_scan_4x4;
-      } else if (tx_type == ADST_DCT) {
-        scan = vp9_row_scan_4x4;
-      } else {
-        scan = vp9_default_zig_zag1d_4x4;
-      }
+      scan = get_scan_4x4(tx_type);
       break;
     }
     case TX_8X8: {
@@ -349,13 +343,7 @@ static void optimize_b(VP9_COMMON *const cm,
       const int sz = 3 + mb_width_log2(sb_type);
       const int x = ib & ((1 << sz) - 1), y = ib - x;
       const TX_TYPE tx_type = get_tx_type_8x8(xd, y + (x >> 1));
-      if (tx_type == DCT_ADST) {
-        scan = vp9_col_scan_8x8;
-      } else if (tx_type == ADST_DCT) {
-        scan = vp9_row_scan_8x8;
-      } else {
-        scan = vp9_default_zig_zag1d_8x8;
-      }
+      scan = get_scan_8x8(tx_type);
       default_eob = 64;
       break;
     }
@@ -364,13 +352,7 @@ static void optimize_b(VP9_COMMON *const cm,
       const int sz = 4 + mb_width_log2(sb_type);
       const int x = ib & ((1 << sz) - 1), y = ib - x;
       const TX_TYPE tx_type = get_tx_type_16x16(xd, y + (x >> 2));
-      if (tx_type == DCT_ADST) {
-        scan = vp9_col_scan_16x16;
-      } else if (tx_type == ADST_DCT) {
-        scan = vp9_row_scan_16x16;
-      } else {
-        scan = vp9_default_zig_zag1d_16x16;
-      }
+      scan = get_scan_16x16(tx_type);
       default_eob = 256;
       break;
     }
index 18f0f4f..a654947 100644 (file)
@@ -44,19 +44,7 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
   uint8_t *quant_shift_ptr = b->quant_shift;
   int16_t *dequant_ptr     = d->dequant;
   int zbin_oq_value        = b->zbin_extra;
-  const int *pt_scan;
-
-  switch (tx_type) {
-    case ADST_DCT:
-      pt_scan = vp9_row_scan_4x4;
-      break;
-    case DCT_ADST:
-      pt_scan = vp9_col_scan_4x4;
-      break;
-    default:
-      pt_scan = vp9_default_zig_zag1d_4x4;
-      break;
-  }
+  const int *pt_scan = get_scan_4x4(tx_type);
 
   vpx_memset(qcoeff_ptr, 0, 32);
   vpx_memset(dqcoeff_ptr, 0, 32);
@@ -165,19 +153,7 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
                                       pb_idx.block, 16);
   BLOCK *const b = &mb->block[c_idx];
   BLOCKD *const d = &xd->block[c_idx];
-  const int *pt_scan;
-
-  switch (tx_type) {
-    case ADST_DCT:
-      pt_scan = vp9_row_scan_8x8;
-      break;
-    case DCT_ADST:
-      pt_scan = vp9_col_scan_8x8;
-      break;
-    default:
-      pt_scan = vp9_default_zig_zag1d_8x8;
-      break;
-  }
+  const int *pt_scan = get_scan_8x8(tx_type);
 
   if (c_idx == 0) assert(pb_idx.plane == 0);
   if (c_idx == 16) assert(pb_idx.plane == 1);
@@ -313,19 +289,7 @@ void vp9_regular_quantize_b_16x16(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
   const int c_idx = plane_idx(pb_idx.plane);
   BLOCK *const b = &mb->block[c_idx];
   BLOCKD *const d = &xd->block[c_idx];
-  const int *pt_scan;
-
-  switch (tx_type) {
-    case ADST_DCT:
-      pt_scan = vp9_row_scan_16x16;
-      break;
-    case DCT_ADST:
-      pt_scan = vp9_col_scan_16x16;
-      break;
-    default:
-      pt_scan = vp9_default_zig_zag1d_16x16;
-      break;
-  }
+  const int *pt_scan = get_scan_16x16(tx_type);
 
   if (c_idx == 0) assert(pb_idx.plane == 0);
   if (c_idx == 16) assert(pb_idx.plane == 1);
index 18ad10b..9875c12 100644 (file)
@@ -352,13 +352,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
       l_ec = *l;
       coef_probs = cm->fc.coef_probs_4x4;
       seg_eob = 16;
-      if (tx_type == ADST_DCT) {
-        scan = vp9_row_scan_4x4;
-      } else if (tx_type == DCT_ADST) {
-        scan = vp9_col_scan_4x4;
-      } else {
-        scan = vp9_default_zig_zag1d_4x4;
-      }
+      scan = get_scan_4x4(tx_type);
 #if CONFIG_CODE_ZEROGROUP
       zpc_probs = &cm->fc.zpc_probs_4x4;
 #endif
@@ -372,13 +366,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
           get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
       a_ec = (a[0] + a[1]) != 0;
       l_ec = (l[0] + l[1]) != 0;
-      if (tx_type == ADST_DCT) {
-        scan = vp9_row_scan_8x8;
-      } else if (tx_type == DCT_ADST) {
-        scan = vp9_col_scan_8x8;
-      } else {
-        scan = vp9_default_zig_zag1d_8x8;
-      }
+      scan = get_scan_8x8(tx_type);
       coef_probs = cm->fc.coef_probs_8x8;
       seg_eob = 64;
 #if CONFIG_CODE_ZEROGROUP
@@ -392,13 +380,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
       const int x = ib & ((1 << sz) - 1), y = ib - x;
       TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
           get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
-      if (tx_type == ADST_DCT) {
-        scan = vp9_row_scan_16x16;
-      } else if (tx_type == DCT_ADST) {
-        scan = vp9_col_scan_16x16;
-      } else {
-        scan = vp9_default_zig_zag1d_16x16;
-      }
+      scan = get_scan_16x16(tx_type);
       coef_probs = cm->fc.coef_probs_16x16;
       seg_eob = 256;
       if (type == PLANE_TYPE_UV) {
index f6a7206..9d02e3a 100644 (file)
@@ -204,14 +204,7 @@ static void tokenize_b(VP9_COMP *cpi,
       a_ec = *a;
       l_ec = *l;
       seg_eob = 16;
-      scan = vp9_default_zig_zag1d_4x4;
-      if (tx_type != DCT_DCT) {
-        if (tx_type == ADST_DCT) {
-          scan = vp9_row_scan_4x4;
-        } else if (tx_type == DCT_ADST) {
-          scan = vp9_col_scan_4x4;
-        }
-      }
+      scan = get_scan_4x4(tx_type);
       counts = cpi->coef_counts_4x4;
       coef_probs = cpi->common.fc.coef_probs_4x4;
 #if CONFIG_CODE_ZEROGROUP
@@ -228,14 +221,7 @@ static void tokenize_b(VP9_COMP *cpi,
       a_ec = (a[0] + a[1]) != 0;
       l_ec = (l[0] + l[1]) != 0;
       seg_eob = 64;
-      scan = vp9_default_zig_zag1d_8x8;
-      if (tx_type != DCT_DCT) {
-        if (tx_type == ADST_DCT) {
-          scan = vp9_row_scan_8x8;
-        } else if (tx_type == DCT_ADST) {
-          scan = vp9_col_scan_8x8;
-        }
-      }
+      scan = get_scan_8x8(tx_type);
       counts = cpi->coef_counts_8x8;
       coef_probs = cpi->common.fc.coef_probs_8x8;
 #if CONFIG_CODE_ZEROGROUP
@@ -257,14 +243,7 @@ static void tokenize_b(VP9_COMP *cpi,
         l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0;
       }
       seg_eob = 256;
-      scan = vp9_default_zig_zag1d_16x16;
-      if (tx_type != DCT_DCT) {
-        if (tx_type == ADST_DCT) {
-          scan = vp9_row_scan_16x16;
-        } else if (tx_type == DCT_ADST) {
-          scan = vp9_col_scan_16x16;
-        }
-      }
+      scan = get_scan_16x16(tx_type);
       counts = cpi->coef_counts_16x16;
       coef_probs = cpi->common.fc.coef_probs_16x16;
 #if CONFIG_CODE_ZEROGROUP