alt_ref_aq_segment_test.cc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (c) 2012 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/i420_video_source.h"
  14. #include "test/util.h"
  15. namespace {
  16. class AltRefAqSegmentTest
  17. : public ::libvpx_test::EncoderTest,
  18. public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
  19. protected:
  20. AltRefAqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
  21. virtual ~AltRefAqSegmentTest() {}
  22. virtual void SetUp() {
  23. InitializeConfig();
  24. SetMode(GET_PARAM(1));
  25. set_cpu_used_ = GET_PARAM(2);
  26. aq_mode_ = 0;
  27. alt_ref_aq_mode_ = 0;
  28. }
  29. virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
  30. ::libvpx_test::Encoder *encoder) {
  31. if (video->frame() == 0) {
  32. encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
  33. encoder->Control(VP9E_SET_ALT_REF_AQ, alt_ref_aq_mode_);
  34. encoder->Control(VP9E_SET_AQ_MODE, aq_mode_);
  35. encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 100);
  36. }
  37. }
  38. int set_cpu_used_;
  39. int aq_mode_;
  40. int alt_ref_aq_mode_;
  41. };
  42. // Validate that this ALT_REF_AQ/AQ segmentation mode
  43. // (ALT_REF_AQ=0, AQ=0/no_aq)
  44. // encodes and decodes without a mismatch.
  45. TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ0) {
  46. cfg_.rc_min_quantizer = 8;
  47. cfg_.rc_max_quantizer = 56;
  48. cfg_.rc_end_usage = VPX_VBR;
  49. cfg_.rc_buf_initial_sz = 500;
  50. cfg_.rc_buf_optimal_sz = 500;
  51. cfg_.rc_buf_sz = 1000;
  52. cfg_.rc_target_bitrate = 300;
  53. aq_mode_ = 0;
  54. alt_ref_aq_mode_ = 1;
  55. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  56. 30, 1, 0, 100);
  57. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  58. }
  59. // Validate that this ALT_REF_AQ/AQ segmentation mode
  60. // (ALT_REF_AQ=0, AQ=1/variance_aq)
  61. // encodes and decodes without a mismatch.
  62. TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ1) {
  63. cfg_.rc_min_quantizer = 8;
  64. cfg_.rc_max_quantizer = 56;
  65. cfg_.rc_end_usage = VPX_VBR;
  66. cfg_.rc_buf_initial_sz = 500;
  67. cfg_.rc_buf_optimal_sz = 500;
  68. cfg_.rc_buf_sz = 1000;
  69. cfg_.rc_target_bitrate = 300;
  70. aq_mode_ = 1;
  71. alt_ref_aq_mode_ = 1;
  72. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  73. 30, 1, 0, 100);
  74. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  75. }
  76. // Validate that this ALT_REF_AQ/AQ segmentation mode
  77. // (ALT_REF_AQ=0, AQ=2/complexity_aq)
  78. // encodes and decodes without a mismatch.
  79. TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ2) {
  80. cfg_.rc_min_quantizer = 8;
  81. cfg_.rc_max_quantizer = 56;
  82. cfg_.rc_end_usage = VPX_VBR;
  83. cfg_.rc_buf_initial_sz = 500;
  84. cfg_.rc_buf_optimal_sz = 500;
  85. cfg_.rc_buf_sz = 1000;
  86. cfg_.rc_target_bitrate = 300;
  87. aq_mode_ = 2;
  88. alt_ref_aq_mode_ = 1;
  89. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  90. 30, 1, 0, 100);
  91. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  92. }
  93. // Validate that this ALT_REF_AQ/AQ segmentation mode
  94. // (ALT_REF_AQ=0, AQ=3/cyclicrefresh_aq)
  95. // encodes and decodes without a mismatch.
  96. TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ3) {
  97. cfg_.rc_min_quantizer = 8;
  98. cfg_.rc_max_quantizer = 56;
  99. cfg_.rc_end_usage = VPX_VBR;
  100. cfg_.rc_buf_initial_sz = 500;
  101. cfg_.rc_buf_optimal_sz = 500;
  102. cfg_.rc_buf_sz = 1000;
  103. cfg_.rc_target_bitrate = 300;
  104. aq_mode_ = 3;
  105. alt_ref_aq_mode_ = 1;
  106. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  107. 30, 1, 0, 100);
  108. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  109. }
  110. // Validate that this ALT_REF_AQ/AQ segmentation mode
  111. // (ALT_REF_AQ=0, AQ=4/equator360_aq)
  112. // encodes and decodes without a mismatch.
  113. TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ4) {
  114. cfg_.rc_min_quantizer = 8;
  115. cfg_.rc_max_quantizer = 56;
  116. cfg_.rc_end_usage = VPX_VBR;
  117. cfg_.rc_buf_initial_sz = 500;
  118. cfg_.rc_buf_optimal_sz = 500;
  119. cfg_.rc_buf_sz = 1000;
  120. cfg_.rc_target_bitrate = 300;
  121. aq_mode_ = 4;
  122. alt_ref_aq_mode_ = 1;
  123. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  124. 30, 1, 0, 100);
  125. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  126. }
  127. VP9_INSTANTIATE_TEST_CASE(AltRefAqSegmentTest,
  128. ::testing::Values(::libvpx_test::kOnePassGood,
  129. ::libvpx_test::kTwoPassGood),
  130. ::testing::Range(2, 5));
  131. } // namespace