blob: ffe4a3146b78e9caf48cb67713ff659f4b2d1092 [file] [log] [blame]
Tom Finegan5a9f21d2016-06-15 13:42:59 -07001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Tom Finegan5a9f21d2016-06-15 13:42:59 -07003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * 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 Finegan5a9f21d2016-06-15 13:42:59 -070010 */
Yaowu Xubde4ac82016-11-28 15:26:06 -080011
Tom Finegan5a9f21d2016-06-15 13:42:59 -070012#include "test/codec_factory.h"
13#include "test/encode_test_driver.h"
14#include "test/util.h"
15#include "test/video_source.h"
Tom Finegan7a07ece2017-02-07 17:14:05 -080016#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Tom Finegan5a9f21d2016-06-15 13:42:59 -070017
18namespace {
19
20const int kVideoSourceWidth = 320;
21const int kVideoSourceHeight = 240;
22const int kFramesToEncode = 2;
23
24class RealtimeTest
Yaowu Xuc27fc142016-08-22 16:08:15 -070025 : public ::libaom_test::EncoderTest,
26 public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
Tom Finegan5a9f21d2016-06-15 13:42:59 -070027 protected:
clang-format3a826f12016-08-11 17:46:05 -070028 RealtimeTest() : EncoderTest(GET_PARAM(0)), frame_packets_(0) {}
Tom Finegan5a9f21d2016-06-15 13:42:59 -070029 virtual ~RealtimeTest() {}
30
31 virtual void SetUp() {
32 InitializeConfig();
33 cfg_.g_lag_in_frames = 0;
Yaowu Xuc27fc142016-08-22 16:08:15 -070034 SetMode(::libaom_test::kRealTime);
Tom Finegan5a9f21d2016-06-15 13:42:59 -070035 }
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 Xuf883b422016-08-30 14:01:10 -070040 // AOM_RC_FIRST_PASS. This is necessary because EncoderTest::RunLoop() sets
Tom Finegan5a9f21d2016-06-15 13:42:59 -070041 // the pass value based on the mode passed into EncoderTest::SetMode(),
42 // which overrides the one specified in SetUp() above.
Yaowu Xuf883b422016-08-30 14:01:10 -070043 cfg_.g_pass = AOM_RC_FIRST_PASS;
Tom Finegan5a9f21d2016-06-15 13:42:59 -070044 }
Yaowu Xuf883b422016-08-30 14:01:10 -070045 virtual void FramePktHook(const aom_codec_cx_pkt_t * /*pkt*/) {
Tom Finegan5a9f21d2016-06-15 13:42:59 -070046 frame_packets_++;
47 }
Tom Finegan5a9f21d2016-06-15 13:42:59 -070048
Tom Finegan5a9f21d2016-06-15 13:42:59 -070049 int frame_packets_;
50};
51
52TEST_P(RealtimeTest, RealtimeFirstPassProducesFrames) {
Yaowu Xuc27fc142016-08-22 16:08:15 -070053 ::libaom_test::RandomVideoSource video;
Tom Finegan5a9f21d2016-06-15 13:42:59 -070054 video.SetSize(kVideoSourceWidth, kVideoSourceHeight);
55 video.set_limit(kFramesToEncode);
56 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
Tom Finegan5a9f21d2016-06-15 13:42:59 -070057 EXPECT_EQ(kFramesToEncode, frame_packets_);
58}
59
Yaowu Xuf883b422016-08-30 14:01:10 -070060AV1_INSTANTIATE_TEST_CASE(RealtimeTest,
Yaowu Xuc27fc142016-08-22 16:08:15 -070061 ::testing::Values(::libaom_test::kRealTime));
Tom Finegan5a9f21d2016-06-15 13:42:59 -070062
63} // namespace