Home | History | Annotate | Download | only in test
      1 /*
      2  *  Copyright (c) 2017 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 
     11 #include "third_party/googletest/src/include/gtest/gtest.h"
     12 
     13 #include "test/codec_factory.h"
     14 #include "test/encode_test_driver.h"
     15 #include "test/util.h"
     16 #include "test/yuv_video_source.h"
     17 
     18 namespace {
     19 #define MAX_EXTREME_MV 1
     20 #define MIN_EXTREME_MV 2
     21 
     22 // Encoding modes
     23 const libvpx_test::TestMode kEncodingModeVectors[] = {
     24   ::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
     25   ::libvpx_test::kRealTime,
     26 };
     27 
     28 // Encoding speeds
     29 const int kCpuUsedVectors[] = { 0, 1, 2, 3, 4, 5, 6 };
     30 
     31 // MV test modes: 1 - always use maximum MV; 2 - always use minimum MV.
     32 const int kMVTestModes[] = { MAX_EXTREME_MV, MIN_EXTREME_MV };
     33 
     34 class MotionVectorTestLarge
     35     : public ::libvpx_test::EncoderTest,
     36       public ::libvpx_test::CodecTestWith3Params<libvpx_test::TestMode, int,
     37                                                  int> {
     38  protected:
     39   MotionVectorTestLarge()
     40       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
     41         cpu_used_(GET_PARAM(2)), mv_test_mode_(GET_PARAM(3)) {}
     42 
     43   virtual ~MotionVectorTestLarge() {}
     44 
     45   virtual void SetUp() {
     46     InitializeConfig();
     47     SetMode(encoding_mode_);
     48     if (encoding_mode_ != ::libvpx_test::kRealTime) {
     49       cfg_.g_lag_in_frames = 3;
     50       cfg_.rc_end_usage = VPX_VBR;
     51     } else {
     52       cfg_.g_lag_in_frames = 0;
     53       cfg_.rc_end_usage = VPX_CBR;
     54       cfg_.rc_buf_sz = 1000;
     55       cfg_.rc_buf_initial_sz = 500;
     56       cfg_.rc_buf_optimal_sz = 600;
     57     }
     58   }
     59 
     60   virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
     61                                   ::libvpx_test::Encoder *encoder) {
     62     if (video->frame() == 1) {
     63       encoder->Control(VP8E_SET_CPUUSED, cpu_used_);
     64       encoder->Control(VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST, mv_test_mode_);
     65       if (encoding_mode_ != ::libvpx_test::kRealTime) {
     66         encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
     67         encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
     68         encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
     69         encoder->Control(VP8E_SET_ARNR_TYPE, 3);
     70       }
     71     }
     72   }
     73 
     74   libvpx_test::TestMode encoding_mode_;
     75   int cpu_used_;
     76   int mv_test_mode_;
     77 };
     78 
     79 TEST_P(MotionVectorTestLarge, OverallTest) {
     80   cfg_.rc_target_bitrate = 24000;
     81   cfg_.g_profile = 0;
     82   init_flags_ = VPX_CODEC_USE_PSNR;
     83 
     84   testing::internal::scoped_ptr<libvpx_test::VideoSource> video;
     85   video.reset(new libvpx_test::YUVVideoSource(
     86       "niklas_640_480_30.yuv", VPX_IMG_FMT_I420, 3840, 2160,  // 2048, 1080,
     87       30, 1, 0, 5));
     88 
     89   ASSERT_TRUE(video.get() != NULL);
     90   ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
     91 }
     92 
     93 VP9_INSTANTIATE_TEST_CASE(MotionVectorTestLarge,
     94                           ::testing::ValuesIn(kEncodingModeVectors),
     95                           ::testing::ValuesIn(kCpuUsedVectors),
     96                           ::testing::ValuesIn(kMVTestModes));
     97 }  // namespace
     98