]> granicus.if.org Git - libvpx/commitdiff
Parameterize transform scale for quantizer
authorAngie Chiang <angiebird@google.com>
Mon, 28 Mar 2016 22:41:44 +0000 (15:41 -0700)
committerAngie Chiang <angiebird@google.com>
Wed, 30 Mar 2016 22:25:26 +0000 (15:25 -0700)
This is to facilitate changing transform scale later

Change-Id: Ic8ca5afba57d2489ebd191ccc40c1b31605a0d8c

vp10/common/idct.c
vp10/common/idct.h
vp10/decoder/detokenize.c
vp10/encoder/encodemb.c
vp10/encoder/quantize.c
vp10/encoder/quantize.h
vp10/encoder/rdopt.c

index 47a3219b8de9610cf3a3ad314bd3b83a6bfaa0c5..b06a5e9e33026344209dbc8768f2ee64baf46cc9 100644 (file)
 #include "vpx_dsp/inv_txfm.h"
 #include "vpx_ports/mem.h"
 
+int get_tx_scale(const MACROBLOCKD *const xd, const TX_TYPE tx_type,
+                 const TX_SIZE tx_size) {
+  (void) tx_type;
+#if CONFIG_VP9_HIGHBITDEPTH
+  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+    if (xd->bd == BITDEPTH_10) {
+      return 0;
+    } else {
+      return tx_size == TX_32X32;
+    }
+  }
+#else
+  (void)xd;
+#endif
+  return tx_size == TX_32X32;
+}
+
 #if CONFIG_EXT_TX
 static void iidtx4_c(const tran_low_t *input, tran_low_t *output) {
   int i;
index 31b26b89ce231152c6a02ce6fca1e91097680349..ffdad0caafb06d99f93cae0e4251f0a626e080d5 100644 (file)
@@ -14,6 +14,7 @@
 #include <assert.h>
 
 #include "./vpx_config.h"
+#include "vp10/common/blockd.h"
 #include "vp10/common/common.h"
 #include "vp10/common/enums.h"
 #include "vpx_dsp/inv_txfm.h"
@@ -48,6 +49,10 @@ typedef struct {
 } highbd_transform_2d;
 #endif  // CONFIG_VP9_HIGHBITDEPTH
 
+#define MAX_TX_SCALE 1
+int get_tx_scale(const MACROBLOCKD *const xd, const TX_TYPE tx_type,
+                 const TX_SIZE tx_size);
+
 void vp10_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                      int eob);
 void vp10_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
index bf482219741eefcea19d7211a9c8fad8b64499a6..cfc19d44855772c05e60aa5a7215ec4aecffc3fb 100644 (file)
@@ -15,9 +15,7 @@
 #include "vp10/common/blockd.h"
 #include "vp10/common/common.h"
 #include "vp10/common/entropy.h"
-#if CONFIG_COEFFICIENT_RANGE_CHECKING
 #include "vp10/common/idct.h"
-#endif
 
 #include "vp10/decoder/detokenize.h"
 
