]> granicus.if.org Git - libvpx/blob - test/aq_segment_test.cc
Merge "endian_inl.h: fix mips32 android build"
[libvpx] / test / aq_segment_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 "third_party/googletest/src/include/gtest/gtest.h"
11 #include "test/codec_factory.h"
12 #include "test/encode_test_driver.h"
13 #include "test/i420_video_source.h"
14 #include "test/util.h"
15
16 namespace {
17
18 class AqSegmentTest
19     : public ::libvpx_test::EncoderTest,
20       public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
21  protected:
22   AqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
23   virtual ~AqSegmentTest() {}
24
25   virtual void SetUp() {
26     InitializeConfig();
27     SetMode(GET_PARAM(1));
28     set_cpu_used_ = GET_PARAM(2);
29     aq_mode_ = 0;
30   }
31
32   virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
33                                   ::libvpx_test::Encoder *encoder) {
34     if (video->frame() == 1) {
35       encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
36       encoder->Control(VP9E_SET_AQ_MODE, aq_mode_);
37       encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 100);
38     }
39   }
40
41   int set_cpu_used_;
42   int aq_mode_;
43 };
44
45 // Validate that this AQ segmentation mode (AQ=1, variance_ap)
46 // encodes and decodes without a mismatch.
47 TEST_P(AqSegmentTest, TestNoMisMatchAQ1) {
48   cfg_.rc_min_quantizer = 8;
49   cfg_.rc_max_quantizer = 56;
50   cfg_.rc_end_usage = VPX_CBR;
51   cfg_.g_lag_in_frames = 0;
52   cfg_.rc_buf_initial_sz = 500;
53   cfg_.rc_buf_optimal_sz = 500;
54   cfg_.rc_buf_sz = 1000;
55   cfg_.rc_target_bitrate = 300;
56
57   aq_mode_ = 1;
58
59   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
60                                         30, 1, 0, 100);
61
62   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
63 }
64
65 // Validate that this AQ segmentation mode (AQ=2, complexity_aq)
66 // encodes and decodes without a mismatch.
67 TEST_P(AqSegmentTest, TestNoMisMatchAQ2) {
68   cfg_.rc_min_quantizer = 8;
69   cfg_.rc_max_quantizer = 56;
70   cfg_.rc_end_usage = VPX_CBR;
71   cfg_.g_lag_in_frames = 0;
72   cfg_.rc_buf_initial_sz = 500;
73   cfg_.rc_buf_optimal_sz = 500;
74   cfg_.rc_buf_sz = 1000;
75   cfg_.rc_target_bitrate = 300;
76
77   aq_mode_ = 2;
78
79   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
80                                         30, 1, 0, 100);
81
82   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
83 }
84
85 // Validate that this AQ segmentation mode (AQ=3, cyclic_refresh_aq)
86 // encodes and decodes without a mismatch.
87 TEST_P(AqSegmentTest, TestNoMisMatchAQ3) {
88   cfg_.rc_min_quantizer = 8;
89   cfg_.rc_max_quantizer = 56;
90   cfg_.rc_end_usage = VPX_CBR;
91   cfg_.g_lag_in_frames = 0;
92   cfg_.rc_buf_initial_sz = 500;
93   cfg_.rc_buf_optimal_sz = 500;
94   cfg_.rc_buf_sz = 1000;
95   cfg_.rc_target_bitrate = 300;
96
97   aq_mode_ = 3;
98
99   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
100                                         30, 1, 0, 100);
101
102   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
103 }
104
105 VP9_INSTANTIATE_TEST_CASE(AqSegmentTest,
106                           ::testing::Values(::libvpx_test::kRealTime,
107                                             ::libvpx_test::kOnePassGood),
108                           ::testing::Range(3, 9));
109 }  // namespace