blob: 026b0022bbca6f4f85117808754d2b2c759a64c5 [file] [log] [blame]
Marco Paniconi6b838842014-03-14 14:35:47 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Marco Paniconi6b838842014-03-14 14:35:47 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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)9f28cb82016-09-22 14:23:45 +020012#include "./aom_config.h"
Tom Finegan7a07ece2017-02-07 17:14:05 -080013#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Marco Paniconi6b838842014-03-14 14:35:47 -070014#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
19namespace {
20
James Zern6de8dae2014-07-01 18:22:30 -070021class AqSegmentTest
Sebastien Alaiwan4322bc12017-06-05 10:18:28 +020022 : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
23 public ::libaom_test::EncoderTest {
Marco Paniconi6b838842014-03-14 14:35:47 -070024 protected:
25 AqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
James Zern6de8dae2014-07-01 18:22:30 -070026 virtual ~AqSegmentTest() {}
Marco Paniconi6b838842014-03-14 14:35:47 -070027
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 Xuc27fc142016-08-22 16:08:15 -070035 virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
36 ::libaom_test::Encoder *encoder) {
Marco Paniconi6b838842014-03-14 14:35:47 -070037 if (video->frame() == 1) {
Yaowu Xuf883b422016-08-30 14:01:10 -070038 encoder->Control(AOME_SET_CPUUSED, set_cpu_used_);
39 encoder->Control(AV1E_SET_AQ_MODE, aq_mode_);
Fangwen Fu4e2df092017-05-01 16:58:38 -070040#if CONFIG_EXT_DELTA_Q
41 encoder->Control(AV1E_SET_DELTAQ_MODE, deltaq_mode_);
42#endif
Yaowu Xuf883b422016-08-30 14:01:10 -070043 encoder->Control(AOME_SET_MAX_INTRA_BITRATE_PCT, 100);
Marco Paniconi6b838842014-03-14 14:35:47 -070044 }
45 }
46
Debargha Mukherjee567ee692016-06-15 11:26:48 -070047 void DoTest(int aq_mode) {
48 aq_mode_ = aq_mode;
Fangwen Fu4e2df092017-05-01 16:58:38 -070049#if CONFIG_EXT_DELTA_Q
50 deltaq_mode_ = 0;
51#endif
Debargha Mukherjee567ee692016-06-15 11:26:48 -070052 cfg_.kf_max_dist = 12;
53 cfg_.rc_min_quantizer = 8;
54 cfg_.rc_max_quantizer = 56;
Yaowu Xuf883b422016-08-30 14:01:10 -070055 cfg_.rc_end_usage = AOM_CBR;
Debargha Mukherjee567ee692016-06-15 11:26:48 -070056 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 Xuc27fc142016-08-22 16:08:15 -070061 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
clang-format3a826f12016-08-11 17:46:05 -070062 288, 30, 1, 0, 15);
Debargha Mukherjee567ee692016-06-15 11:26:48 -070063 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
64 }
65
Marco Paniconi6b838842014-03-14 14:35:47 -070066 int set_cpu_used_;
67 int aq_mode_;
Fangwen Fu4e2df092017-05-01 16:58:38 -070068#if CONFIG_EXT_DELTA_Q
69 int deltaq_mode_;
70#endif
Marco Paniconi6b838842014-03-14 14:35:47 -070071};
72
73// Validate that this AQ segmentation mode (AQ=1, variance_ap)
74// encodes and decodes without a mismatch.
clang-format3a826f12016-08-11 17:46:05 -070075TEST_P(AqSegmentTest, TestNoMisMatchAQ1) { DoTest(1); }
Marco Paniconi6b838842014-03-14 14:35:47 -070076
77// Validate that this AQ segmentation mode (AQ=2, complexity_aq)
78// encodes and decodes without a mismatch.
clang-format3a826f12016-08-11 17:46:05 -070079TEST_P(AqSegmentTest, TestNoMisMatchAQ2) { DoTest(2); }
Marco Paniconi6b838842014-03-14 14:35:47 -070080
81// Validate that this AQ segmentation mode (AQ=3, cyclic_refresh_aq)
82// encodes and decodes without a mismatch.
clang-format3a826f12016-08-11 17:46:05 -070083TEST_P(AqSegmentTest, TestNoMisMatchAQ3) { DoTest(3); }
Marco Paniconi6b838842014-03-14 14:35:47 -070084
Debargha Mukherjee567ee692016-06-15 11:26:48 -070085class AqSegmentTestLarge : public AqSegmentTest {};
Marco Paniconi6b838842014-03-14 14:35:47 -070086
clang-format3a826f12016-08-11 17:46:05 -070087TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ1) { DoTest(1); }
Marco Paniconi6b838842014-03-14 14:35:47 -070088
clang-format3a826f12016-08-11 17:46:05 -070089TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ2) { DoTest(2); }
Debargha Mukherjee567ee692016-06-15 11:26:48 -070090
clang-format3a826f12016-08-11 17:46:05 -070091TEST_P(AqSegmentTestLarge, TestNoMisMatchAQ3) { DoTest(3); }
Debargha Mukherjee567ee692016-06-15 11:26:48 -070092
Fangwen Fu4e2df092017-05-01 16:58:38 -070093#if CONFIG_DELTA_Q & !CONFIG_EXT_DELTA_Q
Arild Fuldseth (arilfuld)9f28cb82016-09-22 14:23:45 +020094// Validate that this AQ mode (AQ=4, delta q)
95// encodes and decodes without a mismatch.
96TEST_P(AqSegmentTest, TestNoMisMatchAQ4) {
97 cfg_.rc_end_usage = AOM_CQ;
Arild Fuldseth (arilfuld)9f28cb82016-09-22 14:23:45 +020098 aq_mode_ = 4;
99
100 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
Yaowu Xua51cb562017-05-08 14:49:29 -0700101 30, 1, 0, 15);
Arild Fuldseth (arilfuld)9f28cb82016-09-22 14:23:45 +0200102
103 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
104}
105#endif
106
Fangwen Fu4e2df092017-05-01 16:58:38 -0700107#if CONFIG_EXT_DELTA_Q
108// Validate that this delta q mode
109// encodes and decodes without a mismatch.
110TEST_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 Xua51cb562017-05-08 14:49:29 -0700115 30, 1, 0, 15);
Fangwen Fu4e2df092017-05-01 16:58:38 -0700116
117 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
118}
119#endif
120
Yaowu Xuf883b422016-08-30 14:01:10 -0700121AV1_INSTANTIATE_TEST_CASE(AqSegmentTest,
122 ::testing::Values(::libaom_test::kRealTime,
123 ::libaom_test::kOnePassGood),
124 ::testing::Range(5, 9));
125AV1_INSTANTIATE_TEST_CASE(AqSegmentTestLarge,
126 ::testing::Values(::libaom_test::kRealTime,
127 ::libaom_test::kOnePassGood),
128 ::testing::Range(3, 5));
Marco Paniconi6b838842014-03-14 14:35:47 -0700129} // namespace