@@ -113,15 +111,7 @@ static int decode_coefs(const MACROBLOCKD *xd,
   cat6_prob = vp10_cat6_prob;
 #endif
 
-#if CONFIG_VP9_HIGHBITDEPTH
-  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH && xd->bd == BITDEPTH_10) {
-    dq_shift = 0;
-  } else {
-    dq_shift = (tx_size == TX_32X32);
-  }
-#else
-  dq_shift = (tx_size == TX_32X32);
-#endif
+  dq_shift = get_tx_scale(xd, 0, tx_size);
 
   while (c < max_eob) {
     int val = -1;
@@ -257,15 +247,7 @@ static int decode_coefs_ans(const MACROBLOCKD *const xd,
   const uint8_t *cat5_prob;
   const uint8_t *cat6_prob;
 
-#if CONFIG_VP9_HIGHBITDEPTH
-  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH && xd->bd == BITDEPTH_10) {
-    dq_shift = 0;
-  } else {
-    dq_shift = (tx_size == TX_32X32);
-  }
-#else
-  dq_shift = (tx_size == TX_32X32);
-#endif
+  dq_shift = get_tx_scale(xd, 0, tx_size);
 
   if (counts) {
     coef_counts = counts->coef[tx_size][type][ref];
index 429ac4f5be9574c97a85967326043e46c9d8a4f7..060fe0be4b25761a48b34a6b3fe041f53c7a67cb 100644 (file)
@@ -129,15 +129,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
   assert((!type && !plane) || (type && plane));
   assert(eob <= default_eob);
 
-#if CONFIG_VP9_HIGHBITDEPTH
-  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH && xd->bd == BITDEPTH_10) {
-    mul = 1;
-  } else {
-    mul = 1 + (tx_size == TX_32X32);
-  }
-#else
-  mul = 1 + (tx_size == TX_32X32);
-#endif
+  mul = 1 << get_tx_scale(xd, tx_type, tx_size);
 
   /* Now set up a Viterbi trellis to evaluate alternative roundings. */
   if (!ref)
@@ -323,35 +315,29 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
 #if CONFIG_VP9_HIGHBITDEPTH
 typedef enum QUANT_FUNC {
   QUANT_FUNC_LOWBD = 0,
-  QUANT_FUNC_LOWBD_32 = 1,
-  QUANT_FUNC_HIGHBD = 2,
-  QUANT_FUNC_HIGHBD_32 = 3,
-  QUANT_FUNC_LAST = 4
+  QUANT_FUNC_HIGHBD = 1,
+  QUANT_FUNC_LAST = 2
 } QUANT_FUNC;
 
 static VP10_QUANT_FACADE
     quant_func_list[VP10_XFORM_QUANT_LAST][QUANT_FUNC_LAST] = {
-        {vp10_quantize_fp_facade, vp10_quantize_fp_32x32_facade,
-         vp10_highbd_quantize_fp_facade, vp10_highbd_quantize_fp_32x32_facade},
-        {vp10_quantize_b_facade, vp10_quantize_b_32x32_facade,
-         vp10_highbd_quantize_b_facade, vp10_highbd_quantize_b_32x32_facade},
-        {vp10_quantize_dc_facade, vp10_quantize_dc_32x32_facade,
-         vp10_highbd_quantize_dc_facade, vp10_highbd_quantize_dc_32x32_facade},
-        {NULL, NULL, NULL, NULL}};
+        {vp10_quantize_fp_facade, vp10_highbd_quantize_fp_facade},
+        {vp10_quantize_b_facade, vp10_highbd_quantize_b_facade},
+        {vp10_quantize_dc_facade, vp10_highbd_quantize_dc_facade},
+        {NULL, NULL}};
 
 #else
 typedef enum QUANT_FUNC {
   QUANT_FUNC_LOWBD = 0,
-  QUANT_FUNC_LOWBD_32 = 1,
-  QUANT_FUNC_LAST = 2
+  QUANT_FUNC_LAST = 1
 } QUANT_FUNC;
 
 static VP10_QUANT_FACADE
     quant_func_list[VP10_XFORM_QUANT_LAST][QUANT_FUNC_LAST] = {
-        {vp10_quantize_fp_facade, vp10_quantize_fp_32x32_facade},
-        {vp10_quantize_b_facade, vp10_quantize_b_32x32_facade},
-        {vp10_quantize_dc_facade, vp10_quantize_dc_32x32_facade},
-        {NULL, NULL}};
+        {vp10_quantize_fp_facade},
+        {vp10_quantize_b_facade},
+        {vp10_quantize_dc_facade},
+        {NULL}};
 #endif
 
 static FWD_TXFM_OPT fwd_txfm_opt_list[VP10_XFORM_QUANT_LAST] = {
@@ -378,7 +364,9 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
   const int tx2d_size = tx1d_size * tx1d_size;
 
   FWD_TXFM_PARAM fwd_txfm_param;
-  fwd_txfm_param.tx_type = get_tx_type(plane_type, xd, block, tx_size);
+  QUANT_PARAM qparam;
+
+  fwd_txfm_param.tx_type = tx_type;
   fwd_txfm_param.tx_size = tx_size;
   fwd_txfm_param.fwd_txfm_opt = fwd_txfm_opt_list[xform_quant_idx];
   fwd_txfm_param.rd_transform = x->use_lp32x32fdct;
@@ -386,6 +374,7 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
 
   src_diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)];
 
+  qparam.log_scale = get_tx_scale(xd, tx_type, tx_size);
 #if CONFIG_VP9_HIGHBITDEPTH
   fwd_txfm_param.bd = xd->bd;
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -394,12 +383,9 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
       if (x->skip_block) {
         vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob);
       } else {
-        if (tx_size == TX_32X32 && xd->bd != 10)
-          quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD_32](
-              coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
-        else
-          quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD](
-              coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
+        quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD](
+            coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob,
+            scan_order, &qparam);
       }
     }
     return;
