Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
| 10 | */ |
| 11 | |
Arild Fuldseth (arilfuld) | 9f28cb8 | 2016-09-22 14:23:45 +0200 | [diff] [blame] | 12 | #include "./aom_config.h" |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 13 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 14 | #include "test/codec_factory.h" |
| 15 | #include "test/encode_test_driver.h" |
| 16 | #include "test/i420_video_source.h" |
| 17 | #include "test/util.h" |
| 18 | |
| 19 | namespace { |
| 20 | |
James Zern | 6de8dae | 2014-07-01 18:22:30 -0700 | [diff] [blame] | 21 | class AqSegmentTest |
Sebastien Alaiwan | 4322bc1 | 2017-06-05 10:18:28 +0200 | [diff] [blame] | 22 | : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>, |
| 23 | public ::libaom_test::EncoderTest { |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 24 | protected: |
| 25 | AqSegmentTest() : EncoderTest(GET_PARAM(0)) {} |
James Zern | 6de8dae | 2014-07-01 18:22:30 -0700 | [diff] [blame] | 26 | virtual ~AqSegmentTest() {} |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 27 | |
| 28 | virtual void SetUp() { |
| 29 | InitializeConfig(); |
| 30 | SetMode(GET_PARAM(1)); |
| 31 | set_cpu_used_ = GET_PARAM(2); |
| 32 | aq_mode_ = 0; |
| 33 | } |
| 34 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 35 | virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video, |
| 36 | ::libaom_test::Encoder *encoder) { |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 37 | if (video->frame() == 1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 38 | encoder->Control(AOME_SET_CPUUSED, set_cpu_used_); |
| 39 | encoder->Control(AV1E_SET_AQ_MODE, aq_mode_); |
Fangwen Fu | 4e2df09 | 2017-05-01 16:58:38 -0700 | [diff] [blame] | 40 | #if CONFIG_EXT_DELTA_Q |
| 41 | encoder->Control(AV1E_SET_DELTAQ_MODE, deltaq_mode_); |
| 42 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 43 | encoder->Control(AOME_SET_MAX_INTRA_BITRATE_PCT, 100); |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
Debargha Mukherjee | 567ee69 | 2016-06-15 11:26:48 -0700 | [diff] [blame] | 47 | void DoTest(int aq_mode) { |
| 48 | aq_mode_ = aq_mode; |
Fangwen Fu | 4e2df09 | 2017-05-01 16:58:38 -0700 | [diff] [blame] | 49 | #if CONFIG_EXT_DELTA_Q |
| 50 | deltaq_mode_ = 0; |
| 51 | #endif |
Debargha Mukherjee | 567ee69 | 2016-06-15 11:26:48 -0700 | [diff] [blame] | 52 | cfg_.kf_max_dist = 12; |
| 53 | cfg_.rc_min_quantizer = 8; |
| 54 | cfg_.rc_max_quantizer = 56; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 55 | cfg_.rc_end_usage = AOM_CBR; |
Debargha Mukherjee | 567ee69 | 2016-06-15 11:26:48 -0700 | [diff] [blame] | 56 | cfg_.g_lag_in_frames = 6; |
| 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; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 61 | ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 62 | 288, 30, 1, 0, 15); |
Debargha Mukherjee | 567ee69 | 2016-06-15 11:26:48 -0700 | [diff] [blame] | 63 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 64 | } |
| 65 | |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 66 | int set_cpu_used_; |
| 67 | int aq_mode_; |
Fangwen Fu | 4e2df09 | 2017-05-01 16:58:38 -0700 | [diff] [blame] | 68 | #if CONFIG_EXT_DELTA_Q |
| 69 | int deltaq_mode_; |
| 70 | #endif |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | // Validate that this AQ segmentation mode (AQ=1, variance_ap) |
| 74 | // encodes and decodes without a mismatch. |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 75 | TEST_P(AqSegmentTest, TestNoMisMatchAQ1) { DoTest(1); } |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 76 | |
| 77 | // Validate that this AQ segmentation mode (AQ=2, complexity_aq) |
| 78 | // encodes and decodes without a mismatch. |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 79 | TEST_P(AqSegmentTest, TestNoMisMatchAQ2) { DoTest(2); } |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 80 | |
| 81 | // Validate that this AQ segmentation mode (AQ=3, cyclic_refresh_aq) |
| 82 | // encodes and decodes without a mismatch. |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 83 | TEST_P(AqSegmentTest, TestNoMisMatchAQ3) { DoTest(3); } |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 84 | |
Debargha Mukherjee | 567ee69 | 2016-06-15 11:26:48 -0700 | [diff] [blame] | 85 | class AqSegmentTestLarge : public AqSegmentTest {}; |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 86 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 87 | TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ1) { DoTest(1); } |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 88 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 89 | TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ2) { DoTest(2); } |
Debargha Mukherjee | 567ee69 | 2016-06-15 11:26:48 -0700 | [diff] [blame] | 90 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 91 | TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ3) { DoTest(3); } |
Debargha Mukherjee | 567ee69 | 2016-06-15 11:26:48 -0700 | [diff] [blame] | 92 | |
Fangwen Fu | 4e2df09 | 2017-05-01 16:58:38 -0700 | [diff] [blame] | 93 | #if CONFIG_DELTA_Q & !CONFIG_EXT_DELTA_Q |
Arild Fuldseth (arilfuld) | 9f28cb8 | 2016-09-22 14:23:45 +0200 | [diff] [blame] | 94 | // Validate that this AQ mode (AQ=4, delta q) |
| 95 | // encodes and decodes without a mismatch. |
| 96 | TEST_P(AqSegmentTest, TestNoMisMatchAQ4) { |
| 97 | cfg_.rc_end_usage = AOM_CQ; |
Arild Fuldseth (arilfuld) | 9f28cb8 | 2016-09-22 14:23:45 +0200 | [diff] [blame] | 98 | aq_mode_ = 4; |
| 99 | |
| 100 | ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
Yaowu Xu | a51cb56 | 2017-05-08 14:49:29 -0700 | [diff] [blame] | 101 | 30, 1, 0, 15); |
Arild Fuldseth (arilfuld) | 9f28cb8 | 2016-09-22 14:23:45 +0200 | [diff] [blame] | 102 | |
| 103 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 104 | } |
| 105 | #endif |
| 106 | |
Fangwen Fu | 4e2df09 | 2017-05-01 16:58:38 -0700 | [diff] [blame] | 107 | #if CONFIG_EXT_DELTA_Q |
| 108 | // Validate that this delta q mode |
| 109 | // encodes and decodes without a mismatch. |
| 110 | TEST_P(AqSegmentTest, TestNoMisMatchExtDeltaQ) { |
| 111 | cfg_.rc_end_usage = AOM_CQ; |
| 112 | aq_mode_ = 0; |
| 113 | deltaq_mode_ = 2; |
| 114 | ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
Yaowu Xu | a51cb56 | 2017-05-08 14:49:29 -0700 | [diff] [blame] | 115 | 30, 1, 0, 15); |
Fangwen Fu | 4e2df09 | 2017-05-01 16:58:38 -0700 | [diff] [blame] | 116 | |
| 117 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 118 | } |
| 119 | #endif |
| 120 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 121 | AV1_INSTANTIATE_TEST_CASE(AqSegmentTest, |
| 122 | ::testing::Values(::libaom_test::kRealTime, |
| 123 | ::libaom_test::kOnePassGood), |
| 124 | ::testing::Range(5, 9)); |
| 125 | AV1_INSTANTIATE_TEST_CASE(AqSegmentTestLarge, |
| 126 | ::testing::Values(::libaom_test::kRealTime, |
| 127 | ::libaom_test::kOnePassGood), |
| 128 | ::testing::Range(3, 5)); |
Marco Paniconi | 6b83884 | 2014-03-14 14:35:47 -0700 | [diff] [blame] | 129 | } // namespace |