Commit 65f1c906 authored by Paul Wilkins's avatar Paul Wilkins Committed by Gerrit Code Review
Browse files

Merge "Fix bug in intra mode rd penalty."

parents 08fda52e 0657f473
......@@ -1182,19 +1182,6 @@ static const REF_MODE ref_mode_set_svc[RT_INTER_MODES] = {
{ LAST_FRAME, NEWMV }, { GOLDEN_FRAME, NEWMV }
};
static int set_intra_cost_penalty(const VP9_COMP *const cpi, BLOCK_SIZE bsize) {
const VP9_COMMON *const cm = &cpi->common;
// Reduce the intra cost penalty for small blocks (<=16x16).
int reduction_fac =
(bsize <= BLOCK_16X16) ? ((bsize <= BLOCK_8X8) ? 4 : 2) : 0;
if (cpi->noise_estimate.enabled && cpi->noise_estimate.level == kHigh)
// Don't reduce intra cost penalty if estimated noise level is high.
reduction_fac = 0;
return vp9_get_intra_cost_penalty(cm->base_qindex, cm->y_dc_delta_q,
cm->bit_depth) >>
reduction_fac;
}
static INLINE void find_predictors(
VP9_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame,
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES],
......@@ -1450,7 +1437,8 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data,
// var_y and sse_y are saved to be used in skipping checking
unsigned int var_y = UINT_MAX;
unsigned int sse_y = UINT_MAX;
const int intra_cost_penalty = set_intra_cost_penalty(cpi, bsize);
const int intra_cost_penalty =
vp9_get_intra_cost_penalty(cpi, bsize, cm->base_qindex, cm->y_dc_delta_q);
int64_t inter_mode_thresh =
RDCOST(x->rdmult, x->rddiv, intra_cost_penalty, 0);
const int *const rd_threshes = cpi->rd.threshes[mi->segment_id][bsize];
......
......@@ -670,19 +670,21 @@ void vp9_update_rd_thresh_fact(int (*factor_buf)[MAX_MODES], int rd_thresh,
}
}
int vp9_get_intra_cost_penalty(int qindex, int qdelta,
vpx_bit_depth_t bit_depth) {
const int q = vp9_dc_quant(qindex, qdelta, bit_depth);
#if CONFIG_VP9_HIGHBITDEPTH
switch (bit_depth) {
case VPX_BITS_8: return 20 * q;
case VPX_BITS_10: return 5 * q;
case VPX_BITS_12: return ROUND_POWER_OF_TWO(5 * q, 2);
default:
assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
return -1;
}
#else
return 20 * q;
#endif // CONFIG_VP9_HIGHBITDEPTH
int vp9_get_intra_cost_penalty(const VP9_COMP *const cpi, BLOCK_SIZE bsize,
int qindex, int qdelta) {
// Reduce the intra cost penalty for small blocks (<=16x16).
int reduction_fac =
(bsize <= BLOCK_16X16) ? ((bsize <= BLOCK_8X8) ? 4 : 2) : 0;
if (cpi->noise_estimate.enabled && cpi->noise_estimate.level == kHigh)
// Don't reduce intra cost penalty if estimated noise level is high.
reduction_fac = 0;
// Always use VPX_BITS_8 as input here because the penalty is applied
// to rate not distortion so we want a consistent penalty for all bit
// depths. If the actual bit depth were passed in here then the value
// retured by vp9_dc_quant() would scale with the bit depth and we would
// then need to apply inverse scaling to correct back to a bit depth
// independent rate penalty.
return (20 * vp9_dc_quant(qindex, qdelta, VPX_BITS_8)) >> reduction_fac;
}
......@@ -191,8 +191,8 @@ void vp9_setup_pred_block(const MACROBLOCKD *xd,
const struct scale_factors *scale,
const struct scale_factors *scale_uv);
int vp9_get_intra_cost_penalty(int qindex, int qdelta,
vpx_bit_depth_t bit_depth);
int vp9_get_intra_cost_penalty(const struct VP9_COMP *const cpi,
BLOCK_SIZE bsize, int qindex, int qdelta);
unsigned int vp9_get_sby_perpixel_variance(struct VP9_COMP *cpi,
const struct buf_2d *ref,
......
......@@ -3038,8 +3038,8 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, TileDataEnc *tile_data,
int64_t dist_uv[TX_SIZES];
int skip_uv[TX_SIZES];
PREDICTION_MODE mode_uv[TX_SIZES];
const int intra_cost_penalty = vp9_get_intra_cost_penalty(
cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth);
const int intra_cost_penalty =
vp9_get_intra_cost_penalty(cpi, bsize, cm->base_qindex, cm->y_dc_delta_q);
int best_skip2 = 0;
uint8_t ref_frame_skip_mask[2] = { 0 };
uint16_t mode_skip_mask[MAX_REF_FRAMES] = { 0 };
......@@ -3802,8 +3802,8 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, TileDataEnc *tile_data,
int64_t dist_uv;
int skip_uv;
PREDICTION_MODE mode_uv = DC_PRED;
const int intra_cost_penalty = vp9_get_intra_cost_penalty(
cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth);
const int intra_cost_penalty =
vp9_get_intra_cost_penalty(cpi, bsize, cm->base_qindex, cm->y_dc_delta_q);
int_mv seg_mvs[4][MAX_REF_FRAMES];
b_mode_info best_bmodes[4];
int best_skip2 = 0;
......
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