Commit 5a6dc0e7 authored by Yunqing Wang's avatar Yunqing Wang
Browse files

Further modify the sample selection in warped motion

1. Reduce the worst-case number of samples from 34 to 16.
2. Simplify the trimming strategy to not use multiplication and
division operations.

Overall, this modification reduces the complexity without affecting
the coding gain too much.

Turning on "ext_warped_motion", the Borg test showed:
             avg_psnr ovr_psnr ssim
cam_lowres:  -0.912   -0.920  -1.246
lowres:      -0.229   -0.219  -0.373

Change-Id: Ida21d1d3f22998c851b1270fe61a5e30f9e4ec38
parent 6534ba84
......@@ -2050,6 +2050,7 @@ int sortSamples(int *pts_mv, MV *mv, int *pts, int *pts_inref, int len) {
int pts_mvd[SAMPLES_ARRAY_SIZE] = { 0 };
int i, j, k;
int ret = len;
assert(len <= SAMPLES_MAX);
for (i = 0; i < len; ++i)
pts_mvd[i] =
......@@ -2084,13 +2085,12 @@ int sortSamples(int *pts_mv, MV *mv, int *pts, int *pts_inref, int len) {
}
}
for (i = len - 1; i >= 1; i--) {
int low = (i == 1) ? 1 : AOMMAX((pts_mvd[i - 1] - pts_mvd[0]) / (i - 1), 1);
len = AOMMIN(len, LEAST_SQUARES_SAMPLES_MAX);
if ((pts_mvd[i] - pts_mvd[i - 1]) >= TRIM_THR * low) ret = i;
for (i = len - 1; i >= 1; i--) {
if ((pts_mvd[i] - pts_mvd[i - 1]) >= TRIM_THR) ret = i;
}
if (ret > LEAST_SQUARES_SAMPLES_MAX) ret = LEAST_SQUARES_SAMPLES_MAX;
return ret;
}
......@@ -2130,6 +2130,7 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
pts_inref += 2;
pts_mv += 2;
np++;
if (np >= SAMPLES_MAX) return SAMPLES_MAX;
}
} else {
// Handle "current block width > above block width" case.
......@@ -2148,11 +2149,12 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
pts_inref += 2;
pts_mv += 2;
np++;
if (np >= SAMPLES_MAX) return SAMPLES_MAX;
}
}
}
}
assert(2 * np <= SAMPLES_ARRAY_SIZE);
assert(np <= SAMPLES_MAX);
// scan the nearest left columns
if (left_available) {
......@@ -2175,6 +2177,7 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
pts_inref += 2;
pts_mv += 2;
np++;
if (np >= SAMPLES_MAX) return SAMPLES_MAX;
}
} else {
// Handle "current block height > above block height" case.
......@@ -2193,11 +2196,12 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
pts_inref += 2;
pts_mv += 2;
np++;
if (np >= SAMPLES_MAX) return SAMPLES_MAX;
}
}
}
}
assert(2 * np <= SAMPLES_ARRAY_SIZE);
assert(np <= SAMPLES_MAX);
// Top-left block
if (do_tl && left_available && up_available) {
......@@ -2214,9 +2218,10 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
pts_inref += 2;
pts_mv += 2;
np++;
if (np >= SAMPLES_MAX) return SAMPLES_MAX;
}
}
assert(2 * np <= SAMPLES_ARRAY_SIZE);
assert(np <= SAMPLES_MAX);
// Top-right block
if (do_tr &&
......@@ -2234,10 +2239,11 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
record_samples(mbmi, pts, pts_inref, pts_mv, global_offset_r,
global_offset_c, 0, -1, xd->n8_w, 1);
np++;
if (np >= SAMPLES_MAX) return SAMPLES_MAX;
}
}
}
assert(2 * np <= SAMPLES_ARRAY_SIZE);
assert(np <= SAMPLES_MAX);
return np;
}
......
......@@ -31,8 +31,11 @@
#if CONFIG_EXT_WARPED_MOTION
// Search 1 row on the top and 1 column on the left, 1 upper-left block,
// 1 upper-right block.
#define SAMPLES_ARRAY_SIZE ((MAX_MIB_SIZE * 2 + 2) * 2)
// 1 upper-right block. In worst case, the samples are (MAX_MIB_SIZE * 2 + 2).
// Here force number of samples within SAMPLES_MAX.
#define SAMPLES_MAX (LEAST_SQUARES_SAMPLES_MAX * 2)
#define SAMPLES_ARRAY_SIZE (SAMPLES_MAX * 2)
#define SCALING_FCT 3
#else
#define SAMPLES_ARRAY_SIZE (LEAST_SQUARES_SAMPLES_MAX * 2)
......
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