Commit bd99b38c authored by Angie Chiang's avatar Angie Chiang Committed by Yi Luo

Pass mbmi into get_scan()

This is to facilitate future experiment related to adapt_scan

Change-Id: I51628f3df81bd82db7f8f553d13da0ee5792d7d9
parent a3d70911
......@@ -78,12 +78,14 @@ static INLINE const SCAN_ORDER *get_default_scan(TX_SIZE tx_size,
}
static INLINE const SCAN_ORDER *get_scan(const AV1_COMMON *cm, TX_SIZE tx_size,
TX_TYPE tx_type, int is_inter) {
TX_TYPE tx_type,
const MB_MODE_INFO *mbmi) {
#if CONFIG_ADAPT_SCAN
(void)is_inter;
(void)mbmi;
return &cm->fc->sc[tx_size][tx_type];
#else // CONFIG_ADAPT_SCAN
(void)cm;
const int is_inter = is_inter_block(mbmi);
return get_default_scan(tx_size, tx_type, is_inter);
#endif // CONFIG_ADAPT_SCAN
}
......
......@@ -697,7 +697,7 @@ static void predict_and_reconstruct_intra_block(
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
#else // CONFIG_LV_MAP
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
int16_t max_scan_line = 0;
const int eob =
av1_decode_block_tokens(cm, xd, plane, scan_order, col, row, tx_size,
......@@ -769,7 +769,7 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, plane_tx_size);
#else // CONFIG_LV_MAP
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, plane_tx_size);
const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, 1);
const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, mbmi);
int16_t max_scan_line = 0;
const int eob = av1_decode_block_tokens(
cm, xd, plane, sc, blk_col, blk_row, plane_tx_size, tx_type,
......@@ -829,7 +829,8 @@ static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd,
#else // CONFIG_LV_MAP
int16_t max_scan_line = 0;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 1);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
const int eob =
av1_decode_block_tokens(cm, xd, plane, scan_order, col, row, tx_size,
tx_type, &max_scan_line, r, segment_id);
......
......@@ -81,8 +81,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
av1_read_tx_type(cm, xd, block, plane, r);
#endif
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan;
for (c = 0; c < seg_eob; ++c) {
......
......@@ -157,7 +157,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
const uint8_t *const band_translate = get_band_translate(tx_size);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
const int16_t *const scan = scan_order->scan;
const int16_t *const nb = scan_order->neighbors;
int dqv;
......@@ -553,8 +553,12 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
#endif
PLANE_TYPE plane_type = get_plane_type(plane);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
#if CONFIG_AOM_QM || CONFIG_NEW_QUANT
const int is_inter = is_inter_block(mbmi);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, is_inter);
#endif
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
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);
......@@ -1303,7 +1307,8 @@ void av1_encode_block_intra_dpcm(const AV1_COMMON *cm, MACROBLOCK *x,
const int dst_stride = pd->dst.stride;
const int tx1d_width = tx_size_wide[tx_size];
const int tx1d_height = tx_size_high[tx_size];
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, 0);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
uint8_t *dst =
......
......@@ -79,8 +79,7 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_SIZE txs_ctx = get_txsize_context(tx_size);
const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan;
int c;
int is_nz;
......@@ -309,8 +308,7 @@ int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
aom_prob(*coeff_base)[COEFF_BASE_CONTEXTS] =
xd->fc->coeff_base[txs_ctx][plane_type];
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan;
cost = 0;
......@@ -1491,8 +1489,7 @@ int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
const aom_prob *coeff_lps = xd->fc->coeff_lps[txs_ctx][plane_type];
const int is_inter = is_inter_block(mbmi);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const TxbProbs txb_probs = { xd->fc->dc_sign[plane_type],
nz_map,
......@@ -1547,8 +1544,7 @@ void av1_update_txb_context_b(int plane, int block, int blk_row, int blk_col,
const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
const PLANE_TYPE plane_type = pd->plane_type;
const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
(void)plane_bsize;
int cul_level = av1_get_txb_entropy_context(qcoeff, scan_order, eob);
......@@ -1573,8 +1569,7 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
tran_low_t *tcoeff = BLOCK_OFFSET(x->mbmi_ext->tcoeff[plane], block);
const int segment_id = mbmi->segment_id;
const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan;
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
int c, i;
......@@ -1893,8 +1888,7 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
av1_dist_block(cpi, x, plane, plane_bsize, block, blk_row, blk_col, tx_size,
&this_rd_stats.dist, &this_rd_stats.sse,
OUTPUT_HAS_PREDICTED_PIXELS);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
this_rd_stats.rate = av1_cost_coeffs(
cpi, x, plane, block, tx_size, scan_order, a, l, use_fast_coef_costing);
int rd = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist);
......
......@@ -1653,8 +1653,7 @@ CALCULATE_RD : {}
#if !CONFIG_PVQ
const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
this_rd_stats.rate =
av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order, a, l,
args->use_fast_coef_costing);
......@@ -2845,7 +2844,8 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
#endif
if (is_lossless) {
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
const int coeff_ctx =
combine_entropy_contexts(tempa[idx], templ[idy]);
#if !CONFIG_PVQ
......@@ -2889,7 +2889,8 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
int64_t dist;
unsigned int tmp;
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
const int coeff_ctx =
combine_entropy_contexts(tempa[idx], templ[idy]);
#if !CONFIG_PVQ
......@@ -3044,7 +3045,8 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
#endif // !CONFIG_PVQ
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
const int coeff_ctx = combine_entropy_contexts(tempa[idx], templ[idy]);
#if CONFIG_CB4X4
block = 4 * block;
......@@ -3963,7 +3965,7 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
PLANE_TYPE plane_type = get_plane_type(plane);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
BLOCK_SIZE txm_bsize = txsize_to_bsize[tx_size];
int bh = block_size_high[txm_bsize];
int bw = block_size_wide[txm_bsize];
......
......@@ -277,9 +277,8 @@ static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col,
struct macroblock_plane *p = &x->plane[plane];
struct macroblockd_plane *pd = &xd->plane[plane];
const PLANE_TYPE type = pd->plane_type;
const int ref = is_inter_block(mbmi);
const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, ref);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int rate = av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order,
pd->above_context + blk_col,
pd->left_context + blk_row, 0);
......@@ -435,8 +434,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
#endif // CONFIG_SUEPRTX
const int16_t *scan, *nb;
const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int ref = is_inter_block(mbmi);
unsigned int(*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
td->rd_counts.coef_counts[txsize_sqr_map[tx_size]][type][ref];
......
......@@ -140,6 +140,13 @@ class AV1PartialIDctTest
};
#if !CONFIG_ADAPT_SCAN
static MB_MODE_INFO get_mbmi() {
MB_MODE_INFO mbmi;
mbmi.ref_frame[0] = LAST_FRAME;
assert(is_inter_block(&mbmi));
return mbmi;
}
TEST_P(AV1PartialIDctTest, RunQuantCheck) {
int size;
switch (tx_size_) {
......@@ -186,9 +193,10 @@ TEST_P(AV1PartialIDctTest, RunQuantCheck) {
// quantization with maximum allowed step sizes
test_coef_block1[0] = (output_ref_block[0] / 1336) * 1336;
MB_MODE_INFO mbmi = get_mbmi();
for (int j = 1; j < last_nonzero_; ++j)
test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT,
0)
&mbmi)
->scan[j]] = (output_ref_block[j] / 1828) * 1828;
}
......@@ -239,7 +247,9 @@ TEST_P(AV1PartialIDctTest, ResultsMatch) {
max_energy_leftover = 0;
coef = 0;
}
test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT, 0)
MB_MODE_INFO mbmi = get_mbmi();
test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT,
&mbmi)
->scan[j]] = coef;
}
......
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