2 * Copyright (c) 2012 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"
20 class AqSegmentTest : public ::libvpx_test::EncoderTest,
21 public ::libvpx_test::CodecTestWith2Params<
22 libvpx_test::TestMode, int> {
24 AqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
26 virtual void SetUp() {
28 SetMode(GET_PARAM(1));
29 set_cpu_used_ = GET_PARAM(2);
33 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
34 ::libvpx_test::Encoder *encoder) {
35 if (video->frame() == 1) {
36 encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
37 encoder->Control(VP9E_SET_AQ_MODE, aq_mode_);
38 encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 100);
42 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
43 if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) {
50 // Validate that this AQ segmentation mode (AQ=1, variance_ap)
51 // encodes and decodes without a mismatch.
52 TEST_P(AqSegmentTest, TestNoMisMatchAQ1) {
53 cfg_.rc_min_quantizer = 8;
54 cfg_.rc_max_quantizer = 56;
55 cfg_.rc_end_usage = VPX_CBR;
56 cfg_.g_lag_in_frames = 0;
57 cfg_.rc_buf_initial_sz = 500;
58 cfg_.rc_buf_optimal_sz = 500;
59 cfg_.rc_buf_sz = 1000;
60 cfg_.rc_target_bitrate = 300;
64 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
67 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
70 // Validate that this AQ segmentation mode (AQ=2, complexity_aq)
71 // encodes and decodes without a mismatch.
72 TEST_P(AqSegmentTest, TestNoMisMatchAQ2) {
73 cfg_.rc_min_quantizer = 8;
74 cfg_.rc_max_quantizer = 56;
75 cfg_.rc_end_usage = VPX_CBR;
76 cfg_.g_lag_in_frames = 0;
77 cfg_.rc_buf_initial_sz = 500;
78 cfg_.rc_buf_optimal_sz = 500;
79 cfg_.rc_buf_sz = 1000;
80 cfg_.rc_target_bitrate = 300;
84 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
87 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
90 // Validate that this AQ segmentation mode (AQ=3, cyclic_refresh_aq)
91 // encodes and decodes without a mismatch.
92 TEST_P(AqSegmentTest, TestNoMisMatchAQ3) {
93 cfg_.rc_min_quantizer = 8;
94 cfg_.rc_max_quantizer = 56;
95 cfg_.rc_end_usage = VPX_CBR;
96 cfg_.g_lag_in_frames = 0;
97 cfg_.rc_buf_initial_sz = 500;
98 cfg_.rc_buf_optimal_sz = 500;
99 cfg_.rc_buf_sz = 1000;
100 cfg_.rc_target_bitrate = 300;
104 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
107 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
110 using std::tr1::make_tuple;
112 #define VP9_FACTORY \
113 static_cast<const libvpx_test::CodecFactory*> (&libvpx_test::kVP9)
115 VP9_INSTANTIATE_TEST_CASE(AqSegmentTest,
116 ::testing::Values(::libvpx_test::kRealTime,
117 ::libvpx_test::kOnePassGood),
118 ::testing::Range(3, 9));