diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c index 3668fcdae..e521a69d6 100644 --- a/vp9/common/vp9_reconinter.c +++ b/vp9/common/vp9_reconinter.c @@ -17,6 +17,78 @@ #include "vp9/common/vp9_reconinter.h" #include "vp9/common/vp9_reconintra.h" +static int scale_value_x_with_scaling(int val, + const struct scale_factors *scale) { + return val * scale->x_num / scale->x_den; +} + +static int scale_value_y_with_scaling(int val, + const struct scale_factors *scale) { + return val * scale->y_num / scale->y_den; +} + +static int unscaled_value(int val, const struct scale_factors *scale) { + (void) scale; + return val; +} + +static int_mv32 mv_q3_to_q4_with_scaling(const int_mv *src_mv, + const struct scale_factors *scale) { + // returns mv * scale + offset + int_mv32 result; + const int32_t mv_row_q4 = src_mv->as_mv.row << 1; + const int32_t mv_col_q4 = src_mv->as_mv.col << 1; + + /* TODO(jkoleszar): make fixed point, or as a second multiply? */ + result.as_mv.row = mv_row_q4 * scale->y_num / scale->y_den + + scale->y_offset_q4; + result.as_mv.col = mv_col_q4 * scale->x_num / scale->x_den + + scale->x_offset_q4; + return result; +} + +static int_mv32 mv_q3_to_q4_without_scaling(const int_mv *src_mv, + const struct scale_factors *scale) { + // returns mv * scale + offset + int_mv32 result; + + result.as_mv.row = src_mv->as_mv.row << 1; + result.as_mv.col = src_mv->as_mv.col << 1; + return result; +} + +static int32_t mv_component_q4_with_scaling(int mv_q4, int num, int den, + int offset_q4) { + // returns the scaled and offset value of the mv component. + + /* TODO(jkoleszar): make fixed point, or as a second multiply? */ + return mv_q4 * num / den + offset_q4; +} + +static int32_t mv_component_q4_without_scaling(int mv_q4, int num, int den, + int offset_q4) { + // returns the scaled and offset value of the mv component. + (void)num; + (void)den; + (void)offset_q4; + return mv_q4; +} + +static void set_offsets_with_scaling(struct scale_factors *scale, + int row, int col) { + const int x_q4 = 16 * col; + const int y_q4 = 16 * row; + + scale->x_offset_q4 = (x_q4 * scale->x_num / scale->x_den) & 0xf; + scale->y_offset_q4 = (y_q4 * scale->y_num / scale->y_den) & 0xf; +} + +static void set_offsets_without_scaling(struct scale_factors *scale, + int row, int col) { + scale->x_offset_q4 = 0; + scale->y_offset_q4 = 0; +} + void vp9_setup_scale_factors_for_frame(struct scale_factors *scale, int other_w, int other_h, int this_w, int this_h) { @@ -34,18 +106,14 @@ void vp9_setup_scale_factors_for_frame(struct scale_factors *scale, scale->scale_value_x = unscaled_value; scale->scale_value_y = unscaled_value; scale->set_scaled_offsets = set_offsets_without_scaling; - scale->scale_motion_vector_q3_to_q4 = - motion_vector_q3_to_q4_without_scaling; - scale->scale_motion_vector_component_q4 = - motion_vector_component_q4_without_scaling; + scale->scale_motion_vector_q3_to_q4 = mv_q3_to_q4_without_scaling; + scale->scale_motion_vector_component_q4 = mv_component_q4_without_scaling; } else { scale->scale_value_x = scale_value_x_with_scaling; scale->scale_value_y = scale_value_y_with_scaling; scale->set_scaled_offsets = set_offsets_with_scaling; - scale->scale_motion_vector_q3_to_q4 = - motion_vector_q3_to_q4_with_scaling; - scale->scale_motion_vector_component_q4 = - motion_vector_component_q4_with_scaling; + scale->scale_motion_vector_q3_to_q4 = mv_q3_to_q4_with_scaling; + scale->scale_motion_vector_component_q4 = mv_component_q4_with_scaling; } // TODO(agrange): Investigate the best choice of functions to use here diff --git a/vp9/common/vp9_reconinter.h b/vp9/common/vp9_reconinter.h index faf018c0d..885e1de31 100644 --- a/vp9/common/vp9_reconinter.h +++ b/vp9/common/vp9_reconinter.h @@ -52,21 +52,6 @@ void vp9_build_inter_predictor_q4(const uint8_t *src, int src_stride, int w, int h, int do_avg, const struct subpix_fn_table *subpix); -static int scale_value_x_with_scaling(int val, - const struct scale_factors *scale) { - return val * scale->x_num / scale->x_den; -} - -static int scale_value_y_with_scaling(int val, - const struct scale_factors *scale) { - return val * scale->y_num / scale->y_den; -} - -static int unscaled_value(int val, const struct scale_factors *scale) { - (void) scale; - return val; -} - static int scaled_buffer_offset(int x_offset, int y_offset, int stride, const struct scale_factors *scale) { const int x = scale ? scale->scale_value_x(x_offset, scale) : x_offset; @@ -137,66 +122,4 @@ static void set_scale_factors(MACROBLOCKD *xd, xd->scale_factor_uv[1] = xd->scale_factor[1]; } -static void set_offsets_with_scaling(struct scale_factors *scale, - int row, int col) { - const int x_q4 = 16 * col; - const int y_q4 = 16 * row; - - scale->x_offset_q4 = (x_q4 * scale->x_num / scale->x_den) & 0xf; - scale->y_offset_q4 = (y_q4 * scale->y_num / scale->y_den) & 0xf; -} - -static void set_offsets_without_scaling(struct scale_factors *scale, - int row, int col) { - scale->x_offset_q4 = 0; - scale->y_offset_q4 = 0; -} - -static int_mv32 motion_vector_q3_to_q4_with_scaling( - const int_mv *src_mv, - const struct scale_factors *scale) { - // returns mv * scale + offset - int_mv32 result; - const int32_t mv_row_q4 = src_mv->as_mv.row << 1; - const int32_t mv_col_q4 = src_mv->as_mv.col << 1; - - /* TODO(jkoleszar): make fixed point, or as a second multiply? */ - result.as_mv.row = mv_row_q4 * scale->y_num / scale->y_den - + scale->y_offset_q4; - result.as_mv.col = mv_col_q4 * scale->x_num / scale->x_den - + scale->x_offset_q4; - return result; -} - -static int_mv32 motion_vector_q3_to_q4_without_scaling( - const int_mv *src_mv, - const struct scale_factors *scale) { - // returns mv * scale + offset - int_mv32 result; - - result.as_mv.row = src_mv->as_mv.row << 1; - result.as_mv.col = src_mv->as_mv.col << 1; - return result; -} - -static int32_t motion_vector_component_q4_with_scaling(int mv_q4, - int num, - int den, - int offset_q4) { - // returns the scaled and offset value of the mv component. - - /* TODO(jkoleszar): make fixed point, or as a second multiply? */ - return mv_q4 * num / den + offset_q4; -} - -static int32_t motion_vector_component_q4_without_scaling(int mv_q4, - int num, - int den, - int offset_q4) { - // returns the scaled and offset value of the mv component. - (void)num; - (void)den; - (void)offset_q4; - return mv_q4; -} #endif // VP9_COMMON_VP9_RECONINTER_H_