Refactor build_inter_predictors
Unify inter prediction function calls for sub8x8 blocks.
Change-Id: If7eb137a7199e45517334c64931b41c7e885d7e3
diff --git a/av1/encoder/reconinter_enc.c b/av1/encoder/reconinter_enc.c
index 853b548..c4db6a6 100644
--- a/av1/encoder/reconinter_enc.c
+++ b/av1/encoder/reconinter_enc.c
@@ -75,8 +75,7 @@
static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
int plane, const MB_MODE_INFO *mi,
- int build_for_obmc, int bw, int bh,
- int mi_x, int mi_y) {
+ int bw, int bh, int mi_x, int mi_y) {
struct macroblockd_plane *const pd = &xd->plane[plane];
int is_compound = has_second_ref(mi);
int ref;
@@ -100,14 +99,11 @@
// worth of pixels. Thus (mi_x, mi_y) may not be the correct coordinates for
// the top-left corner of the prediction source - the correct top-left corner
// is at (pre_x, pre_y).
- const int row_start =
- (block_size_high[bsize] == 4) && ss_y && !build_for_obmc ? -1 : 0;
- const int col_start =
- (block_size_wide[bsize] == 4) && ss_x && !build_for_obmc ? -1 : 0;
+ const int row_start = (block_size_high[bsize] == 4) && ss_y ? -1 : 0;
+ const int col_start = (block_size_wide[bsize] == 4) && ss_x ? -1 : 0;
const int pre_x = (mi_x + MI_SIZE * col_start) >> ss_x;
const int pre_y = (mi_y + MI_SIZE * row_start) >> ss_y;
- sub8x8_inter = sub8x8_inter && !build_for_obmc;
if (sub8x8_inter) {
for (int row = row_start; row <= 0 && sub8x8_inter; ++row) {
for (int col = col_start; col <= 0; ++col) {
@@ -134,16 +130,10 @@
int col = col_start;
for (int x = 0; x < b8_w; x += b4_w) {
MB_MODE_INFO *this_mbmi = xd->mi[row * xd->mi_stride + col];
- is_compound = has_second_ref(this_mbmi);
int tmp_dst_stride = 8;
assert(bw < 8 || bh < 8);
- InterPredParams inter_pred_params;
- inter_pred_params.conv_params = get_conv_params_no_round(
- 0, plane, xd->tmp_conv_dst, tmp_dst_stride, is_compound, xd->bd);
- inter_pred_params.conv_params.use_dist_wtd_comp_avg = 0;
struct buf_2d *const dst_buf = &pd->dst;
uint8_t *dst = dst_buf->buf + dst_buf->stride * y + x;
-
ref = 0;
const RefCntBuffer *ref_buf =
get_ref_frame_buf(cm, this_mbmi->ref_frame[ref]);
@@ -152,10 +142,6 @@
pd->pre[ref].buf0 =
(plane == 1) ? ref_buf->buf.u_buffer : ref_buf->buf.v_buffer;
- pd->pre[ref].buf =
- pd->pre[ref].buf0 + scaled_buffer_offset(pre_x, pre_y,
- ref_buf->buf.uv_stride,
- ref_scale_factors);
pd->pre[ref].width = ref_buf->buf.uv_crop_width;
pd->pre[ref].height = ref_buf->buf.uv_crop_height;
pd->pre[ref].stride = ref_buf->buf.uv_stride;
@@ -165,22 +151,19 @@
struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
const MV mv = this_mbmi->mv[ref].as_mv;
+ InterPredParams inter_pred_params;
+ av1_init_inter_params(&inter_pred_params, b4_w, b4_h, pre_y + y,
+ pre_x + x, pd->subsampling_x, pd->subsampling_y,
+ xd->bd, is_cur_buf_hbd(xd), mi->use_intrabc, sf,
+ pre_buf, this_mbmi->interp_filters);
- uint8_t *pre;
- SubpelParams subpel_params;
+ inter_pred_params.conv_params = get_conv_params_no_round(
+ 0, plane, xd->tmp_conv_dst, tmp_dst_stride, 0, xd->bd);
+ inter_pred_params.conv_params.use_dist_wtd_comp_avg = 0;
- calc_subpel_params(xd, sf, mv, plane, pre_x, pre_y, x, y, pre_buf, &pre,
- &subpel_params, bw, bh);
- inter_pred_params.conv_params.do_average = ref;
-
- av1_init_inter_params(
- &inter_pred_params, b4_w, b4_h, (mi_y >> pd->subsampling_y) + y,
- (mi_x >> pd->subsampling_x) + x, pd->subsampling_x,
- pd->subsampling_y, xd->bd, is_cur_buf_hbd(xd), mi->use_intrabc, sf,
- pre_buf, this_mbmi->interp_filters);
- av1_make_inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride,
- &inter_pred_params, &subpel_params);
-
+ av1_build_inter_predictor(pre_buf->buf, pre_buf->stride, dst,
+ dst_buf->stride, &mv, mi_x, mi_y,
+ &inter_pred_params);
++col;
}
++row;
@@ -222,9 +205,8 @@
pd->subsampling_y, xd->bd, is_cur_buf_hbd(xd),
mi->use_intrabc, sf, pre_buf, mi->interp_filters);
- if (!build_for_obmc)
- av1_init_warp_params(&inter_pred_params, &pd->pre[ref], &warp_types,
- ref, xd, mi);
+ av1_init_warp_params(&inter_pred_params, &pd->pre[ref], &warp_types, ref,
+ xd, mi);
if (ref && is_masked_compound_type(mi->interinter_comp.type)) {
// masked compound type has its own average mechanism
@@ -252,7 +234,7 @@
const int mi_x = mi_col * MI_SIZE;
const int mi_y = mi_row * MI_SIZE;
- build_inter_predictors(cm, xd, plane_idx, xd->mi[0], 0, pd->width, pd->height,
+ build_inter_predictors(cm, xd, plane_idx, xd->mi[0], pd->width, pd->height,
mi_x, mi_y);
if (is_interintra_pred(xd->mi[0])) {