Removed shadow warnings : postproc.c decodframe.c threading.c
[aom.git] / test / altref_test.cc
blobca055773df70ba7b416171df435dd238199934e1
1 /*
2 * Copyright (c) 2012 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.
9 */
10 #include "third_party/googletest/src/include/gtest/gtest.h"
11 #include "test/encode_test_driver.h"
12 #include "test/i420_video_source.h"
14 namespace {
16 // lookahead range: [kLookAheadMin, kLookAheadMax).
17 const int kLookAheadMin = 5;
18 const int kLookAheadMax = 26;
20 class AltRefTest : public libvpx_test::EncoderTest,
21 public ::testing::TestWithParam<int> {
22 protected:
23 AltRefTest() : altref_count_(0) {}
24 virtual ~AltRefTest() {}
26 virtual void SetUp() {
27 InitializeConfig();
28 SetMode(libvpx_test::kTwoPassGood);
31 virtual void BeginPassHook(unsigned int pass) {
32 altref_count_ = 0;
35 virtual bool Continue() const {
36 return !HasFatalFailure() && !abort_;
39 virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
40 libvpx_test::Encoder *encoder) {
41 if (video->frame() == 1) {
42 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
43 encoder->Control(VP8E_SET_CPUUSED, 3);
47 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
48 if (pkt->data.frame.flags & VPX_FRAME_IS_INVISIBLE) ++altref_count_;
51 int altref_count() const { return altref_count_; }
53 private:
54 int altref_count_;
57 TEST_P(AltRefTest, MonotonicTimestamps) {
58 const vpx_rational timebase = { 33333333, 1000000000 };
59 cfg_.g_timebase = timebase;
60 cfg_.rc_target_bitrate = 1000;
61 cfg_.g_lag_in_frames = GetParam();
63 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
64 timebase.den, timebase.num, 0, 30);
65 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
66 EXPECT_GE(altref_count(), 1);
69 INSTANTIATE_TEST_CASE_P(NonZeroLag, AltRefTest,
70 ::testing::Range(kLookAheadMin, kLookAheadMax));
71 } // namespace