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