Commit e8d0d4cf authored by Sarah Parker's avatar Sarah Parker

Remove ctx from new-quant profile lookup

This simplifies the profile lookup table and removes the requirement
of computing the ctx for new-quant. This change produces a
0.01% drop in performance on 40 frames of lowres.

Change-Id: Ifcbd7d6e427090e02bb43f6de15e551796aa74c4
parent 0c72b2fb
...@@ -94,26 +94,23 @@ static INLINE int qindex_to_qrange(int qindex) { ...@@ -94,26 +94,23 @@ static INLINE int qindex_to_qrange(int qindex) {
return (qindex < 140 ? 1 : 0); return (qindex < 140 ? 1 : 0);
} }
static INLINE int get_dq_profile_from_ctx(int qindex, int q_ctx, int is_inter, static INLINE int get_dq_profile(int qindex, int is_inter,
PLANE_TYPE plane_type) { PLANE_TYPE plane_type) {
// intra/inter, Y/UV, ctx, qrange // intra/inter, Y/UV, ctx, qrange
static const int static const int dq_profile_lookup[REF_TYPES][PLANE_TYPES][QUANT_RANGES] = {
def_dq_profile_lookup[REF_TYPES][PLANE_TYPES][COEFF_CONTEXTS0] {
[QUANT_RANGES] = { // intra
{ { 2, 1 }, // Y
// intra { 3, 1 }, // UV
{ { 2, 1 }, { 2, 1 }, { 2, 1 } }, // Y },
{ { 3, 1 }, { 3, 1 }, { 3, 1 } }, // UV {
}, // inter
{ { 2, 1 }, // Y
// inter { 3, 1 }, // UV
{ { 3, 1 }, { 2, 1 }, { 2, 1 } }, // Y },
{ { 3, 1 }, { 3, 1 }, { 3, 1 } }, // UV };
},
};
if (!qindex) return 0; // lossless if (!qindex) return 0; // lossless
return def_dq_profile_lookup[is_inter][plane_type][q_ctx] return dq_profile_lookup[is_inter][plane_type][qindex_to_qrange(qindex)];
[qindex_to_qrange(qindex)];
} }
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
......
...@@ -322,8 +322,7 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane, ...@@ -322,8 +322,7 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
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
const int ref = is_inter_block(&xd->mi[0]->mbmi); const int ref = is_inter_block(&xd->mi[0]->mbmi);
int dq = int dq = get_dq_profile(xd->qindex[seg_id], ref, pd->plane_type);
get_dq_profile_from_ctx(xd->qindex[seg_id], ctx, ref, pd->plane_type);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
const int eob = const int eob =
......
...@@ -165,7 +165,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, ...@@ -165,7 +165,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
: cm->giqmatrix[NUM_QM_LEVELS - 1][0][qm_tx_size]; : cm->giqmatrix[NUM_QM_LEVELS - 1][0][qm_tx_size];
#endif // CONFIG_AOM_QM #endif // CONFIG_AOM_QM
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
int dq = get_dq_profile_from_ctx(mb->qindex, ctx, ref, plane_type); int dq = get_dq_profile(mb->qindex, ref, plane_type);
const dequant_val_type_nuq *dequant_val = p->dequant_val_nuq_QTX[dq]; const dequant_val_type_nuq *dequant_val = p->dequant_val_nuq_QTX[dq];
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
int64_t rd_cost0, rd_cost1; int64_t rd_cost0, rd_cost1;
...@@ -480,8 +480,7 @@ static const fwdTxfmFunc fwd_txfm_func[2] = { av1_fwd_txfm, ...@@ -480,8 +480,7 @@ static const fwdTxfmFunc fwd_txfm_func[2] = { av1_fwd_txfm,
void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
int blk_row, int blk_col, BLOCK_SIZE plane_bsize, int blk_row, int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx, TX_SIZE tx_size, AV1_XFORM_QUANT xform_quant_idx) {
AV1_XFORM_QUANT xform_quant_idx) {
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
#if !CONFIG_DIST_8X8 #if !CONFIG_DIST_8X8
...@@ -542,7 +541,7 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, ...@@ -542,7 +541,7 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
#endif #endif
qparam.tx_size = tx_size; qparam.tx_size = tx_size;
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
qparam.dq = get_dq_profile_from_ctx(x->qindex, ctx, is_inter, plane_type); qparam.dq = get_dq_profile(x->qindex, is_inter, plane_type);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
#if CONFIG_AOM_QM #if CONFIG_AOM_QM
qparam.qmatrix = qmatrix; qparam.qmatrix = qmatrix;
...@@ -576,8 +575,6 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, ...@@ -576,8 +575,6 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
} }
#endif // CONFIG_DIST_8X8 #endif // CONFIG_DIST_8X8
(void)ctx;
txfm_param.tx_type = tx_type; txfm_param.tx_type = tx_type;
txfm_param.tx_size = tx_size; txfm_param.tx_size = tx_size;
txfm_param.lossless = xd->lossless[mbmi->segment_id]; txfm_param.lossless = xd->lossless[mbmi->segment_id];
...@@ -621,7 +618,6 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, ...@@ -621,7 +618,6 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
AV1_COMMON *cm = args->cm; AV1_COMMON *cm = args->cm;
MACROBLOCK *const x = args->x; MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
int ctx;
struct macroblock_plane *const p = &x->plane[plane]; struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
...@@ -634,14 +630,13 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, ...@@ -634,14 +630,13 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
a = &args->ta[blk_col]; a = &args->ta[blk_col];
l = &args->tl[blk_row]; l = &args->tl[blk_row];
ctx = get_entropy_context(tx_size, a, l);
// Assert not magic number (uninitialized). // Assert not magic number (uninitialized).
assert(x->blk_skip[plane][blk_row * bw + blk_col] != 234); assert(x->blk_skip[plane][blk_row * bw + blk_col] != 234);
if (x->blk_skip[plane][blk_row * bw + blk_col] == 0) { if (x->blk_skip[plane][blk_row * bw + blk_col] == 0) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
ctx, AV1_XFORM_QUANT_FP); AV1_XFORM_QUANT_FP);
} else { } else {
p->eobs[block] = 0; p->eobs[block] = 0;
} }
...@@ -734,12 +729,11 @@ static void encode_block_pass1(int plane, int block, int blk_row, int blk_col, ...@@ -734,12 +729,11 @@ static void encode_block_pass1(int plane, int block, int blk_row, int blk_col,
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
TxfmParam txfm_param; TxfmParam txfm_param;
uint8_t *dst; uint8_t *dst;
int ctx = 0;
dst = &pd->dst dst = &pd->dst
.buf[(blk_row * pd->dst.stride + blk_col) << tx_size_wide_log2[0]]; .buf[(blk_row * pd->dst.stride + blk_col) << tx_size_wide_log2[0]];
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
ctx, AV1_XFORM_QUANT_B); AV1_XFORM_QUANT_B);
if (p->eobs[block] > 0) { if (p->eobs[block] > 0) {
txfm_param.bd = xd->bd; txfm_param.bd = xd->bd;
...@@ -915,15 +909,14 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col, ...@@ -915,15 +909,14 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
const ENTROPY_CONTEXT *a = &args->ta[blk_col]; const ENTROPY_CONTEXT *a = &args->ta[blk_col];
const ENTROPY_CONTEXT *l = &args->tl[blk_row]; const ENTROPY_CONTEXT *l = &args->tl[blk_row];
int ctx = combine_entropy_contexts(*a, *l);
if (args->enable_optimize_b) { if (args->enable_optimize_b) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
ctx, AV1_XFORM_QUANT_FP); AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size, av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l, CONFIG_LV_MAP); a, l, CONFIG_LV_MAP);
} else { } else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
ctx, AV1_XFORM_QUANT_B); AV1_XFORM_QUANT_B);
} }
av1_inverse_transform_block(xd, dqcoeff, plane, tx_type, tx_size, dst, av1_inverse_transform_block(xd, dqcoeff, plane, tx_type, tx_size, dst,
......
...@@ -48,7 +48,7 @@ void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row, ...@@ -48,7 +48,7 @@ void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row,
void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize); void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
int blk_row, int blk_col, BLOCK_SIZE plane_bsize, int blk_row, int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx, AV1_XFORM_QUANT xform_quant_idx); TX_SIZE tx_size, AV1_XFORM_QUANT xform_quant_idx);
int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int blk_row, int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int blk_row,
int blk_col, int block, BLOCK_SIZE plane_bsize, int blk_col, int block, BLOCK_SIZE plane_bsize,
......
...@@ -2506,7 +2506,6 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -2506,7 +2506,6 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
TX_TYPE best_tx_type = txk_start; TX_TYPE best_tx_type = txk_start;
int64_t best_rd = INT64_MAX; int64_t best_rd = INT64_MAX;
uint8_t best_eob = 0; uint8_t best_eob = 0;
const int coeff_ctx = combine_entropy_contexts(*a, *l);
RD_STATS best_rd_stats; RD_STATS best_rd_stats;
TX_TYPE tx_type; TX_TYPE tx_type;
...@@ -2532,10 +2531,10 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -2532,10 +2531,10 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
av1_invalid_rd_stats(&this_rd_stats); av1_invalid_rd_stats(&this_rd_stats);
#if DISABLE_TRELLISQ_SEARCH #if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_B); AV1_XFORM_QUANT_B);
#else #else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size, av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l, 1); a, l, 1);
#endif #endif
...@@ -2569,10 +2568,10 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -2569,10 +2568,10 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
// can use it for prediction. // can use it for prediction.
#if DISABLE_TRELLISQ_SEARCH #if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_B); AV1_XFORM_QUANT_B);
#else #else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size, av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l, 1); a, l, 1);
#endif #endif
......
...@@ -2077,14 +2077,13 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, ...@@ -2077,14 +2077,13 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
} }
#if !CONFIG_TXK_SEL #if !CONFIG_TXK_SEL
// full forward transform and quantization // full forward transform and quantization
const int coeff_ctx = combine_entropy_contexts(*a, *l);
#if DISABLE_TRELLISQ_SEARCH #if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_B); AV1_XFORM_QUANT_B);
#else #else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); AV1_XFORM_QUANT_FP);
// TX-domain results need to shift down to Q2/D10 to match pixel // TX-domain results need to shift down to Q2/D10 to match pixel
// domain distortion values which are in Q2^2 // domain distortion values which are in Q2^2
...@@ -3763,11 +3762,11 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, ...@@ -3763,11 +3762,11 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
#if DISABLE_TRELLISQ_SEARCH #if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_B); AV1_XFORM_QUANT_B);
#else #else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP); AV1_XFORM_QUANT_FP);
// TX-domain results need to shift down to Q2/D10 to match pixel // TX-domain results need to shift down to Q2/D10 to match pixel
// domain distortion values which are in Q2^2 // domain distortion values which are in Q2^2
......
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