vp9_motion_vector_test.cc 3.1 KB

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