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) {
return (qindex < 140 ? 1 : 0);
}
static INLINE int get_dq_profile_from_ctx(int qindex, int q_ctx, int is_inter,
PLANE_TYPE plane_type) {
static INLINE int get_dq_profile(int qindex, int is_inter,
PLANE_TYPE plane_type) {
// intra/inter, Y/UV, ctx, qrange
static const int
def_dq_profile_lookup[REF_TYPES][PLANE_TYPES][COEFF_CONTEXTS0]
[QUANT_RANGES] = {
{
// intra
{ { 2, 1 }, { 2, 1 }, { 2, 1 } }, // Y
{ { 3, 1 }, { 3, 1 }, { 3, 1 } }, // UV
},
{
// inter
{ { 3, 1 }, { 2, 1 }, { 2, 1 } }, // Y
{ { 3, 1 }, { 3, 1 }, { 3, 1 } }, // UV
},
};
static const int dq_profile_lookup[REF_TYPES][PLANE_TYPES][QUANT_RANGES] = {
{
// intra
{ 2, 1 }, // Y
{ 3, 1 }, // UV
},
{
// inter
{ 2, 1 }, // Y
{ 3, 1 }, // UV
},
};
if (!qindex) return 0; // lossless
return def_dq_profile_lookup[is_inter][plane_type][q_ctx]
[qindex_to_qrange(qindex)];
return dq_profile_lookup[is_inter][plane_type][qindex_to_qrange(qindex)];
}
#endif // CONFIG_NEW_QUANT
......
......@@ -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);
#if CONFIG_NEW_QUANT
const int ref = is_inter_block(&xd->mi[0]->mbmi);
int dq =
get_dq_profile_from_ctx(xd->qindex[seg_id], ctx, ref, pd->plane_type);
int dq = get_dq_profile(xd->qindex[seg_id], ref, pd->plane_type);
#endif // CONFIG_NEW_QUANT
const int eob =
......
......@@ -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];
#endif // CONFIG_AOM_QM
#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];
#endif // CONFIG_NEW_QUANT
int64_t rd_cost0, rd_cost1;
......@@ -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,
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) {
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
#if !CONFIG_DIST_8X8
......@@ -542,7 +541,7 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
#endif
qparam.tx_size = tx_size;
#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
#if CONFIG_AOM_QM
qparam.qmatrix = qmatrix;
......@@ -576,8 +575,6 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
}
#endif // CONFIG_DIST_8X8
(void)ctx;
txfm_param.tx_type = tx_type;
txfm_param.tx_size = tx_size;
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,
AV1_COMMON *cm = args->cm;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
int ctx;
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
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,
a = &args->ta[blk_col];
l = &args->tl[blk_row];
ctx = get_entropy_context(tx_size, a, l);
// Assert not magic number (uninitialized).
assert(x->blk_skip[plane][blk_row * bw + blk_col] != 234);
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,
ctx, AV1_XFORM_QUANT_FP);
AV1_XFORM_QUANT_FP);
} else {
p->eobs[block] = 0;
}
......@@ -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);
TxfmParam txfm_param;
uint8_t *dst;
int ctx = 0;
dst = &pd->dst
.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,
ctx, AV1_XFORM_QUANT_B);
AV1_XFORM_QUANT_B);
if (p->eobs[block] > 0) {
txfm_param.bd = xd->bd;
......@@ -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 *l = &args->tl[blk_row];
int ctx = combine_entropy_contexts(*a, *l);
if (args->enable_optimize_b) {
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,
a, l, CONFIG_LV_MAP);
} else {
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,
......
......@@ -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_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
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 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,
TX_TYPE best_tx_type = txk_start;
int64_t best_rd = INT64_MAX;
uint8_t best_eob = 0;
const int coeff_ctx = combine_entropy_contexts(*a, *l);
RD_STATS best_rd_stats;
TX_TYPE tx_type;
......@@ -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);
#if DISABLE_TRELLISQ_SEARCH
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
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,
a, l, 1);
#endif
......@@ -2569,10 +2568,10 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
// can use it for prediction.
#if DISABLE_TRELLISQ_SEARCH
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
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,
a, l, 1);
#endif
......
......@@ -2077,14 +2077,13 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
}
#if !CONFIG_TXK_SEL
// full forward transform and quantization
const int coeff_ctx = combine_entropy_contexts(*a, *l);
// full forward transform and quantization
#if DISABLE_TRELLISQ_SEARCH
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
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
// 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,
#if DISABLE_TRELLISQ_SEARCH
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
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
// 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