Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 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 | |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 12 | #include <climits> |
| 13 | #include <vector> |
| 14 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 15 | #include "test/codec_factory.h" |
| 16 | #include "test/encode_test_driver.h" |
| 17 | #include "test/i420_video_source.h" |
| 18 | #include "test/util.h" |
| 19 | |
| 20 | namespace { |
| 21 | |
| 22 | class ActiveMapTest |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 23 | : public ::libaom_test::EncoderTest, |
| 24 | public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> { |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 25 | protected: |
| 26 | static const int kWidth = 208; |
| 27 | static const int kHeight = 144; |
| 28 | |
| 29 | ActiveMapTest() : EncoderTest(GET_PARAM(0)) {} |
| 30 | virtual ~ActiveMapTest() {} |
| 31 | |
| 32 | virtual void SetUp() { |
| 33 | InitializeConfig(); |
| 34 | SetMode(GET_PARAM(1)); |
| 35 | cpu_used_ = GET_PARAM(2); |
| 36 | } |
| 37 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 38 | virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video, |
| 39 | ::libaom_test::Encoder *encoder) { |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 40 | if (video->frame() == 1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 41 | encoder->Control(AOME_SET_CPUUSED, cpu_used_); |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 42 | } else if (video->frame() == 3) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 43 | aom_active_map_t map = aom_active_map_t(); |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 44 | /* clang-format off */ |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 45 | uint8_t active_map[9 * 13] = { |
| 46 | 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, |
| 47 | 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, |
| 48 | 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, |
| 49 | 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, |
| 50 | 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, |
| 51 | 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, |
| 52 | 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, |
| 53 | 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, |
| 54 | 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, |
| 55 | }; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 56 | /* clang-format on */ |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 57 | map.cols = (kWidth + 15) / 16; |
| 58 | map.rows = (kHeight + 15) / 16; |
| 59 | ASSERT_EQ(map.cols, 13u); |
| 60 | ASSERT_EQ(map.rows, 9u); |
| 61 | map.active_map = active_map; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 62 | encoder->Control(AOME_SET_ACTIVEMAP, &map); |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 63 | } else if (video->frame() == 15) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 64 | aom_active_map_t map = aom_active_map_t(); |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 65 | map.cols = (kWidth + 15) / 16; |
| 66 | map.rows = (kHeight + 15) / 16; |
| 67 | map.active_map = NULL; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 68 | encoder->Control(AOME_SET_ACTIVEMAP, &map); |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 69 | } |
| 70 | } |
| 71 | |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 72 | void DoTest() { |
| 73 | // Validate that this non multiple of 64 wide clip encodes |
| 74 | cfg_.g_lag_in_frames = 0; |
| 75 | cfg_.rc_target_bitrate = 400; |
| 76 | cfg_.rc_resize_allowed = 0; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 77 | cfg_.g_pass = AOM_RC_ONE_PASS; |
| 78 | cfg_.rc_end_usage = AOM_CBR; |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 79 | cfg_.kf_max_dist = 90000; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 80 | ::libaom_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 30, |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 81 | 1, 0, 20); |
| 82 | |
| 83 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 84 | } |
| 85 | |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 86 | int cpu_used_; |
| 87 | }; |
| 88 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 89 | TEST_P(ActiveMapTest, Test) { DoTest(); } |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 90 | |
Debargha Mukherjee | 6abddf3 | 2016-06-14 14:50:30 -0700 | [diff] [blame] | 91 | class ActiveMapTestLarge : public ActiveMapTest {}; |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 92 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 93 | TEST_P(ActiveMapTestLarge, Test) { DoTest(); } |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 94 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 95 | AV1_INSTANTIATE_TEST_CASE(ActiveMapTestLarge, |
| 96 | ::testing::Values(::libaom_test::kRealTime), |
| 97 | ::testing::Range(0, 5)); |
Geza Lore | 7172e97 | 2016-06-17 11:46:23 +0100 | [diff] [blame] | 98 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 99 | AV1_INSTANTIATE_TEST_CASE(ActiveMapTest, |
| 100 | ::testing::Values(::libaom_test::kRealTime), |
| 101 | ::testing::Range(5, 9)); |
Geza Lore | 7172e97 | 2016-06-17 11:46:23 +0100 | [diff] [blame] | 102 | |
Alex Converse | a565469 | 2014-03-11 16:40:57 -0700 | [diff] [blame] | 103 | } // namespace |