}
}
+// Examines 64x64 block and chooses a best reference frame
+static void rd_pick_reference_frame(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
+ int mi_col, int *rate, int64_t *dist) {
+ VP9_COMMON * const cm = &cpi->common;
+ MACROBLOCK * const x = &cpi->mb;
+ MACROBLOCKD * const xd = &x->e_mbd;
+ int bsl = b_width_log2(BLOCK_SIZE_SB64X64), bs = 1 << bsl;
+ int ms = bs / 2;
+ ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE];
+ PARTITION_CONTEXT sl[8], sa[8];
+ int pl;
+ int r;
+ int64_t d;
+
+ save_context(cpi, mi_row, mi_col, a, l, sa, sl, BLOCK_SIZE_SB64X64);
+
+ // Default is non mask (all reference frames allowed.
+ cpi->ref_frame_mask = 0;
+
+ // Do RD search for 64x64.
+ if ((mi_row + (ms >> 1) < cm->mi_rows) &&
+ (mi_col + (ms >> 1) < cm->mi_cols)) {
+ cpi->set_ref_frame_mask = 1;
+ pick_sb_modes(cpi, mi_row, mi_col, tp, &r, &d, BLOCK_SIZE_SB64X64,
+ get_block_context(x, BLOCK_SIZE_SB64X64));
+ set_partition_seg_context(cm, xd, mi_row, mi_col);
+ pl = partition_plane_context(xd, BLOCK_SIZE_SB64X64);
+ r += x->partition_cost[pl][PARTITION_NONE];
+
+ *(get_sb_partitioning(x, BLOCK_SIZE_SB64X64)) = BLOCK_SIZE_SB64X64;
+ cpi->set_ref_frame_mask = 0;
+ }
+
+ *rate = r;
+ *dist = d;
+ // RDCOST(x->rdmult, x->rddiv, r, d)
+
+ restore_context(cpi, mi_row, mi_col, a, l, sa, sl, BLOCK_SIZE_SB64X64);
+
+ /*if (srate < INT_MAX && sdist < INT_MAX)
+ encode_sb(cpi, tp, mi_row, mi_col, 1, BLOCK_SIZE_SB64X64);
+
+ if (bsize == BLOCK_SIZE_SB64X64) {
+ assert(tp_orig < *tp);
+ assert(srate < INT_MAX);
+ assert(sdist < INT_MAX);
+ } else {
+ assert(tp_orig == *tp);
+ }
+ */
+}
+
static void encode_sb_row(VP9_COMP *cpi, int mi_row, TOKENEXTRA **tp,
int *totalrate) {
VP9_COMMON * const cm = &cpi->common;
mi_col += 64 / MI_SIZE) {
int dummy_rate;
int64_t dummy_dist;
+
+ // Initialize a mask of modes that we will not consider;
+ // cpi->unused_mode_skip_mask = 0x0000000AAE17F800 (test no golden)
+ if (cpi->common.frame_type == KEY_FRAME)
+ cpi->unused_mode_skip_mask = 0;
+ else
+ cpi->unused_mode_skip_mask = 0xFFFFFFFFFFFFFE00;
+
+ if (cpi->sf.reference_masking) {
+ rd_pick_reference_frame(cpi, tp, mi_row, mi_col,
+ &dummy_rate, &dummy_dist);
+ }
+
if (cpi->sf.partition_by_variance || cpi->sf.use_lastframe_partitioning ||
cpi->sf.use_one_partition_size_always ) {
const int idx_str = cm->mode_info_stride * mi_row + mi_col;
sf->tx_size_search_method = USE_FULL_RD;
sf->use_8tap_always = 0;
sf->use_avoid_tested_higherror = 0;
+ sf->reference_masking = 0;
sf->skip_lots_of_modes = 0;
sf->adjust_thresholds_by_speed = 0;
sf->partition_by_variance = 0;
sf->disable_splitmv = 0;
sf->conditional_oblique_intramodes = 0;
+ // Skip any mode not chosen at size < X for all sizes > X
+ // Hence BLOCK_SIZE_SB64X64 (skip is off)
+ sf->unused_mode_skip_lvl = BLOCK_SIZE_SB64X64;
+
#if CONFIG_MULTIPLE_ARF
// Switch segmentation off.
sf->static_segmentation = 0;
sf->auto_mv_step_size = 1;
sf->use_avoid_tested_higherror = 1;
sf->adaptive_rd_thresh = 1;
-
if (speed == 1) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
sf->less_rectangular_check = 1;
sf->use_square_partition_only = !(cpi->common.frame_type == KEY_FRAME ||
cpi->common.intra_only ||
cpi->common.show_frame == 0);
+ sf->unused_mode_skip_lvl = BLOCK_SIZE_SB32X32;
}
if (speed == 2) {
sf->adjust_thresholds_by_speed = 1;
sf->less_rectangular_check = 1;
sf->use_square_partition_only = 1;
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
- sf->reduce_first_step_size = 1;
- sf->optimize_coefficients = 0;
sf->use_lastframe_partitioning = 1;
sf->adjust_partitioning_from_last_frame = 1;
sf->last_partitioning_redo_frequency = 3;
sf->tx_size_search_method = USE_LARGESTALL;
sf->conditional_oblique_intramodes = 1;
+ sf->unused_mode_skip_lvl = BLOCK_SIZE_SB32X32;
+ sf->reduce_first_step_size = 1;
+ sf->optimize_coefficients = 0;
+ // sf->reference_masking = 1;
}
if (speed == 3) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
int use_one_partition_size_always;
int less_rectangular_check;
int use_square_partition_only;
+ int unused_mode_skip_lvl;
+ int reference_masking;
BLOCK_SIZE_TYPE always_this_block_size;
int use_partitions_greater_than;
BLOCK_SIZE_TYPE greater_than_block_size;
unsigned int mode_check_freq[MAX_MODES];
unsigned int mode_test_hit_counts[MAX_MODES];
unsigned int mode_chosen_counts[MAX_MODES];
+ int64_t unused_mode_skip_mask;
+ int ref_frame_mask;
+ int set_ref_frame_mask;
int rd_thresh_mult[MAX_MODES];
int rd_baseline_thresh[BLOCK_SIZE_TYPES][MAX_MODES];
for (i = 0; i < NB_TXFM_MODES; ++i)
txfm_cache[i] = INT64_MAX;
+ this_mode = vp9_mode_order[mode_index].mode;
+ ref_frame = vp9_mode_order[mode_index].ref_frame;
+
+ // Slip modes that have been masked off but always consider first mode.
+ if ( mode_index && (bsize > cpi->sf.unused_mode_skip_lvl) &&
+ (cpi->unused_mode_skip_mask & (1 << mode_index)) )
+ continue;
+
+ // Skip if the current refernce frame has been masked off
+ if (cpi->sf.reference_masking && !cpi->set_ref_frame_mask &&
+ (cpi->ref_frame_mask & (1 << ref_frame)))
+ continue;
+
// Test best rd so far against threshold for trying this mode.
if ((best_rd < ((cpi->rd_threshes[bsize][mode_index] *
cpi->rd_thresh_freq_fact[bsize][mode_index]) >> 4)) ||
continue;
x->skip = 0;
- this_mode = vp9_mode_order[mode_index].mode;
- ref_frame = vp9_mode_order[mode_index].ref_frame;
if (cpi->sf.use_avoid_tested_higherror && bsize >= BLOCK_SIZE_SB8X8) {
if (!(ref_frame_mask & (1 << ref_frame))) {
if (x->skip && !mode_excluded)
break;
}
+
+ // If indicated then mark the index of the chosen mode to be inspected at
+ // other block sizes.
+ if (bsize <= cpi->sf.unused_mode_skip_lvl) {
+ cpi->unused_mode_skip_mask = cpi->unused_mode_skip_mask &
+ (~((int64_t)1 << best_mode_index));
+ }
+
+ // If we are using reference masking and the set mask flag is set then
+ // create the reference frame mask.
+ if (cpi->sf.reference_masking && cpi->set_ref_frame_mask)
+ cpi->ref_frame_mask = ~(1 << vp9_mode_order[best_mode_index].ref_frame);
+
// Flag all modes that have a distortion thats > 2x the best we found at
// this level.
for (mode_index = 0; mode_index < MB_MODE_COUNT; ++mode_index) {