| /* |
| * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
| * |
| * Use of this source code is governed by a BSD-style license |
| * that can be found in the LICENSE file in the root of the source |
| * tree. An additional intellectual property rights grant can be found |
| * in the file PATENTS. All contributing project authors may |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| #include "third_party/googletest/src/include/gtest/gtest.h" |
| #include "test/codec_factory.h" |
| #include "test/encode_test_driver.h" |
| #include "test/i420_video_source.h" |
| #include "test/util.h" |
| |
| namespace { |
| |
| class AqSegmentTest |
| : public ::libaom_test::EncoderTest, |
| public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> { |
| protected: |
| AqSegmentTest() : EncoderTest(GET_PARAM(0)) {} |
| virtual ~AqSegmentTest() {} |
| |
| virtual void SetUp() { |
| InitializeConfig(); |
| SetMode(GET_PARAM(1)); |
| set_cpu_used_ = GET_PARAM(2); |
| aq_mode_ = 0; |
| } |
| |
| virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video, |
| ::libaom_test::Encoder *encoder) { |
| if (video->frame() == 1) { |
| encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_); |
| encoder->Control(VP9E_SET_AQ_MODE, aq_mode_); |
| encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 100); |
| } |
| } |
| |
| void DoTest(int aq_mode) { |
| aq_mode_ = aq_mode; |
| cfg_.kf_max_dist = 12; |
| cfg_.rc_min_quantizer = 8; |
| cfg_.rc_max_quantizer = 56; |
| cfg_.rc_end_usage = VPX_CBR; |
| cfg_.g_lag_in_frames = 6; |
| cfg_.rc_buf_initial_sz = 500; |
| cfg_.rc_buf_optimal_sz = 500; |
| cfg_.rc_buf_sz = 1000; |
| cfg_.rc_target_bitrate = 300; |
| ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, |
| 288, 30, 1, 0, 15); |
| ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| } |
| |
| int set_cpu_used_; |
| int aq_mode_; |
| }; |
| |
| // Validate that this AQ segmentation mode (AQ=1, variance_ap) |
| // encodes and decodes without a mismatch. |
| TEST_P(AqSegmentTest, TestNoMisMatchAQ1) { DoTest(1); } |
| |
| // Validate that this AQ segmentation mode (AQ=2, complexity_aq) |
| // encodes and decodes without a mismatch. |
| TEST_P(AqSegmentTest, TestNoMisMatchAQ2) { DoTest(2); } |
| |
| // Validate that this AQ segmentation mode (AQ=3, cyclic_refresh_aq) |
| // encodes and decodes without a mismatch. |
| TEST_P(AqSegmentTest, TestNoMisMatchAQ3) { DoTest(3); } |
| |
| class AqSegmentTestLarge : public AqSegmentTest {}; |
| |
| TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ1) { DoTest(1); } |
| |
| TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ2) { DoTest(2); } |
| |
| TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ3) { DoTest(3); } |
| |
| VP10_INSTANTIATE_TEST_CASE(AqSegmentTest, |
| ::testing::Values(::libaom_test::kRealTime, |
| ::libaom_test::kOnePassGood), |
| ::testing::Range(5, 9)); |
| VP10_INSTANTIATE_TEST_CASE(AqSegmentTestLarge, |
| ::testing::Values(::libaom_test::kRealTime, |
| ::libaom_test::kOnePassGood), |
| ::testing::Range(3, 5)); |
| } // namespace |