]> granicus.if.org Git - libvpx/commitdiff
Change non-uniform-quant parameters
authorDebargha Mukherjee <debargha@google.com>
Fri, 23 Sep 2016 17:52:13 +0000 (10:52 -0700)
committerDebargha Mukherjee <debargha@google.com>
Wed, 28 Sep 2016 16:09:35 +0000 (09:09 -0700)
Also adds hooks to choose different profiles for UV and intra.

Results
lowres: -0.15%
midres: -0.24%

Change-Id: I4af8bc3e9b82b6f8a061dce9f52c89afa6239ae1

av1/common/quant_common.c
av1/common/quant_common.h
av1/decoder/detokenize.c
av1/encoder/encodemb.c

index 4b5101647c0a6d98e12b392030f3bde24f19369c..4f3d481c465602f28096245984a1660ca7539067 100644 (file)
@@ -20,8 +20,8 @@
 static void make_qmatrices(qm_val_t *wmatrix[NUM_QM_LEVELS][2][2][TX_SIZES],
                            qm_val_t *iwmatrix[NUM_QM_LEVELS][2][2][TX_SIZES]);
 #endif
-#if CONFIG_NEW_QUANT
 
+#if CONFIG_NEW_QUANT
 // Bin widths expressed as a fraction over 128 of the quant stepsize,
 // for the quantization bins 0-4.
 // So a value x indicates the bin is actually factor x/128 of the
