ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int *bestrate, int *bestratey,
int64_t *bestdistortion,
- BLOCK_SIZE_TYPE bsize) {
+ BLOCK_SIZE_TYPE bsize,
+ int64_t rd_thresh) {
MB_PREDICTION_MODE mode;
MACROBLOCKD *xd = &x->e_mbd;
- int64_t best_rd = INT64_MAX;
+ int64_t best_rd = rd_thresh;
int rate = 0;
int64_t distortion;
VP9_COMMON *const cm = &cpi->common;
distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff,
block, 16),
16, &ssz) >> 2;
+ if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
+ goto next;
if (tx_type != DCT_DCT)
vp9_short_iht4x4_add(BLOCK_OFFSET(pd->dqcoeff, block, 16),
best_tx_type = tx_type;
vpx_memcpy(a, tempa, sizeof(tempa));
vpx_memcpy(l, templ, sizeof(templ));
+ // FIXME(rbultje) why are we storing best_dqcoeff instead of the
+ // dst buffer here?
for (idy = 0; idy < num_4x4_blocks_high; ++idy) {
for (idx = 0; idx < num_4x4_blocks_wide; ++idx) {
block = ib + idy * 2 + idx;
}
}
}
+ next:
+ {}
}
- if (x->skip_encode)
+ if (best_rd >= rd_thresh || x->skip_encode)
return best_rd;
for (idy = 0; idy < num_4x4_blocks_high; ++idy) {
const int mis = xd->mode_info_stride;
MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry);
- int64_t UNINITIALIZED_IS_SAFE(d);
+ int64_t UNINITIALIZED_IS_SAFE(d), this_rd;
i = idy * 2 + idx;
if (cpi->common.frame_type == KEY_FRAME) {
bmode_costs = mb->y_mode_costs[A][L];
}
- total_rd += rd_pick_intra4x4block(cpi, mb, i, &best_mode, bmode_costs,
- t_above + idx, t_left + idy,
- &r, &ry, &d, bsize);
+ this_rd = rd_pick_intra4x4block(cpi, mb, i, &best_mode, bmode_costs,
+ t_above + idx, t_left + idy,
+ &r, &ry, &d, bsize,
+ best_rd - total_rd);
+ if (this_rd >= best_rd - total_rd)
+ return INT64_MAX;
+
+ total_rd += this_rd;
cost += r;
distortion += d;
tot_rate_y += ry;
*/
mbmi->txfm_size = TX_4X4;
- rd_pick_intra4x4mby_modes(cpi, x, &rate, &rate_y,
- &distortion_y, INT64_MAX);
+ if (rd_pick_intra4x4mby_modes(cpi, x, &rate, &rate_y,
+ &distortion_y, best_rd) >= best_rd)
+ continue;
rate2 += rate;
rate2 += intra_cost_penalty;
distortion2 += distortion_y;