const int t = q * rd_thresh_block_size_factor[bsize];
const int thresh_max = INT_MAX / t;
- for (i = 0; i < MAX_MODES; ++i)
- rd->threshes[segment_id][bsize][i] =
- rd->thresh_mult[i] < thresh_max ? rd->thresh_mult[i] * t / 4
- : INT_MAX;
-
- for (i = 0; i < MAX_REFS; ++i) {
- rd->thresh_sub8x8[segment_id][bsize][i] =
- rd->thresh_mult_sub8x8[i] < thresh_max
- ? rd->thresh_mult_sub8x8[i] * t / 4
- : INT_MAX;
+ if (bsize >= BLOCK_8X8) {
+ for (i = 0; i < MAX_MODES; ++i)
+ rd->threshes[segment_id][bsize][i] =
+ rd->thresh_mult[i] < thresh_max
+ ? rd->thresh_mult[i] * t / 4
+ : INT_MAX;
+ } else {
+ for (i = 0; i < MAX_REFS; ++i)
+ rd->threshes[segment_id][bsize][i] =
+ rd->thresh_mult_sub8x8[i] < thresh_max
+ ? rd->thresh_mult_sub8x8[i] * t / 4
+ : INT_MAX;
}
}
}
ctx->mic = *xd->mi[0];
}
+static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh,
+ int thresh_fact) {
+ return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX;
+}
+
+// Updating rd_thresh_freq_fact[] here means that the different
+// partition/block sizes are handled independently based on the best
+// choice for the current partition. It may well be better to keep a scaled
+// best rd so far value and update rd_thresh_freq_fact based on the mode/size
+// combination that wins out.
+static void update_rd_thresh_fact(VP9_COMP *cpi, int bsize,
+ int best_mode_index) {
+ if (cpi->sf.adaptive_rd_thresh) {
+ const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES;
+ int mode_index;
+ for (mode_index = 0; mode_index < top_mode; ++mode_index) {
+ int *const fact = &cpi->rd.thresh_freq_fact[bsize][mode_index];
+
+ if (mode_index == best_mode_index) {
+ *fact -= (*fact >> 3);
+ } else {
+ *fact = MIN(*fact + RD_THRESH_INC,
+ cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
+ }
+ }
+ }
+}
+
int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
const TileInfo *const tile,
int mi_row, int mi_col,
continue;
// Test best rd so far against threshold for trying this mode.
- if (best_rd < ((int64_t)rd_threshes[mode_index] *
- rd_thresh_freq_fact[mode_index] >> 5) ||
- rd_threshes[mode_index] == INT_MAX)
- continue;
+ if (rd_less_than_thresh(best_rd, rd_threshes[mode_index],
+ rd_thresh_freq_fact[mode_index]))
+ continue;
this_mode = vp9_mode_order[mode_index].mode;
ref_frame = vp9_mode_order[mode_index].ref_frame[0];
(cm->interp_filter == best_mbmode.interp_filter) ||
!is_inter_block(&best_mbmode));
- // Updating rd_thresh_freq_fact[] here means that the different
- // partition/block sizes are handled independently based on the best
- // choice for the current partition. It may well be better to keep a scaled
- // best rd so far value and update rd_thresh_freq_fact based on the mode/size
- // combination that wins out.
- if (cpi->sf.adaptive_rd_thresh) {
- for (mode_index = 0; mode_index < MAX_MODES; ++mode_index) {
- int *const fact = &rd_opt->thresh_freq_fact[bsize][mode_index];
-
- if (mode_index == best_mode_index) {
- *fact -= (*fact >> 3);
- } else {
- *fact = MIN(*fact + RD_THRESH_INC,
- cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
- }
- }
- }
+ update_rd_thresh_fact(cpi, bsize, best_mode_index);
// macroblock modes
*mbmi = best_mbmode;
}
// Test best rd so far against threshold for trying this mode.
- if ((best_rd <
- ((int64_t)rd_opt->thresh_sub8x8[segment_id][bsize][mode_index] *
- rd_opt->thresh_freq_sub8x8[bsize][mode_index] >> 5)) ||
- rd_opt->thresh_sub8x8[segment_id][bsize][mode_index] == INT_MAX)
+ if (rd_less_than_thresh(best_rd,
+ rd_opt->threshes[segment_id][bsize][mode_index],
+ rd_opt->thresh_freq_fact[bsize][mode_index]))
continue;
if (ref_frame > INTRA_FRAME &&
int uv_skippable;
this_rd_thresh = (ref_frame == LAST_FRAME) ?
- rd_opt->thresh_sub8x8[segment_id][bsize][THR_LAST] :
- rd_opt->thresh_sub8x8[segment_id][bsize][THR_ALTR];
+ rd_opt->threshes[segment_id][bsize][THR_LAST] :
+ rd_opt->threshes[segment_id][bsize][THR_ALTR];
this_rd_thresh = (ref_frame == GOLDEN_FRAME) ?
- rd_opt->thresh_sub8x8[segment_id][bsize][THR_GOLD] : this_rd_thresh;
+ rd_opt->threshes[segment_id][bsize][THR_GOLD] : this_rd_thresh;
rd_opt->mask_filter = 0;
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i)
rd_opt->filter_cache[i] = INT64_MAX;
(cm->interp_filter == best_mbmode.interp_filter) ||
!is_inter_block(&best_mbmode));
- // Updating rd_thresh_freq_fact[] here means that the different
- // partition/block sizes are handled independently based on the best
- // choice for the current partition. It may well be better to keep a scaled
- // best rd so far value and update rd_thresh_freq_fact based on the mode/size
- // combination that wins out.
- if (cpi->sf.adaptive_rd_thresh) {
- for (mode_index = 0; mode_index < MAX_REFS; ++mode_index) {
- int *const fact = &rd_opt->thresh_freq_sub8x8[bsize][mode_index];
-
- if (mode_index == best_mode_index) {
- *fact -= (*fact >> 3);
- } else {
- *fact = MIN(*fact + RD_THRESH_INC,
- cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
- }
- }
- }
+ update_rd_thresh_fact(cpi, bsize, best_mode_index);
// macroblock modes
*mbmi = best_mbmode;