Commit 13797462 authored by David Barker's avatar David Barker Committed by Debargha Mukherjee

Warp filter improvements

* The restriction on the parameter 'delta' was too strict, so we
  loosen it (delta only ever gets multiplied by -4, ... , 4,
  whereas beta gets multiplied by -7, ..., 7)
* Correct a comment about the border clamping
* Fix an issue with the test case

Change-Id: I30e55203455ba6e419b5a8b646151a6d1fd5cc3b
parent 7a428ba2
......@@ -713,7 +713,7 @@ static void highbd_warp_plane(WarpedMotionParams *wm, uint8_t *ref8, int width,
uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
if ((4 * abs(alpha) + 7 * abs(beta) > (1 << WARPEDMODEL_PREC_BITS)) ||
(4 * abs(gamma) + 7 * abs(delta) > (1 << WARPEDMODEL_PREC_BITS))) {
(4 * abs(gamma) + 4 * abs(delta) > (1 << WARPEDMODEL_PREC_BITS))) {
// assert(0 &&
// "Warped motion model is incompatible with new warp filter");
highbd_warp_plane_old(wm, ref8, width, height, stride, pred8, p_col,
......@@ -972,7 +972,7 @@ void av1_warp_affine_c(int32_t *mat, uint8_t *ref, int width, int height,
}
} else if (ix4 >= width + 6) {
// In this case, the leftmost pixel sampled is in column
// ix4 - 3 + 0 - 3 = ix4 - 6 >= width, ie. the entire block
// ix4 - 4 + 0 - 3 = ix4 - 7 >= width - 1, ie. the entire block
// will sample only from the rightmost column
// (once border extension is taken into account)
for (l = 0; l < 8; ++l) {
......@@ -1062,7 +1062,7 @@ static void warp_plane(WarpedMotionParams *wm, uint8_t *ref, int width,
(1 << WARPEDMODEL_PREC_BITS);
if ((4 * abs(alpha) + 7 * abs(beta) > (1 << WARPEDMODEL_PREC_BITS)) ||
(4 * abs(gamma) + 7 * abs(delta) > (1 << WARPEDMODEL_PREC_BITS))) {
(4 * abs(gamma) + 4 * abs(delta) > (1 << WARPEDMODEL_PREC_BITS))) {
// assert(0 &&
// "Warped motion model is incompatible with new warp filter");
warp_plane_old(wm, ref, width, height, stride, pred, p_col, p_row,
......@@ -1827,7 +1827,7 @@ int find_projection(const int np, double *pts1, double *pts2,
(1 << WARPEDMODEL_PREC_BITS);
if ((4 * abs(alpha) + 7 * abs(beta) > (1 << WARPEDMODEL_PREC_BITS)) ||
(4 * abs(gamma) + 7 * abs(delta) > (1 << WARPEDMODEL_PREC_BITS))) {
(4 * abs(gamma) + 4 * abs(delta) > (1 << WARPEDMODEL_PREC_BITS))) {
return 1;
}
}
......
......@@ -85,24 +85,33 @@ class AV1WarpFilterTest : public ::testing::TestWithParam<WarpTestParam> {
void RunCheckOutput() {
const int w = 128, h = 128;
const int border = 16;
const int stride = w + 2 * border;
const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
const int num_iters = GET_PARAM(2);
int i, j;
uint8_t *input = new uint8_t[w * h];
uint8_t *input_ = new uint8_t[h * stride];
uint8_t *input = input_ + border;
uint8_t *output = new uint8_t[out_w * out_h];
uint8_t *output2 = new uint8_t[out_w * out_h];
int32_t mat[8], alpha, beta, gamma, delta;
// Generate an input block and extend its borders horizontally
for (i = 0; i < h; ++i)
for (j = 0; j < w; ++j) input[i * w + j] = rnd_.Rand8();
for (j = 0; j < w; ++j) input[i * stride + j] = rnd_.Rand8();
for (i = 0; i < h; ++i) {
memset(input + i * stride - border, input[i * stride], border);
memset(input + i * stride + w, input[i * stride + (w - 1)], border);
}
/* Try different sizes of prediction block */
for (i = 0; i < num_iters; ++i) {
generate_model(mat, &alpha, &beta, &gamma, &delta);
av1_warp_affine_c(mat, input, w, h, w, output, 32, 32, out_w, out_h,
av1_warp_affine_c(mat, input, w, h, stride, output, 32, 32, out_w, out_h,
out_w, 0, 0, 0, alpha, beta, gamma, delta);
av1_warp_affine_sse2(mat, input, w, h, w, output2, 32, 32, out_w, out_h,
out_w, 0, 0, 0, alpha, beta, gamma, delta);
av1_warp_affine_sse2(mat, input, w, h, stride, output2, 32, 32, out_w,
out_h, out_w, 0, 0, 0, alpha, beta, gamma, delta);
for (j = 0; j < out_w * out_h; ++j)
ASSERT_EQ(output[j], output2[j])
......@@ -110,7 +119,7 @@ class AV1WarpFilterTest : public ::testing::TestWithParam<WarpTestParam> {
<< (j / out_w) << ") on iteration " << i;
}
delete[] input;
delete[] input_;
delete[] output;
delete[] output2;
}
......
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