Give skip_txfm constants names.

This is using a define instead of an enum to keep byte packing.

Change-Id: I3abb07c8bfe377e19be4531b624af7b7b4207792
This commit is contained in:
Alex Converse 2015-07-30 11:52:28 -07:00
parent 0e3f494b21
commit 4ac5058afc
4 changed files with 30 additions and 24 deletions

View File

@ -122,6 +122,9 @@ struct macroblock {
// skip forward transform and quantization // skip forward transform and quantization
uint8_t skip_txfm[MAX_MB_PLANE << 2]; uint8_t skip_txfm[MAX_MB_PLANE << 2];
#define SKIP_TXFM_NONE 0
#define SKIP_TXFM_AC_DC 1
#define SKIP_TXFM_AC_ONLY 2
int64_t bsse[MAX_MB_PLANE << 2]; int64_t bsse[MAX_MB_PLANE << 2];

View File

@ -611,7 +611,7 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
if (!x->skip_recode) { if (!x->skip_recode) {
if (x->quant_fp) { if (x->quant_fp) {
// Encoding process for rtc mode // Encoding process for rtc mode
if (x->skip_txfm[0] == 1 && plane == 0) { if (x->skip_txfm[0] == SKIP_TXFM_AC_DC && plane == 0) {
// skip forward transform // skip forward transform
p->eobs[block] = 0; p->eobs[block] = 0;
*a = *l = 0; *a = *l = 0;
@ -622,10 +622,10 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize,
} else { } else {
if (max_txsize_lookup[plane_bsize] == tx_size) { if (max_txsize_lookup[plane_bsize] == tx_size) {
int txfm_blk_index = (plane << 2) + (block >> (tx_size << 1)); int txfm_blk_index = (plane << 2) + (block >> (tx_size << 1));
if (x->skip_txfm[txfm_blk_index] == 0) { if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_NONE) {
// full forward transform and quantization // full forward transform and quantization
vp9_xform_quant(x, plane, block, plane_bsize, tx_size); vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
} else if (x->skip_txfm[txfm_blk_index]== 2) { } else if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_AC_ONLY) {
// fast path forward transform and quantization // fast path forward transform and quantization
vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size); vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size);
} else { } else {

View File

@ -341,7 +341,7 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize,
sse32x32, sum32x32); sse32x32, sum32x32);
// Skipping test // Skipping test
x->skip_txfm[0] = 0; x->skip_txfm[0] = SKIP_TXFM_NONE;
for (k = 0; k < num; k++) for (k = 0; k < num; k++)
// Check if all ac coefficients can be quantized to zero. // Check if all ac coefficients can be quantized to zero.
if (!(var_tx[k] < ac_thr || var == 0)) { if (!(var_tx[k] < ac_thr || var == 0)) {
@ -357,16 +357,16 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize,
} }
if (ac_test) { if (ac_test) {
x->skip_txfm[0] = 2; x->skip_txfm[0] = SKIP_TXFM_AC_ONLY;
if (dc_test) if (dc_test)
x->skip_txfm[0] = 1; x->skip_txfm[0] = SKIP_TXFM_AC_DC;
} else if (dc_test) { } else if (dc_test) {
skip_dc = 1; skip_dc = 1;
} }
} }
if (x->skip_txfm[0] == 1) { if (x->skip_txfm[0] == SKIP_TXFM_AC_DC) {
int skip_uv[2] = {0}; int skip_uv[2] = {0};
unsigned int var_uv[2]; unsigned int var_uv[2];
unsigned int sse_uv[2]; unsigned int sse_uv[2];
@ -501,20 +501,20 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize,
const unsigned int sse_tx = sse >> num_blk_log2; const unsigned int sse_tx = sse >> num_blk_log2;
const unsigned int var_tx = var >> num_blk_log2; const unsigned int var_tx = var >> num_blk_log2;
x->skip_txfm[0] = 0; x->skip_txfm[0] = SKIP_TXFM_NONE;
// Check if all ac coefficients can be quantized to zero. // Check if all ac coefficients can be quantized to zero.
if (var_tx < ac_thr || var == 0) { if (var_tx < ac_thr || var == 0) {
x->skip_txfm[0] = 2; x->skip_txfm[0] = SKIP_TXFM_AC_ONLY;
// Check if dc coefficient can be quantized to zero. // Check if dc coefficient can be quantized to zero.
if (sse_tx - var_tx < dc_thr || sse == var) if (sse_tx - var_tx < dc_thr || sse == var)
x->skip_txfm[0] = 1; x->skip_txfm[0] = SKIP_TXFM_AC_DC;
} else { } else {
if (sse_tx - var_tx < dc_thr || sse == var) if (sse_tx - var_tx < dc_thr || sse == var)
skip_dc = 1; skip_dc = 1;
} }
} }
if (x->skip_txfm[0] == 1) { if (x->skip_txfm[0] == SKIP_TXFM_AC_DC) {
*out_rate_sum = 0; *out_rate_sum = 0;
*out_dist_sum = sse << 4; *out_dist_sum = sse << 4;
return; return;
@ -1073,7 +1073,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG, static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
VP9_ALT_FLAG }; VP9_ALT_FLAG };
RD_COST this_rdc, best_rdc; RD_COST this_rdc, best_rdc;
uint8_t skip_txfm = 0, best_mode_skip_txfm = 0; uint8_t skip_txfm = SKIP_TXFM_NONE, best_mode_skip_txfm = SKIP_TXFM_NONE;
// var_y and sse_y are saved to be used in skipping checking // var_y and sse_y are saved to be used in skipping checking
unsigned int var_y = UINT_MAX; unsigned int var_y = UINT_MAX;
unsigned int sse_y = UINT_MAX; unsigned int sse_y = UINT_MAX;
@ -1396,7 +1396,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
} else { } else {
this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1); this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1);
this_rdc.dist = this_sse; this_rdc.dist = this_sse;
x->skip_txfm[0] = 1; x->skip_txfm[0] = SKIP_TXFM_AC_DC;
} }
} }
@ -1881,7 +1881,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
mbmi->mode = xd->mi[0]->bmi[3].as_mode; mbmi->mode = xd->mi[0]->bmi[3].as_mode;
ctx->mic = *(xd->mi[0]); ctx->mic = *(xd->mi[0]);
ctx->mbmi_ext = *x->mbmi_ext; ctx->mbmi_ext = *x->mbmi_ext;
ctx->skip_txfm[0] = 0; ctx->skip_txfm[0] = SKIP_TXFM_NONE;
ctx->skip = 0; ctx->skip = 0;
// Dummy assignment for speed -5. No effect in speed -6. // Dummy assignment for speed -5. No effect in speed -6.
rd_cost->rdcost = best_rd; rd_cost->rdcost = best_rd;

