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) ...@@ -236,12 +236,11 @@ if (CONFIG_CDEF)
${AOM_AV1_COMMON_SOURCES} ${AOM_AV1_COMMON_SOURCES}
"${AOM_ROOT}/av1/common/clpf.c" "${AOM_ROOT}/av1/common/clpf.c"
"${AOM_ROOT}/av1/common/clpf_simd.h" "${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.c"
"${AOM_ROOT}/av1/common/cdef.h" "${AOM_ROOT}/av1/common/cdef.h"
"${AOM_ROOT}/av1/common/od_dering.c" "${AOM_ROOT}/av1/common/cdef_block.c"
"${AOM_ROOT}/av1/common/od_dering.h" "${AOM_ROOT}/av1/common/cdef_block.h"
"${AOM_ROOT}/av1/common/od_dering_simd.h") "${AOM_ROOT}/av1/common/cdef_block_simd.h")
set(AOM_AV1_ENCODER_SOURCES set(AOM_AV1_ENCODER_SOURCES
${AOM_AV1_ENCODER_SOURCES} ${AOM_AV1_ENCODER_SOURCES}
...@@ -250,22 +249,22 @@ if (CONFIG_CDEF) ...@@ -250,22 +249,22 @@ if (CONFIG_CDEF)
set(AOM_AV1_COMMON_INTRIN_SSE2 set(AOM_AV1_COMMON_INTRIN_SSE2
${AOM_AV1_COMMON_INTRIN_SSE2} ${AOM_AV1_COMMON_INTRIN_SSE2}
"${AOM_ROOT}/av1/common/clpf_sse2.c" "${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 set(AOM_AV1_COMMON_INTRIN_SSSE3
${AOM_AV1_COMMON_INTRIN_SSSE3} ${AOM_AV1_COMMON_INTRIN_SSSE3}
"${AOM_ROOT}/av1/common/clpf_ssse3.c" "${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 set(AOM_AV1_COMMON_INTRIN_SSE4_1
${AOM_AV1_COMMON_INTRIN_SSE4_1} ${AOM_AV1_COMMON_INTRIN_SSE4_1}
"${AOM_ROOT}/av1/common/clpf_sse4.c" "${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 set(AOM_AV1_COMMON_INTRIN_NEON
${AOM_AV1_COMMON_INTRIN_NEON} ${AOM_AV1_COMMON_INTRIN_NEON}
"${AOM_ROOT}/av1/common/clpf_neon.c" "${AOM_ROOT}/av1/common/clpf_neon.c"
"${AOM_ROOT}/av1/common/od_dering_neon.c") "${AOM_ROOT}/av1/common/cdef_block_neon.c")
endif () endif ()
if (CONFIG_CONVOLVE_ROUND) if (CONFIG_CONVOLVE_ROUND)
......
...@@ -92,18 +92,17 @@ endif ...@@ -92,18 +92,17 @@ endif
ifeq ($(CONFIG_CDEF),yes) ifeq ($(CONFIG_CDEF),yes)
AV1_COMMON_SRCS-yes += common/clpf.c AV1_COMMON_SRCS-yes += common/clpf.c
AV1_COMMON_SRCS-yes += common/clpf_simd.h 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_SSE2) += common/clpf_sse2.c
AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/clpf_ssse3.c AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/clpf_ssse3.c
AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/clpf_sse4.c AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/clpf_sse4.c
AV1_COMMON_SRCS-$(HAVE_NEON) += common/clpf_neon.c AV1_COMMON_SRCS-$(HAVE_NEON) += common/clpf_neon.c
AV1_COMMON_SRCS-$(HAVE_SSE2) += common/od_dering_sse2.c AV1_COMMON_SRCS-$(HAVE_SSE2) += common/cdef_block_sse2.c
AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/od_dering_ssse3.c AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/cdef_block_ssse3.c
AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/od_dering_sse4.c AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/cdef_block_sse4.c
AV1_COMMON_SRCS-$(HAVE_NEON) += common/od_dering_neon.c AV1_COMMON_SRCS-$(HAVE_NEON) += common/cdef_block_neon.c
AV1_COMMON_SRCS-yes += common/od_dering.c AV1_COMMON_SRCS-yes += common/cdef_block.c
AV1_COMMON_SRCS-yes += common/od_dering.h AV1_COMMON_SRCS-yes += common/cdef_block.h
AV1_COMMON_SRCS-yes += common/od_dering_simd.h AV1_COMMON_SRCS-yes += common/cdef_block_simd.h
AV1_COMMON_SRCS-yes += common/cdef.c AV1_COMMON_SRCS-yes += common/cdef.c
AV1_COMMON_SRCS-yes += common/cdef.h AV1_COMMON_SRCS-yes += common/cdef.h
endif endif
......
...@@ -24,7 +24,6 @@ struct search_site_config; ...@@ -24,7 +24,6 @@ struct search_site_config;
struct mv; struct mv;
union int_mv; union int_mv;
struct yv12_buffer_config; struct yv12_buffer_config;
typedef uint16_t od_dering_in;
EOF EOF
} }
forward_decls qw/av1_common_forward_decls/; forward_decls qw/av1_common_forward_decls/;
...@@ -561,9 +560,9 @@ if (aom_config("CONFIG_CDEF") eq "yes") { ...@@ -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_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_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/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/int cdef_find_dir/, "const uint16_t *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 cdef_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/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_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"; 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") { ...@@ -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_hblock_hbd sse2 ssse3 sse4_1 neon/;
specialize qw/aom_clpf_block 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/aom_clpf_hblock sse2 ssse3 sse4_1 neon/;
specialize qw/od_dir_find8 sse2 ssse3 sse4_1 neon/; specialize qw/cdef_find_dir sse2 ssse3 sse4_1 neon/;
specialize qw/od_filter_dering_direction_4x4 sse2 ssse3 sse4_1 neon/; specialize qw/cdef_direction_4x4 sse2 ssse3 sse4_1 neon/;
specialize qw/od_filter_dering_direction_8x8 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_8x8_16bit_to_8bit sse2 ssse3 sse4_1 neon/;
specialize qw/copy_4x4_16bit_to_8bit sse2 ssse3 sse4_1 neon/; specialize qw/copy_4x4_16bit_to_8bit sse2 ssse3 sse4_1 neon/;
......
This diff is collapsed.
...@@ -8,20 +8,19 @@ ...@@ -8,20 +8,19 @@
* Media Patent License 1.0 was not distributed with this source code in the * 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. * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/ */
#ifndef AV1_COMMON_DERING_H_ #ifndef AV1_COMMON_CDEF_H_
#define AV1_COMMON_DERING_H_ #define AV1_COMMON_CDEF_H_
#define CDEF_STRENGTH_BITS 7 #define CDEF_STRENGTH_BITS 7
#define DERING_STRENGTHS 32 #define CDEF_PRI_STRENGTHS 32
#define CLPF_STRENGTHS 4 #define CDEF_SEC_STRENGTHS 4
#include "./aom_config.h" #include "./aom_config.h"
#include "aom/aom_integer.h" #include "aom/aom_integer.h"
#include "aom_ports/mem.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 "av1/common/onyxc_int.h"
#include "./od_dering.h"
static INLINE int sign(int i) { return i < 0 ? -1 : 1; } static INLINE int sign(int i) { return i < 0 ? -1 : 1; }
...@@ -40,8 +39,8 @@ extern "C" { ...@@ -40,8 +39,8 @@ extern "C" {
#endif #endif
int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col); int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col);
int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col, int sb_compute_cdef_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
dering_list *dlist, int filter_skip); cdef_list *dlist, int filter_skip);
void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd); void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd);
void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref, void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
...@@ -50,4 +49,4 @@ void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref, ...@@ -50,4 +49,4 @@ void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
#endif // AV1_COMMON_DERING_H_ #endif // AV1_COMMON_CDEF_H_
...@@ -21,17 +21,15 @@ ...@@ -21,17 +21,15 @@
#include "./cdef.h" #include "./cdef.h"
/* Generated from gen_filter_tables.c. */ /* Generated from gen_filter_tables.c. */
const int OD_DIRECTION_OFFSETS_TABLE[8][3] = { const int cdef_directions[8][3] = {
{ -1 * OD_FILT_BSTRIDE + 1, -2 * OD_FILT_BSTRIDE + 2, { -1 * CDEF_BSTRIDE + 1, -2 * CDEF_BSTRIDE + 2, -3 * CDEF_BSTRIDE + 3 },
-3 * OD_FILT_BSTRIDE + 3 }, { 0 * CDEF_BSTRIDE + 1, -1 * CDEF_BSTRIDE + 2, -1 * CDEF_BSTRIDE + 3 },
{ 0 * OD_FILT_BSTRIDE + 1, -1 * OD_FILT_BSTRIDE + 2, { 0 * CDEF_BSTRIDE + 1, 0 * CDEF_BSTRIDE + 2, 0 * CDEF_BSTRIDE + 3 },
-1 * OD_FILT_BSTRIDE + 3 }, { 0 * CDEF_BSTRIDE + 1, 1 * CDEF_BSTRIDE + 2, 1 * CDEF_BSTRIDE + 3 },
{ 0 * OD_FILT_BSTRIDE + 1, 0 * OD_FILT_BSTRIDE + 2, 0 * OD_FILT_BSTRIDE + 3 }, { 1 * CDEF_BSTRIDE + 1, 2 * CDEF_BSTRIDE + 2, 3 * CDEF_BSTRIDE + 3 },
{ 0 * OD_FILT_BSTRIDE + 1, 1 * OD_FILT_BSTRIDE + 2, 1 * OD_FILT_BSTRIDE + 3 }, { 1 * CDEF_BSTRIDE + 0, 2 * CDEF_BSTRIDE + 1, 3 * CDEF_BSTRIDE + 1 },
{ 1 * OD_FILT_BSTRIDE + 1, 2 * OD_FILT_BSTRIDE + 2, 3 * OD_FILT_BSTRIDE + 3 }, { 1 * CDEF_BSTRIDE + 0, 2 * CDEF_BSTRIDE + 0, 3 * CDEF_BSTRIDE + 0 },
{ 1 * OD_FILT_BSTRIDE + 0, 2 * OD_FILT_BSTRIDE + 1, 3 * OD_FILT_BSTRIDE + 1 }, { 1 * CDEF_BSTRIDE + 0, 2 * CDEF_BSTRIDE - 1, 3 * CDEF_BSTRIDE - 1 }
{ 1 * OD_FILT_BSTRIDE + 0, 2 * OD_FILT_BSTRIDE + 0, 3 * OD_FILT_BSTRIDE + 0 },
{ 1 * OD_FILT_BSTRIDE + 0, 2 * OD_FILT_BSTRIDE - 1, 3 * OD_FILT_BSTRIDE - 1 },
}; };
/* Detect direction. 0 means 45-degree up-right, 2 is horizontal, and so on. /* Detect direction. 0 means 45-degree up-right, 2 is horizontal, and so on.
...@@ -41,8 +39,8 @@ const int OD_DIRECTION_OFFSETS_TABLE[8][3] = { ...@@ -41,8 +39,8 @@ const int OD_DIRECTION_OFFSETS_TABLE[8][3] = {
in a particular direction. Since each direction have the same sum(x^2) term, in a particular direction. Since each direction have the same sum(x^2) term,
that term is never computed. See Section 2, step 2, of: that term is never computed. See Section 2, step 2, of:
http://jmvalin.ca/notes/intra_paint.pdf */ http://jmvalin.ca/notes/intra_paint.pdf */
int od_dir_find8_c(const uint16_t *img, int stride, int32_t *var, int cdef_find_dir_c(const uint16_t *img, int stride, int32_t *var,
int coeff_shift) { int coeff_shift) {
int i; int i;
int32_t cost[8] = { 0 }; int32_t cost[8] = { 0 };
int partial[8][15] = { { 0 } }; int partial[8][15] = { { 0 } };
...@@ -113,9 +111,8 @@ int od_dir_find8_c(const uint16_t *img, int stride, int32_t *var, ...@@ -113,9 +111,8 @@ int od_dir_find8_c(const uint16_t *img, int stride, int32_t *var,
} }
/* Smooth in the direction detected. */ /* Smooth in the direction detected. */
void od_filter_dering_direction_8x8_c(uint16_t *y, int ystride, void cdef_direction_8x8_c(uint16_t *y, int ystride, const uint16_t *in,
const uint16_t *in, int threshold, int threshold, int dir, int damping) {
int dir, int damping) {
int i; int i;
int j; int j;
int k; int k;
...@@ -125,15 +122,13 @@ void od_filter_dering_direction_8x8_c(uint16_t *y, int ystride, ...@@ -125,15 +122,13 @@ void od_filter_dering_direction_8x8_c(uint16_t *y, int ystride,
int16_t sum; int16_t sum;
int16_t xx; int16_t xx;
int16_t yy; int16_t yy;
xx = in[i * OD_FILT_BSTRIDE + j]; xx = in[i * CDEF_BSTRIDE + j];
sum = 0; sum = 0;
for (k = 0; k < 3; k++) { for (k = 0; k < 3; k++) {
int16_t p0; int16_t p0;
int16_t p1; int16_t p1;
p0 = in[i * OD_FILT_BSTRIDE + j + OD_DIRECTION_OFFSETS_TABLE[dir][k]] - p0 = in[i * CDEF_BSTRIDE + j + cdef_directions[dir][k]] - xx;
xx; p1 = in[i * CDEF_BSTRIDE + j - cdef_directions[dir][k]] - xx;
p1 = in[i * OD_FILT_BSTRIDE + j - OD_DIRECTION_OFFSETS_TABLE[dir][k]] -
xx;
sum += taps[k] * constrain(p0, threshold, damping); sum += taps[k] * constrain(p0, threshold, damping);
sum += taps[k] * constrain(p1, threshold, damping); sum += taps[k] * constrain(p1, threshold, damping);
} }
...@@ -145,9 +140,8 @@ void od_filter_dering_direction_8x8_c(uint16_t *y, int ystride, ...@@ -145,9 +140,8 @@ void od_filter_dering_direction_8x8_c(uint16_t *y, int ystride,
} }
/* Smooth in the direction detected. */ /* Smooth in the direction detected. */
void od_filter_dering_direction_4x4_c(uint16_t *y, int ystride, void cdef_direction_4x4_c(uint16_t *y, int ystride, const uint16_t *in,
const uint16_t *in, int threshold, int threshold, int dir, int damping) {
int dir, int damping) {
int i; int i;
int j; int j;
int k; int k;
...@@ -157,15 +151,13 @@ void od_filter_dering_direction_4x4_c(uint16_t *y, int ystride, ...@@ -157,15 +151,13 @@ void od_filter_dering_direction_4x4_c(uint16_t *y, int ystride,
int16_t sum; int16_t sum;
int16_t xx; int16_t xx;
int16_t yy; int16_t yy;
xx = in[i * OD_FILT_BSTRIDE + j]; xx = in[i * CDEF_BSTRIDE + j];
sum = 0; sum = 0;
for (k = 0; k < 2; k++) { for (k = 0; k < 2; k++) {
int16_t p0; int16_t p0;
int16_t p1; int16_t p1;
p0 = in[i * OD_FILT_BSTRIDE + j + OD_DIRECTION_OFFSETS_TABLE[dir][k]] - p0 = in[i * CDEF_BSTRIDE + j + cdef_directions[dir][k]] - xx;
xx; p1 = in[i * CDEF_BSTRIDE + j - cdef_directions[dir][k]] - xx;
p1 = in[i * OD_FILT_BSTRIDE + j - OD_DIRECTION_OFFSETS_TABLE[dir][k]] -
xx;
sum += taps[k] * constrain(p0, threshold, damping); sum += taps[k] * constrain(p0, threshold, damping);
sum += taps[k] * constrain(p1, threshold, damping); sum += taps[k] * constrain(p1, threshold, damping);
} }
...@@ -176,16 +168,16 @@ void od_filter_dering_direction_4x4_c(uint16_t *y, int ystride, ...@@ -176,16 +168,16 @@ void od_filter_dering_direction_4x4_c(uint16_t *y, int ystride,
} }
} }
/* Compute deringing filter threshold for an 8x8 block based on the /* Compute the primary filter strength for an 8x8 block based on the
directional variance difference. A high variance difference means that we directional variance difference. A high variance difference means
have a highly directional pattern (e.g. a high contrast edge), so we can that we have a highly directional pattern (e.g. a high contrast
apply more deringing. A low variance means that we either have a low edge), so we can apply more deringing. A low variance means that we
contrast edge, or a non-directional texture, so we want to be careful not either have a low contrast edge, or a non-directional texture, so
to blur. */ we want to be careful not to blur. */
static INLINE int od_adjust_thresh(int threshold, int32_t var) { static INLINE int adjust_strength(int strength, int32_t var) {
const int i = var >> 6 ? AOMMIN(get_msb(var >> 6), 12) : 0; const int i = var >> 6 ? AOMMIN(get_msb(var >> 6), 12) : 0;
/* We use the variance of 8x8 blocks to adjust the threshold. */ /* We use the variance of 8x8 blocks to adjust the strength. */
return var ? (threshold * (4 + i) + 8) >> 4 : 0; return var ? (strength * (4 + i) + 8) >> 4 : 0;
} }
void copy_8x8_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, void copy_8x8_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src,
...@@ -202,20 +194,20 @@ void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, ...@@ -202,20 +194,20 @@ void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src,
for (j = 0; j < 4; j++) dst[i * dstride + j] = src[i * sstride + j]; for (j = 0; j < 4; j++) dst[i * dstride + j] = src[i * sstride + j];
} }
static void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride, static void copy_block_16bit_to_16bit(uint16_t *dst, int dstride, uint16_t *src,
uint16_t *src, dering_list *dlist, cdef_list *dlist, int cdef_count,
int dering_count, int bsize) { int bsize) {
int bi, bx, by; int bi, bx, by;
if (bsize == BLOCK_8X8) { if (bsize == BLOCK_8X8) {
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_8x8_16bit_to_16bit(&dst[(by << 3) * dstride + (bx << 3)], dstride, copy_8x8_16bit_to_16bit(&dst[(by << 3) * dstride + (bx << 3)], dstride,
&src[bi << (3 + 3)], 8); &src[bi << (3 + 3)], 8);
} }
} else if (bsize == BLOCK_4X8) { } else if (bsize == BLOCK_4X8) {
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_4x4_16bit_to_16bit(&dst[(by << 3) * dstride + (bx << 2)], dstride, copy_4x4_16bit_to_16bit(&dst[(by << 3) * dstride + (bx << 2)], dstride,
...@@ -224,7 +216,7 @@ static void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride, ...@@ -224,7 +216,7 @@ static void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride,
dstride, &src[(bi << (3 + 2)) + 4 * 4], 4); dstride, &src[(bi << (3 + 2)) + 4 * 4], 4);
} }
} else if (bsize == BLOCK_8X4) { } else if (bsize == BLOCK_8X4) {
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_4x4_16bit_to_16bit(&dst[(by << 2) * dstride + (bx << 3)], dstride, copy_4x4_16bit_to_16bit(&dst[(by << 2) * dstride + (bx << 3)], dstride,
...@@ -234,7 +226,7 @@ static void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride, ...@@ -234,7 +226,7 @@ static void copy_dering_16bit_to_16bit(uint16_t *dst, int dstride,
} }
} else { } else {
assert(bsize == BLOCK_4X4); assert(bsize == BLOCK_4X4);
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_4x4_16bit_to_16bit(&dst[(by << 2) * dstride + (bx << 2)], dstride, copy_4x4_16bit_to_16bit(&dst[(by << 2) * dstride + (bx << 2)], dstride,
...@@ -259,19 +251,19 @@ void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, ...@@ -259,19 +251,19 @@ void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src,
dst[i * dstride + j] = (uint8_t)src[i * sstride + j]; dst[i * dstride + j] = (uint8_t)src[i * sstride + j];
} }
static void copy_dering_16bit_to_8bit(uint8_t *dst, int dstride, static void copy_block_16bit_to_8bit(uint8_t *dst, int dstride,
const uint16_t *src, dering_list *dlist, const uint16_t *src, cdef_list *dlist,
int dering_count, int bsize) { int cdef_count, int bsize) {
int bi, bx, by; int bi, bx, by;
if (bsize == BLOCK_8X8) { if (bsize == BLOCK_8X8) {
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_8x8_16bit_to_8bit(&dst[(by << 3) * dstride + (bx << 3)], dstride, copy_8x8_16bit_to_8bit(&dst[(by << 3) * dstride + (bx << 3)], dstride,
&src[bi << (3 + 3)], 8); &src[bi << (3 + 3)], 8);
} }
} else if (bsize == BLOCK_4X8) { } else if (bsize == BLOCK_4X8) {
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_4x4_16bit_to_8bit(&dst[(by << 3) * dstride + (bx << 2)], dstride, copy_4x4_16bit_to_8bit(&dst[(by << 3) * dstride + (bx << 2)], dstride,
...@@ -280,7 +272,7 @@ static void copy_dering_16bit_to_8bit(uint8_t *dst, int dstride, ...@@ -280,7 +272,7 @@ static void copy_dering_16bit_to_8bit(uint8_t *dst, int dstride,
dstride, &src[(bi << (3 + 2)) + 4 * 4], 4); dstride, &src[(bi << (3 + 2)) + 4 * 4], 4);
} }
} else if (bsize == BLOCK_8X4) { } else if (bsize == BLOCK_8X4) {
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_4x4_16bit_to_8bit(&dst[(by << 2) * dstride + (bx << 3)], dstride, copy_4x4_16bit_to_8bit(&dst[(by << 2) * dstride + (bx << 3)], dstride,
...@@ -290,7 +282,7 @@ static void copy_dering_16bit_to_8bit(uint8_t *dst, int dstride, ...@@ -290,7 +282,7 @@ static void copy_dering_16bit_to_8bit(uint8_t *dst, int dstride,
} }
} else { } else {
assert(bsize == BLOCK_4X4); assert(bsize == BLOCK_4X4);
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
copy_4x4_16bit_to_8bit(&dst[(by << 2) * dstride + (bx << 2)], dstride, copy_4x4_16bit_to_8bit(&dst[(by << 2) * dstride + (bx << 2)], dstride,
...@@ -305,12 +297,12 @@ int get_filter_skip(int level) { ...@@ -305,12 +297,12 @@ int get_filter_skip(int level) {
return filter_skip; return filter_skip;
} }
void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec, void cdef_filter_fb(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in,
int ydec, int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int xdec, int ydec, int dir[CDEF_NBLOCKS][CDEF_NBLOCKS],
int *dirinit, int var[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS], int *dirinit, int var[CDEF_NBLOCKS][CDEF_NBLOCKS], int pli,
int pli, dering_list *dlist, int dering_count, int level, cdef_list *dlist, int cdef_count, int level,
int clpf_strength, int clpf_damping, int dering_damping, int sec_strength, int sec_damping, int pri_damping,
int coeff_shift, int skip_dering, int hbd) { int coeff_shift, int skip_dering, int hbd) {
int bi; int bi;
int bx; int bx;
int by; int by;
...@@ -320,11 +312,10 @@ void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec, ...@@ -320,11 +312,10 @@ void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec,
int filter_skip = get_filter_skip(level); int filter_skip = get_filter_skip(level);
if (level == 1) threshold = 31 << coeff_shift; if (level == 1) threshold = 31 << coeff_shift;
od_filter_dering_direction_func filter_dering_direction[] = { cdef_direction_func cdef_direction[] = { cdef_direction_4x4,
od_filter_dering_direction_4x4, od_filter_dering_direction_8x8 cdef_direction_8x8 };
}; sec_damping += coeff_shift - (pli != AOM_PLANE_Y);
clpf_damping += coeff_shift - (pli != AOM_PLANE_Y); pri_damping += coeff_shift - (pli != AOM_PLANE_Y);
dering_damping += coeff_shift - (pli != AOM_PLANE_Y);
bsize = bsize =
ydec ? (xdec ? BLOCK_4X4 : BLOCK_8X4) : (xdec ? BLOCK_4X8 : BLOCK_8X8); ydec ? (xdec ? BLOCK_4X4 : BLOCK_8X4) : (xdec ? BLOCK_4X8 : BLOCK_8X8);
bsizex = 3 - xdec; bsizex = 3 - xdec;
...@@ -333,12 +324,11 @@ void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec, ...@@ -333,12 +324,11 @@ void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec,
if (!skip_dering) { if (!skip_dering) {
if (pli == 0) { if (pli == 0) {
if (!dirinit || !*dirinit) { if (!dirinit || !*dirinit) {
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
dir[by][bx] = dir[by][bx] = cdef_find_dir(&in[8 * by * CDEF_BSTRIDE + 8 * bx],
od_dir_find8(&in[8 * by * OD_FILT_BSTRIDE + 8 * bx], CDEF_BSTRIDE, &var[by][bx], coeff_shift);
OD_FILT_BSTRIDE, &var[by][bx], coeff_shift);
} }
if (dirinit) *dirinit = 1; if (dirinit) *dirinit = 1;
} }
...@@ -348,24 +338,23 @@ void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec, ...@@ -348,24 +338,23 @@ void od_dering(uint8_t *dst, int dstride, uint16_t *y, uint16_t *in, int xdec,
// something out in y[] later. // something out in y[] later.
if (threshold != 0) { if (threshold != 0) {
assert(bsize == BLOCK_8X8 || bsize == BLOCK_4X4); assert(bsize == BLOCK_8X8 || bsize == BLOCK_4X4);
for (bi = 0; bi < dering_count; bi++) { for (bi = 0; bi < cdef_count; bi++) {
int t = !filter_skip && dlist[bi].skip ? 0 : threshold; int t = !filter_skip && dlist[bi].skip ? 0 : threshold;
by = dlist[bi].by; by = dlist[bi].by;
bx = dlist[bi].bx; bx = dlist[bi].bx;
(filter_dering_direction[bsize == BLOCK_8X8])( (cdef_direction[bsize == BLOCK_8X8])(
&y[bi << (bsizex + bsizey)], 1 << bsizex, &y[bi << (bsizex + bsizey)], 1 << bsizex,
&in[(by * OD_FILT_BSTRIDE << bsizey) + (bx << bsizex)], &in[(by * CDEF_BSTRIDE << bsizey) + (bx << bsizex)],
pli ? t : od_adjust_thresh(t, var[by][bx]), dir[by][bx], pli ? t : adjust_strength(t, var[by][bx]), dir[by][bx],
dering_damping); pri_damping);
} }
} }
} }
if (clpf_strength) { if (sec_strength) {
if (threshold && !skip_dering) if (threshold && !skip_dering)
copy_dering_16bit_to_16bit(in, OD_FILT_BSTRIDE, y, dlist, dering_count, copy_block_16bit_to_16bit(in, CDEF_BSTRIDE, y, dlist, cdef_count, bsize);
bsize);