@@ -411,12 +397,9 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
     if (x->skip_block) {
       vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob);
     } else {
-      if (tx_size == TX_32X32)
-        quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD_32](
-            coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
-      else
-        quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD](
-            coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order);
+      quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD](
+          coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob,
+          scan_order, &qparam);
     }
   }
 }
index 3f8f0f4273d7b1a5f840230c772df7bc89122b2a..e1d0addecf93de92d1c2a10e012be799961a9ff0 100644 (file)
@@ -33,52 +33,79 @@ void vp10_quantize_fp_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
                              const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
                              const MACROBLOCKD_PLANE *pd,
                              tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                             const scan_order *sc) {
+                             const scan_order *sc, const QUANT_PARAM *qparam) {
   // obsolete skip_block
   const int skip_block = 0;
 
-  vp10_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
-                   p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
-                   pd->dequant, eob_ptr, sc->scan, sc->iscan);
+  if (qparam->log_scale == 0) {
+    vp10_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
+                     p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
+                     pd->dequant, eob_ptr, sc->scan, sc->iscan);
+  } else {
+    vp10_quantize_fp_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
+                           p->round_fp, p->quant_fp, p->quant_shift, qcoeff_ptr,
+                           dqcoeff_ptr, pd->dequant, eob_ptr, sc->scan,
+                           sc->iscan);
+  }
 }
 
 void vp10_quantize_b_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
                             const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
                             const MACROBLOCKD_PLANE *pd,
                             tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                            const scan_order *sc) {
+                            const scan_order *sc, const QUANT_PARAM *qparam) {
   // obsolete skip_block
   const int skip_block = 0;
 
-  vpx_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round, p->quant,
-                 p->quant_shift, qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
-                 sc->scan, sc->iscan);
+  if (qparam->log_scale == 0) {
+    vpx_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round, p->quant,
+                   p->quant_shift, qcoeff_ptr, dqcoeff_ptr, pd->dequant,
+                   eob_ptr, sc->scan, sc->iscan);
+  } else {
+    vpx_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
+                         p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
+                         pd->dequant, eob_ptr, sc->scan, sc->iscan);
+  }
 }
 
 void vp10_quantize_dc_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
                              const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
                              const MACROBLOCKD_PLANE *pd,
                              tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                             const scan_order *sc) {
+                             const scan_order *sc, const QUANT_PARAM *qparam) {
   // obsolete skip_block
   const int skip_block = 0;
   (void)sc;
-  vpx_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
-                  p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr, pd->dequant[0],
-                  eob_ptr);
+  if (qparam->log_scale == 0) {
+    vpx_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
+                    p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr, pd->dequant[0],
+                    eob_ptr);
+  } else {
+    vpx_quantize_dc_32x32(coeff_ptr, skip_block, p->round, p->quant_fp[0],
+                          qcoeff_ptr, dqcoeff_ptr, pd->dequant[0], eob_ptr);
+  }
 }
 
 #if CONFIG_VP9_HIGHBITDEPTH
 void vp10_highbd_quantize_fp_facade(
     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
     tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc) {
+    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc,
+    const QUANT_PARAM *qparam) {
   // obsolete skip_block
   const int skip_block = 0;
 
-  vp10_highbd_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
-                          p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
-                          pd->dequant, eob_ptr, sc->scan, sc->iscan);
+  if (qparam->log_scale == 0) {
+    vp10_highbd_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin,
+                            p->round_fp, p->quant_fp, p->quant_shift,
+                            qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
+                            sc->scan, sc->iscan);
+  } else {
+    vp10_highbd_quantize_fp_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
+                                  p->round_fp, p->quant_fp, p->quant_shift,
+                                  qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
+                                  sc->scan, sc->iscan);
+  }
 }
 
 void vp10_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
