2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 #include "third_party/googletest/src/include/gtest/gtest.h"
13 #include "test/codec_factory.h"
14 #include "test/encode_test_driver.h"
15 #include "test/i420_video_source.h"
16 #include "test/util.h"
21 : public ::libvpx_test::EncoderTest,
22 public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
24 static const int kWidth = 208;
25 static const int kHeight = 144;
27 ActiveMapTest() : EncoderTest(GET_PARAM(0)) {}
28 virtual ~ActiveMapTest() {}
30 virtual void SetUp() {
32 SetMode(GET_PARAM(1));
33 cpu_used_ = GET_PARAM(2);
36 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
37 ::libvpx_test::Encoder *encoder) {
38 if (video->frame() == 0) {
39 encoder->Control(VP8E_SET_CPUUSED, cpu_used_);
40 encoder->Control(VP9E_SET_AQ_MODE, 3);
41 } else if (video->frame() == 3) {
42 vpx_active_map_t map = vpx_active_map_t();
43 /* clang-format off */
44 uint8_t active_map[9 * 13] = {
45 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
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 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1,
50 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1,
51 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1,
52 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
53 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
56 map.cols = (kWidth + 15) / 16;
57 map.rows = (kHeight + 15) / 16;
58 ASSERT_EQ(map.cols, 13u);
59 ASSERT_EQ(map.rows, 9u);
60 map.active_map = active_map;
61 encoder->Control(VP8E_SET_ACTIVEMAP, &map);
62 } else if (video->frame() == 15) {
63 vpx_active_map_t map = vpx_active_map_t();
64 map.cols = (kWidth + 15) / 16;
65 map.rows = (kHeight + 15) / 16;
66 map.active_map = nullptr;
67 encoder->Control(VP8E_SET_ACTIVEMAP, &map);
74 TEST_P(ActiveMapTest, Test) {
75 // Validate that this non multiple of 64 wide clip encodes
76 cfg_.g_lag_in_frames = 0;
77 cfg_.rc_target_bitrate = 400;
78 cfg_.rc_resize_allowed = 0;
79 cfg_.g_pass = VPX_RC_ONE_PASS;
80 cfg_.rc_end_usage = VPX_CBR;
81 cfg_.kf_max_dist = 90000;
83 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 30, 1,
86 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
89 VP9_INSTANTIATE_TEST_SUITE(ActiveMapTest,
90 ::testing::Values(::libvpx_test::kRealTime),
91 ::testing::Range(0, 10));