blob: 8bdd2e6750127f20047e605aaf18bbab0c6dc12a [file] [log] [blame]
Elliott Karpilovsky5fb44032019-11-13 14:34:37 -08001/*
2 * Copyright (c) 2019, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12#include <stdbool.h>
13#include "test/util.h"
14#include "av1/common/reconinter.h"
15#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
16
17#if CONFIG_ILLUM_MCOMP
18
19namespace {
20
21// To instantiate a regular test.
22class IllumMcompTest : public ::testing::Test {};
23
Elliott Karpilovsky7264e712020-08-10 20:58:56 -070024#if ILLUM_MCOMP_OLD
25
Elliott Karpilovsky5fb44032019-11-13 14:34:37 -080026TEST_F(IllumMcompTest, ComputeDc) {
27 uint8_t pred[256];
28 // Averaging the same color, is always that color.
29 for (int i = 0; i < 256; ++i) {
30 for (int j = 0; j < 256; ++j) {
31 pred[j] = i;
32 }
33 // Try different shapes/sizes/strides. They should all
34 // produce the same value.
Elliott Karpilovsky2a28eb82020-03-02 15:37:45 -080035 ASSERT_EQ(i, illum_mcomp_compute_dc_lowbd(pred, 8, 8, 8));
36 ASSERT_EQ(i, illum_mcomp_compute_dc_lowbd(pred, 1, 1, 256));
37 ASSERT_EQ(i, illum_mcomp_compute_dc_lowbd(pred, 2, 1, 128));
38 ASSERT_EQ(i, illum_mcomp_compute_dc_lowbd(pred, 2, 2, 128));
Elliott Karpilovsky5fb44032019-11-13 14:34:37 -080039 }
40
41 // Try half black, half white. Average should be grey.
42 for (int j = 0; j < 256; ++j) {
43 pred[j] = (j < 128) ? 0 : 255;
44 }
Elliott Karpilovsky2a28eb82020-03-02 15:37:45 -080045 ASSERT_EQ(128, illum_mcomp_compute_dc_lowbd(pred, 16, 16, 16));
46 ASSERT_EQ(128, illum_mcomp_compute_dc_lowbd(pred, 1, 1, 256));
47 ASSERT_EQ(128, illum_mcomp_compute_dc_lowbd(pred, 2, 1, 128));
48 ASSERT_EQ(128, illum_mcomp_compute_dc_lowbd(pred, 2, 2, 128));
Elliott Karpilovsky5fb44032019-11-13 14:34:37 -080049}
50
51TEST_F(IllumMcompTest, ComputeDcHigh) {
52 uint16_t pred[256];
53 for (int i = 0; i < 1024; ++i) {
54 for (int j = 0; j < 256; ++j) {
55 pred[j] = i;
56 }
57 // Try different shapes/sizes/strides. They should all
58 // produce the same value.
Elliott Karpilovsky2a28eb82020-03-02 15:37:45 -080059 ASSERT_EQ(i, illum_mcomp_compute_dc_highbd(pred, 16, 16, 16));
60 ASSERT_EQ(i, illum_mcomp_compute_dc_highbd(pred, 1, 1, 256));
61 ASSERT_EQ(i, illum_mcomp_compute_dc_highbd(pred, 2, 1, 128));
62 ASSERT_EQ(i, illum_mcomp_compute_dc_highbd(pred, 2, 2, 128));
Elliott Karpilovsky5fb44032019-11-13 14:34:37 -080063 }
64
65 // Try half black, half white. Average should be grey.
66 for (int j = 0; j < 256; ++j) {
67 pred[j] = (j < 128) ? 0 : 1023;
68 }
Elliott Karpilovsky2a28eb82020-03-02 15:37:45 -080069 ASSERT_EQ(512, illum_mcomp_compute_dc_highbd(pred, 16, 16, 16));
70 ASSERT_EQ(512, illum_mcomp_compute_dc_highbd(pred, 1, 1, 256));
71 ASSERT_EQ(512, illum_mcomp_compute_dc_highbd(pred, 2, 1, 128));
72 ASSERT_EQ(512, illum_mcomp_compute_dc_highbd(pred, 2, 2, 128));
Elliott Karpilovsky5fb44032019-11-13 14:34:37 -080073}
74
Elliott Karpilovsky7264e712020-08-10 20:58:56 -070075#endif // ILLUM_MCOMP_OLD
76
Elliott Karpilovsky5fb44032019-11-13 14:34:37 -080077} // namespace
78
79#endif // CONFIG_ILLUM_MCOMP