Commit ff6d8905 authored by Angie Chiang's avatar Angie Chiang

Pass AV1_COMMON into get_scan

This CL will facilitate adapt_scan experiment.
In adapt_scan experiment, dynamic scan order will be stored in
AV1_COMMON

Change-Id: I4763ea931b5e1af54d4f173971befeb01a4db335
parent 646e52a8
......@@ -80,8 +80,9 @@ static INLINE const SCAN_ORDER *get_inter_scan(TX_SIZE tx_size,
}
#endif // CONFIG_EXT_TX
static INLINE const SCAN_ORDER *get_scan(TX_SIZE tx_size, TX_TYPE tx_type,
int is_inter) {
static INLINE const SCAN_ORDER *get_scan(const AV1_COMMON *cm, TX_SIZE tx_size,
TX_TYPE tx_type, int is_inter) {
(void)cm;
#if CONFIG_EXT_TX
return is_inter ? &av1_inter_scan_orders[tx_size][tx_type]
: &av1_intra_scan_orders[tx_size][tx_type];
......
......@@ -272,7 +272,8 @@ static void inverse_transform_block(MACROBLOCKD *xd, int plane,
}
}
static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
static void predict_and_reconstruct_intra_block(AV1_COMMON *cm,
MACROBLOCKD *const xd,
#if CONFIG_ANS
struct AnsDecoder *const r,
#else
......@@ -296,7 +297,7 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
if (!mbmi->skip) {
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const SCAN_ORDER *scan_order = get_scan(tx_size, tx_type, 0);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
const int eob = av1_decode_block_tokens(
xd, plane, scan_order, col, row, tx_size, tx_type, r, mbmi->segment_id);
inverse_transform_block(xd, plane, tx_type, tx_size, dst, pd->dst.stride,
......@@ -305,9 +306,9 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
}
#if CONFIG_VAR_TX
static void decode_reconstruct_tx(MACROBLOCKD *const xd, aom_reader *r,
MB_MODE_INFO *const mbmi, int plane,
BLOCK_SIZE plane_bsize, int block,
static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
aom_reader *r, MB_MODE_INFO *const mbmi,
int plane, BLOCK_SIZE plane_bsize, int block,
int blk_row, int blk_col, TX_SIZE tx_size,
int *eob_total) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
......@@ -330,7 +331,7 @@ static void decode_reconstruct_tx(MACROBLOCKD *const xd, aom_reader *r,
if (tx_size == plane_tx_size) {
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, plane_tx_size);
const SCAN_ORDER *sc = get_scan(plane_tx_size, tx_type, 1);
const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, 1);
const int eob =
av1_decode_block_tokens(xd, plane, sc, blk_col, blk_row, plane_tx_size,
tx_type, r, mbmi->segment_id);
......@@ -353,15 +354,16 @@ static void decode_reconstruct_tx(MACROBLOCKD *const xd, aom_reader *r,
if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue;
decode_reconstruct_tx(xd, r, mbmi, plane, plane_bsize, block + i * step,
offsetr, offsetc, tx_size - 1, eob_total);
decode_reconstruct_tx(cm, xd, r, mbmi, plane, plane_bsize,
block + i * step, offsetr, offsetc, tx_size - 1,
eob_total);
}
}
}
#endif // CONFIG_VAR_TX
#if !CONFIG_VAR_TX || CONFIG_SUPERTX || (CONFIG_EXT_TX && CONFIG_RECT_TX)
static int reconstruct_inter_block(MACROBLOCKD *const xd,
static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd,
#if CONFIG_ANS
struct AnsDecoder *const r,
#else
......@@ -373,7 +375,7 @@ static int reconstruct_inter_block(MACROBLOCKD *const xd,
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
int block_idx = (row << 1) + col;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const SCAN_ORDER *scan_order = get_scan(tx_size, tx_type, 1);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 1);
const int eob = av1_decode_block_tokens(xd, plane, scan_order, col, row,
tx_size, tx_type, r, segment_id);
......@@ -1248,7 +1250,7 @@ static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
predict_and_reconstruct_intra_block(xd, r, mbmi, plane, row, col,
predict_and_reconstruct_intra_block(cm, xd, r, mbmi, plane, row, col,
tx_size);
}
} else {
......@@ -1338,14 +1340,14 @@ static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
eobtotal += reconstruct_inter_block(xd, r, mbmi->segment_id,
eobtotal += reconstruct_inter_block(cm, xd, r, mbmi->segment_id,
plane, row, col, tx_size);
} else {
#endif
for (row = 0; row < num_4x4_h; row += bh_var_tx) {
for (col = 0; col < num_4x4_w; col += bw_var_tx) {
decode_reconstruct_tx(xd, r, mbmi, plane, plane_bsize, block, row,
col, max_tx_size, &eobtotal);
decode_reconstruct_tx(cm, xd, r, mbmi, plane, plane_bsize, block,
row, col, max_tx_size, &eobtotal);
block += step;
}
}
......@@ -1368,8 +1370,8 @@ static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
eobtotal += reconstruct_inter_block(xd, r, mbmi->segment_id, plane,
row, col, tx_size);
eobtotal += reconstruct_inter_block(cm, xd, r, mbmi->segment_id,
plane, row, col, tx_size);
#endif
}
......@@ -1768,8 +1770,8 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
eobtotal += reconstruct_inter_block(xd, r, mbmi->segment_id_supertx,
i, row, col, tx_size);
eobtotal += reconstruct_inter_block(
cm, xd, r, mbmi->segment_id_supertx, i, row, col, tx_size);
}
if (!(subsize < BLOCK_8X8) && eobtotal == 0) skip = 1;
}
......
......@@ -2213,7 +2213,7 @@ static void encode_sb(const AV1_COMP *const cpi, ThreadData *td,
int this_rate = 0;
x->use_lp32x32fdct = cpi->sf.use_lp32x32fdct;
av1_encode_sb_supertx(x, bsize);
av1_encode_sb_supertx((AV1_COMMON *)cm, x, bsize);
av1_tokenize_sb_supertx(cpi, td, tp, dry_run, bsize, rate);
if (rate) *rate += this_rate;
} else {
......@@ -5107,7 +5107,8 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
int plane;
mbmi->skip = 1;
for (plane = 0; plane < MAX_MB_PLANE; ++plane)
av1_encode_intra_block_plane(x, AOMMAX(bsize, BLOCK_8X8), plane, 1);
av1_encode_intra_block_plane((AV1_COMMON *)cm, x,
AOMMAX(bsize, BLOCK_8X8), plane, 1);
if (!dry_run)
sum_intra_stats(td->counts, mi, xd->above_mi, xd->left_mi,
frame_is_intra_only(cm));
......@@ -5229,7 +5230,7 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
}
#endif // CONFIG_MOTION_VAR
av1_encode_sb(x, AOMMAX(bsize, BLOCK_8X8));
av1_encode_sb((AV1_COMMON *)cm, x, AOMMAX(bsize, BLOCK_8X8));
#if CONFIG_VAR_TX
#if CONFIG_EXT_TX && CONFIG_RECT_TX
if (is_rect_tx(mbmi->tx_size))
......
This diff is collapsed.
......@@ -25,6 +25,7 @@ struct optimize_ctx {
};
struct encode_b_args {
AV1_COMMON *cm;
MACROBLOCK *x;
struct optimize_ctx *ctx;
int8_t *skip;
......@@ -41,38 +42,39 @@ typedef enum AV1_XFORM_QUANT {
AV1_XFORM_QUANT_LAST = 4
} AV1_XFORM_QUANT;
void av1_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
#if CONFIG_SUPERTX
void av1_encode_sb_supertx(MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_encode_sb_supertx(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
#endif // CONFIG_SUPERTX
void av1_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
AV1_XFORM_QUANT xform_quant_idx);
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, AV1_XFORM_QUANT xform_quant_idx);
#if CONFIG_NEW_QUANT
void av1_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
int ctx);
void av1_xform_quant_nuq(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);
void av1_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx);
void av1_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx);
void av1_xform_quant_fp_nuq(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);
void av1_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx);
#endif
int av1_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
int ctx);
int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block,
TX_SIZE tx_size, int ctx);
void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane);
void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg);
void av1_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane,
void av1_encode_intra_block_plane(AV1_COMMON *cm, MACROBLOCK *x,
BLOCK_SIZE bsize, int plane,
int enable_optimize_b);
#ifdef __cplusplus
......
......@@ -590,7 +590,7 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
xd->mi[0]->mbmi.mode = DC_PRED;
xd->mi[0]->mbmi.tx_size =
use_dc_pred ? (bsize >= BLOCK_16X16 ? TX_16X16 : TX_8X8) : TX_4X4;
av1_encode_intra_block_plane(x, bsize, 0, 0);
av1_encode_intra_block_plane(cm, x, bsize, 0, 0);
this_error = aom_get_mb_ss(x->plane[0].src_diff);
// Keep a record of blocks that have almost no intra error residual
......@@ -811,7 +811,7 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
xd->mi[0]->mbmi.ref_frame[0] = LAST_FRAME;
xd->mi[0]->mbmi.ref_frame[1] = NONE;
av1_build_inter_predictors_sby(xd, mb_row << 1, mb_col << 1, bsize);
av1_encode_sby_pass1(x, bsize);
av1_encode_sby_pass1(cm, x, bsize);
sum_mvr += mv.row;
sum_mvr_abs += abs(mv.row);
sum_mvc += mv.col;
......
This diff is collapsed.
......@@ -363,7 +363,7 @@ static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col,
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(tx_size, tx_type, ref);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, ref);
int pt = get_entropy_context(tx_size, pd->above_context + blk_col,
pd->left_context + blk_row);
int rate = av1_cost_coeffs(cm, x, plane, block, pt, tx_size, scan_order->scan,
......@@ -453,6 +453,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct tokenize_b_args *const args = arg;
const AV1_COMP *cpi = args->cpi;
const AV1_COMMON *const cm = &cpi->common;
ThreadData *const td = args->td;
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
......@@ -475,7 +476,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
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(tx_size, tx_type, is_inter_block(mbmi));
get_scan(cm, tx_size, tx_type, is_inter_block(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];
......
......@@ -184,8 +184,9 @@ TEST_P(AV1PartialIDctTest, RunQuantCheck) {
// quantization with maximum allowed step sizes
test_coef_block1[0] = (output_ref_block[0] / 1336) * 1336;
for (int j = 1; j < last_nonzero_; ++j)
test_coef_block1[get_scan(tx_size_, DCT_DCT, 0)->scan[j]] =
(output_ref_block[j] / 1828) * 1828;
test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT,
0)
->scan[j]] = (output_ref_block[j] / 1828) * 1828;
}
ASM_REGISTER_STATE_CHECK(full_itxfm_(test_coef_block1, dst1, size));
......@@ -235,7 +236,8 @@ TEST_P(AV1PartialIDctTest, ResultsMatch) {
max_energy_leftover = 0;
coef = 0;
}
test_coef_block1[get_scan(tx_size_, DCT_DCT, 0)->scan[j]] = coef;
test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT, 0)
->scan[j]] = coef;
}
memcpy(test_coef_block2, test_coef_block1,
......
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