2 * Copyright (c) 2016 The WebM project authors. All Rights Reserved.
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.
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"
18 const int kVideoSourceWidth = 320;
19 const int kVideoSourceHeight = 240;
20 const int kFramesToEncode = 2;
23 : public ::libvpx_test::EncoderTest,
24 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
26 RealtimeTest() : EncoderTest(GET_PARAM(0)), frame_packets_(0) {}
27 virtual ~RealtimeTest() {}
29 virtual void SetUp() {
31 cfg_.g_lag_in_frames = 0;
32 SetMode(::libvpx_test::kRealTime);
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
38 // VPX_RC_FIRST_PASS. This is necessary because EncoderTest::RunLoop() sets
39 // the pass value based on the mode passed into EncoderTest::SetMode(),
40 // which overrides the one specified in SetUp() above.
41 cfg_.g_pass = VPX_RC_FIRST_PASS;
43 virtual void FramePktHook(const vpx_codec_cx_pkt_t * /*pkt*/) {
50 TEST_P(RealtimeTest, RealtimeFirstPassProducesFrames) {
51 ::libvpx_test::RandomVideoSource video;
52 video.SetSize(kVideoSourceWidth, kVideoSourceHeight);
53 video.set_limit(kFramesToEncode);
54 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
55 EXPECT_EQ(kFramesToEncode, frame_packets_);
58 VP8_INSTANTIATE_TEST_CASE(RealtimeTest,
59 ::testing::Values(::libvpx_test::kRealTime));
60 VP9_INSTANTIATE_TEST_CASE(RealtimeTest,
61 ::testing::Values(::libvpx_test::kRealTime));