ref: c872d2be65216c6d05bba570028ff59f8e80fc7f
parent: 5bfd475104fd30adaec102543f84e3343bced726
author: Dmitry Kovalev <dkovalev@google.com>
date: Thu Dec 19 06:16:05 EST 2013
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
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -80,17 +80,23 @@
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,
--- a/vp9/common/vp9_reconinter.h
+++ b/vp9/common/vp9_reconinter.h
@@ -30,10 +30,11 @@
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) {
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1496,7 +1496,8 @@
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 @@
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 @@
&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 @@
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 @@
&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)
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -40,7 +40,8 @@
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,9 +60,8 @@
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,
&mv,
@@ -68,7 +68,7 @@
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 @@
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 @@
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,
--
⑨