svc_test.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2018 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. #ifndef VPX_TEST_SVC_TEST_H_
  11. #define VPX_TEST_SVC_TEST_H_
  12. #include "./vpx_config.h"
  13. #include "third_party/googletest/src/include/gtest/gtest.h"
  14. #include "test/codec_factory.h"
  15. #include "test/encode_test_driver.h"
  16. #include "test/i420_video_source.h"
  17. #include "test/util.h"
  18. #include "test/y4m_video_source.h"
  19. #include "vpx/vpx_codec.h"
  20. #include "vpx_ports/bitops.h"
  21. namespace svc_test {
  22. class OnePassCbrSvc : public ::libvpx_test::EncoderTest {
  23. public:
  24. explicit OnePassCbrSvc(const ::libvpx_test::CodecFactory *codec)
  25. : EncoderTest(codec), base_speed_setting_(0), speed_setting_(0),
  26. superframe_count_(0), temporal_layer_id_(0), number_temporal_layers_(0),
  27. number_spatial_layers_(0) {
  28. memset(&svc_params_, 0, sizeof(svc_params_));
  29. memset(bits_in_buffer_model_, 0,
  30. sizeof(bits_in_buffer_model_[0]) * VPX_MAX_LAYERS);
  31. memset(layer_target_avg_bandwidth_, 0,
  32. sizeof(layer_target_avg_bandwidth_[0]) * VPX_MAX_LAYERS);
  33. }
  34. protected:
  35. virtual ~OnePassCbrSvc() {}
  36. virtual void SetConfig(const int num_temporal_layer) = 0;
  37. virtual void SetSvcConfig(const int num_spatial_layer,
  38. const int num_temporal_layer);
  39. virtual void PreEncodeFrameHookSetup(::libvpx_test::VideoSource *video,
  40. ::libvpx_test::Encoder *encoder);
  41. virtual void PostEncodeFrameHook(::libvpx_test::Encoder *encoder);
  42. virtual void AssignLayerBitrates();
  43. virtual void MismatchHook(const vpx_image_t *, const vpx_image_t *) {}
  44. vpx_svc_extra_cfg_t svc_params_;
  45. int64_t bits_in_buffer_model_[VPX_MAX_LAYERS];
  46. int layer_target_avg_bandwidth_[VPX_MAX_LAYERS];
  47. int base_speed_setting_;
  48. int speed_setting_;
  49. int superframe_count_;
  50. int temporal_layer_id_;
  51. int number_temporal_layers_;
  52. int number_spatial_layers_;
  53. };
  54. } // namespace svc_test
  55. #endif // VPX_TEST_SVC_TEST_H_