Commit d280a845 authored by Steinar Midtskogen's avatar Steinar Midtskogen

Remove boundary checks in CLPF

Change-Id: Icc93783f47fe7fe3aac395aadcc8bbc307dae1fb
parent 6eca835f
......@@ -852,7 +852,7 @@ add_proto qw/void aom_lpf_horizontal_4_dual/, "uint8_t *s, int pitch, const uint
specialize qw/aom_lpf_horizontal_4_dual sse2 neon dspr2 msa/;
if (aom_config("CONFIG_CDEF") eq "yes") {
add_proto qw/void aom_clpf_block_hbd/, "const uint16_t *src, uint16_t *dst, int sstride, int dstride, int x0, int y0, int sizex, int sizey, unsigned int strength, BOUNDARY_TYPE bt, unsigned int bd";
add_proto qw/void aom_clpf_block_hbd/, "const uint16_t *src, uint16_t *dst, int sstride, int dstride, int x0, int y0, int sizex, int sizey, unsigned int strength, unsigned int bd";
if (aom_config("CONFIG_AOM_HIGHBITDEPTH") eq "yes") {
add_proto qw/void aom_clpf_detect_hbd/, "const uint16_t *rec, const uint16_t *org, int rstride, int ostride, int x0, int y0, int width, int height, int *sum0, int *sum1, unsigned int strength, int size, unsigned int bd, unsigned int dmp";
add_proto qw/void aom_clpf_detect_multi_hbd/, "const uint16_t *rec, const uint16_t *org, int rstride, int ostride, int x0, int y0, int width, int height, int *sum, int size, unsigned int bd, unsigned int dmp";
......@@ -867,7 +867,7 @@ if (aom_config("CONFIG_CDEF") eq "yes") {
if ($opts{config} !~ /libs-x86-win32-vs.*/) {
specialize qw/aom_clpf_block_hbd sse2 ssse3 sse4_1 neon/;
}
add_proto qw/void aom_clpf_block/, "const uint8_t *src, uint8_t *dst, int sstride, int dstride, int x0, int y0, int sizex, int sizey, unsigned int strength, BOUNDARY_TYPE bt, unsigned int bd";
add_proto qw/void aom_clpf_block/, "const uint8_t *src, uint8_t *dst, int sstride, int dstride, int x0, int y0, int sizex, int sizey, unsigned int strength, unsigned int bd";
add_proto qw/void aom_clpf_detect/, "const uint8_t *rec, const uint8_t *org, int rstride, int ostride, int x0, int y0, int width, int height, int *sum0, int *sum1, unsigned int strength, int size, unsigned int dmp";
add_proto qw/void aom_clpf_detect_multi/, "const uint8_t *rec, const uint8_t *org, int rstride, int ostride, int x0, int y0, int width, int height, int *sum, int size, unsigned int dmp";
# VS compiling for 32 bit targets does not support vector types in
......
......@@ -265,10 +265,12 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd,
int level, clpf_strength;
int nhb, nvb;
int cstart = 0;
#if 0 // TODO(stemidts/jmvalin): Handle tile borders correctly
BOUNDARY_TYPE boundary_type =
cm->mi_grid_visible[MAX_MIB_SIZE * sbr * cm->mi_stride +
MAX_MIB_SIZE * sbc]
->mbmi.boundary_info;
#endif
if (!dering_left) cstart = -OD_FILT_HBORDER;
nhb = AOMMIN(MAX_MIB_SIZE, cm->mi_cols - MAX_MIB_SIZE * sbc);
nvb = AOMMIN(MAX_MIB_SIZE, cm->mi_rows - MAX_MIB_SIZE * sbr);
......@@ -435,7 +437,7 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd,
od_dering(dst,
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER],
dec[pli], dir, pli, dlist, dering_count, threshold,
clpf_strength, clpf_damping, coeff_shift, boundary_type);
clpf_strength, clpf_damping, coeff_shift);
#if CONFIG_AOM_HIGHBITDEPTH
if (cm->use_highbitdepth) {
copy_dering_16bit_to_16bit(
......
......@@ -33,25 +33,20 @@ int av1_clpf_sample(int X, int A, int B, int C, int D, int E, int F, int G,
void aom_clpf_block_c(const uint8_t *src, uint8_t *dst, int sstride,
int dstride, int x0, int y0, int sizex, int sizey,
unsigned int strength, BOUNDARY_TYPE bt,
unsigned int damping) {
unsigned int strength, unsigned int damping) {
int x, y;
const int xmin = x0 - !(bt & TILE_LEFT_BOUNDARY) * 2;
const int ymin = y0 - !(bt & TILE_ABOVE_BOUNDARY) * 2;
const int xmax = x0 + sizex + !(bt & TILE_RIGHT_BOUNDARY) * 2 - 1;
const int ymax = y0 + sizey + !(bt & TILE_BOTTOM_BOUNDARY) * 2 - 1;
for (y = y0; y < y0 + sizey; y++) {
for (x = x0; x < x0 + sizex; x++) {
const int X = src[y * sstride + x];
const int A = src[AOMMAX(ymin, y - 2) * sstride + x];
const int B = src[AOMMAX(ymin, y - 1) * sstride + x];
const int C = src[y * sstride + AOMMAX(xmin, x - 2)];
const int D = src[y * sstride + AOMMAX(xmin, x - 1)];
const int E = src[y * sstride + AOMMIN(xmax, x + 1)];
const int F = src[y * sstride + AOMMIN(xmax, x + 2)];
const int G = src[AOMMIN(ymax, y + 1) * sstride + x];
const int H = src[AOMMIN(ymax, y + 2) * sstride + x];
const int A = src[(y - 2) * sstride + x];
const int B = src[(y - 1) * sstride + x];
const int C = src[y * sstride + x - 2];
const int D = src[y * sstride + x - 1];
const int E = src[y * sstride + x + 1];
const int F = src[y * sstride + x + 2];
const int G = src[(y + 1) * sstride + x];
const int H = src[(y + 2) * sstride + x];
const int delta =
av1_clpf_sample(X, A, B, C, D, E, F, G, H, strength, damping);
dst[y * dstride + x] = X + delta;
......@@ -63,25 +58,20 @@ void aom_clpf_block_c(const uint8_t *src, uint8_t *dst, int sstride,
// TODO(stemidts): Put under CONFIG_AOM_HIGHBITDEPTH if CDEF do 8 bit internally
void aom_clpf_block_hbd_c(const uint16_t *src, uint16_t *dst, int sstride,
int dstride, int x0, int y0, int sizex, int sizey,
unsigned int strength, BOUNDARY_TYPE bt,
unsigned int damping) {
unsigned int strength, unsigned int damping) {
int x, y;
const int xmin = x0 - !(bt & TILE_LEFT_BOUNDARY) * 2;
const int ymin = y0 - !(bt & TILE_ABOVE_BOUNDARY) * 2;
const int xmax = x0 + sizex + !(bt & TILE_RIGHT_BOUNDARY) * 2 - 1;
const int ymax = y0 + sizey + !(bt & TILE_BOTTOM_BOUNDARY) * 2 - 1;
for (y = y0; y < y0 + sizey; y++) {
for (x = x0; x < x0 + sizex; x++) {
const int X = src[y * sstride + x];
const int A = src[AOMMAX(ymin, y - 2) * sstride + x];
const int B = src[AOMMAX(ymin, y - 1) * sstride + x];
const int C = src[y * sstride + AOMMAX(xmin, x - 2)];
const int D = src[y * sstride + AOMMAX(xmin, x - 1)];
const int E = src[y * sstride + AOMMIN(xmax, x + 1)];
const int F = src[y * sstride + AOMMIN(xmax, x + 2)];
const int G = src[AOMMIN(ymax, y + 1) * sstride + x];
const int H = src[AOMMIN(ymax, y + 2) * sstride + x];
const int A = src[(y - 2) * sstride + x];
const int B = src[(y - 1) * sstride + x];
const int C = src[y * sstride + x - 2];
const int D = src[y * sstride + x - 1];
const int E = src[y * sstride + x + 1];
const int F = src[y * sstride + x + 2];
const int G = src[(y + 1) * sstride + x];
const int H = src[(y + 2) * sstride + x];
const int delta =
av1_clpf_sample(X, A, B, C, D, E, F, G, H, strength, damping);
dst[y * dstride + x] = X + delta;
......
This diff is collapsed.
......@@ -242,8 +242,7 @@ void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride, uint16_t *src,
void od_dering(uint16_t *y, uint16_t *in, int xdec,
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int pli,
dering_list *dlist, int dering_count, int threshold,
int clpf_strength, int clpf_damping, int coeff_shift,
BOUNDARY_TYPE bt) {
int clpf_strength, int clpf_damping, int coeff_shift) {
int bi;
int bx;
int by;
......@@ -286,17 +285,12 @@ void od_dering(uint16_t *y, uint16_t *in, int xdec,
copy_dering_16bit_to_16bit(in, OD_FILT_BSTRIDE, y, dlist, dering_count,
bsize);
for (bi = 0; bi < dering_count; bi++) {
BOUNDARY_TYPE bt2 = 0;
by = dlist[bi].by;
bx = dlist[bi].bx;
// Prevent CLPF from reading across superblock boundaries
if (!by) bt2 |= TILE_ABOVE_BOUNDARY;
if (by == (1 << bsize) - 1) bt2 |= TILE_BOTTOM_BOUNDARY;
aom_clpf_block_hbd(in, &y[((bi - by) << 2 * bsize) - (bx << bsize)],
OD_FILT_BSTRIDE, 1 << bsize, bx << bsize, by << bsize,
1 << bsize, 1 << bsize, clpf_strength << coeff_shift,
bt | bt2, clpf_damping + coeff_shift);
clpf_damping + coeff_shift);
}
}
......@@ -49,8 +49,7 @@ void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride, uint16_t *src,
void od_dering(uint16_t *y, uint16_t *in, int xdec,
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int pli,
dering_list *dlist, int dering_count, int threshold,
int clpf_strength, int clpf_damping, int coeff_shift,
BOUNDARY_TYPE bt);
int clpf_strength, int clpf_damping, int coeff_shift);
int od_filter_dering_direction_4x4_c(uint16_t *y, int ystride,
const uint16_t *in, int threshold,
int dir);
......
......@@ -140,7 +140,7 @@ void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
}
for (i = 0; i < CLPF_STRENGTHS; i++) {
od_dering(tmp_dst, in, 0, dir, 0, dlist, dering_count, threshold,
i + (i == 3), clpf_damping, coeff_shift, 0);
i + (i == 3), clpf_damping, coeff_shift);
copy_dering_16bit_to_16bit(dst, MAX_MIB_SIZE << bsize[0], tmp_dst,
dlist, dering_count, bsize[0]);
mse[sb_count][gi][i] = (int)compute_dist(
......
......@@ -28,8 +28,7 @@ namespace {
typedef void (*clpf_block_t)(const uint8_t *src, uint8_t *dst, int sstride,
int dstride, int x0, int y0, int sizex, int sizey,
unsigned int strength, BOUNDARY_TYPE bt,
unsigned int bitdepth);
unsigned int strength, unsigned int bitdepth);
typedef std::tr1::tuple<clpf_block_t, clpf_block_t, int, int>
clpf_block_param_t;
......@@ -59,7 +58,7 @@ typedef ClpfBlockTest ClpfSpeedTest;
typedef void (*clpf_block_hbd_t)(const uint16_t *src, uint16_t *dst,
int sstride, int dstride, int x0, int y0,
int sizex, int sizey, unsigned int strength,
BOUNDARY_TYPE bt, unsigned int bitdepth);
unsigned int bitdepth);
typedef std::tr1::tuple<clpf_block_hbd_t, clpf_block_hbd_t, int, int>
clpf_block_hbd_param_t;
......@@ -91,12 +90,11 @@ template <typename pixel>
void test_clpf(int w, int h, int depth, int iterations,
void (*clpf)(const pixel *src, pixel *dst, int sstride,
int dstride, int x0, int y0, int sizex, int sizey,
unsigned int strength, BOUNDARY_TYPE bt,
unsigned int bitdepth),
unsigned int strength, unsigned int bitdepth),
void (*ref_clpf)(const pixel *src, pixel *dst, int sstride,
int dstride, int x0, int y0, int sizex,
int sizey, unsigned int strength,
BOUNDARY_TYPE bt, unsigned int bitdepth)) {
unsigned int bitdepth)) {
const int size = 24;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED(16, pixel, s[size * size]);
......@@ -125,16 +123,11 @@ void test_clpf(int w, int h, int depth, int iterations,
for (xpos = 0; xpos < size && !error; xpos += w * !error) {
for (strength = depth - 8; strength < depth - 5 && !error;
strength += !error) {
BOUNDARY_TYPE bt =
BOUNDARY_TYPE((TILE_LEFT_BOUNDARY & -(!xpos)) |
(TILE_ABOVE_BOUNDARY & -(!ypos)) |
(TILE_RIGHT_BOUNDARY & -(xpos + w == size)) |
(TILE_BOTTOM_BOUNDARY & -(ypos + h == size)));
ref_clpf(s, ref_d, size, size, xpos, ypos, w, h, 1 << strength,
bt, depth);
depth);
if (clpf != ref_clpf)
ASM_REGISTER_STATE_CHECK(clpf(s, d, size, size, xpos, ypos, w,
h, 1 << strength, bt, depth));
h, 1 << strength, depth));
if (ref_clpf != clpf)
for (pos = 0; pos < size * size && !error; pos++) {
error = ref_d[pos] != d[pos];
......@@ -175,11 +168,10 @@ void test_clpf_speed(int w, int h, int depth, int iterations,
void (*clpf)(const pixel *src, pixel *dst, int sstride,
int dstride, int x0, int y0, int sizex,
int sizey, unsigned int strength,
BOUNDARY_TYPE bt, unsigned int bitdepth),
unsigned int bitdepth),
void (*ref_clpf)(const pixel *src, pixel *dst, int sstride,
int dstride, int x0, int y0, int sizex,
int sizey, unsigned int strength,
BOUNDARY_TYPE bt,
unsigned int bitdepth)) {
aom_usec_timer ref_timer;
aom_usec_timer timer;
......
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