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 18namespace { 19 20class AqSegmentTest : public ::libvpx_test::EncoderTest, 21 public ::libvpx_test::CodecTestWith2Params< 22 libvpx_test::TestMode, int> { 23 protected: 24 AqSegmentTest() : EncoderTest(GET_PARAM(0)) {} 25 26 virtual void SetUp() { 27 InitializeConfig(); 28 SetMode(GET_PARAM(1)); 29 set_cpu_used_ = GET_PARAM(2); 30 aq_mode_ = 0; 31 } 32 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); 39 } 40 } 41 42 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { 43 if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) { 44 } 45 } 46 int set_cpu_used_; 47 int aq_mode_; 48}; 49 50// Validate that this AQ segmentation mode (AQ=1, variance_ap) 51// encodes and decodes without a mismatch. 52TEST_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; 61 62 aq_mode_ = 1; 63 64 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 65 30, 1, 0, 100); 66 67 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 68} 69 70// Validate that this AQ segmentation mode (AQ=2, complexity_aq) 71// encodes and decodes without a mismatch. 72TEST_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; 81 82 aq_mode_ = 2; 83 84 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 85 30, 1, 0, 100); 86 87 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 88} 89 90// Validate that this AQ segmentation mode (AQ=3, cyclic_refresh_aq) 91// encodes and decodes without a mismatch. 92TEST_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; 101 102 aq_mode_ = 3; 103 104 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 105 30, 1, 0, 100); 106 107 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 108} 109 110using std::tr1::make_tuple; 111 112#define VP9_FACTORY \ 113 static_cast<const libvpx_test::CodecFactory*> (&libvpx_test::kVP9) 114 115VP9_INSTANTIATE_TEST_CASE(AqSegmentTest, 116 ::testing::Values(::libvpx_test::kRealTime, 117 ::libvpx_test::kOnePassGood), 118 ::testing::Range(3, 9)); 119} // namespace 120