Commit 9324d388 authored by Debargha Mukherjee's avatar Debargha Mukherjee
Browse files

Change non-uniform-quant parameters

Also adds hooks to choose different profiles for UV and intra.

Results
lowres: -0.15%
midres: -0.24%

Change-Id: I4af8bc3e9b82b6f8a061dce9f52c89afa6239ae1
parent 60b2927d
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
static void make_qmatrices(qm_val_t *wmatrix[NUM_QM_LEVELS][2][2][TX_SIZES], 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]); qm_val_t *iwmatrix[NUM_QM_LEVELS][2][2][TX_SIZES]);
#endif #endif
#if CONFIG_NEW_QUANT
#if CONFIG_NEW_QUANT
// Bin widths expressed as a fraction over 128 of the quant stepsize, // Bin widths expressed as a fraction over 128 of the quant stepsize,
// for the quantization bins 0-4. // for the quantization bins 0-4.
// So a value x indicates the bin is actually factor x/128 of the // 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] = { ...@@ -47,54 +47,54 @@ static const qprofile_type nuq_lossless[COEF_BANDS] = {
static const qprofile_type nuq[QUANT_PROFILES][QUANT_RANGES][COEF_BANDS] = { static const qprofile_type nuq[QUANT_PROFILES][QUANT_RANGES][COEF_BANDS] = {
{ { { {
{ { 64, 128, 128 }, 0 }, // dc, band 0 { { 64, 128, 128 }, 8 }, // dc, band 0
{ { 64, 128, 128 }, 0 }, // band 1 { { 64, 128, 128 }, 10 }, // band 1
{ { 64, 128, 128 }, 0 }, // band 2 { { 64, 128, 128 }, 12 }, // band 2
{ { 64, 128, 128 }, 0 }, // band 3 { { 72, 128, 128 }, 14 }, // band 3
{ { 64, 128, 128 }, 0 }, // band 4 { { 76, 128, 128 }, 16 }, // band 4
{ { 64, 128, 128 }, 0 } // band 5 { { 80, 128, 128 }, 18 } // band 5
}, },
{ {
{ { 64, 128, 128 }, 0 }, // dc, band 0 { { 64, 128, 128 }, 4 }, // dc, band 0
{ { 64, 128, 128 }, 0 }, // band 1 { { 64, 128, 128 }, 6 }, // band 1
{ { 64, 128, 128 }, 0 }, // band 2 { { 64, 128, 128 }, 8 }, // band 2
{ { 64, 128, 128 }, 0 }, // band 3 { { 64, 128, 128 }, 10 }, // band 3
{ { 64, 128, 128 }, 0 }, // band 4 { { 72, 128, 128 }, 12 }, // band 4
{ { 64, 128, 128 }, 0 } // band 5 { { 80, 128, 128 }, 14 } // band 5
} }, } },
#if QUANT_PROFILES > 1 #if QUANT_PROFILES > 1
{ { { {
{ { 64, 128, 128 }, 0 }, // dc, band 0 { { 64, 128, 128 }, 6 }, // dc, band 0
{ { 64, 128, 128 }, 0 }, // band 1 { { 64, 128, 128 }, 8 }, // band 1
{ { 64, 128, 128 }, 0 }, // band 2 { { 64, 128, 128 }, 10 }, // band 2
{ { 64, 128, 128 }, 0 }, // band 3 { { 64, 128, 128 }, 12 }, // band 3
{ { 64, 128, 128 }, 0 }, // band 4 { { 72, 128, 128 }, 14 }, // band 4
{ { 64, 128, 128 }, 0 } // band 5 { { 80, 128, 128 }, 16 } // band 5
}, },
{ {
{ { 64, 128, 128 }, 0 }, // dc, band 0 { { 64, 128, 128 }, 4 }, // dc, band 0
{ { 64, 128, 128 }, 0 }, // band 1 { { 64, 128, 128 }, 6 }, // band 1
{ { 64, 128, 128 }, 0 }, // band 2 { { 64, 128, 128 }, 8 }, // band 2
{ { 64, 128, 128 }, 0 }, // band 3 { { 64, 128, 128 }, 10 }, // band 3
{ { 64, 128, 128 }, 0 }, // band 4 { { 72, 128, 128 }, 12 }, // band 4
{ { 64, 128, 128 }, 0 } // band 5 { { 80, 128, 128 }, 14 } // band 5
} }, } },
#if QUANT_PROFILES > 2 #if QUANT_PROFILES > 2
{ { { {
{ { 64, 128, 128 }, 0 }, // dc, band 0 { { 64, 128, 128 }, 6 }, // dc, band 0
{ { 64, 128, 128 }, 0 }, // band 1 { { 64, 128, 128 }, 8 }, // band 1
{ { 64, 128, 128 }, 0 }, // band 2 { { 64, 128, 128 }, 10 }, // band 2
{ { 64, 128, 128 }, 0 }, // band 3 { { 64, 128, 128 }, 12 }, // band 3
{ { 64, 128, 128 }, 0 }, // band 4 { { 72, 128, 128 }, 14 }, // band 4
{ { 64, 128, 128 }, 0 }, // band 5 { { 80, 128, 128 }, 16 } // band 5
}, },
{ {
{ { 64, 128, 128 }, 0 }, // dc, band 0 { { 64, 128, 128 }, 4 }, // dc, band 0
{ { 64, 128, 128 }, 0 }, // band 1 { { 64, 128, 128 }, 6 }, // band 1
{ { 64, 128, 128 }, 0 }, // band 2 { { 64, 128, 128 }, 8 }, // band 2
{ { 64, 128, 128 }, 0 }, // band 3 { { 64, 128, 128 }, 10 }, // band 3
{ { 64, 128, 128 }, 0 }, // band 4 { { 72, 128, 128 }, 12 }, // band 4
{ { 64, 128, 128 }, 0 }, // band 5 { { 80, 128, 128 }, 14 } // band 5
} } } }
#endif // QUANT_PROFILES > 2 #endif // QUANT_PROFILES > 2
#endif // QUANT_PROFILES > 1 #endif // QUANT_PROFILES > 1
......
...@@ -70,7 +70,10 @@ void av1_get_dequant_val_nuq(int q, int qindex, int band, tran_low_t *dq, ...@@ -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_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); 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); return AOMMIN(q_ctx, QUANT_PROFILES - 1);
} }
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
......
...@@ -505,7 +505,8 @@ int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane, ...@@ -505,7 +505,8 @@ int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
const int ctx = const int ctx =
get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y); get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y);
#if CONFIG_NEW_QUANT #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 #endif // CONFIG_NEW_QUANT
#if !CONFIG_ANS #if !CONFIG_ANS
......
...@@ -96,7 +96,7 @@ int av1_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size, ...@@ -96,7 +96,7 @@ int av1_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
#endif #endif
const int shift = get_tx_scale(xd, tx_type, tx_size); const int shift = get_tx_scale(xd, tx_type, tx_size);
#if CONFIG_NEW_QUANT #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]; const dequant_val_type_nuq *dequant_val = pd->dequant_val_nuq[dq];
#else #else
const int dq_step[2] = { dequant_ptr[0] >> shift, dequant_ptr[1] >> shift }; 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, ...@@ -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]; const struct macroblockd_plane *const pd = &xd->plane[plane];
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV; 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); TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const scan_order *const scan_order = const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
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);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block); tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, 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]; uint16_t *const eob = &p->eobs[block];
const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
const int16_t *src_diff; const int16_t *src_diff;
...@@ -584,11 +584,11 @@ void av1_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row, ...@@ -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; MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane]; const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->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; 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); TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const scan_order *const scan_order = const scan_order *const scan_order = get_scan(tx_size, tx_type, is_inter);
get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi)); 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 coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, 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, ...@@ -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]; uint16_t *const eob = &p->eobs[block];
const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
const int16_t *src_diff; 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; 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, ...@@ -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]; uint16_t *const eob = &p->eobs[block];
const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
const int16_t *src_diff; 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; FWD_TXFM_PARAM fwd_txfm_param;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment