Commit ae7b2f3a authored by Linfeng Zhang's avatar Linfeng Zhang Committed by Jingning Han

Add av1_get_br_level_counts_sse2()

Change-Id: I6ce7aea19e3bdeef24d3fe66ac6eba7b8d585f9a
parent 7d163c50
......@@ -254,7 +254,8 @@ set(AOM_AV1_ENCODER_SOURCES
set(AOM_AV1_COMMON_INTRIN_SSE2
${AOM_AV1_COMMON_INTRIN_SSE2}
"${AOM_ROOT}/av1/common/cdef_block_sse2.c")
"${AOM_ROOT}/av1/common/cdef_block_sse2.c"
"${AOM_ROOT}/av1/common/x86/mem_sse2.h")
set(AOM_AV1_COMMON_INTRIN_SSSE3
${AOM_AV1_COMMON_INTRIN_SSSE3}
......@@ -384,6 +385,10 @@ if (CONFIG_LV_MAP)
"${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"
......
......@@ -76,6 +76,7 @@ AV1_COMMON_SRCS-yes += common/av1_fwd_txfm1d_cfg.h
AV1_COMMON_SRCS-yes += common/av1_inv_txfm2d.c
AV1_COMMON_SRCS-yes += common/av1_inv_txfm1d_cfg.h
AV1_COMMON_SRCS-$(HAVE_AVX2) += common/x86/convolve_avx2.c
AV1_COMMON_SRCS-$(HAVE_SSE2) += common/x86/mem_sse2.h
AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/x86/av1_convolve_ssse3.c
ifeq ($(CONFIG_CONVOLVE_ROUND)x$(CONFIG_COMPOUND_ROUND),yesx)
AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/av1_convolve_scale_sse4.c
......@@ -167,6 +168,10 @@ AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/x86/highbd_convolve_2d_ssse3.c
endif
endif
ifeq ($(CONFIG_LV_MAP),yes)
AV1_COMMON_SRCS-$(HAVE_SSE2) += common/x86/txb_sse2.c
endif
ifeq ($(CONFIG_Q_ADAPT_PROBS),yes)
AV1_COMMON_SRCS-yes += common/token_cdfs.h
endif
......
......@@ -66,6 +66,14 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
specialize qw/av1_highbd_convolve_vert sse4_1/;
}
#
# txb
#
if (aom_config("CONFIG_LV_MAP") eq "yes") {
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
#
......
......@@ -333,8 +333,8 @@ void av1_get_base_level_counts(const uint8_t *const levels,
}
}
void av1_get_br_level_counts(const uint8_t *const levels, const int width,
const int height, uint8_t *const level_counts) {
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;
......
......@@ -391,7 +391,7 @@ static INLINE int get_nz_map_ctx_from_count(int count,
const int width = 1 << bwl;
int ctx = 0;
int tx_class = get_tx_class(tx_type);
const TX_CLASS tx_class = get_tx_class(tx_type);
int offset;
if (tx_class == TX_CLASS_2D)
offset = 0;
......@@ -455,7 +455,7 @@ static INLINE int get_nz_map_ctx(const uint8_t *const levels,
const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << bwl);
int tx_class = get_tx_class(tx_type);
const TX_CLASS tx_class = get_tx_class(tx_type);
#if USE_CAUSAL_BASE_CTX
int mag = 0;
int count = get_nz_count_mag(levels, bwl, row, col, tx_class, &mag);
......@@ -578,7 +578,4 @@ 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);
void av1_get_br_level_counts(const uint8_t *const levels, const int width,
const int height, uint8_t *const level_counts);
#endif // AV1_COMMON_TXB_COMMON_H_
/*
* 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.
*/
#ifndef AV1_COMMON_X86_MEM_SSE2_H_
#define AV1_COMMON_X86_MEM_SSE2_H_
#include <emmintrin.h> // SSE2
#include "./aom_config.h"
#include "aom/aom_integer.h"
static INLINE __m128i loadh_epi64(const void *const src, const __m128i s) {
return _mm_castps_si128(
_mm_loadh_pi(_mm_castsi128_ps(s), (const __m64 *)src));
}
#endif // AV1_COMMON_X86_MEM_SSE2_H_
This diff is collapsed.
......@@ -9,6 +9,7 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "aom_ports/mem.h"
#include "av1/common/scan.h"
#include "av1/common/idct.h"
#include "av1/common/txb_common.h"
......@@ -74,7 +75,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
int cul_level = 0;
uint8_t levels_buf[TX_PAD_2D];
uint8_t *const levels = set_levels(levels_buf, width);
uint8_t level_counts[MAX_TX_SQUARE];
DECLARE_ALIGNED(16, uint8_t, level_counts[MAX_TX_SQUARE]);
int8_t signs[MAX_TX_SQUARE];
memset(tcoeffs, 0, sizeof(*tcoeffs) * seg_eob);
......
......@@ -9,6 +9,7 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "aom_ports/mem.h"
#include "av1/common/scan.h"
#include "av1/common/blockd.h"
#include "av1/common/idct.h"
......@@ -321,7 +322,7 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
uint8_t levels_buf[TX_PAD_2D];
uint8_t *const levels = set_levels(levels_buf, width);
uint8_t level_counts[MAX_TX_SQUARE];
DECLARE_ALIGNED(16, uint8_t, level_counts[MAX_TX_SQUARE]);
(void)blk_row;
(void)blk_col;
......@@ -635,7 +636,7 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
const int16_t *scan = scan_order->scan;
uint8_t levels_buf[TX_PAD_2D];
uint8_t *const levels = set_levels(levels_buf, width);
uint8_t level_counts[MAX_TX_SQUARE];
DECLARE_ALIGNED(16, uint8_t, level_counts[MAX_TX_SQUARE]);
LV_MAP_COEFF_COST *coeff_costs = &x->coeff_costs[txs_ctx][plane_type];
......@@ -2144,7 +2145,7 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
const int height = tx_size_high[tx_size];
uint8_t levels_buf[TX_PAD_2D];
uint8_t *const levels = set_levels(levels_buf, width);
uint8_t level_counts[MAX_TX_SQUARE];
DECLARE_ALIGNED(16, uint8_t, level_counts[MAX_TX_SQUARE]);
const uint8_t allow_update_cdf = args->allow_update_cdf;
TX_SIZE txsize_ctx = get_txsize_context(tx_size);
......
......@@ -169,6 +169,12 @@ if (NOT BUILD_SHARED_LIBS)
endif ()
endif ()
if (CONFIG_LV_MAP)
set(AOM_UNIT_TEST_COMMON_SOURCES
${AOM_UNIT_TEST_COMMON_SOURCES}
"${AOM_ROOT}/test/txb_test.cc")
endif ()
set(AOM_UNIT_TEST_COMMON_INTRIN_NEON
${AOM_UNIT_TEST_COMMON_INTRIN_NEON}
"${AOM_ROOT}/test/simd_cmp_neon.cc")
......
......@@ -154,6 +154,7 @@ LIBAOM_TEST_SRCS-$(HAVE_SSE4_1) += simd_sse4_test.cc
LIBAOM_TEST_SRCS-$(HAVE_AVX2) += simd_avx2_test.cc
LIBAOM_TEST_SRCS-$(HAVE_NEON) += simd_neon_test.cc
LIBAOM_TEST_SRCS-yes += intrapred_test.cc
LIBAOM_TEST_SRCS-$(CONFIG_LV_MAP) += txb_test.cc
LIBAOM_TEST_SRCS-$(CONFIG_INTRABC) += intrabc_test.cc
#LIBAOM_TEST_SRCS-$(CONFIG_AV1_DECODER) += av1_thread_test.cc
LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += dct16x16_test.cc
......
/*
* 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 "third_party/googletest/src/googletest/include/gtest/gtest.h"
#include "./aom_config.h"
#include "./av1_rtcd.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_) * MAX_TX_SQUARE);
for (int i = 0; i < kNumTests && !result; ++i) {
InitLevels(width, height);
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_) * MAX_TX_SQUARE);
InitLevels(width, height);
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);
}
}
void InitLevels(const int width, const int height) {
const int stride = width + TX_PAD_HOR;
for (int i = 0; i < height; ++i) {
for (int j = 0; j < width; ++j) {
levels_[i * stride + j] = rnd_.Rand8() % (NUM_BASE_LEVELS + 2);
}
}
for (int i = 0; i < MAX_TX_SQUARE; ++i) {
level_counts_ref_[i] = level_counts_[i] = 255;
}
}
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_;
tran_low_t *coeff_;
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment