Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 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 "third_party/googletest/src/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 | |
| 18 | namespace { |
| 19 | |
| 20 | class BordersTest : public ::libvpx_test::EncoderTest, |
| 21 | public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> { |
| 22 | protected: |
| 23 | BordersTest() : EncoderTest(GET_PARAM(0)) {} |
Alex Converse | 6207a38 | 2014-03-12 14:51:42 -0700 | [diff] [blame] | 24 | virtual ~BordersTest() {} |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 25 | |
| 26 | virtual void SetUp() { |
| 27 | InitializeConfig(); |
| 28 | SetMode(GET_PARAM(1)); |
| 29 | } |
| 30 | |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 31 | virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, |
| 32 | ::libvpx_test::Encoder *encoder) { |
Yaowu Xu | afffa3d | 2013-09-05 08:45:56 -0700 | [diff] [blame] | 33 | if (video->frame() == 1) { |
Yaowu Xu | 040ffb6 | 2013-09-13 09:23:53 -0700 | [diff] [blame] | 34 | encoder->Control(VP8E_SET_CPUUSED, 1); |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 35 | encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); |
| 36 | encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); |
| 37 | encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); |
Adrian Grange | 0a386b9 | 2014-04-28 14:28:58 -0700 | [diff] [blame] | 38 | encoder->Control(VP8E_SET_ARNR_TYPE, 3); |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 39 | } |
| 40 | } |
| 41 | |
| 42 | virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { |
| 43 | if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) { |
| 44 | } |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | TEST_P(BordersTest, TestEncodeHighBitrate) { |
| 49 | // Validate that this non multiple of 64 wide clip encodes and decodes |
| 50 | // without a mismatch when passing in a very low max q. This pushes |
| 51 | // the encoder to producing lots of big partitions which will likely |
| 52 | // extend into the border and test the border condition. |
| 53 | cfg_.g_lag_in_frames = 25; |
| 54 | cfg_.rc_2pass_vbr_minsection_pct = 5; |
| 55 | cfg_.rc_2pass_vbr_minsection_pct = 2000; |
| 56 | cfg_.rc_target_bitrate = 2000; |
| 57 | cfg_.rc_max_quantizer = 10; |
| 58 | |
| 59 | ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, |
| 60 | 40); |
| 61 | |
| 62 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 63 | } |
| 64 | TEST_P(BordersTest, TestLowBitrate) { |
| 65 | // Validate that this clip encodes and decodes without a mismatch |
| 66 | // when passing in a very high min q. This pushes the encoder to producing |
| 67 | // lots of small partitions which might will test the other condition. |
| 68 | |
| 69 | cfg_.g_lag_in_frames = 25; |
| 70 | cfg_.rc_2pass_vbr_minsection_pct = 5; |
Adrian Grange | 15cf596 | 2013-12-13 08:48:12 -0800 | [diff] [blame] | 71 | cfg_.rc_2pass_vbr_maxsection_pct = 2000; |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 72 | cfg_.rc_target_bitrate = 200; |
| 73 | cfg_.rc_min_quantizer = 40; |
| 74 | |
| 75 | ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, |
| 76 | 40); |
| 77 | |
| 78 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 79 | } |
| 80 | |
| 81 | VP9_INSTANTIATE_TEST_CASE(BordersTest, ::testing::Values( |
| 82 | ::libvpx_test::kTwoPassGood)); |
| 83 | } // namespace |