/* * 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/googletest/include/gtest/gtest.h" #include "./aom_config.h" #include "./av1_rtcd.h" #include "aom_ports/aom_timer.h" #include "av1/common/od_dering.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)(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bitdepth); typedef std::tr1::tuple clpf_block_param_t; class CDEFClpfBlockTest : public ::testing::TestWithParam { public: virtual ~CDEFClpfBlockTest() {} 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 CDEFClpfBlockTest CDEFClpfSpeedTest; #if CONFIG_HIGHBITDEPTH typedef void (*clpf_block_hbd_t)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bitdepth); typedef std::tr1::tuple clpf_block_hbd_param_t; class CDEFClpfBlockHbdTest : public ::testing::TestWithParam { public: virtual ~CDEFClpfBlockHbdTest() {} 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 CDEFClpfBlockHbdTest ClpfHbdSpeedTest; #endif template void test_clpf(int w, int h, unsigned int depth, unsigned int iterations, void (*clpf)(pixel *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bitdepth), void (*ref_clpf)(pixel *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bitdepth)) { const int size = 24; ACMRandom rnd(ACMRandom::DeterministicSeed()); DECLARE_ALIGNED(16, uint16_t, 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, xpos = 8, ypos = 8; unsigned int strength = 0, bits, level, count, damp = 0, boundary = 0; assert(size >= w + 16 && size >= h + 16); assert(depth >= 8); // Test every combination of: // * Input with up to bits of noise // * Noise level around every value from 0 to (1<