Commit 81b2e502 authored by Angie Chiang's avatar Angie Chiang
Browse files

Pass conv_params into warp-related functions

This aims at integrate convolve_round/compound_round
with global_motion

Change-Id: I1d91ff2de6b075f807eaaaa0a7a66edb2036e57b
parent 31d19279
......@@ -605,11 +605,11 @@ if (aom_config("CONFIG_PVQ") eq "yes") {
if ((aom_config("CONFIG_WARPED_MOTION") eq "yes") ||
(aom_config("CONFIG_GLOBAL_MOTION") eq "yes")) {
add_proto qw/void av1_warp_affine/, "const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
add_proto qw/void av1_warp_affine/, "const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
specialize qw/av1_warp_affine sse2 ssse3/;
if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
specialize qw/av1_highbd_warp_affine ssse3/;
}
}
......
......@@ -433,8 +433,7 @@ static INLINE void av1_make_inter_predictor(
#endif // CONFIG_HIGHBITDEPTH
pre_buf->buf0, pre_buf->width, pre_buf->height,
pre_buf->stride, dst, p_col, p_row, w, h, dst_stride,
pd->subsampling_x, pd->subsampling_y, xs, ys,
conv_params->do_average);
pd->subsampling_x, pd->subsampling_y, xs, ys, conv_params);
return;
}
#endif // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
......
......@@ -913,11 +913,14 @@ static INLINE int highbd_error_measure(int err, int bd) {
error_measure_lut[256 + e1] * e2;
}
static void highbd_warp_plane_old(
const WarpedMotionParams *const wm, const uint8_t *const ref8, int width,
int height, int stride, const uint8_t *const pred8, int p_col, int p_row,
int p_width, int p_height, int p_stride, int subsampling_x,
int subsampling_y, int x_scale, int y_scale, int bd, int comp_avg) {
static void highbd_warp_plane_old(const WarpedMotionParams *const wm,
const uint8_t *const ref8, int width,
int height, int stride,
const uint8_t *const pred8, int p_col,
int p_row, int p_width, int p_height,
int p_stride, int subsampling_x,
int subsampling_y, int x_scale, int y_scale,
int bd, ConvolveParams *conv_params) {
int i, j;
ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
......@@ -931,7 +934,7 @@ static void highbd_warp_plane_old(
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
if (comp_avg)
if (conv_params->do_average)
pred[(j - p_col) + (i - p_row) * p_stride] = ROUND_POWER_OF_TWO(
pred[(j - p_col) + (i - p_row) * p_stride] +
highbd_warp_interpolate(ref, out[0], out[1], width, height,
......@@ -951,9 +954,9 @@ void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref,
int width, int height, int stride, uint16_t *pred,
int p_col, int p_row, int p_width, int p_height,
int p_stride, int subsampling_x,
int subsampling_y, int bd, int comp_avg,
int16_t alpha, int16_t beta, int16_t gamma,
int16_t delta) {
int subsampling_y, int bd,
ConvolveParams *conv_params, int16_t alpha,
int16_t beta, int16_t gamma, int16_t delta) {
int32_t tmp[15 * 8];
int i, j, k, l, m;
......@@ -1039,7 +1042,7 @@ void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref,
assert(0 <= sum && sum < (1 << (bd + 2)));
uint16_t px =
clip_pixel_highbd(sum - (1 << (bd - 1)) - (1 << bd), bd);
if (comp_avg)
if (conv_params->do_average)
*p = ROUND_POWER_OF_TWO(*p + px, 1);
else
*p = px;
......@@ -1055,7 +1058,8 @@ static void highbd_warp_plane(WarpedMotionParams *wm, const uint8_t *const ref8,
const uint8_t *const pred8, int p_col, int p_row,
int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y, int x_scale,
int y_scale, int bd, int comp_avg) {
int y_scale, int bd,
ConvolveParams *conv_params) {
if (wm->wmtype == ROTZOOM) {
wm->wmmat[5] = wm->wmmat[2];
wm->wmmat[4] = -wm->wmmat[3];
......@@ -1072,12 +1076,12 @@ static void highbd_warp_plane(WarpedMotionParams *wm, const uint8_t *const ref8,
uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
av1_highbd_warp_affine(mat, ref, width, height, stride, pred, p_col, p_row,
p_width, p_height, p_stride, subsampling_x,
subsampling_y, bd, comp_avg, alpha, beta, gamma,
subsampling_y, bd, conv_params, alpha, beta, gamma,
delta);
} else {
highbd_warp_plane_old(wm, ref8, width, height, stride, pred8, p_col, p_row,
p_width, p_height, p_stride, subsampling_x,
subsampling_y, x_scale, y_scale, bd, comp_avg);
subsampling_y, x_scale, y_scale, bd, conv_params);
}
}
......@@ -1105,6 +1109,7 @@ static int64_t highbd_warp_error(
int error_bsize_h = AOMMIN(p_height, WARP_ERROR_BLOCK);
uint16_t tmp[WARP_ERROR_BLOCK * WARP_ERROR_BLOCK];
ConvolveParams conv_params = get_conv_params(0, 0, 0);
for (int i = p_row; i < p_row + p_height; i += WARP_ERROR_BLOCK) {
for (int j = p_col; j < p_col + p_width; j += WARP_ERROR_BLOCK) {
// avoid warping extra 8x8 blocks in the padded region of the frame
......@@ -1114,7 +1119,7 @@ static int64_t highbd_warp_error(
highbd_warp_plane(wm, ref8, width, height, stride,
CONVERT_TO_BYTEPTR(tmp), j, i, warp_w, warp_h,
WARP_ERROR_BLOCK, subsampling_x, subsampling_y, x_scale,
y_scale, bd, 0);
y_scale, bd, &conv_params);
gm_sumerr += highbd_frame_error(
tmp, WARP_ERROR_BLOCK, CONVERT_TO_SHORTPTR(dst8) + j + i * p_stride,
......@@ -1135,7 +1140,7 @@ static void warp_plane_old(const WarpedMotionParams *const wm,
int stride, uint8_t *pred, int p_col, int p_row,
int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y, int x_scale,
int y_scale, int comp_avg) {
int y_scale, ConvolveParams *conv_params) {
int i, j;
ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
if (projectpoints == NULL) return;
......@@ -1147,7 +1152,7 @@ static void warp_plane_old(const WarpedMotionParams *const wm,
projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
if (comp_avg)
if (conv_params->do_average)
pred[(j - p_col) + (i - p_row) * p_stride] = ROUND_POWER_OF_TWO(
pred[(j - p_col) + (i - p_row) * p_stride] +
warp_interpolate(ref, out[0], out[1], width, height, stride),
......@@ -1247,9 +1252,9 @@ static void warp_plane_old(const WarpedMotionParams *const wm,
void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width,
int height, int stride, uint8_t *pred, int p_col,
int p_row, int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y, int comp_avg,
int16_t alpha, int16_t beta, int16_t gamma,
int16_t delta) {
int subsampling_x, int subsampling_y,
ConvolveParams *conv_params, int16_t alpha, int16_t beta,
int16_t gamma, int16_t delta) {
int32_t tmp[15 * 8];
int i, j, k, l, m;
const int bd = 8;
......@@ -1341,7 +1346,7 @@ void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width,
sum = ROUND_POWER_OF_TWO(sum, VERSHEAR_REDUCE_PREC_BITS);
assert(0 <= sum && sum < (1 << (bd + 2)));
uint8_t px = clip_pixel(sum - (1 << (bd - 1)) - (1 << bd));
if (comp_avg)
if (conv_params->do_average)
*p = ROUND_POWER_OF_TWO(*p + px, 1);
else
*p = px;
......@@ -1356,7 +1361,7 @@ static void warp_plane(WarpedMotionParams *wm, const uint8_t *const ref,
int width, int height, int stride, uint8_t *pred,
int p_col, int p_row, int p_width, int p_height,
int p_stride, int subsampling_x, int subsampling_y,
int x_scale, int y_scale, int comp_avg) {
int x_scale, int y_scale, ConvolveParams *conv_params) {
if (wm->wmtype == ROTZOOM) {
wm->wmmat[5] = wm->wmmat[2];
wm->wmmat[4] = -wm->wmmat[3];
......@@ -1371,11 +1376,11 @@ static void warp_plane(WarpedMotionParams *wm, const uint8_t *const ref,
av1_warp_affine(mat, ref, width, height, stride, pred, p_col, p_row,
p_width, p_height, p_stride, subsampling_x, subsampling_y,
comp_avg, alpha, beta, gamma, delta);
conv_params, alpha, beta, gamma, delta);
} else {
warp_plane_old(wm, ref, width, height, stride, pred, p_col, p_row, p_width,
p_height, p_stride, subsampling_x, subsampling_y, x_scale,
y_scale, comp_avg);
y_scale, conv_params);
}
}
......@@ -1403,6 +1408,7 @@ static int64_t warp_error(WarpedMotionParams *wm, const uint8_t *const ref,
int error_bsize_w = AOMMIN(p_width, WARP_ERROR_BLOCK);
int error_bsize_h = AOMMIN(p_height, WARP_ERROR_BLOCK);
uint8_t tmp[WARP_ERROR_BLOCK * WARP_ERROR_BLOCK];
ConvolveParams conv_params = get_conv_params(0, 0, 0);
for (int i = p_row; i < p_row + p_height; i += WARP_ERROR_BLOCK) {
for (int j = p_col; j < p_col + p_width; j += WARP_ERROR_BLOCK) {
......@@ -1412,7 +1418,7 @@ static int64_t warp_error(WarpedMotionParams *wm, const uint8_t *const ref,
warp_h = AOMMIN(error_bsize_h, p_row + p_height - i);
warp_plane(wm, ref, width, height, stride, tmp, j, i, warp_w, warp_h,
WARP_ERROR_BLOCK, subsampling_x, subsampling_y, x_scale,
y_scale, 0);
y_scale, &conv_params);
gm_sumerr += frame_error(tmp, WARP_ERROR_BLOCK, dst + j + i * p_stride,
warp_w, warp_h, p_stride);
......@@ -1467,17 +1473,18 @@ void av1_warp_plane(WarpedMotionParams *wm,
const uint8_t *ref, int width, int height, int stride,
uint8_t *pred, int p_col, int p_row, int p_width,
int p_height, int p_stride, int subsampling_x,
int subsampling_y, int x_scale, int y_scale, int comp_avg) {
int subsampling_y, int x_scale, int y_scale,
ConvolveParams *conv_params) {
#if CONFIG_HIGHBITDEPTH
if (use_hbd)
highbd_warp_plane(wm, ref, width, height, stride, pred, p_col, p_row,
p_width, p_height, p_stride, subsampling_x, subsampling_y,
x_scale, y_scale, bd, comp_avg);
x_scale, y_scale, bd, conv_params);
else
#endif // CONFIG_HIGHBITDEPTH
warp_plane(wm, ref, width, height, stride, pred, p_col, p_row, p_width,
p_height, p_stride, subsampling_x, subsampling_y, x_scale,
y_scale, comp_avg);
y_scale, conv_params);
}
#if CONFIG_WARPED_MOTION
......
......@@ -22,6 +22,7 @@
#include "aom_ports/mem.h"
#include "aom_dsp/aom_dsp_common.h"
#include "av1/common/mv.h"
#include "av1/common/convolve.h"
#define MAX_PARAMDIM 9
#if CONFIG_WARPED_MOTION
......@@ -100,7 +101,8 @@ void av1_warp_plane(WarpedMotionParams *wm,
const uint8_t *ref, int width, int height, int stride,
uint8_t *pred, int p_col, int p_row, int p_width,
int p_height, int p_stride, int subsampling_x,
int subsampling_y, int x_scale, int y_scale, int comp_avg);
int subsampling_y, int x_scale, int y_scale,
ConvolveParams *conv_params);
int find_projection(int np, int *pts1, int *pts2, BLOCK_SIZE bsize, int mvy,
int mvx, WarpedMotionParams *wm_params, int mi_row,
......
......@@ -19,8 +19,9 @@ void av1_highbd_warp_affine_ssse3(const int32_t *mat, const uint16_t *ref,
uint16_t *pred, int p_col, int p_row,
int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y, int bd,
int comp_avg, int16_t alpha, int16_t beta,
int16_t gamma, int16_t delta) {
ConvolveParams *conv_params, int16_t alpha,
int16_t beta, int16_t gamma, int16_t delta) {
int comp_avg = conv_params->do_average;
#if HORSHEAR_REDUCE_PREC_BITS >= 5
__m128i tmp[15];
#else
......
......@@ -17,9 +17,10 @@
void av1_warp_affine_sse2(const int32_t *mat, const uint8_t *ref, int width,
int height, int stride, uint8_t *pred, int p_col,
int p_row, int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y, int comp_avg,
int16_t alpha, int16_t beta, int16_t gamma,
int16_t delta) {
int subsampling_x, int subsampling_y,
ConvolveParams *conv_params, int16_t alpha,
int16_t beta, int16_t gamma, int16_t delta) {
int comp_avg = conv_params->do_average;
__m128i tmp[15];
int i, j, k;
const int bd = 8;
......
......@@ -204,9 +204,10 @@ static const uint8_t odd_mask[16] = { 1, 3, 3, 5, 5, 7, 7, 9,
void av1_warp_affine_ssse3(const int32_t *mat, const uint8_t *ref, int width,
int height, int stride, uint8_t *pred, int p_col,
int p_row, int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y, int comp_avg,
int16_t alpha, int16_t beta, int16_t gamma,
int16_t delta) {
int subsampling_x, int subsampling_y,
ConvolveParams *conv_params, int16_t alpha,
int16_t beta, int16_t gamma, int16_t delta) {
int comp_avg = conv_params->do_average;
__m128i tmp[15];
int i, j, k;
const int bd = 8;
......
......@@ -112,6 +112,7 @@ void AV1WarpFilterTest::RunCheckOutput(warp_affine_func test_impl) {
uint8_t *output2 = new uint8_t[output_n];
int32_t mat[8];
int16_t alpha, beta, gamma, delta;
ConvolveParams conv_params = get_conv_params(0, 0, 0);
// Generate an input block and extend its borders horizontally
for (i = 0; i < h; ++i)
......@@ -126,10 +127,10 @@ void AV1WarpFilterTest::RunCheckOutput(warp_affine_func test_impl) {
for (sub_y = 0; sub_y < 2; ++sub_y) {
generate_model(mat, &alpha, &beta, &gamma, &delta);
av1_warp_affine_c(mat, input, w, h, stride, output, 32, 32, out_w,
out_h, out_w, sub_x, sub_y, 0, alpha, beta, gamma,
delta);
out_h, out_w, sub_x, sub_y, &conv_params, alpha, beta,
gamma, delta);
test_impl(mat, input, w, h, stride, output2, 32, 32, out_w, out_h,
out_w, sub_x, sub_y, 0, alpha, beta, gamma, delta);
out_w, sub_x, sub_y, &conv_params, alpha, beta, gamma, delta);
for (j = 0; j < out_w * out_h; ++j)
ASSERT_EQ(output[j], output2[j])
......@@ -248,6 +249,7 @@ void AV1HighbdWarpFilterTest::RunCheckOutput(
uint16_t *output2 = new uint16_t[output_n];
int32_t mat[8];
int16_t alpha, beta, gamma, delta;
ConvolveParams conv_params = get_conv_params(0, 0, 0);
// Generate an input block and extend its borders horizontally
for (i = 0; i < h; ++i)
......@@ -265,10 +267,11 @@ void AV1HighbdWarpFilterTest::RunCheckOutput(
generate_model(mat, &alpha, &beta, &gamma, &delta);
av1_highbd_warp_affine_c(mat, input, w, h, stride, output, 32, 32,
out_w, out_h, out_w, sub_x, sub_y, bd, 0,
alpha, beta, gamma, delta);
out_w, out_h, out_w, sub_x, sub_y, bd,
&conv_params, alpha, beta, gamma, delta);
test_impl(mat, input, w, h, stride, output2, 32, 32, out_w, out_h,
out_w, sub_x, sub_y, bd, 0, alpha, beta, gamma, delta);
out_w, sub_x, sub_y, bd, &conv_params, alpha, beta, gamma,
delta);
for (j = 0; j < out_w * out_h; ++j)
ASSERT_EQ(output[j], output2[j])
......
......@@ -31,8 +31,8 @@ typedef void (*warp_affine_func)(const int32_t *mat, const uint8_t *ref,
uint8_t *pred, int p_col, int p_row,
int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y,
int ref_frm, int16_t alpha, int16_t beta,
int16_t gamma, int16_t delta);
ConvolveParams *conv_params, int16_t alpha,
int16_t beta, int16_t gamma, int16_t delta);
typedef std::tr1::tuple<int, int, int, warp_affine_func> WarpTestParam;
......@@ -60,11 +60,14 @@ class AV1WarpFilterTest : public ::testing::TestWithParam<WarpTestParam> {
#if CONFIG_HIGHBITDEPTH
namespace AV1HighbdWarpFilter {
typedef void (*highbd_warp_affine_func)(
const int32_t *mat, const uint16_t *ref, int width, int height, int stride,
uint16_t *pred, int p_col, int p_row, int p_width, int p_height,
int p_stride, int subsampling_x, int subsampling_y, int bd, int ref_frm,
int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
typedef void (*highbd_warp_affine_func)(const int32_t *mat, const uint16_t *ref,
int width, int height, int stride,
uint16_t *pred, int p_col, int p_row,
int p_width, int p_height, int p_stride,
int subsampling_x, int subsampling_y,
int bd, ConvolveParams *conv_params,
int16_t alpha, int16_t beta,
int16_t gamma, int16_t delta);
typedef std::tr1::tuple<int, int, int, int> HighbdWarpTestParam;
......
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