1 /*
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10 #include <climits>
11 #include <vector>
12 #include "gtest/gtest.h"
13 #include "test/codec_factory.h"
14 #include "test/encode_test_driver.h"
15 #include "test/i420_video_source.h"
16 #include "test/util.h"
17 #include "vpx_config.h"
18
19 namespace {
20
21 class BordersTest
22 : public ::libvpx_test::EncoderTest,
23 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
24 protected:
BordersTest()25 BordersTest() : EncoderTest(GET_PARAM(0)) {}
26 ~BordersTest() override = default;
27
SetUp()28 void SetUp() override {
29 InitializeConfig();
30 SetMode(GET_PARAM(1));
31 }
32
PreEncodeFrameHook(::libvpx_test::VideoSource * video,::libvpx_test::Encoder * encoder)33 void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
34 ::libvpx_test::Encoder *encoder) override {
35 if (video->frame() == 0) {
36 encoder->Control(VP8E_SET_CPUUSED, 1);
37 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
38 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
39 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
40 encoder->Control(VP8E_SET_ARNR_TYPE, 3);
41 }
42 }
43
FramePktHook(const vpx_codec_cx_pkt_t * pkt)44 void FramePktHook(const vpx_codec_cx_pkt_t *pkt) override {
45 if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) {
46 }
47 }
48 };
49
TEST_P(BordersTest,TestEncodeHighBitrate)50 TEST_P(BordersTest, TestEncodeHighBitrate) {
51 // Validate that this non multiple of 64 wide clip encodes and decodes
52 // without a mismatch when passing in a very low max q. This pushes
53 // the encoder to producing lots of big partitions which will likely
54 // extend into the border and test the border condition.
55 cfg_.g_lag_in_frames = 25;
56 cfg_.rc_2pass_vbr_minsection_pct = 5;
57 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
58 cfg_.rc_target_bitrate = 2000;
59 cfg_.rc_max_quantizer = 10;
60
61 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
62 40);
63
64 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
65 }
TEST_P(BordersTest,TestLowBitrate)66 TEST_P(BordersTest, TestLowBitrate) {
67 // Validate that this clip encodes and decodes without a mismatch
68 // when passing in a very high min q. This pushes the encoder to producing
69 // lots of small partitions which might will test the other condition.
70
71 cfg_.g_lag_in_frames = 25;
72 cfg_.rc_2pass_vbr_minsection_pct = 5;
73 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
74 cfg_.rc_target_bitrate = 200;
75 cfg_.rc_min_quantizer = 40;
76
77 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
78 40);
79
80 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
81 }
82
83 #if CONFIG_REALTIME_ONLY
84 VP9_INSTANTIATE_TEST_SUITE(BordersTest,
85 ::testing::Values(::libvpx_test::kRealTime));
86 #else
87 VP9_INSTANTIATE_TEST_SUITE(BordersTest,
88 ::testing::Values(::libvpx_test::kTwoPassGood));
89 #endif
90 } // namespace
91