Index: source/libvpx/vp9/encoder/vp9_encodeframe.c |
=================================================================== |
--- source/libvpx/vp9/encoder/vp9_encodeframe.c (revision 281795) |
+++ source/libvpx/vp9/encoder/vp9_encodeframe.c (working copy) |
@@ -38,6 +38,7 @@ |
#include "vp9/encoder/vp9_encodemv.h" |
#include "vp9/encoder/vp9_extend.h" |
#include "vp9/encoder/vp9_pickmode.h" |
+#include "vp9/encoder/vp9_rd.h" |
#include "vp9/encoder/vp9_rdopt.h" |
#include "vp9/encoder/vp9_segmentation.h" |
#include "vp9/encoder/vp9_tokenize.h" |
@@ -70,12 +71,6 @@ |
128, 128, 128, 128, 128, 128, 128, 128 |
}; |
-typedef struct { |
- unsigned int sse; |
- int sum; |
- unsigned int var; |
-} diff; |
- |
static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi, |
const struct buf_2d *ref, |
BLOCK_SIZE bs) { |
@@ -139,42 +134,6 @@ |
xd->mi[0] = cm->mi + idx_str; |
} |
-static int is_block_in_mb_map(const VP9_COMP *cpi, int mi_row, int mi_col, |
- BLOCK_SIZE bsize) { |
- const VP9_COMMON *const cm = &cpi->common; |
- const int mb_rows = cm->mb_rows; |
- const int mb_cols = cm->mb_cols; |
- const int mb_row = mi_row >> 1; |
- const int mb_col = mi_col >> 1; |
- const int mb_width = num_8x8_blocks_wide_lookup[bsize] >> 1; |
- const int mb_height = num_8x8_blocks_high_lookup[bsize] >> 1; |
- int r, c; |
- if (bsize <= BLOCK_16X16) { |
- return cpi->active_map[mb_row * mb_cols + mb_col]; |
- } |
- for (r = 0; r < mb_height; ++r) { |
- for (c = 0; c < mb_width; ++c) { |
- int row = mb_row + r; |
- int col = mb_col + c; |
- if (row >= mb_rows || col >= mb_cols) |
- continue; |
- if (cpi->active_map[row * mb_cols + col]) |
- return 1; |
- } |
- } |
- return 0; |
-} |
- |
-static int check_active_map(const VP9_COMP *cpi, const MACROBLOCK *x, |
- int mi_row, int mi_col, |
- BLOCK_SIZE bsize) { |
- if (cpi->active_map_enabled && !x->e_mbd.lossless) { |
- return is_block_in_mb_map(cpi, mi_row, mi_col, bsize); |
- } else { |
- return 1; |
- } |
-} |
- |
static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, |
int mi_row, int mi_col, BLOCK_SIZE bsize) { |
MACROBLOCK *const x = &cpi->mb; |
@@ -187,9 +146,6 @@ |
set_skip_context(xd, mi_row, mi_col); |
- // Activity map pointer |
- x->in_active_map = check_active_map(cpi, x, mi_row, mi_col, bsize); |
- |
set_modeinfo_offsets(cm, xd, mi_row, mi_col); |
mbmi = &xd->mi[0]->mbmi; |
@@ -723,7 +679,6 @@ |
xd->mi[0]->bmi[0].as_mv[0].as_int = 0; |
x->skip = 1; |
- x->skip_encode = 1; |
*rate = 0; |
*dist = 0; |
@@ -822,12 +777,17 @@ |
vp9_rd_pick_intra_mode_sb(cpi, x, totalrate, totaldist, bsize, ctx, |
best_rd); |
} else { |
- if (bsize >= BLOCK_8X8) |
- vp9_rd_pick_inter_mode_sb(cpi, x, tile, mi_row, mi_col, |
- totalrate, totaldist, bsize, ctx, best_rd); |
- else |
+ if (bsize >= BLOCK_8X8) { |
+ if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) |
+ vp9_rd_pick_inter_mode_sb_seg_skip(cpi, x, totalrate, totaldist, bsize, |
+ ctx, best_rd); |
+ else |
+ vp9_rd_pick_inter_mode_sb(cpi, x, tile, mi_row, mi_col, |
+ totalrate, totaldist, bsize, ctx, best_rd); |
+ } else { |
vp9_rd_pick_inter_mode_sub8x8(cpi, x, tile, mi_row, mi_col, totalrate, |
totaldist, bsize, ctx, best_rd); |
+ } |
} |
x->rdmult = orig_rdmult; |
@@ -909,6 +869,7 @@ |
vpx_memcpy(xd->left_seg_context + (mi_row & MI_MASK), sl, |
sizeof(xd->left_seg_context[0]) * mi_height); |
} |
+ |
static void save_context(VP9_COMP *cpi, int mi_row, int mi_col, |
ENTROPY_CONTEXT a[16 * MAX_MB_PLANE], |
ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], |
@@ -946,7 +907,6 @@ |
TOKENEXTRA **tp, int mi_row, int mi_col, |
int output_enabled, BLOCK_SIZE bsize, |
PICK_MODE_CONTEXT *ctx) { |
- |
set_offsets(cpi, tile, mi_row, mi_col, bsize); |
update_state(cpi, ctx, mi_row, mi_col, bsize, output_enabled); |
encode_superblock(cpi, tp, output_enabled, mi_row, mi_col, bsize, ctx); |
@@ -1175,7 +1135,6 @@ |
} |
} |
- |
const struct { |
int row; |
int col; |
@@ -1208,35 +1167,27 @@ |
// In-image SB64 |
if ((col8x8_remaining >= MI_BLOCK_SIZE) && |
(row8x8_remaining >= MI_BLOCK_SIZE)) { |
- const int src_stride = x->plane[0].src.stride; |
- const int pre_stride = cpi->Last_Source->y_stride; |
- const uint8_t *src = x->plane[0].src.buf; |
- const int pre_offset = (mi_row * MI_SIZE) * pre_stride + |
- (mi_col * MI_SIZE); |
- const uint8_t *pre_src = cpi->Last_Source->y_buffer + pre_offset; |
- const unsigned int thr_32x32 = cpi->sf.source_var_thresh; |
- const unsigned int thr_64x64 = thr_32x32 << 1; |
int i, j; |
int index; |
diff d32[4]; |
- int use16x16 = 0; |
+ const int offset = (mi_row >> 1) * cm->mb_cols + (mi_col >> 1); |
+ int is_larger_better = 0; |
+ int use32x32 = 0; |
+ unsigned int thr = cpi->source_var_thresh; |
+ vpx_memset(d32, 0, 4 * sizeof(diff)); |
+ |
for (i = 0; i < 4; i++) { |
- diff d16[4]; |
+ diff *d16[4]; |
for (j = 0; j < 4; j++) { |
int b_mi_row = coord_lookup[i * 4 + j].row; |
int b_mi_col = coord_lookup[i * 4 + j].col; |
- int b_offset = b_mi_row * MI_SIZE * src_stride + |
- b_mi_col * MI_SIZE; |
+ int boffset = b_mi_row / 2 * cm->mb_cols + |
+ b_mi_col / 2; |
- vp9_get16x16var(src + b_offset, src_stride, |
- pre_src + b_offset, pre_stride, |
- &d16[j].sse, &d16[j].sum); |
+ d16[j] = cpi->source_diff_var + offset + boffset; |
- d16[j].var = d16[j].sse - |
- (((uint32_t)d16[j].sum * d16[j].sum) >> 8); |
- |
index = b_mi_row * mis + b_mi_col; |
mi_8x8[index] = mi_upper_left + index; |
mi_8x8[index]->mbmi.sb_type = BLOCK_16X16; |
@@ -1245,14 +1196,16 @@ |
// size to further improve quality. |
} |
- if (d16[0].var < thr_32x32 && d16[1].var < thr_32x32 && |
- d16[2].var < thr_32x32 && d16[3].var < thr_32x32) { |
- d32[i].sse = d16[0].sse; |
- d32[i].sum = d16[0].sum; |
+ is_larger_better = (d16[0]->var < thr) && (d16[1]->var < thr) && |
+ (d16[2]->var < thr) && (d16[3]->var < thr); |
- for (j = 1; j < 4; j++) { |
- d32[i].sse += d16[j].sse; |
- d32[i].sum += d16[j].sum; |
+ // Use 32x32 partition |
+ if (is_larger_better) { |
+ use32x32 += 1; |
+ |
+ for (j = 0; j < 4; j++) { |
+ d32[i].sse += d16[j]->sse; |
+ d32[i].sum += d16[j]->sum; |
} |
d32[i].var = d32[i].sse - (((int64_t)d32[i].sum * d32[i].sum) >> 10); |
@@ -1260,18 +1213,16 @@ |
index = coord_lookup[i*4].row * mis + coord_lookup[i*4].col; |
mi_8x8[index] = mi_upper_left + index; |
mi_8x8[index]->mbmi.sb_type = BLOCK_32X32; |
- |
- if (!((cm->current_video_frame - 1) % |
- cpi->sf.search_type_check_frequency)) |
- cpi->use_large_partition_rate += 1; |
- } else { |
- use16x16 = 1; |
} |
} |
- if (!use16x16) { |
- if (d32[0].var < thr_64x64 && d32[1].var < thr_64x64 && |
- d32[2].var < thr_64x64 && d32[3].var < thr_64x64) { |
+ if (use32x32 == 4) { |
+ thr <<= 1; |
+ is_larger_better = (d32[0].var < thr) && (d32[1].var < thr) && |
+ (d32[2].var < thr) && (d32[3].var < thr); |
+ |
+ // Use 64x64 partition |
+ if (is_larger_better) { |
mi_8x8[0] = mi_upper_left; |
mi_8x8[0]->mbmi.sb_type = BLOCK_64X64; |
} |
@@ -1508,20 +1459,8 @@ |
if (bsize == BLOCK_16X16) { |
set_offsets(cpi, tile, mi_row, mi_col, bsize); |
x->mb_energy = vp9_block_energy(cpi, x, bsize); |
- } else { |
- x->in_active_map = check_active_map(cpi, x, mi_row, mi_col, bsize); |
} |
- if (!x->in_active_map) { |
- do_partition_search = 0; |
- if (mi_row + (mi_step >> 1) < cm->mi_rows && |
- mi_col + (mi_step >> 1) < cm->mi_cols) { |
- pc_tree->partitioning = PARTITION_NONE; |
- bs_type = mi_8x8[0]->mbmi.sb_type = bsize; |
- subsize = bsize; |
- partition = PARTITION_NONE; |
- } |
- } |
if (do_partition_search && |
cpi->sf.partition_search_type == SEARCH_PARTITION && |
cpi->sf.adjust_partitioning_from_last_frame) { |
@@ -1984,8 +1923,6 @@ |
if (bsize == BLOCK_16X16) { |
set_offsets(cpi, tile, mi_row, mi_col, bsize); |
x->mb_energy = vp9_block_energy(cpi, x, bsize); |
- } else { |
- x->in_active_map = check_active_map(cpi, x, mi_row, mi_col, bsize); |
} |
// Determine partition types in search according to the speed features. |
// The threshold set here has to be of square block size. |
@@ -2018,8 +1955,6 @@ |
} |
} |
- if (!x->in_active_map && (partition_horz_allowed || partition_vert_allowed)) |
- do_split = 0; |
// PARTITION_NONE |
if (partition_none_allowed) { |
rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &this_rate, &this_dist, bsize, |
@@ -2053,10 +1988,6 @@ |
} |
} |
} |
- if (!x->in_active_map) { |
- do_split = 0; |
- do_rect = 0; |
- } |
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
} |
@@ -2310,7 +2241,8 @@ |
sf->always_this_block_size); |
rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, |
&dummy_rate, &dummy_dist, 1, cpi->pc_root); |
- } else if (sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { |
+ } else if (cpi->skippable_frame || |
+ sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { |
BLOCK_SIZE bsize; |
set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); |
bsize = get_rd_var_based_fixed_partition(cpi, mi_row, mi_col); |
@@ -2322,8 +2254,15 @@ |
rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, |
&dummy_rate, &dummy_dist, 1, cpi->pc_root); |
} else { |
+ GF_GROUP * gf_grp = &cpi->twopass.gf_group; |
+ int last_was_mid_sequence_overlay = 0; |
+ if ((cpi->pass == 2) && (gf_grp->index)) { |
+ if (gf_grp->update_type[gf_grp->index - 1] == OVERLAY_UPDATE) |
+ last_was_mid_sequence_overlay = 1; |
+ } |
if ((cm->current_video_frame |
% sf->last_partitioning_redo_frequency) == 0 |
+ || last_was_mid_sequence_overlay |
|| cm->prev_mi == 0 |
|| cm->show_frame == 0 |
|| cm->frame_type == KEY_FRAME |
@@ -2436,7 +2375,7 @@ |
rd_opt->tx_select_threshes[frame_type][TX_MODE_SELECT] ? |
ALLOW_32X32 : TX_MODE_SELECT; |
} else if (cpi->sf.tx_size_search_method == USE_TX_8X8) { |
- return ALLOW_8X8; |
+ return TX_MODE_SELECT; |
} else { |
unsigned int total = 0; |
int i; |
@@ -2453,20 +2392,6 @@ |
} |
} |
-static void set_mode_info(MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, |
- PREDICTION_MODE mode) { |
- mbmi->mode = mode; |
- mbmi->uv_mode = mode; |
- mbmi->mv[0].as_int = 0; |
- mbmi->mv[1].as_int = 0; |
- mbmi->ref_frame[0] = INTRA_FRAME; |
- mbmi->ref_frame[1] = NONE; |
- mbmi->tx_size = max_txsize_lookup[bsize]; |
- mbmi->skip = 0; |
- mbmi->sb_type = bsize; |
- mbmi->segment_id = 0; |
-} |
- |
static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, |
int mi_row, int mi_col, |
int *rate, int64_t *dist, |
@@ -2479,19 +2404,15 @@ |
mbmi = &xd->mi[0]->mbmi; |
mbmi->sb_type = bsize; |
- if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) { |
+ if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) |
if (mbmi->segment_id && x->in_static_area) |
x->rdmult = vp9_cyclic_refresh_get_rdmult(cpi->cyclic_refresh); |
- } |
- if (!frame_is_intra_only(cm)) { |
- if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) |
- set_mode_info_seg_skip(x, cm->tx_mode, rate, dist, bsize); |
- else |
- vp9_pick_inter_mode(cpi, x, tile, mi_row, mi_col, rate, dist, bsize); |
- } else { |
- set_mode_info(&xd->mi[0]->mbmi, bsize, DC_PRED); |
- } |
+ if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) |
+ set_mode_info_seg_skip(x, cm->tx_mode, rate, dist, bsize); |
+ else |
+ vp9_pick_inter_mode(cpi, x, tile, mi_row, mi_col, rate, dist, bsize); |
+ |
duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); |
} |
@@ -2586,8 +2507,6 @@ |
assert(num_8x8_blocks_wide_lookup[bsize] == |
num_8x8_blocks_high_lookup[bsize]); |
- x->in_active_map = check_active_map(cpi, x, mi_row, mi_col, bsize); |
- |
// Determine partition types in search according to the speed features. |
// The threshold set here has to be of square block size. |
if (cpi->sf.auto_min_max_partition_size) { |
@@ -2606,15 +2525,13 @@ |
partition_vert_allowed &= force_vert_split; |
} |
- if (!x->in_active_map && (partition_horz_allowed || partition_vert_allowed)) |
- do_split = 0; |
- |
// PARTITION_NONE |
if (partition_none_allowed) { |
nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, |
&this_rate, &this_dist, bsize); |
ctx->mic.mbmi = xd->mi[0]->mbmi; |
ctx->skip_txfm = x->skip_txfm; |
+ ctx->skip = x->skip; |
if (this_rate != INT_MAX) { |
int pl = partition_plane_context(xd, mi_row, mi_col, bsize); |
@@ -2643,10 +2560,6 @@ |
} |
} |
} |
- if (!x->in_active_map) { |
- do_split = 0; |
- do_rect = 0; |
- } |
} |
// store estimated motion vector |
@@ -2702,6 +2615,7 @@ |
pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->horizontal[0].skip_txfm = x->skip_txfm; |
+ pc_tree->horizontal[0].skip = x->skip; |
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); |
@@ -2712,6 +2626,7 @@ |
pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->horizontal[1].skip_txfm = x->skip_txfm; |
+ pc_tree->horizontal[1].skip = x->skip; |
if (this_rate == INT_MAX) { |
sum_rd = INT64_MAX; |
@@ -2742,6 +2657,7 @@ |
&this_rate, &this_dist, subsize); |
pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->vertical[0].skip_txfm = x->skip_txfm; |
+ pc_tree->vertical[0].skip = x->skip; |
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); |
if (sum_rd < best_rd && mi_col + ms < cm->mi_cols) { |
load_pred_mv(x, ctx); |
@@ -2749,6 +2665,7 @@ |
&this_rate, &this_dist, subsize); |
pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->vertical[1].skip_txfm = x->skip_txfm; |
+ pc_tree->vertical[1].skip = x->skip; |
if (this_rate == INT_MAX) { |
sum_rd = INT64_MAX; |
} else { |
@@ -2838,16 +2755,19 @@ |
nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize); |
pc_tree->none.mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->none.skip_txfm = x->skip_txfm; |
+ pc_tree->none.skip = x->skip; |
break; |
case PARTITION_VERT: |
nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize); |
pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->vertical[0].skip_txfm = x->skip_txfm; |
+ pc_tree->vertical[0].skip = x->skip; |
if (mi_col + hbs < cm->mi_cols) { |
nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + hbs, |
&rate, &dist, subsize); |
pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->vertical[1].skip_txfm = x->skip_txfm; |
+ pc_tree->vertical[1].skip = x->skip; |
if (rate != INT_MAX && dist != INT64_MAX && |
*totrate != INT_MAX && *totdist != INT64_MAX) { |
*totrate += rate; |
@@ -2859,11 +2779,13 @@ |
nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize); |
pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->horizontal[0].skip_txfm = x->skip_txfm; |
+ pc_tree->horizontal[0].skip = x->skip; |
if (mi_row + hbs < cm->mi_rows) { |
nonrd_pick_sb_modes(cpi, tile, mi_row + hbs, mi_col, |
&rate, &dist, subsize); |
pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; |
pc_tree->horizontal[1].skip_txfm = x->skip_txfm; |
+ pc_tree->horizontal[1].skip = x->skip; |
if (rate != INT_MAX && dist != INT64_MAX && |
*totrate != INT_MAX && *totdist != INT64_MAX) { |
*totrate += rate; |
@@ -2984,6 +2906,93 @@ |
} |
// end RTC play code |
+static int set_var_thresh_from_histogram(VP9_COMP *cpi) { |
+ SPEED_FEATURES *const sf = &cpi->sf; |
+ VP9_COMMON *const cm = &cpi->common; |
+ |
+ const uint8_t *src = cpi->Source->y_buffer; |
+ const uint8_t *last_src = cpi->Last_Source->y_buffer; |
+ const int src_stride = cpi->Source->y_stride; |
+ const int last_stride = cpi->Last_Source->y_stride; |
+ |
+ // Pick cutoff threshold |
+ const int cutoff = (MIN(cm->width, cm->height) >= 720) ? |
+ (cm->MBs * VAR_HIST_LARGE_CUT_OFF / 100) : |
+ (cm->MBs * VAR_HIST_SMALL_CUT_OFF / 100); |
+ DECLARE_ALIGNED_ARRAY(16, int, hist, VAR_HIST_BINS); |
+ diff *var16 = cpi->source_diff_var; |
+ |
+ int sum = 0; |
+ int i, j; |
+ |
+ vpx_memset(hist, 0, VAR_HIST_BINS * sizeof(hist[0])); |
+ |
+ for (i = 0; i < cm->mb_rows; i++) { |
+ for (j = 0; j < cm->mb_cols; j++) { |
+ vp9_get16x16var(src, src_stride, last_src, last_stride, |
+ &var16->sse, &var16->sum); |
+ |
+ var16->var = var16->sse - |
+ (((uint32_t)var16->sum * var16->sum) >> 8); |
+ |
+ if (var16->var >= VAR_HIST_MAX_BG_VAR) |
+ hist[VAR_HIST_BINS - 1]++; |
+ else |
+ hist[var16->var / VAR_HIST_FACTOR]++; |
+ |
+ src += 16; |
+ last_src += 16; |
+ var16++; |
+ } |
+ |
+ src = src - cm->mb_cols * 16 + 16 * src_stride; |
+ last_src = last_src - cm->mb_cols * 16 + 16 * last_stride; |
+ } |
+ |
+ cpi->source_var_thresh = 0; |
+ |
+ if (hist[VAR_HIST_BINS - 1] < cutoff) { |
+ for (i = 0; i < VAR_HIST_BINS - 1; i++) { |
+ sum += hist[i]; |
+ |
+ if (sum > cutoff) { |
+ cpi->source_var_thresh = (i + 1) * VAR_HIST_FACTOR; |
+ return 0; |
+ } |
+ } |
+ } |
+ |
+ return sf->search_type_check_frequency; |
+} |
+ |
+static void source_var_based_partition_search_method(VP9_COMP *cpi) { |
+ VP9_COMMON *const cm = &cpi->common; |
+ SPEED_FEATURES *const sf = &cpi->sf; |
+ |
+ if (cm->frame_type == KEY_FRAME) { |
+ // For key frame, use SEARCH_PARTITION. |
+ sf->partition_search_type = SEARCH_PARTITION; |
+ } else if (cm->intra_only) { |
+ sf->partition_search_type = FIXED_PARTITION; |
+ } else { |
+ if (cm->last_width != cm->width || cm->last_height != cm->height) { |
+ if (cpi->source_diff_var) |
+ vpx_free(cpi->source_diff_var); |
+ |
+ CHECK_MEM_ERROR(cm, cpi->source_diff_var, |
+ vpx_calloc(cm->MBs, sizeof(diff))); |
+ } |
+ |
+ if (!cpi->frames_till_next_var_check) |
+ cpi->frames_till_next_var_check = set_var_thresh_from_histogram(cpi); |
+ |
+ if (cpi->frames_till_next_var_check > 0) { |
+ sf->partition_search_type = FIXED_PARTITION; |
+ cpi->frames_till_next_var_check--; |
+ } |
+ } |
+} |
+ |
static int get_skip_encode_frame(const VP9_COMMON *cm) { |
unsigned int intra_count = 0, inter_count = 0; |
int j; |
@@ -3014,7 +3023,7 @@ |
vp9_tile_init(&tile, cm, tile_row, tile_col); |
for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end; |
mi_row += MI_BLOCK_SIZE) { |
- if (cpi->sf.use_nonrd_pick_mode && cm->frame_type != KEY_FRAME) |
+ if (cpi->sf.use_nonrd_pick_mode && !frame_is_intra_only(cm)) |
encode_nonrd_sb_row(cpi, &tile, mi_row, &tok); |
else |
encode_rd_sb_row(cpi, &tile, mi_row, &tok); |
@@ -3066,6 +3075,7 @@ |
init_encode_frame_mb_context(cpi); |
set_prev_mi(cm); |
+ x->quant_fp = cpi->sf.use_quant_fp; |
x->skip_txfm = 0; |
if (sf->use_nonrd_pick_mode) { |
// Initialize internal buffer pointers for rtc coding, where non-RD |
@@ -3083,28 +3093,8 @@ |
} |
vp9_zero(x->zcoeff_blk); |
- if (sf->partition_search_type == SOURCE_VAR_BASED_PARTITION && |
- cm->current_video_frame > 0) { |
- int check_freq = sf->search_type_check_frequency; |
- |
- if ((cm->current_video_frame - 1) % check_freq == 0) { |
- cpi->use_large_partition_rate = 0; |
- } |
- |
- if ((cm->current_video_frame - 1) % check_freq == 1) { |
- const int mbs_in_b32x32 = 1 << ((b_width_log2_lookup[BLOCK_32X32] - |
- b_width_log2_lookup[BLOCK_16X16]) + |
- (b_height_log2_lookup[BLOCK_32X32] - |
- b_height_log2_lookup[BLOCK_16X16])); |
- cpi->use_large_partition_rate = cpi->use_large_partition_rate * 100 * |
- mbs_in_b32x32 / cm->MBs; |
- } |
- |
- if ((cm->current_video_frame - 1) % check_freq >= 1) { |
- if (cpi->use_large_partition_rate < 15) |
- sf->partition_search_type = FIXED_PARTITION; |
- } |
- } |
+ if (sf->partition_search_type == SOURCE_VAR_BASED_PARTITION) |
+ source_var_based_partition_search_method(cpi); |
} |
{ |
@@ -3269,7 +3259,6 @@ |
} |
} else { |
cm->reference_mode = SINGLE_REFERENCE; |
- cm->interp_filter = SWITCHABLE; |
encode_frame_internal(cpi); |
} |
} |
@@ -3364,8 +3353,11 @@ |
vp9_setup_pre_planes(xd, ref, cfg, mi_row, mi_col, |
&xd->block_refs[ref]->sf); |
} |
- vp9_build_inter_predictors_sb(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
+ if (!cpi->sf.reuse_inter_pred_sby) |
+ vp9_build_inter_predictors_sby(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
+ vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
+ |
if (!x->skip) { |
mbmi->skip = 1; |
vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); |