#include <string.h>
#include <tuple>
#include "gtest/gtest.h"
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/aom_filter.h"
#include "aom_mem/aom_mem.h"
#include "aom_ports/aom_timer.h"
#include "aom_ports/mem.h"
#include "av1/common/filter.h"
#include "test/acm_random.h"
#include "test/register_state_check.h"
#include "test/util.h"
namespace {
static const unsigned int kMaxDimension = …;
static const int kDataAlignment = …;
static const int kOuterBlockSize = …;
static const int kInputStride = …;
static const int kOutputStride = …;
static const int kInputBufferSize = …;
static const int kOutputBufferSize = …;
static const int16_t kInvalidFilter[8] = …;
static const int kNumFilterBanks = …;
static const int kNumFilters = …;
ConvolveFunc;
struct ConvolveFunctions { … };
ConvolveParam;
#define ALL_SIZES_64(convolve_fn) …
#define ALL_SIZES(convolve_fn) …
#define AV1_FILTER_WEIGHT …
#define AV1_FILTER_SHIFT …
uint8_t clip_pixel(int x) { … }
void filter_block2d_8_c(const uint8_t *src_ptr, unsigned int src_stride,
const int16_t *HFilter, const int16_t *VFilter,
uint8_t *dst_ptr, unsigned int dst_stride,
unsigned int output_width, unsigned int output_height) { … }
void block2d_average_c(uint8_t *src, unsigned int src_stride,
uint8_t *output_ptr, unsigned int output_stride,
unsigned int output_width, unsigned int output_height) { … }
void filter_average_block2d_8_c(const uint8_t *src_ptr,
const unsigned int src_stride,
const int16_t *HFilter, const int16_t *VFilter,
uint8_t *dst_ptr, unsigned int dst_stride,
unsigned int output_width,
unsigned int output_height) { … }
void highbd_filter_block2d_8_c(const uint16_t *src_ptr,
const unsigned int src_stride,
const int16_t *HFilter, const int16_t *VFilter,
uint16_t *dst_ptr, unsigned int dst_stride,
unsigned int output_width,
unsigned int output_height, int bd) { … }
void highbd_block2d_average_c(uint16_t *src, unsigned int src_stride,
uint16_t *output_ptr, unsigned int output_stride,
unsigned int output_width,
unsigned int output_height) { … }
void highbd_filter_average_block2d_8_c(
const uint16_t *src_ptr, unsigned int src_stride, const int16_t *HFilter,
const int16_t *VFilter, uint16_t *dst_ptr, unsigned int dst_stride,
unsigned int output_width, unsigned int output_height, int bd) { … }
class ConvolveTestBase : public ::testing::TestWithParam<ConvolveParam> { … };
uint8_t *ConvolveTestBase::input_ = …;
uint8_t *ConvolveTestBase::ref8_ = …;
uint8_t *ConvolveTestBase::output_ = …;
uint8_t *ConvolveTestBase::output_ref_ = …;
uint16_t *ConvolveTestBase::input16_ = …;
uint16_t *ConvolveTestBase::ref16_ = …;
uint16_t *ConvolveTestBase::output16_ = …;
uint16_t *ConvolveTestBase::output16_ref_ = …;
LowbdConvolveTest;
TEST_P(LowbdConvolveTest, GuardBlocks) { … }
void FiltersWontSaturateWhenAddedPairwise() { … }
TEST(LowbdConvolveTest, FiltersWontSaturateWhenAddedPairwise) { … }
TEST_P(LowbdConvolveTest, MatchesReferenceSubpixelFilter) { … }
TEST_P(LowbdConvolveTest, FilterExtremes) { … }
TEST_P(LowbdConvolveTest, DISABLED_Speed) { … }
make_tuple;
#if CONFIG_AV1_HIGHBITDEPTH
#define WRAP …
#if HAVE_SSE2 && AOM_ARCH_X86_64
WRAP(convolve8_horiz_sse2, 8)
WRAP(convolve8_vert_sse2, 8)
WRAP(convolve8_horiz_sse2, 10)
WRAP(convolve8_vert_sse2, 10)
WRAP(convolve8_horiz_sse2, 12)
WRAP(convolve8_vert_sse2, 12)
#endif
WRAP(convolve8_horiz_c, 8)
WRAP(convolve8_vert_c, 8)
WRAP(convolve8_horiz_c, 10)
WRAP(convolve8_vert_c, 10)
WRAP(convolve8_horiz_c, 12)
WRAP(convolve8_vert_c, 12)
#if HAVE_AVX2
WRAP(convolve8_horiz_avx2, 8)
WRAP(convolve8_vert_avx2, 8)
WRAP(convolve8_horiz_avx2, 10)
WRAP(convolve8_vert_avx2, 10)
WRAP(convolve8_horiz_avx2, 12)
WRAP(convolve8_vert_avx2, 12)
#endif
#if HAVE_NEON
WRAP(convolve8_horiz_neon, 8)
WRAP(convolve8_vert_neon, 8)
WRAP(convolve8_horiz_neon, 10)
WRAP(convolve8_vert_neon, 10)
WRAP(convolve8_horiz_neon, 12)
WRAP(convolve8_vert_neon, 12)
#endif
#if HAVE_SVE
WRAP(convolve8_horiz_sve, 8)
WRAP(convolve8_vert_sve, 8)
WRAP(convolve8_horiz_sve, 10)
WRAP(convolve8_vert_sve, 10)
WRAP(convolve8_horiz_sve, 12)
WRAP(convolve8_vert_sve, 12)
#endif
#endif
#undef WRAP
#if CONFIG_AV1_HIGHBITDEPTH
using HighbdConvolveTest = ConvolveTestBase;
TEST_P(HighbdConvolveTest, GuardBlocks) { CheckGuardBlocks(); }
TEST(HighbdConvolveTest, FiltersWontSaturateWhenAddedPairwise) {
FiltersWontSaturateWhenAddedPairwise();
}
TEST_P(HighbdConvolveTest, MatchesReferenceSubpixelFilter) {
MatchesReferenceSubpixelFilter();
}
TEST_P(HighbdConvolveTest, FilterExtremes) { FilterExtremes(); }
TEST_P(HighbdConvolveTest, DISABLED_Speed) { SpeedTest(); }
const ConvolveFunctions wrap_convolve8_c(wrap_convolve8_horiz_c_8,
wrap_convolve8_vert_c_8, 8);
const ConvolveFunctions wrap_convolve10_c(wrap_convolve8_horiz_c_10,
wrap_convolve8_vert_c_10, 10);
const ConvolveFunctions wrap_convolve12_c(wrap_convolve8_horiz_c_12,
wrap_convolve8_vert_c_12, 12);
const ConvolveParam kArrayHighbdConvolve_c[] = { ALL_SIZES(wrap_convolve8_c),
ALL_SIZES(wrap_convolve10_c),
ALL_SIZES(wrap_convolve12_c) };
INSTANTIATE_TEST_SUITE_P(C, HighbdConvolveTest,
::testing::ValuesIn(kArrayHighbdConvolve_c));
#endif
const ConvolveFunctions convolve8_c(aom_convolve8_horiz_c, aom_convolve8_vert_c,
0);
const ConvolveParam kArrayConvolve_c[] = …;
INSTANTIATE_TEST_SUITE_P(…);
#if HAVE_SSE2 && AOM_ARCH_X86_64
#if CONFIG_AV1_HIGHBITDEPTH
const ConvolveFunctions wrap_convolve8_sse2(wrap_convolve8_horiz_sse2_8,
wrap_convolve8_vert_sse2_8, 8);
const ConvolveFunctions wrap_convolve10_sse2(wrap_convolve8_horiz_sse2_10,
wrap_convolve8_vert_sse2_10, 10);
const ConvolveFunctions wrap_convolve12_sse2(wrap_convolve8_horiz_sse2_12,
wrap_convolve8_vert_sse2_12, 12);
const ConvolveParam kArrayHighbdConvolve_sse2[] = {
ALL_SIZES(wrap_convolve8_sse2), ALL_SIZES(wrap_convolve10_sse2),
ALL_SIZES(wrap_convolve12_sse2)
};
INSTANTIATE_TEST_SUITE_P(SSE2, HighbdConvolveTest,
::testing::ValuesIn(kArrayHighbdConvolve_sse2));
#endif
#endif
#if HAVE_SSSE3
const ConvolveFunctions convolve8_ssse3(aom_convolve8_horiz_ssse3,
aom_convolve8_vert_ssse3, 0);
const ConvolveParam kArrayConvolve8_ssse3[] = …;
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_AVX2
#if CONFIG_AV1_HIGHBITDEPTH
const ConvolveFunctions wrap_convolve8_avx2(wrap_convolve8_horiz_avx2_8,
wrap_convolve8_vert_avx2_8, 8);
const ConvolveFunctions wrap_convolve10_avx2(wrap_convolve8_horiz_avx2_10,
wrap_convolve8_vert_avx2_10, 10);
const ConvolveFunctions wrap_convolve12_avx2(wrap_convolve8_horiz_avx2_12,
wrap_convolve8_vert_avx2_12, 12);
const ConvolveParam kArray_HighbdConvolve8_avx2[] = {
ALL_SIZES_64(wrap_convolve8_avx2), ALL_SIZES_64(wrap_convolve10_avx2),
ALL_SIZES_64(wrap_convolve12_avx2)
};
INSTANTIATE_TEST_SUITE_P(AVX2, HighbdConvolveTest,
::testing::ValuesIn(kArray_HighbdConvolve8_avx2));
#endif
const ConvolveFunctions convolve8_avx2(aom_convolve8_horiz_avx2,
aom_convolve8_vert_avx2, 0);
const ConvolveParam kArray_Convolve8_avx2[] = …;
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_NEON
#if CONFIG_AV1_HIGHBITDEPTH
const ConvolveFunctions wrap_convolve8_neon(wrap_convolve8_horiz_neon_8,
wrap_convolve8_vert_neon_8, 8);
const ConvolveFunctions wrap_convolve10_neon(wrap_convolve8_horiz_neon_10,
wrap_convolve8_vert_neon_10, 10);
const ConvolveFunctions wrap_convolve12_neon(wrap_convolve8_horiz_neon_12,
wrap_convolve8_vert_neon_12, 12);
const ConvolveParam kArray_HighbdConvolve8_neon[] = {
ALL_SIZES_64(wrap_convolve8_neon), ALL_SIZES_64(wrap_convolve10_neon),
ALL_SIZES_64(wrap_convolve12_neon)
};
INSTANTIATE_TEST_SUITE_P(NEON, HighbdConvolveTest,
::testing::ValuesIn(kArray_HighbdConvolve8_neon));
#endif
const ConvolveFunctions convolve8_neon(aom_convolve8_horiz_neon,
aom_convolve8_vert_neon, 0);
const ConvolveParam kArray_Convolve8_neon[] = { ALL_SIZES(convolve8_neon) };
INSTANTIATE_TEST_SUITE_P(NEON, LowbdConvolveTest,
::testing::ValuesIn(kArray_Convolve8_neon));
#endif
#if HAVE_NEON_DOTPROD
const ConvolveFunctions convolve8_neon_dotprod(aom_convolve8_horiz_neon_dotprod,
aom_convolve8_vert_neon_dotprod,
0);
const ConvolveParam kArray_Convolve8_neon_dotprod[] = { ALL_SIZES(
convolve8_neon_dotprod) };
INSTANTIATE_TEST_SUITE_P(NEON_DOTPROD, LowbdConvolveTest,
::testing::ValuesIn(kArray_Convolve8_neon_dotprod));
#endif
#if HAVE_NEON_I8MM
const ConvolveFunctions convolve8_neon_i8mm(aom_convolve8_horiz_neon_i8mm,
aom_convolve8_vert_neon_i8mm, 0);
const ConvolveParam kArray_Convolve8_neon_i8mm[] = { ALL_SIZES(
convolve8_neon_i8mm) };
INSTANTIATE_TEST_SUITE_P(NEON_I8MM, LowbdConvolveTest,
::testing::ValuesIn(kArray_Convolve8_neon_i8mm));
#endif
#if HAVE_SVE
#if CONFIG_AV1_HIGHBITDEPTH
const ConvolveFunctions wrap_convolve8_sve(wrap_convolve8_horiz_sve_8,
wrap_convolve8_vert_sve_8, 8);
const ConvolveFunctions wrap_convolve10_sve(wrap_convolve8_horiz_sve_10,
wrap_convolve8_vert_sve_10, 10);
const ConvolveFunctions wrap_convolve12_sve(wrap_convolve8_horiz_sve_12,
wrap_convolve8_vert_sve_12, 12);
const ConvolveParam kArray_HighbdConvolve8_sve[] = {
ALL_SIZES_64(wrap_convolve8_sve), ALL_SIZES_64(wrap_convolve10_sve),
ALL_SIZES_64(wrap_convolve12_sve)
};
INSTANTIATE_TEST_SUITE_P(SVE, HighbdConvolveTest,
::testing::ValuesIn(kArray_HighbdConvolve8_sve));
#endif
#endif
ConvolveScale2DFunc;
ConvolveScale2DParam;
class ConvolveScale2DTest
: public ::testing::TestWithParam<ConvolveScale2DParam> { … };
TEST_P(ConvolveScale2DTest, DISABLED_Speed) { … }
TEST_P(ConvolveScale2DTest, Correctness) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if HAVE_NEON
INSTANTIATE_TEST_SUITE_P(NEON, ConvolveScale2DTest,
::testing::Values(ALL_SIZES_64(aom_scaled_2d_neon)));
#endif
#if HAVE_NEON_DOTPROD
INSTANTIATE_TEST_SUITE_P(
NEON_DOTPROD, ConvolveScale2DTest,
::testing::Values(ALL_SIZES_64(aom_scaled_2d_neon_dotprod)));
#endif
#if HAVE_NEON_I8MM
INSTANTIATE_TEST_SUITE_P(
NEON_I8MM, ConvolveScale2DTest,
::testing::Values(ALL_SIZES_64(aom_scaled_2d_neon_i8mm)));
#endif
#if HAVE_SSSE3
INSTANTIATE_TEST_SUITE_P(…);
#endif
}