borders_test.cc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <climits>
  11. #include <vector>
  12. #include "third_party/googletest/src/include/gtest/gtest.h"
  13. #include "test/codec_factory.h"
  14. #include "test/encode_test_driver.h"
  15. #include "test/i420_video_source.h"
  16. #include "test/util.h"
  17. namespace {
  18. class BordersTest
  19. : public ::libvpx_test::EncoderTest,
  20. public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
  21. protected:
  22. BordersTest() : EncoderTest(GET_PARAM(0)) {}
  23. virtual ~BordersTest() {}
  24. virtual void SetUp() {
  25. InitializeConfig();
  26. SetMode(GET_PARAM(1));
  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, 1);
  32. encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
  33. encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
  34. encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
  35. encoder->Control(VP8E_SET_ARNR_TYPE, 3);
  36. }
  37. }
  38. virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
  39. if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) {
  40. }
  41. }
  42. };
  43. TEST_P(BordersTest, TestEncodeHighBitrate) {
  44. // Validate that this non multiple of 64 wide clip encodes and decodes
  45. // without a mismatch when passing in a very low max q. This pushes
  46. // the encoder to producing lots of big partitions which will likely
  47. // extend into the border and test the border condition.
  48. cfg_.g_lag_in_frames = 25;
  49. cfg_.rc_2pass_vbr_minsection_pct = 5;
  50. cfg_.rc_2pass_vbr_maxsection_pct = 2000;
  51. cfg_.rc_target_bitrate = 2000;
  52. cfg_.rc_max_quantizer = 10;
  53. ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
  54. 40);
  55. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  56. }
  57. TEST_P(BordersTest, TestLowBitrate) {
  58. // Validate that this clip encodes and decodes without a mismatch
  59. // when passing in a very high min q. This pushes the encoder to producing
  60. // lots of small partitions which might will test the other condition.
  61. cfg_.g_lag_in_frames = 25;
  62. cfg_.rc_2pass_vbr_minsection_pct = 5;
  63. cfg_.rc_2pass_vbr_maxsection_pct = 2000;
  64. cfg_.rc_target_bitrate = 200;
  65. cfg_.rc_min_quantizer = 40;
  66. ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
  67. 40);
  68. ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
  69. }
  70. VP9_INSTANTIATE_TEST_CASE(BordersTest,
  71. ::testing::Values(::libvpx_test::kTwoPassGood));
  72. } // namespace