blob: d1dfbb849b61ae2babe3a7a085d1d4058f534331 [file] [log] [blame]
Thomas Davies9d8004b2018-01-31 13:51:34 +00001/*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
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 */
Tom Finegan60e653d2018-05-22 11:34:58 -070011#include "config/aom_config.h"
12
Thomas Davies9d8004b2018-01-31 13:51:34 +000013#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
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
19namespace {
20
21class QMTest
22 : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
23 public ::libaom_test::EncoderTest {
24 protected:
25 QMTest() : EncoderTest(GET_PARAM(0)) {}
26 virtual ~QMTest() {}
27
28 virtual void SetUp() {
29 InitializeConfig();
30 SetMode(GET_PARAM(1));
31 set_cpu_used_ = GET_PARAM(2);
32 }
33
34 virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
35 ::libaom_test::Encoder *encoder) {
Yunqing Wang51b282d2018-10-01 16:25:34 -070036 if (video->frame() == 0) {
Thomas Davies9d8004b2018-01-31 13:51:34 +000037 encoder->Control(AOME_SET_CPUUSED, set_cpu_used_);
38 encoder->Control(AV1E_SET_ENABLE_QM, 1);
39 encoder->Control(AV1E_SET_QM_MIN, qm_min_);
40 encoder->Control(AV1E_SET_QM_MAX, qm_max_);
41
42 encoder->Control(AOME_SET_MAX_INTRA_BITRATE_PCT, 100);
43 }
44 }
45
46 void DoTest(int qm_min, int qm_max) {
47 qm_min_ = qm_min;
48 qm_max_ = qm_max;
49 cfg_.kf_max_dist = 12;
50 cfg_.rc_min_quantizer = 8;
51 cfg_.rc_max_quantizer = 56;
52 cfg_.rc_end_usage = AOM_CBR;
53 cfg_.g_lag_in_frames = 6;
54 cfg_.rc_buf_initial_sz = 500;
55 cfg_.rc_buf_optimal_sz = 500;
56 cfg_.rc_buf_sz = 1000;
57 cfg_.rc_target_bitrate = 300;
58 ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
59 288, 30, 1, 0, 15);
60 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
61 }
62
63 int set_cpu_used_;
64 int qm_min_;
65 int qm_max_;
66};
67
68// encodes and decodes without a mismatch.
69TEST_P(QMTest, TestNoMisMatchQM1) { DoTest(5, 9); }
70
71// encodes and decodes without a mismatch.
72TEST_P(QMTest, TestNoMisMatchQM2) { DoTest(0, 8); }
73
74// encodes and decodes without a mismatch.
75TEST_P(QMTest, TestNoMisMatchQM3) { DoTest(9, 15); }
76
77AV1_INSTANTIATE_TEST_CASE(QMTest,
78 ::testing::Values(::libaom_test::kRealTime,
79 ::libaom_test::kOnePassGood),
80 ::testing::Range(5, 9));
81} // namespace