@@ -47,54 +47,54 @@ static const qprofile_type nuq_lossless[COEF_BANDS] = {
 
 static const qprofile_type nuq[QUANT_PROFILES][QUANT_RANGES][COEF_BANDS] = {
   { {
-        { { 64, 128, 128 }, 0 },  // dc, band 0
-        { { 64, 128, 128 }, 0 },  // band 1
-        { { 64, 128, 128 }, 0 },  // band 2
-        { { 64, 128, 128 }, 0 },  // band 3
-        { { 64, 128, 128 }, 0 },  // band 4
-        { { 64, 128, 128 }, 0 }   // band 5
+        { { 64, 128, 128 }, 8 },   // dc, band 0
+        { { 64, 128, 128 }, 10 },   // band 1
+        { { 64, 128, 128 }, 12 },  // band 2
+        { { 72, 128, 128 }, 14 },  // band 3
+        { { 76, 128, 128 }, 16 },  // band 4
+        { { 80, 128, 128 }, 18 }   // band 5
     },
     {
-        { { 64, 128, 128 }, 0 },  // dc, band 0
-        { { 64, 128, 128 }, 0 },  // band 1
-        { { 64, 128, 128 }, 0 },  // band 2
-        { { 64, 128, 128 }, 0 },  // band 3
-        { { 64, 128, 128 }, 0 },  // band 4
-        { { 64, 128, 128 }, 0 }   // band 5
+        { { 64, 128, 128 }, 4 },   // dc, band 0
+        { { 64, 128, 128 }, 6 },  // band 1
+        { { 64, 128, 128 }, 8 },  // band 2
+        { { 64, 128, 128 }, 10 },  // band 3
+        { { 72, 128, 128 }, 12 },  // band 4
+        { { 80, 128, 128 }, 14 }   // band 5
     } },
 #if QUANT_PROFILES > 1
   { {
-        { { 64, 128, 128 }, 0 },  // dc, band 0
-        { { 64, 128, 128 }, 0 },  // band 1
-        { { 64, 128, 128 }, 0 },  // band 2
-        { { 64, 128, 128 }, 0 },  // band 3
-        { { 64, 128, 128 }, 0 },  // band 4
-        { { 64, 128, 128 }, 0 }   // band 5
+        { { 64, 128, 128 }, 6 },   // dc, band 0
+        { { 64, 128, 128 }, 8 },   // band 1
+        { { 64, 128, 128 }, 10 },  // band 2
+        { { 64, 128, 128 }, 12 },  // band 3
+        { { 72, 128, 128 }, 14 },  // band 4
+        { { 80, 128, 128 }, 16 }   // band 5
     },
     {
-        { { 64, 128, 128 }, 0 },  // dc, band 0
-        { { 64, 128, 128 }, 0 },  // band 1
-        { { 64, 128, 128 }, 0 },  // band 2
-        { { 64, 128, 128 }, 0 },  // band 3
-        { { 64, 128, 128 }, 0 },  // band 4
-        { { 64, 128, 128 }, 0 }   // band 5
+        { { 64, 128, 128 }, 4 },   // dc, band 0
+        { { 64, 128, 128 }, 6 },   // band 1
+        { { 64, 128, 128 }, 8 },  // band 2
+        { { 64, 128, 128 }, 10 },  // band 3
+        { { 72, 128, 128 }, 12 },  // band 4
+        { { 80, 128, 128 }, 14 }   // band 5
     } },
 #if QUANT_PROFILES > 2
   { {
-        { { 64, 128, 128 }, 0 },  // dc, band 0
-        { { 64, 128, 128 }, 0 },  // band 1
-        { { 64, 128, 128 }, 0 },  // band 2
-        { { 64, 128, 128 }, 0 },  // band 3
-        { { 64, 128, 128 }, 0 },  // band 4
-        { { 64, 128, 128 }, 0 },  // band 5
+        { { 64, 128, 128 }, 6 },   // dc, band 0
+        { { 64, 128, 128 }, 8 },   // band 1
+        { { 64, 128, 128 }, 10 },  // band 2
+        { { 64, 128, 128 }, 12 },  // band 3
+        { { 72, 128, 128 }, 14 },  // band 4
+        { { 80, 128, 128 }, 16 }   // band 5
     },
     {
-        { { 64, 128, 128 }, 0 },  // dc, band 0
-        { { 64, 128, 128 }, 0 },  // band 1
-        { { 64, 128, 128 }, 0 },  // band 2
-        { { 64, 128, 128 }, 0 },  // band 3
-        { { 64, 128, 128 }, 0 },  // band 4
-        { { 64, 128, 128 }, 0 },  // band 5
+        { { 64, 128, 128 }, 4 },   // dc, band 0
+        { { 64, 128, 128 }, 6 },   // band 1
+        { { 64, 128, 128 }, 8 },  // band 2
+        { { 64, 128, 128 }, 10 },  // band 3
+        { { 72, 128, 128 }, 12 },  // band 4
+        { { 80, 128, 128 }, 14 }   // band 5
     } }
 #endif  // QUANT_PROFILES > 2
 #endif  // QUANT_PROFILES > 1
index a2607bfd51a305fe65ab1ea50202cc08b2542919..b4d615bf0cb6c1cc68e046425b992d5a13b243fa 100644 (file)
@@ -70,7 +70,10 @@ void av1_get_dequant_val_nuq(int q, int qindex, int band, tran_low_t *dq,
 tran_low_t av1_dequant_abscoeff_nuq(int v, int q, const tran_low_t *dq);
 tran_low_t av1_dequant_coeff_nuq(int v, int q, const tran_low_t *dq);
 
-static INLINE int get_dq_profile_from_ctx(int q_ctx) {
+static INLINE int get_dq_profile_from_ctx(int q_ctx, int is_inter,
+                                          PLANE_TYPE plane_type) {
+  if (plane_type == PLANE_TYPE_UV) return 0;
+  if (!is_inter) return QUANT_PROFILES - 1;
   return AOMMIN(q_ctx, QUANT_PROFILES - 1);
 }
 #endif  // CONFIG_NEW_QUANT
index fbcf8fe05b517006bd14380710c3a5c376b7f633..4dfac3cb6e4b6998abc209e615dabca57716580a 100644 (file)
@@ -505,7 +505,8 @@ int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
   const int ctx =
       get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y);
 #if CONFIG_NEW_QUANT
-  int dq = get_dq_profile_from_ctx(ctx);
+  const int ref = is_inter_block(&xd->mi[0]->mbmi);
+  int dq = get_dq_profile_from_ctx(ctx, ref, pd->plane_type);
 #endif  //  CONFIG_NEW_QUANT
 
 #if !CONFIG_ANS
index 18fcb370e63c918f82fa49da18b66689b22e97a4..cf371407f7015ed0f94bb20f3c9fd395cb0798e7 100644 (file)
@@ -96,7 +96,7 @@ int av1_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
 #endif
   const int shift = get_tx_scale(xd, tx_type, tx_size);
 #if CONFIG_NEW_QUANT
-  int dq = get_dq_profile_from_ctx(ctx);
+  int dq = get_dq_profile_from_ctx(ctx, ref, type);
   const dequant_val_type_nuq *dequant_val = pd->dequant_val_nuq[dq];
 #else
   const int dq_step[2] = { dequant_ptr[0] >> shift, dequant_ptr[1] >> shift };
@@ -517,12 +517,12 @@ void av1_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const scan_order *const scan_order =
-      get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+  const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
+  const scan_order *const scan_order = get_scan(tx_size, tx_type, is_inter);
   tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
-  int dq = get_dq_profile_from_ctx(ctx);
+  int dq = get_dq_profile_from_ctx(ctx, is_inter, plane_type);
   uint16_t *const eob = &p->eobs[block];
   const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
   const int16_t *src_diff;
@@ -584,11 +584,11 @@ void av1_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
   MACROBLOCKD *const xd = &x->e_mbd;
   const struct macroblock_plane *const p = &x->plane[plane];
   const struct macroblockd_plane *const pd = &xd->plane[plane];
-  int dq = get_dq_profile_from_ctx(ctx);
+  const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
   PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const scan_order *const scan_order =
-      get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+  const scan_order *const scan_order = get_scan(tx_size, tx_type, is_inter);
+  int dq = get_dq_profile_from_ctx(ctx, is_inter, plane_type);
   tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
@@ -660,7 +660,8 @@ void av1_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
   uint16_t *const eob = &p->eobs[block];
   const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
   const int16_t *src_diff;
-  int dq = get_dq_profile_from_ctx(ctx);
+  const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
+  int dq = get_dq_profile_from_ctx(ctx, is_inter, plane_type);
 
   FWD_TXFM_PARAM fwd_txfm_param;
 
@@ -720,7 +721,8 @@ void av1_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
   uint16_t *const eob = &p->eobs[block];
   const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
   const int16_t *src_diff;
-  int dq = get_dq_profile_from_ctx(ctx);
+  const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
+  int dq = get_dq_profile_from_ctx(ctx, is_inter, plane_type);
 
   FWD_TXFM_PARAM fwd_txfm_param;