/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * 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. */ #include #include #include "third_party/googletest/src/include/gtest/gtest.h" #include "./aom_config.h" #include "./aom_dsp_rtcd.h" #include "aom_ports/aom_timer.h" #include "test/acm_random.h" #include "test/clear_system_state.h" #include "test/register_state_check.h" #include "test/util.h" using libaom_test::ACMRandom; 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, int width, int height, unsigned int strength); typedef std::tr1::tuple clpf_block_param_t; class ClpfBlockTest : public ::testing::TestWithParam { public: virtual ~ClpfBlockTest() {} virtual void SetUp() { clpf = GET_PARAM(0); ref_clpf = GET_PARAM(1); sizex = GET_PARAM(2); sizey = GET_PARAM(3); } virtual void TearDown() { libaom_test::ClearSystemState(); } protected: int sizex; int sizey; clpf_block_t clpf; clpf_block_t ref_clpf; }; typedef ClpfBlockTest ClpfSpeedTest; #if CONFIG_AOM_HIGHBITDEPTH 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, int width, int height, unsigned int strength); typedef std::tr1::tuple clpf_block_hbd_param_t; class ClpfBlockHbdTest : public ::testing::TestWithParam { public: virtual ~ClpfBlockHbdTest() {} virtual void SetUp() { clpf = GET_PARAM(0); ref_clpf = GET_PARAM(1); sizex = GET_PARAM(2); sizey = GET_PARAM(3); } virtual void TearDown() { libaom_test::ClearSystemState(); } protected: int sizex; int sizey; clpf_block_hbd_t clpf; clpf_block_hbd_t ref_clpf; }; typedef ClpfBlockHbdTest ClpfHbdSpeedTest; #endif template 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, int width, int height, unsigned int strength), void (*ref_clpf)(const pixel *src, pixel *dst, int sstride, int dstride, int x0, int y0, int sizex, int sizey, int width, int height, unsigned int strength)) { const int size = 24; ACMRandom rnd(ACMRandom::DeterministicSeed()); DECLARE_ALIGNED(16, pixel, s[size * size]); DECLARE_ALIGNED(16, pixel, d[size * size]); DECLARE_ALIGNED(16, pixel, ref_d[size * size]); memset(ref_d, 0, size * size * sizeof(*ref_d)); memset(d, 0, size * size * sizeof(*d)); int error = 0, pos = 0, strength = 0, xpos = 0, ypos = 0; int bits, level, count; // Test every combination of: // * Input with up to bits of noise // * Noise level around every value from 0 to (1<