View File

@ -207,15 +207,15 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize,
x->bsse[(i << 2) + block_idx] = sse; x->bsse[(i << 2) + block_idx] = sse;
sum_sse += sse; sum_sse += sse;
x->skip_txfm[(i << 2) + block_idx] = 0; x->skip_txfm[(i << 2) + block_idx] = SKIP_TXFM_NONE;
if (!x->select_tx_size) { if (!x->select_tx_size) {
// Check if all ac coefficients can be quantized to zero. // Check if all ac coefficients can be quantized to zero.
if (var < ac_thr || var == 0) { if (var < ac_thr || var == 0) {
x->skip_txfm[(i << 2) + block_idx] = 2; x->skip_txfm[(i << 2) + block_idx] = SKIP_TXFM_AC_ONLY;
// Check if dc coefficient can be quantized to zero. // Check if dc coefficient can be quantized to zero.
if (sse - var < dc_thr || sse == var) { if (sse - var < dc_thr || sse == var) {
x->skip_txfm[(i << 2) + block_idx] = 1; x->skip_txfm[(i << 2) + block_idx] = SKIP_TXFM_AC_DC;
if (!sse || (var < low_ac_thr && sse - var < low_dc_thr)) if (!sse || (var < low_ac_thr && sse - var < low_dc_thr))
low_err_skip = 1; low_err_skip = 1;
@ -500,7 +500,8 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize,
dist_block(x, plane, block, tx_size, &dist, &sse); dist_block(x, plane, block, tx_size, &dist, &sse);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
} else if (max_txsize_lookup[plane_bsize] == tx_size) { } else if (max_txsize_lookup[plane_bsize] == tx_size) {
if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 0) { if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] ==
SKIP_TXFM_NONE) {
// full forward transform and quantization // full forward transform and quantization
vp9_xform_quant(x, plane, block, plane_bsize, tx_size); vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
@ -512,7 +513,8 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize,
#else #else
dist_block(x, plane, block, tx_size, &dist, &sse); dist_block(x, plane, block, tx_size, &dist, &sse);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
} else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 2) { } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] ==
SKIP_TXFM_AC_ONLY) {
// compute DC coefficient // compute DC coefficient
tran_low_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block); tran_low_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block); tran_low_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block);
@ -532,6 +534,7 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize,
dist = MAX(0, sse - dc_correct); dist = MAX(0, sse - dc_correct);
} }
} else { } else {
// SKIP_TXFM_AC_DC
// skip forward transform // skip forward transform
x->plane[plane].eobs[block] = 0; x->plane[plane].eobs[block] = 0;
sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4; sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4;
@ -1064,7 +1067,7 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x,
const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0);
bmode_costs = cpi->y_mode_costs[A][L]; bmode_costs = cpi->y_mode_costs[A][L];
memset(x->skip_txfm, 0, sizeof(x->skip_txfm)); memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
/* Y Search for intra prediction mode */ /* Y Search for intra prediction mode */
for (mode = DC_PRED; mode <= TM_PRED; mode++) { for (mode = DC_PRED; mode <= TM_PRED; mode++) {
@ -1170,7 +1173,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x,
int this_rate_tokenonly, this_rate, s; int this_rate_tokenonly, this_rate, s;
int64_t this_distortion, this_sse; int64_t this_distortion, this_sse;
memset(x->skip_txfm, 0, sizeof(x->skip_txfm)); memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
for (mode = DC_PRED; mode <= TM_PRED; ++mode) { for (mode = DC_PRED; mode <= TM_PRED; ++mode) {
if (!(cpi->sf.intra_uv_mode_mask[max_tx_size] & (1 << mode))) if (!(cpi->sf.intra_uv_mode_mask[max_tx_size] & (1 << mode)))
continue; continue;
@ -1208,7 +1211,7 @@ static int64_t rd_sbuv_dcpred(const VP9_COMP *cpi, MACROBLOCK *x,
int64_t unused; int64_t unused;
x->e_mbd.mi[0]->mbmi.uv_mode = DC_PRED; x->e_mbd.mi[0]->mbmi.uv_mode = DC_PRED;
memset(x->skip_txfm, 0, sizeof(x->skip_txfm)); memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
super_block_uvrd(cpi, x, rate_tokenonly, distortion, super_block_uvrd(cpi, x, rate_tokenonly, distortion,
skippable, &unused, bsize, INT64_MAX); skippable, &unused, bsize, INT64_MAX);
*rate = *rate_tokenonly + cpi->intra_uv_mode_cost[cm->frame_type][DC_PRED]; *rate = *rate_tokenonly + cpi->intra_uv_mode_cost[cm->frame_type][DC_PRED];
@ -2673,7 +2676,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
if (is_comp_pred) if (is_comp_pred)
if (single_skippable[this_mode][refs[0]] && if (single_skippable[this_mode][refs[0]] &&
single_skippable[this_mode][refs[1]]) single_skippable[this_mode][refs[1]])
memset(skip_txfm, 1, sizeof(skip_txfm)); memset(skip_txfm, SKIP_TXFM_AC_DC, sizeof(skip_txfm));
if (cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { if (cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) {
// if current pred_error modeled rd is substantially more than the best // if current pred_error modeled rd is substantially more than the best
@ -4077,7 +4080,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi,
// then dont bother looking at UV // then dont bother looking at UV
vp9_build_inter_predictors_sbuv(&x->e_mbd, mi_row, mi_col, vp9_build_inter_predictors_sbuv(&x->e_mbd, mi_row, mi_col,
BLOCK_8X8); BLOCK_8X8);
memset(x->skip_txfm, 0, sizeof(x->skip_txfm)); memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
if (!super_block_uvrd(cpi, x, &rate_uv, &distortion_uv, &uv_skippable, if (!super_block_uvrd(cpi, x, &rate_uv, &distortion_uv, &uv_skippable,
&uv_sse, BLOCK_8X8, tmp_best_rdu)) &uv_sse, BLOCK_8X8, tmp_best_rdu))
continue; continue;