2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
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.
11 #include "config/aom_config.h"
13 #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"
22 : public ::libaom_test::CodecTestWith2Params
<libaom_test::TestMode
, int>,
23 public ::libaom_test::EncoderTest
{
25 QMTest() : EncoderTest(GET_PARAM(0)) {}
28 virtual void SetUp() {
30 SetMode(GET_PARAM(1));
31 set_cpu_used_
= GET_PARAM(2);
34 virtual void PreEncodeFrameHook(::libaom_test::VideoSource
*video
,
35 ::libaom_test::Encoder
*encoder
) {
36 if (video
->frame() == 1) {
37 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_
);
42 encoder
->Control(AOME_SET_MAX_INTRA_BITRATE_PCT
, 100);
46 void DoTest(int qm_min
, int 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,
60 ASSERT_NO_FATAL_FAILURE(RunLoop(&video
));
68 // encodes and decodes without a mismatch.
69 TEST_P(QMTest
, TestNoMisMatchQM1
) { DoTest(5, 9); }
71 // encodes and decodes without a mismatch.
72 TEST_P(QMTest
, TestNoMisMatchQM2
) { DoTest(0, 8); }
74 // encodes and decodes without a mismatch.
75 TEST_P(QMTest
, TestNoMisMatchQM3
) { DoTest(9, 15); }
77 AV1_INSTANTIATE_TEST_CASE(QMTest
,
78 ::testing::Values(::libaom_test::kRealTime
,
79 ::libaom_test::kOnePassGood
),
80 ::testing::Range(5, 9));