Remove dead function: av1_get_br_level_counts
Change-Id: I83bb5daf20774fcc5191f9137ea824a4935df301
diff --git a/av1/av1.cmake b/av1/av1.cmake
index 8e163f3..583c9dc 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -372,10 +372,6 @@
"${AOM_ROOT}/av1/common/txb_common.c"
"${AOM_ROOT}/av1/common/txb_common.h")
-set(AOM_AV1_COMMON_INTRIN_SSE2
- ${AOM_AV1_COMMON_INTRIN_SSE2}
- "${AOM_ROOT}/av1/common/x86/txb_sse2.c")
-
set(AOM_AV1_DECODER_SOURCES
${AOM_AV1_DECODER_SOURCES}
"${AOM_ROOT}/av1/decoder/decodetxb.c"
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 4dcda55..a8ada97 100755
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -80,12 +80,6 @@
specialize qw/av1_highbd_wiener_convolve_add_src avx2/;
#
-# txb
-#
-add_proto qw/void av1_get_br_level_counts/, "const uint8_t *const levels, const int width, const int height, uint8_t *const level_counts";
-specialize qw/av1_get_br_level_counts sse2/;
-
-#
# Inverse dct
#
add_proto qw/void av1_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct txfm_param *param";
diff --git a/av1/common/txb_common.c b/av1/common/txb_common.c
index 1d70be8..c0f61fa 100644
--- a/av1/common/txb_common.c
+++ b/av1/common/txb_common.c
@@ -235,35 +235,3 @@
const int16_t k_eob_group_start[12] = { 0, 1, 2, 3, 5, 9,
17, 33, 65, 129, 257, 513 };
const int16_t k_eob_offset_bits[12] = { 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-
-// Note: because of the SSE2 optimization, levels[] must be in the range [0,
-// 127], inclusive.
-void av1_get_base_level_counts(const uint8_t *const levels,
- const int level_minus_1, const int width,
- const int height, uint8_t *const level_counts) {
- const int stride = width + TX_PAD_HOR;
-
- for (int row = 0; row < height; ++row) {
- for (int col = 0; col < width; ++col) {
- level_counts[row * width + col] =
- get_level_count(levels, stride, row, col, level_minus_1,
- base_ref_offset, BASE_CONTEXT_POSITION_NUM);
- }
- }
-}
-
-// Note: because of the SSE2 optimization, levels[] must be in the range [0,
-// 127], inclusive.
-void av1_get_br_level_counts_c(const uint8_t *const levels, const int width,
- const int height, uint8_t *const level_counts) {
- const int stride = width + TX_PAD_HOR;
- const int level_minus_1 = NUM_BASE_LEVELS;
-
- for (int row = 0; row < height; ++row) {
- for (int col = 0; col < width; ++col) {
- level_counts[row * width + col] =
- get_level_count(levels, stride, row, col, level_minus_1,
- br_ref_offset, BR_CONTEXT_POSITION_NUM);
- }
- }
-}
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h
index 29ad05b..336e1cc 100644
--- a/av1/common/txb_common.h
+++ b/av1/common/txb_common.h
@@ -671,8 +671,4 @@
void av1_init_lv_map(AV1_COMMON *cm);
-void av1_get_base_level_counts(const uint8_t *const levels,
- const int level_minus_1, const int width,
- const int height, uint8_t *const level_counts);
-
#endif // AV1_COMMON_TXB_COMMON_H_
diff --git a/av1/common/x86/txb_sse2.c b/av1/common/x86/txb_sse2.c
deleted file mode 100644
index 775d083..0000000
--- a/av1/common/x86/txb_sse2.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 2017, 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 <assert.h>
-#include <emmintrin.h> // SSE2
-
-#include "aom/aom_integer.h"
-#include "aom_dsp/x86/mem_sse2.h"
-#include "av1/common/onyxc_int.h"
-#include "av1/common/txb_common.h"
-
-static INLINE __m128i load_8bit_4x4_sse2(const void *const s0,
- const void *const s1,
- const void *const s2,
- const void *const s3) {
- return _mm_setr_epi32(*(const uint32_t *)s0, *(const uint32_t *)s1,
- *(const uint32_t *)s2, *(const uint32_t *)s3);
-}
-
-static INLINE void load_levels_4x4x3_sse2(const uint8_t *const s0,
- const uint8_t *const s1,
- const uint8_t *const s2,
- const uint8_t *const s3,
- __m128i *const level) {
- level[0] = load_8bit_4x4_sse2(s0 - 1, s1 - 1, s2 - 1, s3 - 1);
- level[1] = load_8bit_4x4_sse2(s0 + 0, s1 + 0, s2 + 0, s3 + 0);
- level[2] = load_8bit_4x4_sse2(s0 + 1, s1 + 1, s2 + 1, s3 + 1);
-}
-
-// This function calculates 16 pixels' level counts, and updates levels history.
-// These 16 pixels may be from different parts of input levels[] if the width is
-// less than 16.
-static INLINE __m128i get_level_counts_kernel_sse2(__m128i *const level) {
- const __m128i level_minus_1 = _mm_set1_epi8(NUM_BASE_LEVELS);
- __m128i count;
-
- level[6] = _mm_cmpgt_epi8(level[6], level_minus_1);
- level[7] = _mm_cmpgt_epi8(level[7], level_minus_1);
- level[8] = _mm_cmpgt_epi8(level[8], level_minus_1);
- count = _mm_setzero_si128();
- count = _mm_sub_epi8(count, level[0]);
- count = _mm_sub_epi8(count, level[1]);
- count = _mm_sub_epi8(count, level[2]);
- count = _mm_sub_epi8(count, level[3]);
- count = _mm_sub_epi8(count, level[5]);
- count = _mm_sub_epi8(count, level[6]);
- count = _mm_sub_epi8(count, level[7]);
- count = _mm_sub_epi8(count, level[8]);
- level[0] = level[3];
- level[1] = level[4];
- level[2] = level[5];
- level[3] = level[6];
- level[4] = level[7];
- level[5] = level[8];
-
- return count;
-}
-
-static INLINE void get_4_level_counts_sse2(const uint8_t *const levels,
- const int height,
- uint8_t *const level_counts) {
- const int stride = 4 + TX_PAD_HOR;
- const __m128i level_minus_1 = _mm_set1_epi8(NUM_BASE_LEVELS);
- __m128i count;
- __m128i level[9];
-
- /* level_counts must be 16 byte aligned. */
- assert(!((intptr_t)level_counts & 0xf));
- assert(!(height % 4));
-
- if (height == 4) {
- load_levels_4x4x3_sse2(levels - 1 * stride, levels + 0 * stride,
- levels + 1 * stride, levels + 2 * stride, &level[0]);
- load_levels_4x4x3_sse2(levels + 0 * stride, levels + 1 * stride,
- levels + 2 * stride, levels + 3 * stride, &level[3]);
- load_levels_4x4x3_sse2(levels + 1 * stride, levels + 2 * stride,
- levels + 3 * stride, levels + 4 * stride, &level[6]);
- level[0] = _mm_cmpgt_epi8(level[0], level_minus_1);
- level[1] = _mm_cmpgt_epi8(level[1], level_minus_1);
- level[2] = _mm_cmpgt_epi8(level[2], level_minus_1);
- level[3] = _mm_cmpgt_epi8(level[3], level_minus_1);
- level[4] = _mm_cmpgt_epi8(level[4], level_minus_1);
- level[5] = _mm_cmpgt_epi8(level[5], level_minus_1);
- count = get_level_counts_kernel_sse2(level);
- _mm_store_si128((__m128i *)level_counts, count);
- } else {
- const uint8_t *ls[4];
- uint8_t *lcs[4];
- int row = height;
-
- // levels[] are divided into 4 even parts. In each loop, totally 4 rows from
- // different parts are processed together.
- ls[0] = levels + 0 * stride * height / 4;
- ls[1] = levels + 1 * stride * height / 4;
- ls[2] = levels + 2 * stride * height / 4;
- ls[3] = levels + 3 * stride * height / 4;
- lcs[0] = level_counts + 0 * 4 * height / 4;
- lcs[1] = level_counts + 1 * 4 * height / 4;
- lcs[2] = level_counts + 2 * 4 * height / 4;
- lcs[3] = level_counts + 3 * 4 * height / 4;
-
- load_levels_4x4x3_sse2(ls[0] - 1 * stride, ls[1] - 1 * stride,
- ls[2] - 1 * stride, ls[3] - 1 * stride, &level[0]);
- load_levels_4x4x3_sse2(ls[0] + 0 * stride, ls[1] + 0 * stride,
- ls[2] + 0 * stride, ls[3] + 0 * stride, &level[3]);
- level[0] = _mm_cmpgt_epi8(level[0], level_minus_1);
- level[1] = _mm_cmpgt_epi8(level[1], level_minus_1);
- level[2] = _mm_cmpgt_epi8(level[2], level_minus_1);
- level[3] = _mm_cmpgt_epi8(level[3], level_minus_1);
- level[4] = _mm_cmpgt_epi8(level[4], level_minus_1);
- level[5] = _mm_cmpgt_epi8(level[5], level_minus_1);
-
- do {
- load_levels_4x4x3_sse2(ls[0] + 1 * stride, ls[1] + 1 * stride,
- ls[2] + 1 * stride, ls[3] + 1 * stride, &level[6]);
-
- count = get_level_counts_kernel_sse2(level);
- *(int *)(lcs[0]) = _mm_cvtsi128_si32(count);
- *(int *)(lcs[1]) = _mm_cvtsi128_si32(_mm_srli_si128(count, 4));
- *(int *)(lcs[2]) = _mm_cvtsi128_si32(_mm_srli_si128(count, 8));
- *(int *)(lcs[3]) = _mm_cvtsi128_si32(_mm_srli_si128(count, 12));
- ls[0] += stride;
- ls[1] += stride;
- ls[2] += stride;
- ls[3] += stride;
- lcs[0] += 4;
- lcs[1] += 4;
- lcs[2] += 4;
- lcs[3] += 4;
- row -= 4;
- } while (row);
- }
-}
-
-static INLINE void get_8_level_counts_sse2(const uint8_t *const levels,
- const int height,
- uint8_t *const level_counts) {
- const int stride = 8 + TX_PAD_HOR;
- const __m128i level_minus_1 = _mm_set1_epi8(NUM_BASE_LEVELS);
- int row = height;
- __m128i count;
- __m128i level[9];
- const uint8_t *ls[2];
- uint8_t *lcs[2];
-
- assert(!(height % 2));
-
- // levels[] are divided into 2 even parts. In each loop, totally 2 rows from
- // different parts are processed together.
- ls[0] = levels;
- ls[1] = levels + stride * height / 2;
- lcs[0] = level_counts;
- lcs[1] = level_counts + 8 * height / 2;
-
- level[0] = _mm_loadl_epi64((__m128i *)(ls[0] - 1 * stride - 1));
- level[1] = _mm_loadl_epi64((__m128i *)(ls[0] - 1 * stride + 0));
- level[2] = _mm_loadl_epi64((__m128i *)(ls[0] - 1 * stride + 1));
- level[3] = _mm_loadl_epi64((__m128i *)(ls[0] + 0 * stride - 1));
- level[4] = _mm_loadl_epi64((__m128i *)(ls[0] + 0 * stride + 0));
- level[5] = _mm_loadl_epi64((__m128i *)(ls[0] + 0 * stride + 1));
- level[0] = loadh_epi64(ls[1] - 1 * stride - 1, level[0]);
- level[1] = loadh_epi64(ls[1] - 1 * stride + 0, level[1]);
- level[2] = loadh_epi64(ls[1] - 1 * stride + 1, level[2]);
- level[3] = loadh_epi64(ls[1] + 0 * stride - 1, level[3]);
- level[4] = loadh_epi64(ls[1] + 0 * stride + 0, level[4]);
- level[5] = loadh_epi64(ls[1] + 0 * stride + 1, level[5]);
- level[0] = _mm_cmpgt_epi8(level[0], level_minus_1);
- level[1] = _mm_cmpgt_epi8(level[1], level_minus_1);
- level[2] = _mm_cmpgt_epi8(level[2], level_minus_1);
- level[3] = _mm_cmpgt_epi8(level[3], level_minus_1);
- level[4] = _mm_cmpgt_epi8(level[4], level_minus_1);
- level[5] = _mm_cmpgt_epi8(level[5], level_minus_1);
-
- do {
- level[6] = _mm_loadl_epi64((__m128i *)(ls[0] + 1 * stride - 1));
- level[7] = _mm_loadl_epi64((__m128i *)(ls[0] + 1 * stride + 0));
- level[8] = _mm_loadl_epi64((__m128i *)(ls[0] + 1 * stride + 1));
- level[6] = loadh_epi64(ls[1] + 1 * stride - 1, level[6]);
- level[7] = loadh_epi64(ls[1] + 1 * stride + 0, level[7]);
- level[8] = loadh_epi64(ls[1] + 1 * stride + 1, level[8]);
-
- count = get_level_counts_kernel_sse2(level);
- _mm_storel_epi64((__m128i *)(lcs[0]), count);
- _mm_storeh_pi((__m64 *)(lcs[1]), _mm_castsi128_ps(count));
- ls[0] += stride;
- ls[1] += stride;
- lcs[0] += 8;
- lcs[1] += 8;
- row -= 2;
- } while (row);
-}
-
-static INLINE void get_16x_level_counts_sse2(const uint8_t *levels,
- const int width, const int height,
- uint8_t *level_counts) {
- const int stride = width + TX_PAD_HOR;
- const __m128i level_minus_1 = _mm_set1_epi8(NUM_BASE_LEVELS);
- __m128i count;
- __m128i level[9];
-
- /* level_counts must be 16 byte aligned. */
- assert(!((intptr_t)level_counts & 0xf));
- assert(!(width % 16));
-
- for (int i = 0; i < width; i += 16) {
- int row = height;
-
- level[0] = _mm_loadu_si128((__m128i *)(levels + i - 1 * stride - 1));
- level[1] = _mm_loadu_si128((__m128i *)(levels + i - 1 * stride + 0));
- level[2] = _mm_loadu_si128((__m128i *)(levels + i - 1 * stride + 1));
- level[3] = _mm_loadu_si128((__m128i *)(levels + i + 0 * stride - 1));
- level[4] = _mm_loadu_si128((__m128i *)(levels + i + 0 * stride + 0));
- level[5] = _mm_loadu_si128((__m128i *)(levels + i + 0 * stride + 1));
- level[0] = _mm_cmpgt_epi8(level[0], level_minus_1);
- level[1] = _mm_cmpgt_epi8(level[1], level_minus_1);
- level[2] = _mm_cmpgt_epi8(level[2], level_minus_1);
- level[3] = _mm_cmpgt_epi8(level[3], level_minus_1);
- level[4] = _mm_cmpgt_epi8(level[4], level_minus_1);
- level[5] = _mm_cmpgt_epi8(level[5], level_minus_1);
-
- do {
- level[6] = _mm_loadu_si128((__m128i *)(levels + i + 1 * stride - 1));
- level[7] = _mm_loadu_si128((__m128i *)(levels + i + 1 * stride + 0));
- level[8] = _mm_loadu_si128((__m128i *)(levels + i + 1 * stride + 1));
-
- count = get_level_counts_kernel_sse2(level);
- _mm_store_si128((__m128i *)(level_counts + i), count);
- levels += stride;
- level_counts += width;
- } while (--row);
-
- levels -= stride * height;
- level_counts -= width * height;
- }
-}
-
-// Note: levels[] must be in the range [0, 127], inclusive.
-void av1_get_br_level_counts_sse2(const uint8_t *const levels, const int width,
- const int height,
- uint8_t *const level_counts) {
- if (width == 4) {
- get_4_level_counts_sse2(levels, height, level_counts);
- } else if (width == 8) {
- get_8_level_counts_sse2(levels, height, level_counts);
- } else {
- get_16x_level_counts_sse2(levels, width, height, level_counts);
- }
-}
diff --git a/test/test.cmake b/test/test.cmake
index 092b31c..80be8d9 100644
--- a/test/test.cmake
+++ b/test/test.cmake
@@ -162,10 +162,6 @@
"${AOM_ROOT}/test/hiprec_convolve_test_util.h")
endif ()
- set(AOM_UNIT_TEST_COMMON_SOURCES
- ${AOM_UNIT_TEST_COMMON_SOURCES}
- "${AOM_ROOT}/test/txb_test.cc")
-
set(AOM_UNIT_TEST_ENCODER_SOURCES
${AOM_UNIT_TEST_ENCODER_SOURCES}
"${AOM_ROOT}/test/encodetxb_test.cc")
diff --git a/test/txb_test.cc b/test/txb_test.cc
deleted file mode 100644
index d91e4fb..0000000
--- a/test/txb_test.cc
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2017, 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 <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
-
-#include "./aom_config.h"
-#include "./av1_rtcd.h"
-#include "aom/aom_integer.h"
-#include "aom_ports/aom_timer.h"
-#include "aom_ports/mem.h"
-#include "av1/common/onyxc_int.h"
-#include "av1/common/txb_common.h"
-#include "test/acm_random.h"
-#include "test/clear_system_state.h"
-#include "test/register_state_check.h"
-#include "test/util.h"
-
-namespace {
-using libaom_test::ACMRandom;
-
-typedef void (*GetLevelCountsFunc)(const uint8_t *const levels, const int width,
- const int height,
- uint8_t *const level_counts);
-
-class TxbTest : public ::testing::TestWithParam<GetLevelCountsFunc> {
- public:
- TxbTest() : get_br_level_counts_func_(GetParam()) {}
-
- virtual ~TxbTest() {}
-
- virtual void SetUp() {
- level_counts_ref_ = reinterpret_cast<uint8_t *>(
- aom_memalign(16, sizeof(*level_counts_ref_) * MAX_TX_SQUARE));
- ASSERT_TRUE(level_counts_ref_ != NULL);
- level_counts_ = reinterpret_cast<uint8_t *>(
- aom_memalign(16, sizeof(*level_counts_) * MAX_TX_SQUARE));
- ASSERT_TRUE(level_counts_ != NULL);
- }
-
- virtual void TearDown() {
- aom_free(level_counts_ref_);
- aom_free(level_counts_);
- libaom_test::ClearSystemState();
- }
-
- void GetLevelCountsRun() {
- const int kNumTests = 10000;
- int result = 0;
-
- for (int tx_size = TX_4X4; tx_size < TX_SIZES_ALL; ++tx_size) {
- const int width = tx_size_wide[tx_size];
- const int height = tx_size_high[tx_size];
- levels_ = set_levels(levels_buf_, width);
- memset(levels_buf_, 0, sizeof(levels_buf_));
-
- for (int i = 0; i < kNumTests && !result; ++i) {
- InitLevels(width, height, i);
-
- av1_get_br_level_counts_c(levels_, width, height, level_counts_ref_);
- get_br_level_counts_func_(levels_, width, height, level_counts_);
-
- PrintDiff(width, height);
-
- result = memcmp(level_counts_, level_counts_ref_,
- sizeof(*level_counts_ref_) * MAX_TX_SQUARE);
-
- EXPECT_EQ(result, 0) << " width " << width << " height " << height;
- }
- }
- }
-
- void SpeedTestGetLevelCountsRun() {
- const int kNumTests = 10000000;
- aom_usec_timer timer;
-
- for (int tx_size = TX_4X4; tx_size < TX_SIZES_ALL; ++tx_size) {
- const int width = tx_size_wide[tx_size];
- const int height = tx_size_high[tx_size];
- levels_ = set_levels(levels_buf_, width);
- memset(levels_buf_, 0, sizeof(levels_buf_));
- InitLevels(width, height, 0);
-
- aom_usec_timer_start(&timer);
- for (int i = 0; i < kNumTests; ++i) {
- get_br_level_counts_func_(levels_, width, height, level_counts_);
- }
- aom_usec_timer_mark(&timer);
-
- const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
- printf("get_br_level_counts_%2dx%2d: %7.1f ms\n", width, height,
- elapsed_time / 1000.0);
- }
- }
-
- private:
- void InitLevels(const int width, const int height, const int idx) {
- const int stride = width + TX_PAD_HOR;
- // levels_[] is initialized to either the whole possible range, or small
- // values around base level.
- const int max_value = (idx & 1) ? INT8_MAX : (NUM_BASE_LEVELS + 2);
-
- for (int i = 0; i < height; ++i) {
- for (int j = 0; j < width; ++j) {
- levels_[i * stride + j] =
- static_cast<uint8_t>(clamp(rnd_.Rand8(), 0, max_value));
- }
- }
- for (int i = 0; i < MAX_TX_SQUARE; ++i) {
- level_counts_ref_[i] = level_counts_[i] = rnd_.Rand8();
- }
- }
-
- void PrintDiff(const int width, const int height) const {
- if (memcmp(level_counts_, level_counts_ref_,
- sizeof(*level_counts_ref_) * MAX_TX_SQUARE)) {
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- if (level_counts_ref_[y * width + x] !=
- level_counts_[y * width + x]) {
- printf("count[%d][%d] diff:%6d (ref),%6d (opt)\n", y, x,
- level_counts_ref_[y * width + x],
- level_counts_[y * width + x]);
- break;
- }
- }
- }
- }
- }
-
- GetLevelCountsFunc get_br_level_counts_func_;
- ACMRandom rnd_;
- uint8_t levels_buf_[TX_PAD_2D];
- uint8_t *levels_;
- uint8_t *level_counts_ref_;
- uint8_t *level_counts_;
-};
-
-TEST_P(TxbTest, BitExact) { GetLevelCountsRun(); }
-
-TEST_P(TxbTest, DISABLED_Speed) { SpeedTestGetLevelCountsRun(); }
-
-#if HAVE_SSE2
-INSTANTIATE_TEST_CASE_P(SSE2, TxbTest,
- ::testing::Values(av1_get_br_level_counts_sse2));
-#endif
-} // namespace