Commit ec932242 authored by Angie Chiang's avatar Angie Chiang
Browse files

Refactor scan_test.cc

Change-Id: I546a955a95d6d43182631ad5e8d1c137c36e9a0c
parent 09a42657
......@@ -9,75 +9,72 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "av1/common/scan.h"
#include "test/acm_random.h"
#include "third_party/googletest/src/include/gtest/gtest.h"
using libaom_test::ACMRandom;
namespace {
TEST(scan_test, av1_augment_prob) {
int tx1d_size = 4;
TEST(ScanTest, av1_augment_prob) {
const int tx1d_size = 4;
uint32_t prob[16] = { 8, 8, 7, 7, 8, 8, 4, 2, 3, 3, 2, 2, 2, 2, 2, 2 };
uint32_t ref_prob[16] = { 8, 8, 7, 7, 8, 8, 4, 2, 3, 3, 2, 2, 2, 2, 2, 2 };
const uint32_t ref_prob[16] = {
8, 8, 7, 7, 8, 8, 4, 2, 3, 3, 2, 2, 2, 2, 2, 2
};
av1_augment_prob(prob, tx1d_size, tx1d_size);
for (int r = 0; r < tx1d_size; ++r) {
for (int c = 0; c < tx1d_size; ++c) {
int idx = r * tx1d_size + c;
const int idx = r * tx1d_size + c;
EXPECT_EQ(ref_prob[idx], prob[idx] >> 16);
}
}
int mask = (1 << 10) - 1;
const int mask = (1 << 10) - 1;
for (int r = 0; r < tx1d_size; ++r) {
for (int c = 0; c < tx1d_size; ++c) {
int idx = r * tx1d_size + c;
const int idx = r * tx1d_size + c;
EXPECT_EQ(idx, mask ^ (prob[r * tx1d_size + c] & mask));
}
}
}
TEST(scan_test, av1_update_sort_order) {
TX_SIZE tx_size = TX_4X4;
uint32_t prob[16] = { 8, 8, 7, 7, 8, 8, 4, 2, 3, 3, 2, 2, 2, 2, 2, 2 };
int16_t ref_sort_order[16] = { 0, 1, 4, 5, 2, 3, 6, 8,
9, 12, 7, 10, 13, 11, 14, 15 };
TEST(ScanTest, av1_update_sort_order) {
const TX_SIZE tx_size = TX_4X4;
const uint32_t prob[16] = { 8, 8, 7, 7, 8, 8, 4, 2, 3, 3, 2, 2, 2, 2, 2, 2 };
const int16_t ref_sort_order[16] = { 0, 1, 4, 5, 2, 3, 6, 8,
9, 12, 7, 10, 13, 11, 14, 15 };
int16_t sort_order[16];
av1_update_sort_order(tx_size, prob, sort_order);
for (int i = 0; i < 16; ++i) EXPECT_EQ(ref_sort_order[i], sort_order[i]);
}
TEST(scan_test, av1_update_scan_order) {
TEST(ScanTest, av1_update_scan_order) {
TX_SIZE tx_size = TX_4X4;
uint32_t prob[16] = { 4, 5, 7, 4, 5, 6, 8, 2, 3, 3, 2, 2, 2, 2, 2, 2 };
const uint32_t prob[16] = { 4, 5, 7, 4, 5, 6, 8, 2, 3, 3, 2, 2, 2, 2, 2, 2 };
int16_t sort_order[16];
int16_t scan[16];
int16_t iscan[16];
int16_t ref_iscan[16] = {
0, 1, 2, 6, 3, 4, 5, 10, 7, 8, 11, 13, 9, 12, 14, 15
};
const int16_t ref_iscan[16] = { 0, 1, 2, 6, 3, 4, 5, 10,
7, 8, 11, 13, 9, 12, 14, 15 };
av1_update_sort_order(tx_size, prob, sort_order);
av1_update_scan_order(tx_size, sort_order, scan, iscan);
for (int i = 0; i < 16; ++i) EXPECT_EQ(ref_iscan[i], iscan[i]);
for (int i = 0; i < 16; ++i) EXPECT_EQ(i, scan[ref_iscan[i]]);
for (int i = 0; i < 16; ++i) {
EXPECT_EQ(ref_iscan[i], iscan[i]);
EXPECT_EQ(i, scan[ref_iscan[i]]);
}
}
TEST(scan_test, av1_update_neighbors) {
TEST(ScanTest, av1_update_neighbors) {
TX_SIZE tx_size = TX_4X4;
// raster order
int16_t scan[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
const int16_t scan[16] = { 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15 };
int16_t nb[(16 + 1) * 2];
int16_t ref_nb[(16 + 1) * 2] = { 0, 0, 0, 0, 1, 1, 2, 2, 0, 0, 4, 1,
5, 2, 6, 3, 4, 4, 8, 5, 9, 6, 10, 7,
8, 8, 12, 9, 13, 10, 14, 11, 0, 0 };
const int16_t ref_nb[(16 + 1) * 2] = { 0, 0, 0, 0, 1, 1, 2, 2, 0,
0, 4, 1, 5, 2, 6, 3, 4, 4,
8, 5, 9, 6, 10, 7, 8, 8, 12,
9, 13, 10, 14, 11, 0, 0 };
// raster order's scan and iscan are the same
av1_update_neighbors(tx_size, scan, scan, nb);
......
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