Add aq mode 0 and 3 to active map test
[platform/upstream/libvpx.git] / test / borders_test.cc
1 /*
2  *  Copyright (c) 2012 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
18 namespace {
19
20 class BordersTest
21     : public ::libvpx_test::EncoderTest,
22       public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
23  protected:
24   BordersTest() : EncoderTest(GET_PARAM(0)) {}
25   virtual ~BordersTest() {}
26
27   virtual void SetUp() {
28     InitializeConfig();
29     SetMode(GET_PARAM(1));
30   }
31
32   virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
33                                   ::libvpx_test::Encoder *encoder) {
34     if (video->frame() == 0) {
35       encoder->Control(VP8E_SET_CPUUSED, 1);
36       encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
37       encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
38       encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
39       encoder->Control(VP8E_SET_ARNR_TYPE, 3);
40     }
41   }
42
43   virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
44     if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) {
45     }
46   }
47 };
48
49 TEST_P(BordersTest, TestEncodeHighBitrate) {
50   // Validate that this non multiple of 64 wide clip encodes and decodes
51   // without a mismatch when passing in a very low max q.  This pushes
52   // the encoder to producing lots of big partitions which will likely
53   // extend into the border and test the border condition.
54   cfg_.g_lag_in_frames = 25;
55   cfg_.rc_2pass_vbr_minsection_pct = 5;
56   cfg_.rc_2pass_vbr_maxsection_pct = 2000;
57   cfg_.rc_target_bitrate = 2000;
58   cfg_.rc_max_quantizer = 10;
59
60   ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
61                                        40);
62
63   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
64 }
65 TEST_P(BordersTest, TestLowBitrate) {
66   // Validate that this clip encodes and decodes without a mismatch
67   // when passing in a very high min q.  This pushes the encoder to producing
68   // lots of small partitions which might will test the other condition.
69
70   cfg_.g_lag_in_frames = 25;
71   cfg_.rc_2pass_vbr_minsection_pct = 5;
72   cfg_.rc_2pass_vbr_maxsection_pct = 2000;
73   cfg_.rc_target_bitrate = 200;
74   cfg_.rc_min_quantizer = 40;
75
76   ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
77                                        40);
78
79   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
80 }
81
82 VP9_INSTANTIATE_TEST_SUITE(BordersTest,
83                            ::testing::Values(::libvpx_test::kTwoPassGood));
84 }  // namespace