Merge "Refactor internal stats code" into nextgenv2
diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c
index ed56006..898b18f 100644
--- a/vp10/encoder/encodeframe.c
+++ b/vp10/encoder/encodeframe.c
@@ -3280,7 +3280,7 @@
#if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col;
xd->left_txfm_context =
- xd->left_txfm_context_buffer + (mi_row & 0x07);
+ xd->left_txfm_context_buffer + (mi_row & MI_MASK);
restore_context(x, mi_row, mi_col, a, l, sa, sl, ta, tl, bsize);
#else
restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -5187,16 +5187,36 @@
dist_uv = 0;
sse_uv = 0;
for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
+#if CONFIG_VAR_TX
+ ENTROPY_CONTEXT ctxa[16], ctxl[16];
+ const struct macroblockd_plane *const pd = &xd->plane[plane];
+ int coeff_ctx = 1;
+
+ this_rate = 0;
+ this_dist = 0;
+ pnsse = 0;
+ pnskip = 1;
+
+ tx_size = max_txsize_lookup[bsize];
+ tx_size = get_uv_tx_size_impl(tx_size, bsize,
+ cm->subsampling_x, cm->subsampling_y);
+ vp10_get_entropy_contexts(bsize, tx_size, pd, ctxa, ctxl);
+ coeff_ctx = combine_entropy_contexts(ctxa[0], ctxl[0]);
+
+ vp10_subtract_plane(x, bsize, plane);
+ vp10_tx_block_rd_b(cpi, x, tx_size,
+ 0, 0, plane, 0,
+ get_plane_block_size(bsize, pd), coeff_ctx,
+ &this_rate, &this_dist, &pnsse, &pnskip);
+#else
tx_size = max_txsize_lookup[bsize];
tx_size = get_uv_tx_size_impl(tx_size, bsize,
cm->subsampling_x, cm->subsampling_y);
vp10_subtract_plane(x, bsize, plane);
- vp10_txfm_rd_in_plane_supertx(x,
-#if CONFIG_VAR_TX
- cpi,
-#endif
- &this_rate, &this_dist, &pnskip, &pnsse,
+ vp10_txfm_rd_in_plane_supertx(x, &this_rate, &this_dist, &pnskip, &pnsse,
INT64_MAX, plane, bsize, tx_size, 0);
+#endif // CONFIG_VAR_TX
+
rate_uv += this_rate;
dist_uv += this_dist;
sse_uv += pnsse;
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 9e29ce6..78aa590 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -652,13 +652,8 @@
return;
if (!is_inter_block(mbmi)) {
-#if CONFIG_VAR_TX
struct encode_b_args arg = {x, NULL, &mbmi->skip};
-#if CONFIG_VP9_HIGHBITDEPTH
- vp10_encode_block_intra(plane, block, blk_row, blk_col,
- plane_bsize, tx_size, &arg);
- dist_block(x, plane, block, tx_size, &dist, &sse);
-#else
+#if CONFIG_VAR_TX
uint8_t *dst, *src;
int src_stride = x->plane[plane].src.stride;
int dst_stride = xd->plane[plane].dst.stride;
@@ -680,9 +675,7 @@
args->cpi->fn_ptr[txsize_to_bsize[tx_size]].vf(src, src_stride,
dst, dst_stride, &tmp_sse);
dist = (int64_t)tmp_sse * 16;
-#endif // CONFIG_VP9_HIGHBITDEPTH
#else
- struct encode_b_args arg = {x, NULL, &mbmi->skip};
vp10_encode_block_intra(plane, block, blk_row, blk_col,
plane_bsize, tx_size, &arg);
dist_block(x, plane, block, tx_size, &dist, &sse);
@@ -805,9 +798,6 @@
#if CONFIG_SUPERTX
void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x,
-#if CONFIG_VAR_TX
- const VP10_COMP *cpi,
-#endif
int *rate, int64_t *distortion,
int *skippable, int64_t *sse,
int64_t ref_best_rd, int plane,
@@ -820,9 +810,6 @@
vp10_zero(args);
args.x = x;
-#if CONFIG_VAR_TX
- args.cpi = cpi;
-#endif
args.best_rd = ref_best_rd;
args.use_fast_coef_costing = use_fast_coef_casting;
@@ -1487,18 +1474,20 @@
#if CONFIG_VAR_TX
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
*(templ + idy));
-#endif
+#endif // CONFIG_VAR_TX
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, 1);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
- ratey += cost_coeffs(x, 0, block,
#if CONFIG_VAR_TX
- coeff_ctx,
+ ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
+ so->neighbors, cpi->sf.use_fast_coef_costing);
+ *(tempa + idx) = !(p->eobs[block] == 0);
+ *(templ + idy) = !(p->eobs[block] == 0);
#else
- tempa + idx, templ + idy,
-#endif
+ ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy,
TX_4X4,
so->scan, so->neighbors,
cpi->sf.use_fast_coef_costing);
+#endif // CONFIG_VAR_TX
if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
goto next_highbd;
vp10_highbd_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block),
@@ -1511,18 +1500,19 @@
#if CONFIG_VAR_TX
const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
*(templ + idy));
-#endif
+#endif // CONFIG_VAR_TX
vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, 0);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
- ratey += cost_coeffs(x, 0, block,
#if CONFIG_VAR_TX
- coeff_ctx,
+ ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan,
+ so->neighbors, cpi->sf.use_fast_coef_costing);
+ *(tempa + idx) = !(p->eobs[block] == 0);
+ *(templ + idy) = !(p->eobs[block] == 0);
#else
- tempa + idx, templ + idy,
-#endif
- TX_4X4,
- so->scan, so->neighbors,
+ ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy,
+ TX_4X4, so->scan, so->neighbors,
cpi->sf.use_fast_coef_costing);
+#endif // CONFIG_VAR_TX
distortion += vp10_highbd_block_error(
coeff, BLOCK_OFFSET(pd->dqcoeff, block),
16, &unused, xd->bd) >> 2;
@@ -1555,6 +1545,7 @@
next_highbd:
{}
}
+
if (best_rd >= rd_thresh)
return best_rd;
@@ -1604,8 +1595,8 @@
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
const scan_order *so = get_scan(TX_4X4, tx_type, 0);
#if CONFIG_VAR_TX
- int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
- *(templ + idy));
+ const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
+ *(templ + idy));
#endif
vp10_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, 1);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
@@ -1629,8 +1620,8 @@
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
const scan_order *so = get_scan(TX_4X4, tx_type, 0);
#if CONFIG_VAR_TX
- int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
- *(templ + idy));
+ const int coeff_ctx = combine_entropy_contexts(*(tempa + idx),
+ *(templ + idy));
#endif
vp10_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, 0);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
@@ -2321,12 +2312,6 @@
MACROBLOCKD *xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
-#if CONFIG_VP9_HIGHBITDEPTH
- const int ss_txfrm_size = tx_size << 1;
- int64_t this_sse;
- int shift = tx_size == TX_32X32 ? 0 : 2;
- tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
-#endif
unsigned int tmp_sse = 0;
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
@@ -2391,35 +2376,59 @@
cpi->fn_ptr[txm_bsize].vf(src, src_stride, rec_buffer, 32, &tmp_sse);
}
-#if CONFIG_VP9_HIGHBITDEPTH
- *dist += vp10_highbd_block_error(coeff, dqcoeff, 16 << ss_txfrm_size,
- &this_sse, xd->bd) >> shift;
- *bsse += this_sse >> shift;
-#else
*bsse += (int64_t)tmp_sse * 16;
if (p->eobs[block] > 0) {
- switch (tx_size) {
- case TX_32X32:
- vp10_inv_txfm_add_32x32(dqcoeff, rec_buffer, 32, p->eobs[block],
+ const int lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
+#if CONFIG_VP9_HIGHBITDEPTH
+ if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+ const int bd = xd->bd;
+ switch (tx_size) {
+ case TX_32X32:
+ vp10_highbd_inv_txfm_add_32x32(dqcoeff, rec_buffer, 32,
+ p->eobs[block], bd, tx_type);
+ break;
+ case TX_16X16:
+ vp10_highbd_inv_txfm_add_16x16(dqcoeff, rec_buffer, 32,
+ p->eobs[block], bd, tx_type);
+ break;
+ case TX_8X8:
+ vp10_highbd_inv_txfm_add_8x8(dqcoeff, rec_buffer, 32,
+ p->eobs[block], bd, tx_type);
+ break;
+ case TX_4X4:
+ vp10_highbd_inv_txfm_add_4x4(dqcoeff, rec_buffer, 32,
+ p->eobs[block], bd, tx_type, lossless);
+ break;
+ default:
+ assert(0 && "Invalid transform size");
+ break;
+ }
+ } else {
+#else
+ {
+#endif // CONFIG_VP9_HIGHBITDEPTH
+ switch (tx_size) {
+ case TX_32X32:
+ vp10_inv_txfm_add_32x32(dqcoeff, rec_buffer, 32, p->eobs[block],
+ tx_type);
+ break;
+ case TX_16X16:
+ vp10_inv_txfm_add_16x16(dqcoeff, rec_buffer, 32, p->eobs[block],
+ tx_type);
+ break;
+ case TX_8X8:
+ vp10_inv_txfm_add_8x8(dqcoeff, rec_buffer, 32, p->eobs[block],
tx_type);
- break;
- case TX_16X16:
- vp10_inv_txfm_add_16x16(dqcoeff, rec_buffer, 32, p->eobs[block],
- tx_type);
- break;
- case TX_8X8:
- vp10_inv_txfm_add_8x8(dqcoeff, rec_buffer, 32, p->eobs[block],
- tx_type);
- break;
- case TX_4X4:
- vp10_inv_txfm_add_4x4(dqcoeff, rec_buffer, 32, p->eobs[block],
- tx_type,
- xd->lossless[xd->mi[0]->mbmi.segment_id]);
- break;
- default:
- assert(0 && "Invalid transform size");
- break;
+ break;
+ case TX_4X4:
+ vp10_inv_txfm_add_4x4(dqcoeff, rec_buffer, 32, p->eobs[block],
+ tx_type, lossless);
+ break;
+ default:
+ assert(0 && "Invalid transform size");
+ break;
+ }
}
if ((bh >> 2) + blk_col > max_blocks_wide ||
@@ -2444,7 +2453,6 @@
}
}
*dist += (int64_t)tmp_sse * 16;
-#endif // CONFIG_VP9_HIGHBITDEPTH
*rate += cost_coeffs(x, plane, block, coeff_ctx, tx_size,
scan_order->scan, scan_order->neighbors, 0);
@@ -2752,9 +2760,9 @@
}
}
#else // CONFIG_EXT_TX
- if (max_tx_size >= TX_32X32 && tx_type != DCT_DCT) {
+ if (max_tx_size >= TX_32X32 && tx_type != DCT_DCT)
continue;
- }
+
mbmi->tx_type = tx_type;
inter_block_yrd(cpi, x, &this_rate, &this_dist, &this_skip, &this_sse,
@@ -2783,9 +2791,7 @@
if (is_inter && !xd->lossless[xd->mi[0]->mbmi.segment_id] && !this_skip)
rd = VPXMIN(rd, RDCOST(x->rdmult, x->rddiv, s1, this_sse));
- if (rd <
- (is_inter && best_tx_type == DCT_DCT ? ext_tx_th : 1) *
- best_rd) {
+ if (rd < (is_inter && best_tx_type == DCT_DCT ? ext_tx_th : 1) * best_rd) {
best_rd = rd;
*distortion = this_dist;
*rate = this_rate;
@@ -4927,87 +4933,27 @@
xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN);
}
-static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
- BLOCK_SIZE bsize,
- int *rate2, int64_t *distortion,
- int *skippable,
- int *rate_y, int *rate_uv,
- int *disable_skip,
- int_mv (*mode_mv)[MAX_REF_FRAMES],
- int mi_row, int mi_col,
-#if CONFIG_EXT_INTER
- int_mv single_newmvs[2][MAX_REF_FRAMES],
-#else
- int_mv single_newmv[MAX_REF_FRAMES],
-#endif // CONFIG_EXT_INTER
- INTERP_FILTER (*single_filter)[MAX_REF_FRAMES],
- int (*single_skippable)[MAX_REF_FRAMES],
- int64_t *psse,
- const int64_t ref_best_rd,
- int64_t *mask_filter,
- int64_t filter_cache[]) {
- VP10_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
- MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
- const int is_comp_pred = has_second_ref(mbmi);
- const int this_mode = mbmi->mode;
- int_mv *frame_mv = mode_mv[this_mode];
- int i;
- int refs[2] = { mbmi->ref_frame[0],
- (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) };
- int_mv cur_mv[2];
-#if CONFIG_EXT_INTER
- int mv_idx = (this_mode == NEWFROMNEARMV) ? 1 : 0;
- int_mv single_newmv[MAX_REF_FRAMES];
-#if CONFIG_REF_MV
- uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
-#endif
-#endif // CONFIG_EXT_INTER
-#if CONFIG_VP9_HIGHBITDEPTH
- DECLARE_ALIGNED(16, uint16_t, tmp_buf16[MAX_MB_PLANE * 64 * 64]);
- uint8_t *tmp_buf;
-#else
- DECLARE_ALIGNED(16, uint8_t, tmp_buf[MAX_MB_PLANE * 64 * 64]);
-#endif // CONFIG_VP9_HIGHBITDEPTH
- int pred_exists = 0;
- int intpel_mv;
- int64_t rd, tmp_rd, best_rd = INT64_MAX;
- int best_needs_copy = 0;
- uint8_t *orig_dst[MAX_MB_PLANE];
- int orig_dst_stride[MAX_MB_PLANE];
- int rs = 0;
+static INTERP_FILTER predict_interp_filter(const VP10_COMP *cpi,
+ const MACROBLOCK *x,
+ const BLOCK_SIZE bsize,
+ const int mi_row,
+ const int mi_col,
+ INTERP_FILTER
+ (*single_filter)[MAX_REF_FRAMES]
+ ) {
INTERP_FILTER best_filter = SWITCHABLE;
- uint8_t skip_txfm[MAX_MB_PLANE << 2] = {0};
- int64_t bsse[MAX_MB_PLANE << 2] = {0};
+ const VP10_COMMON *cm = &cpi->common;
+ const MACROBLOCKD *xd = &x->e_mbd;
int bsl = mi_width_log2_lookup[bsize];
int pred_filter_search = cpi->sf.cb_pred_filter_search ?
(((mi_row + mi_col) >> bsl) +
get_chessboard_index(cm->current_video_frame)) & 0x1 : 0;
-
- int skip_txfm_sb = 0;
- int64_t skip_sse_sb = INT64_MAX;
- int64_t distortion_y = 0, distortion_uv = 0;
- int16_t mode_ctx = mbmi_ext->mode_context[refs[0]];
-
-#if CONFIG_REF_MV
-#if CONFIG_EXT_INTER
- if (is_comp_pred)
- mode_ctx = mbmi_ext->compound_mode_context[refs[0]];
- else
-#endif // CONFIG_EXT_INTER
- mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context,
- mbmi->ref_frame, bsize, -1);
-#endif
-
-#if CONFIG_VP9_HIGHBITDEPTH
- if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- tmp_buf = CONVERT_TO_BYTEPTR(tmp_buf16);
- } else {
- tmp_buf = (uint8_t *)tmp_buf16;
- }
-#endif // CONFIG_VP9_HIGHBITDEPTH
+ MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ const int is_comp_pred = has_second_ref(mbmi);
+ const int this_mode = mbmi->mode;
+ int refs[2] = { mbmi->ref_frame[0],
+ (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) };
if (pred_filter_search) {
INTERP_FILTER af = SWITCHABLE, lf = SWITCHABLE;
@@ -5024,12 +4970,7 @@
#endif // CONFIG_EXT_INTER
best_filter = af;
}
-
if (is_comp_pred) {
- if (frame_mv[refs[0]].as_int == INVALID_MV ||
- frame_mv[refs[1]].as_int == INVALID_MV)
- return INT64_MAX;
-
if (cpi->sf.adaptive_mode_search) {
#if CONFIG_EXT_INTER
switch (this_mode) {
@@ -5091,6 +5032,101 @@
#endif // CONFIG_EXT_INTER
}
}
+ if (cm->interp_filter != BILINEAR) {
+ if (x->source_variance < cpi->sf.disable_filter_search_var_thresh) {
+ best_filter = EIGHTTAP;
+ }
+#if CONFIG_EXT_INTERP
+ else if (!vp10_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE) {
+ best_filter = EIGHTTAP;
+ }
+#endif
+ }
+ return best_filter;
+}
+
+static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
+ BLOCK_SIZE bsize,
+ int *rate2, int64_t *distortion,
+ int *skippable,
+ int *rate_y, int *rate_uv,
+ int *disable_skip,
+ int_mv (*mode_mv)[MAX_REF_FRAMES],
+ int mi_row, int mi_col,
+#if CONFIG_EXT_INTER
+ int_mv single_newmvs[2][MAX_REF_FRAMES],
+#else
+ int_mv single_newmv[MAX_REF_FRAMES],
+#endif // CONFIG_EXT_INTER
+ INTERP_FILTER (*single_filter)[MAX_REF_FRAMES],
+ int (*single_skippable)[MAX_REF_FRAMES],
+ int64_t *psse,
+ const int64_t ref_best_rd,
+ int64_t *mask_filter,
+ int64_t filter_cache[]) {
+ VP10_COMMON *cm = &cpi->common;
+ MACROBLOCKD *xd = &x->e_mbd;
+ MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
+ const int is_comp_pred = has_second_ref(mbmi);
+ const int this_mode = mbmi->mode;
+ int_mv *frame_mv = mode_mv[this_mode];
+ int i;
+ int refs[2] = { mbmi->ref_frame[0],
+ (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) };
+ int_mv cur_mv[2];
+#if CONFIG_EXT_INTER
+ int mv_idx = (this_mode == NEWFROMNEARMV) ? 1 : 0;
+ int_mv single_newmv[MAX_REF_FRAMES];
+#if CONFIG_REF_MV
+ uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
+#endif
+#endif // CONFIG_EXT_INTER
+#if CONFIG_VP9_HIGHBITDEPTH
+ DECLARE_ALIGNED(16, uint16_t, tmp_buf16[MAX_MB_PLANE * 64 * 64]);
+ uint8_t *tmp_buf;
+#else
+ DECLARE_ALIGNED(16, uint8_t, tmp_buf[MAX_MB_PLANE * 64 * 64]);
+#endif // CONFIG_VP9_HIGHBITDEPTH
+ int pred_exists = 0;
+ int intpel_mv;
+ int64_t rd, tmp_rd, best_rd = INT64_MAX;
+ int best_needs_copy = 0;
+ uint8_t *orig_dst[MAX_MB_PLANE];
+ int orig_dst_stride[MAX_MB_PLANE];
+ int rs = 0;
+ INTERP_FILTER best_filter = SWITCHABLE;
+ uint8_t skip_txfm[MAX_MB_PLANE << 2] = {0};
+ int64_t bsse[MAX_MB_PLANE << 2] = {0};
+
+ int skip_txfm_sb = 0;
+ int64_t skip_sse_sb = INT64_MAX;
+ int64_t distortion_y = 0, distortion_uv = 0;
+ int16_t mode_ctx = mbmi_ext->mode_context[refs[0]];
+
+#if CONFIG_REF_MV
+#if CONFIG_EXT_INTER
+ if (is_comp_pred)
+ mode_ctx = mbmi_ext->compound_mode_context[refs[0]];
+ else
+#endif // CONFIG_EXT_INTER
+ mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context,
+ mbmi->ref_frame, bsize, -1);
+#endif
+
+#if CONFIG_VP9_HIGHBITDEPTH
+ if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+ tmp_buf = CONVERT_TO_BYTEPTR(tmp_buf16);
+ } else {
+ tmp_buf = (uint8_t *)tmp_buf16;
+ }
+#endif // CONFIG_VP9_HIGHBITDEPTH
+
+ if (is_comp_pred) {
+ if (frame_mv[refs[0]].as_int == INVALID_MV ||
+ frame_mv[refs[1]].as_int == INVALID_MV)
+ return INT64_MAX;
+ }
#if CONFIG_EXT_INTER
if (have_newmv_in_inter_mode(this_mode)) {
@@ -5335,106 +5371,100 @@
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i)
filter_cache[i] = INT64_MAX;
- if (cm->interp_filter != BILINEAR) {
- if (x->source_variance < cpi->sf.disable_filter_search_var_thresh) {
- best_filter = EIGHTTAP;
-#if CONFIG_EXT_INTERP
- } else if (!vp10_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE) {
- best_filter = EIGHTTAP;
-#endif
- } else if (best_filter == SWITCHABLE) {
- int newbest;
- int tmp_rate_sum = 0;
- int64_t tmp_dist_sum = 0;
+ best_filter = predict_interp_filter(cpi, x, bsize, mi_row, mi_col,
+ single_filter);
+ if (cm->interp_filter != BILINEAR && best_filter == SWITCHABLE) {
+ int newbest;
+ int tmp_rate_sum = 0;
+ int64_t tmp_dist_sum = 0;
- for (i = 0; i < SWITCHABLE_FILTERS; ++i) {
- int j;
- int64_t rs_rd;
- int tmp_skip_sb = 0;
- int64_t tmp_skip_sse = INT64_MAX;
+ for (i = 0; i < SWITCHABLE_FILTERS; ++i) {
+ int j;
+ int64_t rs_rd;
+ int tmp_skip_sb = 0;
+ int64_t tmp_skip_sse = INT64_MAX;
- mbmi->interp_filter = i;
- rs = vp10_get_switchable_rate(cpi, xd);
- rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0);
+ mbmi->interp_filter = i;
+ rs = vp10_get_switchable_rate(cpi, xd);
+ rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0);
- if (i > 0 && intpel_mv && IsInterpolatingFilter(i)) {
- rd = RDCOST(x->rdmult, x->rddiv, tmp_rate_sum, tmp_dist_sum);
- filter_cache[i] = rd;
- filter_cache[SWITCHABLE_FILTERS] =
- VPXMIN(filter_cache[SWITCHABLE_FILTERS], rd + rs_rd);
- if (cm->interp_filter == SWITCHABLE)
- rd += rs_rd;
- *mask_filter = VPXMAX(*mask_filter, rd);
- } else {
- int rate_sum = 0;
- int64_t dist_sum = 0;
- if (i > 0 && cpi->sf.adaptive_interp_filter_search &&
- (cpi->sf.interp_filter_search_mask & (1 << i))) {
- rate_sum = INT_MAX;
- dist_sum = INT64_MAX;
- continue;
- }
-
- if ((cm->interp_filter == SWITCHABLE &&
- (!i || best_needs_copy)) ||
- (cm->interp_filter != SWITCHABLE &&
- (cm->interp_filter == mbmi->interp_filter ||
- (i == 0 && intpel_mv && IsInterpolatingFilter(i))))) {
- restore_dst_buf(xd, orig_dst, orig_dst_stride);
- } else {
- for (j = 0; j < MAX_MB_PLANE; j++) {
- xd->plane[j].dst.buf = tmp_buf + j * 64 * 64;
- xd->plane[j].dst.stride = 64;
- }
- }
- vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
- model_rd_for_sb(cpi, bsize, x, xd, &rate_sum, &dist_sum,
- &tmp_skip_sb, &tmp_skip_sse);
-
- rd = RDCOST(x->rdmult, x->rddiv, rate_sum, dist_sum);
- filter_cache[i] = rd;
- filter_cache[SWITCHABLE_FILTERS] =
- VPXMIN(filter_cache[SWITCHABLE_FILTERS], rd + rs_rd);
- if (cm->interp_filter == SWITCHABLE)
- rd += rs_rd;
- *mask_filter = VPXMAX(*mask_filter, rd);
-
- if (i == 0 && intpel_mv && IsInterpolatingFilter(i)) {
- tmp_rate_sum = rate_sum;
- tmp_dist_sum = dist_sum;
- }
+ if (i > 0 && intpel_mv && IsInterpolatingFilter(i)) {
+ rd = RDCOST(x->rdmult, x->rddiv, tmp_rate_sum, tmp_dist_sum);
+ filter_cache[i] = rd;
+ filter_cache[SWITCHABLE_FILTERS] =
+ VPXMIN(filter_cache[SWITCHABLE_FILTERS], rd + rs_rd);
+ if (cm->interp_filter == SWITCHABLE)
+ rd += rs_rd;
+ *mask_filter = VPXMAX(*mask_filter, rd);
+ } else {
+ int rate_sum = 0;
+ int64_t dist_sum = 0;
+ if (i > 0 && cpi->sf.adaptive_interp_filter_search &&
+ (cpi->sf.interp_filter_search_mask & (1 << i))) {
+ rate_sum = INT_MAX;
+ dist_sum = INT64_MAX;
+ continue;
}
- if (i == 0 && cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) {
- if (rd / 2 > ref_best_rd) {
- restore_dst_buf(xd, orig_dst, orig_dst_stride);
- return INT64_MAX;
- }
- }
- newbest = i == 0 || rd < best_rd;
-
- if (newbest) {
- best_rd = rd;
- best_filter = mbmi->interp_filter;
- if (cm->interp_filter == SWITCHABLE && i &&
- !(intpel_mv && IsInterpolatingFilter(i)))
- best_needs_copy = !best_needs_copy;
- }
-
- if ((cm->interp_filter == SWITCHABLE && newbest) ||
+ if ((cm->interp_filter == SWITCHABLE &&
+ (!i || best_needs_copy)) ||
(cm->interp_filter != SWITCHABLE &&
- cm->interp_filter == mbmi->interp_filter)) {
- pred_exists = 1;
- tmp_rd = best_rd;
+ (cm->interp_filter == mbmi->interp_filter ||
+ (i == 0 && intpel_mv && IsInterpolatingFilter(i))))) {
+ restore_dst_buf(xd, orig_dst, orig_dst_stride);
+ } else {
+ for (j = 0; j < MAX_MB_PLANE; j++) {
+ xd->plane[j].dst.buf = tmp_buf + j * 64 * 64;
+ xd->plane[j].dst.stride = 64;
+ }
+ }
+ vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
+ model_rd_for_sb(cpi, bsize, x, xd, &rate_sum, &dist_sum,
+ &tmp_skip_sb, &tmp_skip_sse);
- skip_txfm_sb = tmp_skip_sb;
- skip_sse_sb = tmp_skip_sse;
- memcpy(skip_txfm, x->skip_txfm, sizeof(skip_txfm));
- memcpy(bsse, x->bsse, sizeof(bsse));
+ rd = RDCOST(x->rdmult, x->rddiv, rate_sum, dist_sum);
+ filter_cache[i] = rd;
+ filter_cache[SWITCHABLE_FILTERS] =
+ VPXMIN(filter_cache[SWITCHABLE_FILTERS], rd + rs_rd);
+ if (cm->interp_filter == SWITCHABLE)
+ rd += rs_rd;
+ *mask_filter = VPXMAX(*mask_filter, rd);
+
+ if (i == 0 && intpel_mv && IsInterpolatingFilter(i)) {
+ tmp_rate_sum = rate_sum;
+ tmp_dist_sum = dist_sum;
}
}
- restore_dst_buf(xd, orig_dst, orig_dst_stride);
+
+ if (i == 0 && cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) {
+ if (rd / 2 > ref_best_rd) {
+ restore_dst_buf(xd, orig_dst, orig_dst_stride);
+ return INT64_MAX;
+ }
+ }
+ newbest = i == 0 || rd < best_rd;
+
+ if (newbest) {
+ best_rd = rd;
+ best_filter = mbmi->interp_filter;
+ if (cm->interp_filter == SWITCHABLE && i &&
+ !(intpel_mv && IsInterpolatingFilter(i)))
+ best_needs_copy = !best_needs_copy;
+ }
+
+ if ((cm->interp_filter == SWITCHABLE && newbest) ||
+ (cm->interp_filter != SWITCHABLE &&
+ cm->interp_filter == mbmi->interp_filter)) {
+ pred_exists = 1;
+ tmp_rd = best_rd;
+
+ skip_txfm_sb = tmp_skip_sb;
+ skip_sse_sb = tmp_skip_sse;
+ memcpy(skip_txfm, x->skip_txfm, sizeof(skip_txfm));
+ memcpy(bsse, x->bsse, sizeof(bsse));
+ }
}
+ restore_dst_buf(xd, orig_dst, orig_dst_stride);
}
// Set the appropriate filter
diff --git a/vp10/encoder/rdopt.h b/vp10/encoder/rdopt.h
index a6394fa..7c7e9eb 100644
--- a/vp10/encoder/rdopt.h
+++ b/vp10/encoder/rdopt.h
@@ -82,9 +82,6 @@
#endif
void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x,
-#if CONFIG_VAR_TX
- const VP10_COMP *cpi,
-#endif // CONFIG_VAR_TX
int *rate, int64_t *distortion,
int *skippable, int64_t *sse,
int64_t ref_best_rd, int plane,