blob: 63f1ac3c2957d0cd0e6dd3a56e6f0d54cda43fcb [file] [log] [blame]
Tom Finegan5a9f21d2016-06-15 13:42:59 -07001/*
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
16namespace {
17
18const int kVideoSourceWidth = 320;
19const int kVideoSourceHeight = 240;
20const int kFramesToEncode = 2;
21
22class RealtimeTest
23 : public ::libvpx_test::EncoderTest,
24 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
25 protected:
clang-format3a826f12016-08-11 17:46:05 -070026 RealtimeTest() : EncoderTest(GET_PARAM(0)), frame_packets_(0) {}
Tom Finegan5a9f21d2016-06-15 13:42:59 -070027 virtual ~RealtimeTest() {}
28
29 virtual void SetUp() {
30 InitializeConfig();
31 cfg_.g_lag_in_frames = 0;
32 SetMode(::libvpx_test::kRealTime);
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
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;
42 }
43 virtual void FramePktHook(const vpx_codec_cx_pkt_t * /*pkt*/) {
44 frame_packets_++;
45 }
Tom Finegan5a9f21d2016-06-15 13:42:59 -070046
Tom Finegan5a9f21d2016-06-15 13:42:59 -070047 int frame_packets_;
48};
49
50TEST_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));
Tom Finegan5a9f21d2016-06-15 13:42:59 -070055 EXPECT_EQ(kFramesToEncode, frame_packets_);
56}
57
58VP8_INSTANTIATE_TEST_CASE(RealtimeTest,
59 ::testing::Values(::libvpx_test::kRealTime));
60VP9_INSTANTIATE_TEST_CASE(RealtimeTest,
61 ::testing::Values(::libvpx_test::kRealTime));
62
63} // namespace