blob: ea6da474697c33666db27e72b092d46ca7625e36 [file] [log] [blame]
Yaowu Xu253c0012016-08-15 10:27:19 -07001/*Daala video codec
2Copyright (c) 2013 Daala project contributors. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are met:
6
7- Redistributions of source code must retain the above copyright notice, this
8 list of conditions and the following disclaimer.
9
10- Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13
14THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
15AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
24
25#include <stdlib.h>
26
27#include "third_party/googletest/src/include/gtest/gtest.h"
28
29#include "test/acm_random.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070030#include "av1/common/odintrin.h"
Yaowu Xu253c0012016-08-15 10:27:19 -070031
Yaowu Xuc27fc142016-08-22 16:08:15 -070032using libaom_test::ACMRandom;
Yaowu Xu253c0012016-08-15 10:27:19 -070033
34TEST(Daala, TestDIVUuptoMAX) {
35 for (int d = 1; d <= OD_DIVU_DMAX; d++) {
36 for (uint32_t x = 1; x <= 1000000; x++) {
clang-format21a0c2c2016-08-18 15:10:22 -070037 GTEST_ASSERT_EQ(x / d, OD_DIVU_SMALL(x, d))
38 << "x=" << x << " d=" << d << " x/d=" << (x / d)
39 << " != " << OD_DIVU_SMALL(x, d);
Yaowu Xu253c0012016-08-15 10:27:19 -070040 }
41 }
42}
43
44TEST(Daala, TestDIVUrandI31) {
45 ACMRandom rnd(ACMRandom::DeterministicSeed());
46 for (int d = 1; d < OD_DIVU_DMAX; d++) {
47 for (int i = 0; i < 1000000; i++) {
48 uint32_t x = rnd.Rand31();
clang-format21a0c2c2016-08-18 15:10:22 -070049 GTEST_ASSERT_EQ(x / d, OD_DIVU_SMALL(x, d))
50 << "x=" << x << " d=" << d << " x/d=" << (x / d)
51 << " != " << OD_DIVU_SMALL(x, d);
Yaowu Xu253c0012016-08-15 10:27:19 -070052 }
53 }
54}