Commit c872d2be authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Call set_scaled_offsets() just before scale_mv() call.

Before mv scaling it is required to calculate x_offset_q4/y_offset_q4
by calling set_scaled_offsets(). Now offset configuration can not be
missed because it happens just before scale_mv().

Change-Id: I7dd1a85b85811a6cc67c46c9b01e6ccbbb06ce3a
parent 5bfd4751
......@@ -80,17 +80,23 @@ static void inter_predictor(const uint8_t *src, int src_stride,
void vp9_build_inter_predictor(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const MV *src_mv,
const struct scale_factors *scale,
struct scale_factors *scale,
int w, int h, int ref,
const struct subpix_fn_table *subpix,
enum mv_precision precision) {
enum mv_precision precision,
int x, int y) {
const int is_q4 = precision == MV_PRECISION_Q4;
const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
is_q4 ? src_mv->col : src_mv->col * 2 };
const struct scale_factors_common *sfc = scale->sfc;
const MV32 mv = sfc->scale_mv(&mv_q4, scale);
const int subpel_x = mv.col & SUBPEL_MASK;
const int subpel_y = mv.row & SUBPEL_MASK;
int subpel_x, subpel_y;
MV32 mv;
sfc->set_scaled_offsets(scale, y, x);
mv = sfc->scale_mv(&mv_q4, scale);
subpel_x = mv.col & SUBPEL_MASK;
subpel_y = mv.row & SUBPEL_MASK;
src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS);
inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y,
......
......@@ -30,10 +30,11 @@ void vp9_dec_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
void vp9_build_inter_predictor(const uint8_t *src, int src_stride,
uint8_t *dst, int dst_stride,
const MV *mv_q3,
const struct scale_factors *scale,
struct scale_factors *scale,
int w, int h, int do_avg,
const struct subpix_fn_table *subpix,
enum mv_precision precision);
enum mv_precision precision,
int x, int y);
static int scaled_buffer_offset(int x_offset, int y_offset, int stride,
const struct scale_factors *scale) {
......
......@@ -1496,7 +1496,8 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
int *labelyrate,
int64_t *distortion, int64_t *sse,
ENTROPY_CONTEXT *ta,
ENTROPY_CONTEXT *tl) {
ENTROPY_CONTEXT *tl,
int mi_row, int mi_col) {
int k;
MACROBLOCKD *xd = &x->e_mbd;
struct macroblockd_plane *const pd = &xd->plane[0];
......@@ -1522,7 +1523,9 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
dst, pd->dst.stride,
&mi->bmi[i].as_mv[ref].as_mv,
&xd->scale_factor[ref],
width, height, ref, &xd->subpix, MV_PRECISION_Q3);
width, height, ref, &xd->subpix, MV_PRECISION_Q3,
mi_col * MI_SIZE + 4 * (i % 2),
mi_row * MI_SIZE + 4 * (i / 2));
}
vp9_subtract_block(height, width,
......@@ -1956,7 +1959,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
&bsi->rdstat[i][mode_idx].bdist,
&bsi->rdstat[i][mode_idx].bsse,
bsi->rdstat[i][mode_idx].ta,
bsi->rdstat[i][mode_idx].tl);
bsi->rdstat[i][mode_idx].tl,
mi_row, mi_col);
if (bsi->rdstat[i][mode_idx].brdcost < INT64_MAX) {
bsi->rdstat[i][mode_idx].brdcost += RDCOST(x->rdmult, x->rddiv,
bsi->rdstat[i][mode_idx].brate, 0);
......@@ -2487,8 +2491,6 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
setup_pre_planes(xd, ref, scaled_ref_frame[ref], mi_row, mi_col, NULL);
}
xd->scale_factor[ref].sfc->set_scaled_offsets(&xd->scale_factor[ref],
mi_row, mi_col);
frame_mv[refs[ref]].as_int = single_newmv[refs[ref]].as_int;
}
......@@ -2518,7 +2520,8 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
&frame_mv[refs[!id]].as_mv,
&xd->scale_factor[!id],
pw, ph, 0,
&xd->subpix, MV_PRECISION_Q3);
&xd->subpix, MV_PRECISION_Q3,
mi_col * MI_SIZE, mi_row * MI_SIZE);
// Compound motion search on first ref frame.
if (id)
......
......@@ -40,7 +40,8 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd,
int mv_row,
int mv_col,
uint8_t *pred,
struct scale_factors *scale) {
struct scale_factors *scale,
int x, int y) {
const int which_mv = 0;
MV mv = { mv_row, mv_col };
enum mv_precision mv_precision_uv;
......@@ -59,8 +60,7 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd,
scale,
16, 16,
which_mv,
&xd->subpix, MV_PRECISION_Q3);
&xd->subpix, MV_PRECISION_Q3, x, y);
vp9_build_inter_predictor(u_mb_ptr, uv_stride,
&pred[256], uv_block_size,
......@@ -68,7 +68,7 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd,
scale,
uv_block_size, uv_block_size,
which_mv,
&xd->subpix, mv_precision_uv);
&xd->subpix, mv_precision_uv, x, y);
vp9_build_inter_predictor(v_mb_ptr, uv_stride,
&pred[512], uv_block_size,
......@@ -76,7 +76,7 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd,
scale,
uv_block_size, uv_block_size,
which_mv,
&xd->subpix, mv_precision_uv);
&xd->subpix, mv_precision_uv, x, y);
}
void vp9_temporal_filter_apply_c(uint8_t *frame1,
......@@ -296,7 +296,8 @@ static void temporal_filter_iterate_c(VP9_COMP *cpi,
mb_uv_height,
mbd->mi_8x8[0]->bmi[0].as_mv[0].as_mv.row,
mbd->mi_8x8[0]->bmi[0].as_mv[0].as_mv.col,
predictor, scale);
predictor, scale,
mb_col * 16, mb_row * 16);
// Apply the filter (YUV)
vp9_temporal_filter_apply(f->y_buffer + mb_y_offset, f->y_stride,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment