Commit d56df2f9 authored by Yaowu Xu's avatar Yaowu Xu Committed by Gerrit Code Review

Merge "Pass AV1_COMMON into av1_cost_coeffs" into nextgenv2

parents 432d9071 22ba7514
...@@ -875,8 +875,9 @@ int64_t av1_highbd_block_error_c(const tran_low_t *coeff, ...@@ -875,8 +875,9 @@ int64_t av1_highbd_block_error_c(const tran_low_t *coeff,
* can skip this if the last coefficient in this transform block, e.g. the * can skip this if the last coefficient in this transform block, e.g. the
* 16th coefficient in a 4x4 block or the 64th coefficient in a 8x8 block, * 16th coefficient in a 4x4 block or the 64th coefficient in a 8x8 block,
* were non-zero). */ * were non-zero). */
int av1_cost_coeffs(MACROBLOCK *x, int plane, int block, int coeff_ctx, int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
TX_SIZE tx_size, const int16_t *scan, const int16_t *nb, int block, int coeff_ctx, TX_SIZE tx_size,
const int16_t *scan, const int16_t *nb,
int use_fast_coef_costing) { int use_fast_coef_costing) {
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
...@@ -903,6 +904,7 @@ int av1_cost_coeffs(MACROBLOCK *x, int plane, int block, int coeff_ctx, ...@@ -903,6 +904,7 @@ int av1_cost_coeffs(MACROBLOCK *x, int plane, int block, int coeff_ctx,
assert(type == PLANE_TYPE_Y ? mbmi->tx_size == tx_size assert(type == PLANE_TYPE_Y ? mbmi->tx_size == tx_size
: get_uv_tx_size(mbmi, pd) == tx_size); : get_uv_tx_size(mbmi, pd) == tx_size);
#endif // !CONFIG_VAR_TX && !CONFIG_SUPERTX #endif // !CONFIG_VAR_TX && !CONFIG_SUPERTX
(void)cm;
if (eob == 0) { if (eob == 0) {
// single eob token // single eob token
...@@ -1069,8 +1071,9 @@ static void dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane, int block, ...@@ -1069,8 +1071,9 @@ static void dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane, int block,
static int rate_block(int plane, int block, int coeff_ctx, TX_SIZE tx_size, static int rate_block(int plane, int block, int coeff_ctx, TX_SIZE tx_size,
struct rdcost_block_args *args) { struct rdcost_block_args *args) {
return av1_cost_coeffs(args->x, plane, block, coeff_ctx, tx_size, return av1_cost_coeffs(&args->cpi->common, args->x, plane, block, coeff_ctx,
args->scan_order->scan, args->scan_order->neighbors, tx_size, args->scan_order->scan,
args->scan_order->neighbors,
args->use_fast_coef_costing); args->use_fast_coef_costing);
} }
...@@ -1887,6 +1890,7 @@ static int64_t rd_pick_intra4x4block( ...@@ -1887,6 +1890,7 @@ static int64_t rd_pick_intra4x4block(
PREDICTION_MODE *best_mode, const int *bmode_costs, ENTROPY_CONTEXT *a, PREDICTION_MODE *best_mode, const int *bmode_costs, ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l, int *bestrate, int *bestratey, int64_t *bestdistortion, ENTROPY_CONTEXT *l, int *bestrate, int *bestratey, int64_t *bestdistortion,
BLOCK_SIZE bsize, int *y_skip, int64_t rd_thresh) { BLOCK_SIZE bsize, int *y_skip, int64_t rd_thresh) {
const AV1_COMMON *const cm = &cpi->common;
PREDICTION_MODE mode; PREDICTION_MODE mode;
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
int64_t best_rd = rd_thresh; int64_t best_rd = rd_thresh;
...@@ -1958,7 +1962,7 @@ static int64_t rd_pick_intra4x4block( ...@@ -1958,7 +1962,7 @@ static int64_t rd_pick_intra4x4block(
av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8,
TX_4X4, AV1_XFORM_QUANT_FP); TX_4X4, AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
ratey += av1_cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
scan_order->scan, scan_order->neighbors, scan_order->scan, scan_order->neighbors,
cpi->sf.use_fast_coef_costing); cpi->sf.use_fast_coef_costing);
*(tempa + idx) = !(p->eobs[block] == 0); *(tempa + idx) = !(p->eobs[block] == 0);
...@@ -1984,7 +1988,7 @@ static int64_t rd_pick_intra4x4block( ...@@ -1984,7 +1988,7 @@ static int64_t rd_pick_intra4x4block(
TX_4X4, AV1_XFORM_QUANT_FP); TX_4X4, AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
av1_optimize_b(x, 0, block, TX_4X4, coeff_ctx); av1_optimize_b(x, 0, block, TX_4X4, coeff_ctx);
ratey += av1_cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
scan_order->scan, scan_order->neighbors, scan_order->scan, scan_order->neighbors,
cpi->sf.use_fast_coef_costing); cpi->sf.use_fast_coef_costing);
*(tempa + idx) = !(p->eobs[block] == 0); *(tempa + idx) = !(p->eobs[block] == 0);
...@@ -2078,7 +2082,7 @@ static int64_t rd_pick_intra4x4block( ...@@ -2078,7 +2082,7 @@ static int64_t rd_pick_intra4x4block(
av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4, av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4,
AV1_XFORM_QUANT_B); AV1_XFORM_QUANT_B);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
ratey += av1_cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
scan_order->scan, scan_order->neighbors, scan_order->scan, scan_order->neighbors,
cpi->sf.use_fast_coef_costing); cpi->sf.use_fast_coef_costing);
*(tempa + idx) = !(p->eobs[block] == 0); *(tempa + idx) = !(p->eobs[block] == 0);
...@@ -2103,7 +2107,7 @@ static int64_t rd_pick_intra4x4block( ...@@ -2103,7 +2107,7 @@ static int64_t rd_pick_intra4x4block(
AV1_XFORM_QUANT_FP); AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
av1_optimize_b(x, 0, block, TX_4X4, coeff_ctx); av1_optimize_b(x, 0, block, TX_4X4, coeff_ctx);
ratey += av1_cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
scan_order->scan, scan_order->neighbors, scan_order->scan, scan_order->neighbors,
cpi->sf.use_fast_coef_costing); cpi->sf.use_fast_coef_costing);
*(tempa + idx) = !(p->eobs[block] == 0); *(tempa + idx) = !(p->eobs[block] == 0);
...@@ -2888,6 +2892,7 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, ...@@ -2888,6 +2892,7 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
int blk_row, int blk_col, int plane, int block, int blk_row, int blk_col, int plane, int block,
int plane_bsize, int coeff_ctx, int *rate, int64_t *dist, int plane_bsize, int coeff_ctx, int *rate, int64_t *dist,
int64_t *bsse, int *skip) { int64_t *bsse, int *skip) {
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd; MACROBLOCKD *xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane]; const struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
...@@ -3012,7 +3017,7 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, ...@@ -3012,7 +3017,7 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
} }
} }
*dist += tmp * 16; *dist += tmp * 16;
*rate += av1_cost_coeffs(x, plane, block, coeff_ctx, tx_size, *rate += av1_cost_coeffs(cm, x, plane, block, coeff_ctx, tx_size,
scan_order->scan, scan_order->neighbors, 0); scan_order->scan, scan_order->neighbors, 0);
*skip &= (p->eobs[block] == 0); *skip &= (p->eobs[block] == 0);
} }
...@@ -4349,6 +4354,7 @@ static int64_t encode_inter_mb_segment(const AV1_COMP *const cpi, MACROBLOCK *x, ...@@ -4349,6 +4354,7 @@ static int64_t encode_inter_mb_segment(const AV1_COMP *const cpi, MACROBLOCK *x,
int64_t *distortion, int64_t *sse, int64_t *distortion, int64_t *sse,
ENTROPY_CONTEXT *ta, ENTROPY_CONTEXT *tl, ENTROPY_CONTEXT *ta, ENTROPY_CONTEXT *tl,
int ir, int ic, int mi_row, int mi_col) { int ir, int ic, int mi_row, int mi_col) {
const AV1_COMMON *const cm = &cpi->common;
int k; int k;
MACROBLOCKD *xd = &x->e_mbd; MACROBLOCKD *xd = &x->e_mbd;
struct macroblockd_plane *const pd = &xd->plane[0]; struct macroblockd_plane *const pd = &xd->plane[0];
...@@ -4428,7 +4434,7 @@ static int64_t encode_inter_mb_segment(const AV1_COMP *const cpi, MACROBLOCK *x, ...@@ -4428,7 +4434,7 @@ static int64_t encode_inter_mb_segment(const AV1_COMP *const cpi, MACROBLOCK *x,
thisdistortion += dist; thisdistortion += dist;
thissse += ssz; thissse += ssz;
thisrate += thisrate +=
av1_cost_coeffs(x, 0, block, coeff_ctx, tx_size, scan_order->scan, av1_cost_coeffs(cm, x, 0, block, coeff_ctx, tx_size, scan_order->scan,
scan_order->neighbors, cpi->sf.use_fast_coef_costing); scan_order->neighbors, cpi->sf.use_fast_coef_costing);
*(ta + (k & 1)) = !(p->eobs[block] == 0); *(ta + (k & 1)) = !(p->eobs[block] == 0);
*(tl + (k >> 1)) = !(p->eobs[block] == 0); *(tl + (k >> 1)) = !(p->eobs[block] == 0);
......
...@@ -26,8 +26,9 @@ struct AV1_COMP; ...@@ -26,8 +26,9 @@ struct AV1_COMP;
struct macroblock; struct macroblock;
struct RD_COST; struct RD_COST;
int av1_cost_coeffs(MACROBLOCK *x, int plane, int block, int coeff_ctx, int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
TX_SIZE tx_size, const int16_t *scan, const int16_t *nb, int block, int coeff_ctx, TX_SIZE tx_size,
const int16_t *scan, const int16_t *nb,
int use_fast_coef_costing); int use_fast_coef_costing);
void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x, void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x,
struct RD_COST *rd_cost, BLOCK_SIZE bsize, struct RD_COST *rd_cost, BLOCK_SIZE bsize,
......
...@@ -353,6 +353,7 @@ struct tokenize_b_args { ...@@ -353,6 +353,7 @@ struct tokenize_b_args {
static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col, static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) { BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct tokenize_b_args *const args = arg; struct tokenize_b_args *const args = arg;
const AV1_COMMON *cm = &args->cpi->common;
ThreadData *const td = args->td; ThreadData *const td = args->td;
MACROBLOCK *const x = &td->mb; MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
...@@ -365,7 +366,7 @@ static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col, ...@@ -365,7 +366,7 @@ static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col,
const SCAN_ORDER *const scan_order = get_scan(tx_size, tx_type, ref); const SCAN_ORDER *const scan_order = get_scan(tx_size, tx_type, ref);
int pt = get_entropy_context(tx_size, pd->above_context + blk_col, int pt = get_entropy_context(tx_size, pd->above_context + blk_col,
pd->left_context + blk_row); pd->left_context + blk_row);
int rate = av1_cost_coeffs(x, plane, block, pt, tx_size, scan_order->scan, int rate = av1_cost_coeffs(cm, x, plane, block, pt, tx_size, scan_order->scan,
scan_order->neighbors, 0); scan_order->neighbors, 0);
args->this_rate += rate; args->this_rate += rate;
av1_set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0, blk_col, av1_set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0, blk_col,
......
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