Commit 59335fcc authored by Linfeng Zhang's avatar Linfeng Zhang

Update test/txb_test.cc

to cover the whole range of levels[].

Change-Id: I65646761535d1f88bfe12044b1fe87bd0c50e392
parent be7bb583
......@@ -334,6 +334,8 @@ int16_t get_eob_pos_token(int eob, int16_t *extra) {
return t;
}
// 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) {
......@@ -348,6 +350,8 @@ void av1_get_base_level_counts(const uint8_t *const levels,
}
}
// 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;
......
......@@ -35,6 +35,9 @@ static INLINE void load_levels_4x4x3_sse2(const uint8_t *const s0,
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;
......@@ -66,7 +69,6 @@ static INLINE void get_4_level_counts_sse2(const uint8_t *const levels,
uint8_t *const level_counts) {
const int stride = 4 + TX_PAD_HOR;
const __m128i level_minus_1 = _mm_set1_epi8(NUM_BASE_LEVELS);
int row = height;
__m128i count;
__m128i level[9];
......@@ -92,7 +94,10 @@ static INLINE void get_4_level_counts_sse2(const uint8_t *const levels,
} 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;
......@@ -148,6 +153,8 @@ static INLINE void get_8_level_counts_sse2(const uint8_t *const levels,
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;
......@@ -235,6 +242,7 @@ static INLINE void get_16x_level_counts_sse2(const uint8_t *levels,
}
}
// 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) {
......
......@@ -9,6 +9,10 @@
* 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"
......@@ -61,7 +65,7 @@ class TxbTest : public ::testing::TestWithParam<GetLevelCountsFunc> {
memset(levels_buf_, 0, sizeof(*levels_buf_) * MAX_TX_SQUARE);
for (int i = 0; i < kNumTests && !result; ++i) {
InitLevels(width, height);
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_);
......@@ -85,7 +89,7 @@ class TxbTest : public ::testing::TestWithParam<GetLevelCountsFunc> {
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);
InitLevels(width, height, 0);
aom_usec_timer_start(&timer);
for (int i = 0; i < kNumTests; ++i) {
......@@ -99,16 +103,21 @@ class TxbTest : public ::testing::TestWithParam<GetLevelCountsFunc> {
}
}
void InitLevels(const int width, const int height) {
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] = rnd_.Rand8() % (NUM_BASE_LEVELS + 2);
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] = 255;
level_counts_ref_[i] = level_counts_[i] = rnd_.Rand8();
}
}
......
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