Commit 94de0aaa authored by Steinar Midtskogen's avatar Steinar Midtskogen
Browse files

CDEF cleanup

Name changes and code moves to bring code more in line with the
design doc and an upcoming single-pass patch.  No functional changes.

Change-Id: I2bccd58c644e534b139f420b623390aa971fbdb0
parent 3cb5e39c
......@@ -236,12 +236,11 @@ if (CONFIG_CDEF)
${AOM_AV1_COMMON_SOURCES}
"${AOM_ROOT}/av1/common/clpf.c"
"${AOM_ROOT}/av1/common/clpf_simd.h"
"${AOM_ROOT}/av1/common/cdef_simd.h"
"${AOM_ROOT}/av1/common/cdef.c"
"${AOM_ROOT}/av1/common/cdef.h"
"${AOM_ROOT}/av1/common/od_dering.c"
"${AOM_ROOT}/av1/common/od_dering.h"
"${AOM_ROOT}/av1/common/od_dering_simd.h")
"${AOM_ROOT}/av1/common/cdef_block.c"
"${AOM_ROOT}/av1/common/cdef_block.h"
"${AOM_ROOT}/av1/common/cdef_block_simd.h")
set(AOM_AV1_ENCODER_SOURCES
${AOM_AV1_ENCODER_SOURCES}
......@@ -250,22 +249,22 @@ if (CONFIG_CDEF)
set(AOM_AV1_COMMON_INTRIN_SSE2
${AOM_AV1_COMMON_INTRIN_SSE2}
"${AOM_ROOT}/av1/common/clpf_sse2.c"
"${AOM_ROOT}/av1/common/od_dering_sse2.c")
"${AOM_ROOT}/av1/common/cdef_block_sse2.c")
set(AOM_AV1_COMMON_INTRIN_SSSE3
${AOM_AV1_COMMON_INTRIN_SSSE3}
"${AOM_ROOT}/av1/common/clpf_ssse3.c"
"${AOM_ROOT}/av1/common/od_dering_ssse3.c")
"${AOM_ROOT}/av1/common/cdef_block_ssse3.c")
set(AOM_AV1_COMMON_INTRIN_SSE4_1
${AOM_AV1_COMMON_INTRIN_SSE4_1}
"${AOM_ROOT}/av1/common/clpf_sse4.c"
"${AOM_ROOT}/av1/common/od_dering_sse4.c")
"${AOM_ROOT}/av1/common/cdef_block_sse4.c")
set(AOM_AV1_COMMON_INTRIN_NEON
${AOM_AV1_COMMON_INTRIN_NEON}
"${AOM_ROOT}/av1/common/clpf_neon.c"
"${AOM_ROOT}/av1/common/od_dering_neon.c")
"${AOM_ROOT}/av1/common/cdef_block_neon.c")
endif ()
if (CONFIG_CONVOLVE_ROUND)
......
......@@ -92,18 +92,17 @@ endif
ifeq ($(CONFIG_CDEF),yes)
AV1_COMMON_SRCS-yes += common/clpf.c
AV1_COMMON_SRCS-yes += common/clpf_simd.h
AV1_COMMON_SRCS-yes += common/cdef_simd.h
AV1_COMMON_SRCS-$(HAVE_SSE2) += common/clpf_sse2.c
AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/clpf_ssse3.c
AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/clpf_sse4.c
AV1_COMMON_SRCS-$(HAVE_NEON) += common/clpf_neon.c
AV1_COMMON_SRCS-$(HAVE_SSE2) += common/od_dering_sse2.c
AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/od_dering_ssse3.c
AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/od_dering_sse4.c
AV1_COMMON_SRCS-$(HAVE_NEON) += common/od_dering_neon.c
AV1_COMMON_SRCS-yes += common/od_dering.c
AV1_COMMON_SRCS-yes += common/od_dering.h
AV1_COMMON_SRCS-yes += common/od_dering_simd.h
AV1_COMMON_SRCS-$(HAVE_SSE2) += common/cdef_block_sse2.c
AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/cdef_block_ssse3.c
AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/cdef_block_sse4.c
AV1_COMMON_SRCS-$(HAVE_NEON) += common/cdef_block_neon.c
AV1_COMMON_SRCS-yes += common/cdef_block.c
AV1_COMMON_SRCS-yes += common/cdef_block.h
AV1_COMMON_SRCS-yes += common/cdef_block_simd.h
AV1_COMMON_SRCS-yes += common/cdef.c
AV1_COMMON_SRCS-yes += common/cdef.h
endif
......
......@@ -24,7 +24,6 @@ struct search_site_config;
struct mv;
union int_mv;
struct yv12_buffer_config;
typedef uint16_t od_dering_in;
EOF
}
forward_decls qw/av1_common_forward_decls/;
......@@ -561,9 +560,9 @@ if (aom_config("CONFIG_CDEF") eq "yes") {
add_proto qw/void aom_clpf_hblock_hbd/, "uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd";
add_proto qw/void aom_clpf_block/, "uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd";
add_proto qw/void aom_clpf_hblock/, "uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd";
add_proto qw/int od_dir_find8/, "const od_dering_in *img, int stride, int32_t *var, int coeff_shift";
add_proto qw/void od_filter_dering_direction_4x4/, "uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping";
add_proto qw/void od_filter_dering_direction_8x8/, "uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping";
add_proto qw/int cdef_find_dir/, "const uint16_t *img, int stride, int32_t *var, int coeff_shift";
add_proto qw/void cdef_direction_4x4/, "uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping";
add_proto qw/void cdef_direction_8x8/, "uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping";
add_proto qw/void copy_8x8_16bit_to_8bit/, "uint8_t *dst, int dstride, const uint16_t *src, int sstride";
add_proto qw/void copy_4x4_16bit_to_8bit/, "uint8_t *dst, int dstride, const uint16_t *src, int sstride";
......@@ -580,9 +579,9 @@ if (aom_config("CONFIG_CDEF") eq "yes") {
specialize qw/aom_clpf_hblock_hbd sse2 ssse3 sse4_1 neon/;
specialize qw/aom_clpf_block sse2 ssse3 sse4_1 neon/;
specialize qw/aom_clpf_hblock sse2 ssse3 sse4_1 neon/;
specialize qw/od_dir_find8 sse2 ssse3 sse4_1 neon/;
specialize qw/od_filter_dering_direction_4x4 sse2 ssse3 sse4_1 neon/;
specialize qw/od_filter_dering_direction_8x8 sse2 ssse3 sse4_1 neon/;
specialize qw/cdef_find_dir sse2 ssse3 sse4_1 neon/;
specialize qw/cdef_direction_4x4 sse2 ssse3 sse4_1 neon/;
specialize qw/cdef_direction_8x8 sse2 ssse3 sse4_1 neon/;
specialize qw/copy_8x8_16bit_to_8bit sse2 ssse3 sse4_1 neon/;
specialize qw/copy_4x4_16bit_to_8bit sse2 ssse3 sse4_1 neon/;
......
......@@ -16,7 +16,7 @@
#include "./aom_scale_rtcd.h"
#include "aom/aom_integer.h"
#include "av1/common/cdef.h"
#include "av1/common/od_dering.h"
#include "av1/common/cdef_block.h"
#include "av1/common/onyxc_int.h"
#include "av1/common/reconinter.h"
......@@ -50,8 +50,8 @@ static int is_8x8_block_skip(MODE_INFO **grid, int mi_row, int mi_col,
return is_skip;
}
int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
dering_list *dlist, int filter_skip) {
int sb_compute_cdef_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
cdef_list *dlist, int filter_skip) {
int r, c;
int maxc, maxr;
MODE_INFO **grid;
......@@ -156,82 +156,81 @@ static INLINE void copy_rect(uint16_t *dst, int dstride, const uint16_t *src,
void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
MACROBLOCKD *xd) {
int sbr, sbc;
int nhsb, nvsb;
uint16_t src[OD_DERING_INBUF_SIZE];
int fbr, fbc;
int nhfb, nvfb;
uint16_t src[CDEF_INBUF_SIZE];
uint16_t *linebuf[3];
uint16_t *colbuf[3];
dering_list dlist[MI_SIZE_64X64 * MI_SIZE_64X64];
unsigned char *row_dering, *prev_row_dering, *curr_row_dering;
int dering_count;
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
int var[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
cdef_list dlist[MI_SIZE_64X64 * MI_SIZE_64X64];
unsigned char *row_cdef, *prev_row_cdef, *curr_row_cdef;
int cdef_count;
int dir[CDEF_NBLOCKS][CDEF_NBLOCKS] = { { 0 } };
int var[CDEF_NBLOCKS][CDEF_NBLOCKS] = { { 0 } };
int stride;
int mi_wide_l2[3];
int mi_high_l2[3];
int xdec[3];
int ydec[3];
int pli;
int dering_left;
int cdef_left;
int coeff_shift = AOMMAX(cm->bit_depth - 8, 0);
int nplanes = 3;
int chroma_dering =
xd->plane[1].subsampling_x == xd->plane[1].subsampling_y &&
xd->plane[2].subsampling_x == xd->plane[2].subsampling_y;
nvsb = (cm->mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
nhsb = (cm->mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
int nplanes = MAX_MB_PLANE;
int chroma_cdef = xd->plane[1].subsampling_x == xd->plane[1].subsampling_y &&
xd->plane[2].subsampling_x == xd->plane[2].subsampling_y;
nvfb = (cm->mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
nhfb = (cm->mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
av1_setup_dst_planes(xd->plane, cm->sb_size, frame, 0, 0);
row_dering = aom_malloc(sizeof(*row_dering) * (nhsb + 2) * 2);
memset(row_dering, 1, sizeof(*row_dering) * (nhsb + 2) * 2);
prev_row_dering = row_dering + 1;
curr_row_dering = prev_row_dering + nhsb + 2;
row_cdef = aom_malloc(sizeof(*row_cdef) * (nhfb + 2) * 2);
memset(row_cdef, 1, sizeof(*row_cdef) * (nhfb + 2) * 2);
prev_row_cdef = row_cdef + 1;
curr_row_cdef = prev_row_cdef + nhfb + 2;
for (pli = 0; pli < nplanes; pli++) {
xdec[pli] = xd->plane[pli].subsampling_x;
ydec[pli] = xd->plane[pli].subsampling_y;
mi_wide_l2[pli] = MI_SIZE_LOG2 - xd->plane[pli].subsampling_x;
mi_high_l2[pli] = MI_SIZE_LOG2 - xd->plane[pli].subsampling_y;
}
stride = (cm->mi_cols << MI_SIZE_LOG2) + 2 * OD_FILT_HBORDER;
stride = (cm->mi_cols << MI_SIZE_LOG2) + 2 * CDEF_HBORDER;
for (pli = 0; pli < nplanes; pli++) {
linebuf[pli] = aom_malloc(sizeof(*linebuf) * OD_FILT_VBORDER * stride);
linebuf[pli] = aom_malloc(sizeof(*linebuf) * CDEF_VBORDER * stride);
colbuf[pli] =
aom_malloc(sizeof(*colbuf) *
((MAX_SB_SIZE << mi_high_l2[pli]) + 2 * OD_FILT_VBORDER) *
OD_FILT_HBORDER);
((CDEF_BLOCKSIZE << mi_high_l2[pli]) + 2 * CDEF_VBORDER) *
CDEF_HBORDER);
}
for (sbr = 0; sbr < nvsb; sbr++) {
for (fbr = 0; fbr < nvfb; fbr++) {
for (pli = 0; pli < nplanes; pli++) {
const int block_height =
(MI_SIZE_64X64 << mi_high_l2[pli]) + 2 * OD_FILT_VBORDER;
fill_rect(colbuf[pli], OD_FILT_HBORDER, block_height, OD_FILT_HBORDER,
OD_DERING_VERY_LARGE);
(MI_SIZE_64X64 << mi_high_l2[pli]) + 2 * CDEF_VBORDER;
fill_rect(colbuf[pli], CDEF_HBORDER, block_height, CDEF_HBORDER,
CDEF_VERY_LARGE);
}
dering_left = 1;
for (sbc = 0; sbc < nhsb; sbc++) {
int level, clpf_strength;
int uv_level, uv_clpf_strength;
cdef_left = 1;
for (fbc = 0; fbc < nhfb; fbc++) {
int level, sec_strength;
int uv_level, uv_sec_strength;
int nhb, nvb;
int cstart = 0;
curr_row_dering[sbc] = 0;
if (cm->mi_grid_visible[MI_SIZE_64X64 * sbr * cm->mi_stride +
MI_SIZE_64X64 * sbc] == NULL ||
cm->mi_grid_visible[MI_SIZE_64X64 * sbr * cm->mi_stride +
MI_SIZE_64X64 * sbc]
curr_row_cdef[fbc] = 0;
if (cm->mi_grid_visible[MI_SIZE_64X64 * fbr * cm->mi_stride +
MI_SIZE_64X64 * fbc] == NULL ||
cm->mi_grid_visible[MI_SIZE_64X64 * fbr * cm->mi_stride +
MI_SIZE_64X64 * fbc]
->mbmi.cdef_strength == -1) {
dering_left = 0;
cdef_left = 0;
continue;
}
if (!dering_left) cstart = -OD_FILT_HBORDER;
nhb = AOMMIN(MI_SIZE_64X64, cm->mi_cols - MI_SIZE_64X64 * sbc);
nvb = AOMMIN(MI_SIZE_64X64, cm->mi_rows - MI_SIZE_64X64 * sbr);
if (!cdef_left) cstart = -CDEF_HBORDER;
nhb = AOMMIN(MI_SIZE_64X64, cm->mi_cols - MI_SIZE_64X64 * fbc);
nvb = AOMMIN(MI_SIZE_64X64, cm->mi_rows - MI_SIZE_64X64 * fbr);
int tile_top, tile_left, tile_bottom, tile_right;
int mi_idx = MI_SIZE_64X64 * sbr * cm->mi_stride + MI_SIZE_64X64 * sbc;
int mi_idx = MI_SIZE_64X64 * fbr * cm->mi_stride + MI_SIZE_64X64 * fbc;
MODE_INFO *const mi_tl = cm->mi + mi_idx;
BOUNDARY_TYPE boundary_tl = mi_tl->mbmi.boundary_info;
tile_top = boundary_tl & TILE_ABOVE_BOUNDARY;
tile_left = boundary_tl & TILE_LEFT_BOUNDARY;
if (sbr != nvsb - 1 &&
if (fbr != nvfb - 1 &&
(&cm->mi[mi_idx + (MI_SIZE_64X64 - 1) * cm->mi_stride]))
tile_bottom = cm->mi[mi_idx + (MI_SIZE_64X64 - 1) * cm->mi_stride]
.mbmi.boundary_info &
......@@ -239,197 +238,189 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
else
tile_bottom = 1;
if (sbc != nhsb - 1 && (&cm->mi[mi_idx + MI_SIZE_64X64 - 1]))
if (fbc != nhfb - 1 && (&cm->mi[mi_idx + MI_SIZE_64X64 - 1]))
tile_right = cm->mi[mi_idx + MI_SIZE_64X64 - 1].mbmi.boundary_info &
TILE_RIGHT_BOUNDARY;
else
tile_right = 1;
const int mbmi_cdef_strength =
cm->mi_grid_visible[MI_SIZE_64X64 * sbr * cm->mi_stride +
MI_SIZE_64X64 * sbc]
cm->mi_grid_visible[MI_SIZE_64X64 * fbr * cm->mi_stride +
MI_SIZE_64X64 * fbc]
->mbmi.cdef_strength;
level = cm->cdef_strengths[mbmi_cdef_strength] / CLPF_STRENGTHS;
clpf_strength = cm->cdef_strengths[mbmi_cdef_strength] % CLPF_STRENGTHS;
clpf_strength += clpf_strength == 3;
uv_level = cm->cdef_uv_strengths[mbmi_cdef_strength] / CLPF_STRENGTHS;
uv_clpf_strength =
cm->cdef_uv_strengths[mbmi_cdef_strength] % CLPF_STRENGTHS;
uv_clpf_strength += uv_clpf_strength == 3;
if ((level == 0 && clpf_strength == 0 && uv_level == 0 &&
uv_clpf_strength == 0) ||
(dering_count = sb_compute_dering_list(
cm, sbr * MI_SIZE_64X64, sbc * MI_SIZE_64X64, dlist,
level = cm->cdef_strengths[mbmi_cdef_strength] / CDEF_SEC_STRENGTHS;
sec_strength =
cm->cdef_strengths[mbmi_cdef_strength] % CDEF_SEC_STRENGTHS;
sec_strength += sec_strength == 3;
uv_level = cm->cdef_uv_strengths[mbmi_cdef_strength] / CDEF_SEC_STRENGTHS;
uv_sec_strength =
cm->cdef_uv_strengths[mbmi_cdef_strength] % CDEF_SEC_STRENGTHS;
uv_sec_strength += uv_sec_strength == 3;
if ((level == 0 && sec_strength == 0 && uv_level == 0 &&
uv_sec_strength == 0) ||
(cdef_count = sb_compute_cdef_list(
cm, fbr * MI_SIZE_64X64, fbc * MI_SIZE_64X64, dlist,
get_filter_skip(level) || get_filter_skip(uv_level))) == 0) {
dering_left = 0;
cdef_left = 0;
continue;
}
curr_row_dering[sbc] = 1;
curr_row_cdef[fbc] = 1;
for (pli = 0; pli < nplanes; pli++) {
uint16_t dst[MAX_SB_SIZE * MAX_SB_SIZE];
uint16_t dst[CDEF_BLOCKSIZE * CDEF_BLOCKSIZE];
int coffset;
int rend, cend;
int clpf_damping = cm->cdef_clpf_damping;
int dering_damping = cm->cdef_dering_damping;
int pri_damping = cm->cdef_pri_damping;
int sec_damping = cm->cdef_sec_damping;
int hsize = nhb << mi_wide_l2[pli];
int vsize = nvb << mi_high_l2[pli];
if (pli) {
if (chroma_dering)
if (chroma_cdef)
level = uv_level;
else
level = 0;
clpf_strength = uv_clpf_strength;
sec_strength = uv_sec_strength;
}
if (sbc == nhsb - 1)
if (fbc == nhfb - 1)
cend = hsize;
else
cend = hsize + OD_FILT_HBORDER;
cend = hsize + CDEF_HBORDER;
if (sbr == nvsb - 1)
if (fbr == nvfb - 1)
rend = vsize;
else
rend = vsize + OD_FILT_VBORDER;
rend = vsize + CDEF_VBORDER;
coffset = sbc * MI_SIZE_64X64 << mi_wide_l2[pli];
if (sbc == nhsb - 1) {
coffset = fbc * MI_SIZE_64X64 << mi_wide_l2[pli];
if (fbc == nhfb - 1) {
/* On the last superblock column, fill in the right border with
OD_DERING_VERY_LARGE to avoid filtering with the outside. */
fill_rect(&src[cend + OD_FILT_HBORDER], OD_FILT_BSTRIDE,
rend + OD_FILT_VBORDER, hsize + OD_FILT_HBORDER - cend,
OD_DERING_VERY_LARGE);
CDEF_VERY_LARGE to avoid filtering with the outside. */
fill_rect(&src[cend + CDEF_HBORDER], CDEF_BSTRIDE,
rend + CDEF_VBORDER, hsize + CDEF_HBORDER - cend,
CDEF_VERY_LARGE);
}
if (sbr == nvsb - 1) {
if (fbr == nvfb - 1) {
/* On the last superblock row, fill in the bottom border with
OD_DERING_VERY_LARGE to avoid filtering with the outside. */
fill_rect(&src[(rend + OD_FILT_VBORDER) * OD_FILT_BSTRIDE],
OD_FILT_BSTRIDE, OD_FILT_VBORDER,
hsize + 2 * OD_FILT_HBORDER, OD_DERING_VERY_LARGE);
CDEF_VERY_LARGE to avoid filtering with the outside. */
fill_rect(&src[(rend + CDEF_VBORDER) * CDEF_BSTRIDE], CDEF_BSTRIDE,
CDEF_VBORDER, hsize + 2 * CDEF_HBORDER, CDEF_VERY_LARGE);
}
/* Copy in the pixels we need from the current superblock for
deringing.*/
copy_sb8_16(
cm,
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER + cstart],
OD_FILT_BSTRIDE, xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * sbr, coffset + cstart,
xd->plane[pli].dst.stride, rend, cend - cstart);
if (!prev_row_dering[sbc]) {
copy_sb8_16(
cm, &src[OD_FILT_HBORDER], OD_FILT_BSTRIDE,
xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * sbr - OD_FILT_VBORDER,
coffset, xd->plane[pli].dst.stride, OD_FILT_VBORDER, hsize);
} else if (sbr > 0) {
copy_rect(&src[OD_FILT_HBORDER], OD_FILT_BSTRIDE,
&linebuf[pli][coffset], stride, OD_FILT_VBORDER, hsize);
copy_sb8_16(cm,
&src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER + cstart],
CDEF_BSTRIDE, xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * fbr, coffset + cstart,
xd->plane[pli].dst.stride, rend, cend - cstart);
if (!prev_row_cdef[fbc]) {
copy_sb8_16(cm, &src[CDEF_HBORDER], CDEF_BSTRIDE,
xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * fbr - CDEF_VBORDER,
coffset, xd->plane[pli].dst.stride, CDEF_VBORDER, hsize);
} else if (fbr > 0) {
copy_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, &linebuf[pli][coffset],
stride, CDEF_VBORDER, hsize);
} else {
fill_rect(&src[OD_FILT_HBORDER], OD_FILT_BSTRIDE, OD_FILT_VBORDER,
hsize, OD_DERING_VERY_LARGE);
fill_rect(&src[CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER, hsize,
CDEF_VERY_LARGE);
}
if (!prev_row_dering[sbc - 1]) {
copy_sb8_16(
cm, src, OD_FILT_BSTRIDE, xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * sbr - OD_FILT_VBORDER,
coffset - OD_FILT_HBORDER, xd->plane[pli].dst.stride,
OD_FILT_VBORDER, OD_FILT_HBORDER);
} else if (sbr > 0 && sbc > 0) {
copy_rect(src, OD_FILT_BSTRIDE,
&linebuf[pli][coffset - OD_FILT_HBORDER], stride,
OD_FILT_VBORDER, OD_FILT_HBORDER);
if (!prev_row_cdef[fbc - 1]) {
copy_sb8_16(cm, src, CDEF_BSTRIDE, xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * fbr - CDEF_VBORDER,
coffset - CDEF_HBORDER, xd->plane[pli].dst.stride,
CDEF_VBORDER, CDEF_HBORDER);
} else if (fbr > 0 && fbc > 0) {
copy_rect(src, CDEF_BSTRIDE, &linebuf[pli][coffset - CDEF_HBORDER],
stride, CDEF_VBORDER, CDEF_HBORDER);
} else {
fill_rect(src, OD_FILT_BSTRIDE, OD_FILT_VBORDER, OD_FILT_HBORDER,
OD_DERING_VERY_LARGE);
fill_rect(src, CDEF_BSTRIDE, CDEF_VBORDER, CDEF_HBORDER,
CDEF_VERY_LARGE);
}
if (!prev_row_dering[sbc + 1]) {
copy_sb8_16(
cm, &src[OD_FILT_HBORDER + (nhb << mi_wide_l2[pli])],
OD_FILT_BSTRIDE, xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * sbr - OD_FILT_VBORDER,
coffset + hsize, xd->plane[pli].dst.stride, OD_FILT_VBORDER,
OD_FILT_HBORDER);
} else if (sbr > 0 && sbc < nhsb - 1) {
copy_rect(&src[hsize + OD_FILT_HBORDER], OD_FILT_BSTRIDE,
&linebuf[pli][coffset + hsize], stride, OD_FILT_VBORDER,
OD_FILT_HBORDER);
if (!prev_row_cdef[fbc + 1]) {
copy_sb8_16(cm, &src[CDEF_HBORDER + (nhb << mi_wide_l2[pli])],
CDEF_BSTRIDE, xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * fbr - CDEF_VBORDER,
coffset + hsize, xd->plane[pli].dst.stride, CDEF_VBORDER,
CDEF_HBORDER);
} else if (fbr > 0 && fbc < nhfb - 1) {
copy_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE,
&linebuf[pli][coffset + hsize], stride, CDEF_VBORDER,
CDEF_HBORDER);
} else {
fill_rect(&src[hsize + OD_FILT_HBORDER], OD_FILT_BSTRIDE,
OD_FILT_VBORDER, OD_FILT_HBORDER, OD_DERING_VERY_LARGE);
fill_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE, CDEF_VBORDER,
CDEF_HBORDER, CDEF_VERY_LARGE);
}
if (dering_left) {
if (cdef_left) {
/* If we deringed the superblock on the left then we need to copy in
saved pixels. */
copy_rect(src, OD_FILT_BSTRIDE, colbuf[pli], OD_FILT_HBORDER,
rend + OD_FILT_VBORDER, OD_FILT_HBORDER);
copy_rect(src, CDEF_BSTRIDE, colbuf[pli], CDEF_HBORDER,
rend + CDEF_VBORDER, CDEF_HBORDER);
}
/* Saving pixels in case we need to dering the superblock on the
right. */
copy_rect(colbuf[pli], OD_FILT_HBORDER, src + hsize, OD_FILT_BSTRIDE,
rend + OD_FILT_VBORDER, OD_FILT_HBORDER);
copy_rect(colbuf[pli], CDEF_HBORDER, src + hsize, CDEF_BSTRIDE,
rend + CDEF_VBORDER, CDEF_HBORDER);
copy_sb8_16(
cm, &linebuf[pli][coffset], stride, xd->plane[pli].dst.buf,
(MI_SIZE_64X64 << mi_high_l2[pli]) * (sbr + 1) - OD_FILT_VBORDER,
coffset, xd->plane[pli].dst.stride, OD_FILT_VBORDER, hsize);
(MI_SIZE_64X64 << mi_high_l2[pli]) * (fbr + 1) - CDEF_VBORDER,
coffset, xd->plane[pli].dst.stride, CDEF_VBORDER, hsize);
if (tile_top) {
fill_rect(src, OD_FILT_BSTRIDE, OD_FILT_VBORDER,
hsize + 2 * OD_FILT_HBORDER, OD_DERING_VERY_LARGE);
fill_rect(src, CDEF_BSTRIDE, CDEF_VBORDER, hsize + 2 * CDEF_HBORDER,
CDEF_VERY_LARGE);
}
if (tile_left) {
fill_rect(src, OD_FILT_BSTRIDE, vsize + 2 * OD_FILT_VBORDER,
OD_FILT_HBORDER, OD_DERING_VERY_LARGE);
fill_rect(src, CDEF_BSTRIDE, vsize + 2 * CDEF_VBORDER, CDEF_HBORDER,
CDEF_VERY_LARGE);
}
if (tile_bottom) {
fill_rect(&src[(vsize + OD_FILT_VBORDER) * OD_FILT_BSTRIDE],
OD_FILT_BSTRIDE, OD_FILT_VBORDER,
hsize + 2 * OD_FILT_HBORDER, OD_DERING_VERY_LARGE);
fill_rect(&src[(vsize + CDEF_VBORDER) * CDEF_BSTRIDE], CDEF_BSTRIDE,
CDEF_VBORDER, hsize + 2 * CDEF_HBORDER, CDEF_VERY_LARGE);
}
if (tile_right) {
fill_rect(&src[hsize + OD_FILT_HBORDER], OD_FILT_BSTRIDE,
vsize + 2 * OD_FILT_VBORDER, OD_FILT_HBORDER,
OD_DERING_VERY_LARGE);
fill_rect(&src[hsize + CDEF_HBORDER], CDEF_BSTRIDE,
vsize + 2 * CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
}
#if CONFIG_HIGHBITDEPTH
if (cm->use_highbitdepth) {
od_dering(
cdef_filter_fb(
(uint8_t *)&CONVERT_TO_SHORTPTR(
xd->plane[pli]
.dst.buf)[xd->plane[pli].dst.stride *
(MI_SIZE_64X64 * sbr << mi_high_l2[pli]) +
(sbc * MI_SIZE_64X64 << mi_wide_l2[pli])],
(MI_SIZE_64X64 * fbr << mi_high_l2[pli]) +
(fbc * MI_SIZE_64X64 << mi_wide_l2[pli])],
xd->plane[pli].dst.stride, dst,
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER],
xdec[pli], ydec[pli], dir, NULL, var, pli, dlist, dering_count,
level, clpf_strength, clpf_damping, dering_damping, coeff_shift,
0, 1);
&src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER], xdec[pli],
ydec[pli], dir, NULL, var, pli, dlist, cdef_count, level,
sec_strength, sec_damping, pri_damping, coeff_shift, 0, 1);
} else {
#endif
od_dering(&xd->plane[pli]
.dst.buf[xd->plane[pli].dst.stride *
(MI_SIZE_64X64 * sbr << mi_high_l2[pli]) +
(sbc * MI_SIZE_64X64 << mi_wide_l2[pli])],
xd->plane[pli].dst.stride, dst,
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER],
xdec[pli], ydec[pli], dir, NULL, var, pli, dlist,
dering_count, level, clpf_strength, clpf_damping,
dering_damping, coeff_shift, 0, 0);
cdef_filter_fb(
&xd->plane[pli]
.dst.buf[xd->plane[pli].dst.stride *
(MI_SIZE_64X64 * fbr << mi_high_l2[pli]) +
(fbc * MI_SIZE_64X64 << mi_wide_l2[pli])],
xd->plane[pli].dst.stride, dst,
&src[CDEF_VBORDER * CDEF_BSTRIDE + CDEF_HBORDER], xdec[pli],
ydec[pli], dir, NULL, var, pli, dlist, cdef_count, level,
sec_strength, sec_damping, pri_damping, coeff_shift, 0, 0);
#if CONFIG_HIGHBITDEPTH
}
#endif
}
dering_left = 1;
cdef_left = 1;
}
{
unsigned char *tmp;
tmp = prev_row_dering;
prev_row_dering = curr_row_dering;
curr_row_dering = tmp;
tmp = prev_row_cdef;
prev_row_cdef = curr_row_cdef;
curr_row_cdef = tmp;
}
}
aom_free(row_dering);
aom_free(row_cdef);
for (pli = 0; pli < nplanes; pli++) {
aom_free(linebuf[pli]);
aom_free(colbuf[pli]);
......
......@@ -8,20 +8,19 @@
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#ifndef AV1_COMMON_DERING_H_
#define AV1_COMMON_DERING_H_
#ifndef AV1_COMMON_CDEF_H_
#define AV1_COMMON_CDEF_H_
#define CDEF_STRENGTH_BITS 7
#define DERING_STRENGTHS 32
#define CLPF_STRENGTHS 4
#define CDEF_PRI_STRENGTHS 32
#define CDEF_SEC_STRENGTHS 4
#include "./aom_config.h"
#include "aom/aom_integer.h"
#include "aom_ports/mem.h"
#include "av1/common/od_dering.h"
#include "av1/common/cdef_block.h"
#include "av1/common/onyxc_int.h"
#include "./od_dering.h"
static INLINE int sign(int i) { return i < 0 ? -1 : 1; }
......@@ -40,8 +39,8 @@ extern "C" {
#endif