blob: 022199519141266a6b162f360461f8693a041472 [file] [log] [blame]
Alex Conversea5654692014-03-11 16:40:57 -07001/*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 *
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.
9 */
10#include <climits>
11#include <vector>
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"
17
18namespace {
19
20class ActiveMapTest
21 : public ::libvpx_test::EncoderTest,
22 public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
23 protected:
24 static const int kWidth = 208;
25 static const int kHeight = 144;
26
27 ActiveMapTest() : EncoderTest(GET_PARAM(0)) {}
28 virtual ~ActiveMapTest() {}
29
30 virtual void SetUp() {
31 InitializeConfig();
32 SetMode(GET_PARAM(1));
33 cpu_used_ = GET_PARAM(2);
34 }
35
36 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
37 ::libvpx_test::Encoder *encoder) {
38 if (video->frame() == 1) {
39 encoder->Control(VP8E_SET_CPUUSED, cpu_used_);
40 } else if (video->frame() == 3) {
James Zernb070d702014-08-22 17:10:18 -070041 vpx_active_map_t map = vpx_active_map_t();
Alex Conversea5654692014-03-11 16:40:57 -070042 uint8_t active_map[9 * 13] = {
43 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
44 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
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 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1,
48 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1,
49 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1,
50 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
51 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
52 };
53 map.cols = (kWidth + 15) / 16;
54 map.rows = (kHeight + 15) / 16;
55 ASSERT_EQ(map.cols, 13u);
56 ASSERT_EQ(map.rows, 9u);
57 map.active_map = active_map;
58 encoder->Control(VP8E_SET_ACTIVEMAP, &map);
59 } else if (video->frame() == 15) {
James Zernb070d702014-08-22 17:10:18 -070060 vpx_active_map_t map = vpx_active_map_t();
Alex Conversea5654692014-03-11 16:40:57 -070061 map.cols = (kWidth + 15) / 16;
62 map.rows = (kHeight + 15) / 16;
63 map.active_map = NULL;
64 encoder->Control(VP8E_SET_ACTIVEMAP, &map);
65 }
66 }
67
68 int cpu_used_;
69};
70
71TEST_P(ActiveMapTest, Test) {
72 // Validate that this non multiple of 64 wide clip encodes
73 cfg_.g_lag_in_frames = 0;
74 cfg_.rc_target_bitrate = 400;
75 cfg_.rc_resize_allowed = 0;
76 cfg_.g_pass = VPX_RC_ONE_PASS;
77 cfg_.rc_end_usage = VPX_CBR;
78 cfg_.kf_max_dist = 90000;
79
80 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 30,
81 1, 0, 20);
82
83 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
84}
85
Alex Conversea5654692014-03-11 16:40:57 -070086VP9_INSTANTIATE_TEST_CASE(ActiveMapTest,
87 ::testing::Values(::libvpx_test::kRealTime),
88 ::testing::Range(0, 6));
89} // namespace