Commit 68789123 authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review

Merge "Removing PLANE_TYPE argument from cost_coeffs function."

parents a2f76198 2f1a0a0e
...@@ -485,42 +485,39 @@ static const int16_t band_counts[TX_SIZES][8] = { ...@@ -485,42 +485,39 @@ static const int16_t band_counts[TX_SIZES][8] = {
}; };
static INLINE int cost_coeffs(MACROBLOCK *mb, static INLINE int cost_coeffs(MACROBLOCK *mb,
int plane, int block, PLANE_TYPE type, int plane, int block,
ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L, ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L,
TX_SIZE tx_size, TX_SIZE tx_size,
const int16_t *scan, const int16_t *nb) { const int16_t *scan, const int16_t *nb) {
MACROBLOCKD *const xd = &mb->e_mbd; MACROBLOCKD *const xd = &mb->e_mbd;
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
int pt, c, cost; struct macroblockd_plane *pd = &xd->plane[plane];
const PLANE_TYPE type = pd->plane_type;
const int16_t *band_count = &band_counts[tx_size][1]; const int16_t *band_count = &band_counts[tx_size][1];
const int eob = xd->plane[plane].eobs[block]; const int eob = pd->eobs[block];
const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block); const int16_t *const qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
const int ref = mbmi->ref_frame[0] != INTRA_FRAME; const int ref = mbmi->ref_frame[0] != INTRA_FRAME;
unsigned int (*token_costs)[2][PREV_COEF_CONTEXTS] unsigned int (*token_costs)[2][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS] =
[MAX_ENTROPY_TOKENS] = mb->token_costs[tx_size][type][ref]; mb->token_costs[tx_size][type][ref];
ENTROPY_CONTEXT above_ec = !!*A, left_ec = !!*L; const ENTROPY_CONTEXT above_ec = !!*A, left_ec = !!*L;
uint8_t token_cache[1024]; uint8_t token_cache[1024];
int pt = combine_entropy_contexts(above_ec, left_ec);
int c, cost;
// Check for consistency of tx_size with mode info // Check for consistency of tx_size with mode info
assert((!type && !plane) || (type && plane)); assert(type == PLANE_TYPE_Y_WITH_DC ? mbmi->txfm_size == tx_size
if (type == PLANE_TYPE_Y_WITH_DC) { : get_uv_tx_size(mbmi) == tx_size);
assert(xd->mode_info_context->mbmi.txfm_size == tx_size);
} else {
assert(tx_size == get_uv_tx_size(mbmi));
}
pt = combine_entropy_contexts(above_ec, left_ec);
if (eob == 0) { if (eob == 0) {
// single eob token // single eob token
cost = token_costs[0][0][pt][DCT_EOB_TOKEN]; cost = token_costs[0][0][pt][DCT_EOB_TOKEN];
c = 0; c = 0;
} else { } else {
int v, prev_t, band_left = *band_count++; int band_left = *band_count++;
// dc token // dc token
v = qcoeff_ptr[0]; int v = qcoeff_ptr[0];
prev_t = vp9_dct_value_tokens_ptr[v].token; int prev_t = vp9_dct_value_tokens_ptr[v].token;
cost = (*token_costs)[0][pt][prev_t] + vp9_dct_value_cost_ptr[v]; cost = (*token_costs)[0][pt][prev_t] + vp9_dct_value_cost_ptr[v];
token_cache[0] = vp9_pt_energy_class[prev_t]; token_cache[0] = vp9_pt_energy_class[prev_t];
++token_costs; ++token_costs;
...@@ -550,7 +547,7 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, ...@@ -550,7 +547,7 @@ static INLINE int cost_coeffs(MACROBLOCK *mb,
} }
// is eob first coefficient; // is eob first coefficient;
*A = *L = c > 0; *A = *L = (c > 0);
return cost; return cost;
} }
...@@ -598,14 +595,12 @@ static void dist_block(int plane, int block, TX_SIZE tx_size, void *arg) { ...@@ -598,14 +595,12 @@ static void dist_block(int plane, int block, TX_SIZE tx_size, void *arg) {
static void rate_block(int plane, int block, BLOCK_SIZE_TYPE plane_bsize, static void rate_block(int plane, int block, BLOCK_SIZE_TYPE plane_bsize,
TX_SIZE tx_size, void *arg) { TX_SIZE tx_size, void *arg) {
struct rdcost_block_args* args = arg; struct rdcost_block_args* args = arg;
MACROBLOCKD *const xd = &args->x->e_mbd;
struct macroblockd_plane *const pd = &xd->plane[plane];
int x_idx, y_idx; int x_idx, y_idx;
txfrm_block_to_raster_xy(plane_bsize, args->tx_size, block, &x_idx, &y_idx); txfrm_block_to_raster_xy(plane_bsize, args->tx_size, block, &x_idx, &y_idx);
args->rate += cost_coeffs(args->x, plane, block, args->rate += cost_coeffs(args->x, plane, block,
pd->plane_type, args->t_above + x_idx, args->t_above + x_idx,
args->t_left + y_idx, args->tx_size, args->t_left + y_idx, args->tx_size,
args->scan, args->nb); args->scan, args->nb);
} }
...@@ -1091,7 +1086,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, ...@@ -1091,7 +1086,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
} }
scan = get_scan_4x4(get_tx_type_4x4(PLANE_TYPE_Y_WITH_DC, xd, block)); scan = get_scan_4x4(get_tx_type_4x4(PLANE_TYPE_Y_WITH_DC, xd, block));
ratey += cost_coeffs(x, 0, block, PLANE_TYPE_Y_WITH_DC, ratey += cost_coeffs(x, 0, block,
tempa + idx, templ + idy, TX_4X4, scan, tempa + idx, templ + idy, TX_4X4, scan,
vp9_get_coef_neighbors_handle(scan)); vp9_get_coef_neighbors_handle(scan));
distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, block), distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, block),
...@@ -1563,7 +1558,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi, ...@@ -1563,7 +1558,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
thisdistortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, k), thisdistortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, k),
16, &ssz); 16, &ssz);
thissse += ssz; thissse += ssz;
thisrate += cost_coeffs(x, 0, k, PLANE_TYPE_Y_WITH_DC, thisrate += cost_coeffs(x, 0, k,
ta + (k & 1), ta + (k & 1),
tl + (k >> 1), TX_4X4, tl + (k >> 1), TX_4X4,
vp9_default_scan_4x4, vp9_default_scan_4x4,
......
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