aq_segment_test.cc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 AqSegmentTest
  17. : public ::libvpx_test::EncoderTest,
  18. public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
  19. protected:
  20. AqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
  21. virtual ~AqSegmentTest() {}
  22. virtual void SetUp() {
  23. InitializeConfig();
  24. SetMode(GET_PARAM(1));
  25. set_cpu_used_ = GET_PARAM(2);
  26. aq_mode_ = 0;
  27. }
  28. virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
  29. ::libvpx_test::Encoder *encoder) {
  30. if (video->frame() == 0) {
  31. encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
  32. encoder->Control(VP9E_SET_AQ_MODE, aq_mode_);
  33. encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 100);
  34. }
  35. }
  36. int set_cpu_used_;
  37. int aq_mode_;
  38. };
  39. // Validate that this AQ segmentation mode (AQ=1, variance_ap)
  40. // encodes and decodes without a mismatch.
  41. TEST_P(AqSegmentTest, TestNoMisMatchAQ1) {
  42. cfg_.rc_min_quantizer = 8;
  43. cfg_.rc_max_quantizer = 56;
  44. cfg_.rc_end_usage = VPX_CBR;
  45. cfg_.g_lag_in_frames = 0;
  46. cfg_.rc_buf_initial_sz = 500;
  47. cfg_.rc_buf_optimal_sz = 500;
  48. cfg_.rc_buf_sz = 1000;
  49. cfg_.rc_target_bitrate = 300;
  50. aq_mode_ = 1;
  51. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  52. 30, 1, 0, 100);
  53. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  54. }
  55. // Validate that this AQ segmentation mode (AQ=2, complexity_aq)
  56. // encodes and decodes without a mismatch.
  57. TEST_P(AqSegmentTest, TestNoMisMatchAQ2) {
  58. cfg_.rc_min_quantizer = 8;
  59. cfg_.rc_max_quantizer = 56;
  60. cfg_.rc_end_usage = VPX_CBR;
  61. cfg_.g_lag_in_frames = 0;
  62. cfg_.rc_buf_initial_sz = 500;
  63. cfg_.rc_buf_optimal_sz = 500;
  64. cfg_.rc_buf_sz = 1000;
  65. cfg_.rc_target_bitrate = 300;
  66. aq_mode_ = 2;
  67. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  68. 30, 1, 0, 100);
  69. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  70. }
  71. // Validate that this AQ segmentation mode (AQ=3, cyclic_refresh_aq)
  72. // encodes and decodes without a mismatch.
  73. TEST_P(AqSegmentTest, TestNoMisMatchAQ3) {
  74. cfg_.rc_min_quantizer = 8;
  75. cfg_.rc_max_quantizer = 56;
  76. cfg_.rc_end_usage = VPX_CBR;
  77. cfg_.g_lag_in_frames = 0;
  78. cfg_.rc_buf_initial_sz = 500;
  79. cfg_.rc_buf_optimal_sz = 500;
  80. cfg_.rc_buf_sz = 1000;
  81. cfg_.rc_target_bitrate = 300;
  82. aq_mode_ = 3;
  83. ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
  84. 30, 1, 0, 100);
  85. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  86. }
  87. VP9_INSTANTIATE_TEST_CASE(AqSegmentTest,
  88. ::testing::Values(::libvpx_test::kRealTime,
  89. ::libvpx_test::kOnePassGood),
  90. ::testing::Range(3, 9));
  91. } // namespace