vp9_motion_vector_test.cc 3.1 KB

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