@@ -86,114 +113,42 @@ void vp10_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
                                    tran_low_t *qcoeff_ptr,
                                    const MACROBLOCKD_PLANE *pd,
                                    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                   const scan_order *sc) {
+                                   const scan_order *sc,
+                                   const QUANT_PARAM *qparam) {
   // obsolete skip_block
   const int skip_block = 0;
 
-  vpx_highbd_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
-                        p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
-                        pd->dequant, eob_ptr, sc->scan, sc->iscan);
+  if (qparam->log_scale == 0) {
+    vpx_highbd_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
+                          p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
+                          pd->dequant, eob_ptr, sc->scan, sc->iscan);
+  } else {
+    vpx_highbd_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
+                                p->round, p->quant, p->quant_shift, qcoeff_ptr,
+                                dqcoeff_ptr, pd->dequant, eob_ptr, sc->scan,
+                                sc->iscan);
+  }
 }
 
 void vp10_highbd_quantize_dc_facade(
     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
     tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc) {
-  // obsolete skip_block
-  const int skip_block = 0;
-
-  (void)sc;
-
-  vpx_highbd_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
-                         p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr,
-                         pd->dequant[0], eob_ptr);
-}
-#endif  // CONFIG_VP9_HIGHBITDEPTH
-
-void vp10_quantize_fp_32x32_facade(const tran_low_t *coeff_ptr,
-                                   intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-                                   tran_low_t *qcoeff_ptr,
-                                   const MACROBLOCKD_PLANE *pd,
-                                   tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                   const scan_order *sc) {
-  // obsolete skip_block
-  const int skip_block = 0;
-
-  vp10_quantize_fp_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp,
-                         p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
-                         pd->dequant, eob_ptr, sc->scan, sc->iscan);
-}
-
-void vp10_quantize_b_32x32_facade(const tran_low_t *coeff_ptr,
-                                  intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-                                  tran_low_t *qcoeff_ptr,
-                                  const MACROBLOCKD_PLANE *pd,
-                                  tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                  const scan_order *sc) {
-  // obsolete skip_block
-  const int skip_block = 0;
-
-  vpx_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
-                       p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
-                       pd->dequant, eob_ptr, sc->scan, sc->iscan);
-}
-
-void vp10_quantize_dc_32x32_facade(const tran_low_t *coeff_ptr,
-                                   intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-                                   tran_low_t *qcoeff_ptr,
-                                   const MACROBLOCKD_PLANE *pd,
-                                   tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                   const scan_order *sc) {
-  // obsolete skip_block
-  const int skip_block = 0;
-
-  (void)sc;
-  (void)n_coeffs;
-
-  vpx_quantize_dc_32x32(coeff_ptr, skip_block, p->round, p->quant_fp[0],
-                        qcoeff_ptr, dqcoeff_ptr, pd->dequant[0], eob_ptr);
-}
-
-#if CONFIG_VP9_HIGHBITDEPTH
-void vp10_highbd_quantize_fp_32x32_facade(
-    const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-    tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc) {
-  // obsolete skip_block
-  const int skip_block = 0;
-
-  vp10_highbd_quantize_fp_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
-                                p->round_fp, p->quant_fp, p->quant_shift,
-                                qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
-                                sc->scan, sc->iscan);
-}
-
-void vp10_highbd_quantize_b_32x32_facade(
-    const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-    tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc) {
-  // obsolete skip_block
-  const int skip_block = 0;
-
-  vpx_highbd_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
-                              p->round, p->quant, p->quant_shift, qcoeff_ptr,
-                              dqcoeff_ptr, pd->dequant, eob_ptr, sc->scan,
-                              sc->iscan);
-}
-
-void vp10_highbd_quantize_dc_32x32_facade(
-    const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-    tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc) {
+    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc,
+    const QUANT_PARAM *qparam) {
   // obsolete skip_block
   const int skip_block = 0;
 
   (void)sc;
-  (void)n_coeffs;
 
-  vpx_highbd_quantize_dc_32x32(coeff_ptr, skip_block, p->round, p->quant_fp[0],
-                               qcoeff_ptr, dqcoeff_ptr, pd->dequant[0],
-                               eob_ptr);
+  if (qparam->log_scale == 0) {
+    vpx_highbd_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round,
+                           p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr,
+                           pd->dequant[0], eob_ptr);
+  } else {
+    vpx_highbd_quantize_dc_32x32(coeff_ptr, skip_block, p->round,
+                                 p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr,
+                                 pd->dequant[0], eob_ptr);
+  }
 }
 #endif  // CONFIG_VP9_HIGHBITDEPTH
 
index 6128460554c5f461aec4291565cb68bab0ef50c6..92ffd5c1cef4a96bea761e0f85cccaeec0cdb843 100644 (file)
 extern "C" {
 #endif
 
+typedef struct QUANT_PARAM {
+  int log_scale;
+} QUANT_PARAM;
+
 typedef void (*VP10_QUANT_FACADE)(const tran_low_t *coeff_ptr,
                                   intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
                                   tran_low_t *qcoeff_ptr,
                                   const MACROBLOCKD_PLANE *pd,
                                   tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                  const scan_order *sc);
+                                  const scan_order *sc,
+                                  const QUANT_PARAM *qparam);
 
 typedef struct {
   // 0: dc 1: ac 2-8: ac repeated to SIMD width
@@ -48,7 +53,6 @@ typedef struct {
 
 void vp10_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block,
                                  const int16_t *scan, const int16_t *iscan);
-
 struct VP10_COMP;
 struct VP10Common;
 
@@ -71,74 +75,41 @@ void vp10_quantize_fp_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
                              const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
                              const MACROBLOCKD_PLANE *pd,
                              tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                             const scan_order *sc);
