Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 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. |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 10 | */ |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 11 | |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 12 | #include "test/codec_factory.h" |
| 13 | #include "test/encode_test_driver.h" |
| 14 | #include "test/util.h" |
| 15 | #include "test/video_source.h" |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 16 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 17 | |
| 18 | namespace { |
| 19 | |
| 20 | const int kVideoSourceWidth = 320; |
| 21 | const int kVideoSourceHeight = 240; |
| 22 | const int kFramesToEncode = 2; |
| 23 | |
| 24 | class RealtimeTest |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 25 | : public ::libaom_test::EncoderTest, |
| 26 | public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> { |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 27 | protected: |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 28 | RealtimeTest() : EncoderTest(GET_PARAM(0)), frame_packets_(0) {} |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 29 | virtual ~RealtimeTest() {} |
| 30 | |
| 31 | virtual void SetUp() { |
| 32 | InitializeConfig(); |
| 33 | cfg_.g_lag_in_frames = 0; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 34 | SetMode(::libaom_test::kRealTime); |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | virtual void BeginPassHook(unsigned int /*pass*/) { |
| 38 | // TODO(tomfinegan): We're changing the pass value here to make sure |
| 39 | // we get frames when real time mode is combined with |g_pass| set to |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 40 | // AOM_RC_FIRST_PASS. This is necessary because EncoderTest::RunLoop() sets |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 41 | // the pass value based on the mode passed into EncoderTest::SetMode(), |
| 42 | // which overrides the one specified in SetUp() above. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 43 | cfg_.g_pass = AOM_RC_FIRST_PASS; |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 44 | } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 45 | virtual void FramePktHook(const aom_codec_cx_pkt_t * /*pkt*/) { |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 46 | frame_packets_++; |
| 47 | } |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 48 | |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 49 | int frame_packets_; |
| 50 | }; |
| 51 | |
| 52 | TEST_P(RealtimeTest, RealtimeFirstPassProducesFrames) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 53 | ::libaom_test::RandomVideoSource video; |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 54 | video.SetSize(kVideoSourceWidth, kVideoSourceHeight); |
| 55 | video.set_limit(kFramesToEncode); |
| 56 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 57 | EXPECT_EQ(kFramesToEncode, frame_packets_); |
| 58 | } |
| 59 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 60 | AV1_INSTANTIATE_TEST_CASE(RealtimeTest, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 61 | ::testing::Values(::libaom_test::kRealTime)); |
Tom Finegan | 5a9f21d | 2016-06-15 13:42:59 -0700 | [diff] [blame] | 62 | |
| 63 | } // namespace |