blob: 2d30480458a64a6252b3a8191438c741f32feb10 [file] [log] [blame]
Alex Conversea5654692014-03-11 16:40:57 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Alex Conversea5654692014-03-11 16:40:57 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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 Conversea5654692014-03-11 16:40:57 -070012#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
20namespace {
21
22class ActiveMapTest
Yaowu Xuc27fc142016-08-22 16:08:15 -070023 : public ::libaom_test::EncoderTest,
24 public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
Alex Conversea5654692014-03-11 16:40:57 -070025 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 Xuc27fc142016-08-22 16:08:15 -070038 virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
39 ::libaom_test::Encoder *encoder) {
Alex Conversea5654692014-03-11 16:40:57 -070040 if (video->frame() == 1) {
Yaowu Xuf883b422016-08-30 14:01:10 -070041 encoder->Control(AOME_SET_CPUUSED, cpu_used_);
Alex Conversea5654692014-03-11 16:40:57 -070042 } else if (video->frame() == 3) {
Yaowu Xuf883b422016-08-30 14:01:10 -070043 aom_active_map_t map = aom_active_map_t();
clang-format3a826f12016-08-11 17:46:05 -070044 /* clang-format off */
Alex Conversea5654692014-03-11 16:40:57 -070045 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-format3a826f12016-08-11 17:46:05 -070056 /* clang-format on */
Alex Conversea5654692014-03-11 16:40:57 -070057 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 Xuf883b422016-08-30 14:01:10 -070062 encoder->Control(AOME_SET_ACTIVEMAP, &map);
Alex Conversea5654692014-03-11 16:40:57 -070063 } else if (video->frame() == 15) {
Yaowu Xuf883b422016-08-30 14:01:10 -070064 aom_active_map_t map = aom_active_map_t();
Alex Conversea5654692014-03-11 16:40:57 -070065 map.cols = (kWidth + 15) / 16;
66 map.rows = (kHeight + 15) / 16;
67 map.active_map = NULL;
Yaowu Xuf883b422016-08-30 14:01:10 -070068 encoder->Control(AOME_SET_ACTIVEMAP, &map);
Alex Conversea5654692014-03-11 16:40:57 -070069 }
70 }
71
Debargha Mukherjee6abddf32016-06-14 14:50:30 -070072 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 Xuf883b422016-08-30 14:01:10 -070077 cfg_.g_pass = AOM_RC_ONE_PASS;
78 cfg_.rc_end_usage = AOM_CBR;
Debargha Mukherjee6abddf32016-06-14 14:50:30 -070079 cfg_.kf_max_dist = 90000;
Yaowu Xuc27fc142016-08-22 16:08:15 -070080 ::libaom_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 30,
Debargha Mukherjee6abddf32016-06-14 14:50:30 -070081 1, 0, 20);
82
83 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
84 }
85
Alex Conversea5654692014-03-11 16:40:57 -070086 int cpu_used_;
87};
88
clang-format3a826f12016-08-11 17:46:05 -070089TEST_P(ActiveMapTest, Test) { DoTest(); }
Alex Conversea5654692014-03-11 16:40:57 -070090
Debargha Mukherjee6abddf32016-06-14 14:50:30 -070091class ActiveMapTestLarge : public ActiveMapTest {};
Alex Conversea5654692014-03-11 16:40:57 -070092
clang-format3a826f12016-08-11 17:46:05 -070093TEST_P(ActiveMapTestLarge, Test) { DoTest(); }
Alex Conversea5654692014-03-11 16:40:57 -070094
Yaowu Xuf883b422016-08-30 14:01:10 -070095AV1_INSTANTIATE_TEST_CASE(ActiveMapTestLarge,
96 ::testing::Values(::libaom_test::kRealTime),
97 ::testing::Range(0, 5));
Geza Lore7172e972016-06-17 11:46:23 +010098
Yaowu Xuf883b422016-08-30 14:01:10 -070099AV1_INSTANTIATE_TEST_CASE(ActiveMapTest,
100 ::testing::Values(::libaom_test::kRealTime),
101 ::testing::Range(5, 9));
Geza Lore7172e972016-06-17 11:46:23 +0100102
Alex Conversea5654692014-03-11 16:40:57 -0700103} // namespace