+                             const scan_order *sc, const QUANT_PARAM *qparam);
 
 void vp10_quantize_b_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
                             const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
                             const MACROBLOCKD_PLANE *pd,
                             tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                            const scan_order *sc);
+                            const scan_order *sc, const QUANT_PARAM *qparam);
 
 void vp10_quantize_dc_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
                              const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
                              const MACROBLOCKD_PLANE *pd,
                              tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                             const scan_order *sc);
+                             const scan_order *sc, const QUANT_PARAM *qparam);
 #if CONFIG_VP9_HIGHBITDEPTH
 void vp10_highbd_quantize_fp_facade(
     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
     tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
+    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc,
+    const QUANT_PARAM *qparam);
 
 void vp10_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
                                    intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
                                    tran_low_t *qcoeff_ptr,
                                    const MACROBLOCKD_PLANE *pd,
                                    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                   const scan_order *sc);
+                                   const scan_order *sc,
+                                   const QUANT_PARAM *qparam);
 
 void vp10_highbd_quantize_dc_facade(
     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
     tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
+    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc,
+    const QUANT_PARAM *qparam);
 #endif  // CONFIG_VP9_HIGHBITDEPTH
 
-void vp10_quantize_fp_32x32_facade(const tran_low_t *coeff_ptr,
-                                   intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-                                   tran_low_t *qcoeff_ptr,
-                                   const MACROBLOCKD_PLANE *pd,
-                                   tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                   const scan_order *sc);
-
-void vp10_quantize_b_32x32_facade(const tran_low_t *coeff_ptr,
-                                  intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-                                  tran_low_t *qcoeff_ptr,
-                                  const MACROBLOCKD_PLANE *pd,
-                                  tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                  const scan_order *sc);
-
-void vp10_quantize_dc_32x32_facade(const tran_low_t *coeff_ptr,
-                                   intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-                                   tran_low_t *qcoeff_ptr,
-                                   const MACROBLOCKD_PLANE *pd,
-                                   tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
-                                   const scan_order *sc);
-#if CONFIG_VP9_HIGHBITDEPTH
-void vp10_highbd_quantize_fp_32x32_facade(
-    const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-    tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
-
-void vp10_highbd_quantize_b_32x32_facade(
-    const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-    tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
-
-void vp10_highbd_quantize_dc_32x32_facade(
-    const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
-    tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
-    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc);
-#endif  // CONFIG_VP9_HIGHBITDEPTH
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index 328e70c75b66b18500dc408492b2e5c621c73974..c317c0509d60908b4cd96b15017f4d537883ba5c 100644 (file)
@@ -1003,7 +1003,7 @@ static void dist_block(const VP10_COMP *cpi, MACROBLOCK *x, int plane,
     const struct macroblock_plane *const p = &x->plane[plane];
     const struct macroblockd_plane *const pd = &xd->plane[plane];
     int64_t this_sse;
-    int shift = tx_size == TX_32X32 ? 0 : 2;
+    int shift = (MAX_TX_SCALE - get_tx_scale(xd, 0, tx_size)) * 2;
     tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
     tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
 #if CONFIG_VP9_HIGHBITDEPTH
@@ -1177,19 +1177,11 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
         const int64_t orig_sse = (int64_t)coeff[0] * coeff[0];
         const int64_t resd_sse = coeff[0] - dqcoeff[0];
         int64_t dc_correct = orig_sse - resd_sse * resd_sse;
+        int shift = (MAX_TX_SCALE - get_tx_scale(xd, 0, tx_size)) * 2;
 #if CONFIG_VP9_HIGHBITDEPTH
         dc_correct >>= ((xd->bd - 8) * 2);
-        if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH &&
-            xd->bd == BITDEPTH_10) {
-          dc_correct >>= 2;
-        } else {
-          if (tx_size != TX_32X32)
-            dc_correct >>= 2;
-        }
-#else
-        if (tx_size != TX_32X32)
-          dc_correct >>= 2;
 #endif
+        dc_correct >>= shift;
 
         dist = VPXMAX(0, sse - dc_correct);
       }