1 /* 2 * Copyright (c) 2020 The WebRTC 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 MODULES_VIDEO_CODING_SVC_SCALABILITY_STRUCTURE_TEST_HELPERS_H_ 11 #define MODULES_VIDEO_CODING_SVC_SCALABILITY_STRUCTURE_TEST_HELPERS_H_ 12 13 #include <stdint.h> 14 15 #include <vector> 16 17 #include "api/array_view.h" 18 #include "api/transport/rtp/dependency_descriptor.h" 19 #include "api/video/video_bitrate_allocation.h" 20 #include "common_video/generic_frame_descriptor/generic_frame_info.h" 21 #include "modules/video_coding/chain_diff_calculator.h" 22 #include "modules/video_coding/frame_dependencies_calculator.h" 23 #include "modules/video_coding/svc/scalable_video_controller.h" 24 25 namespace webrtc { 26 27 // Creates bitrate allocation with non-zero bitrate for given number of temporal 28 // layers for each spatial layer. 29 VideoBitrateAllocation EnableTemporalLayers(int s0, int s1 = 0, int s2 = 0); 30 31 class ScalabilityStructureWrapper { 32 public: ScalabilityStructureWrapper(ScalableVideoController & structure)33 explicit ScalabilityStructureWrapper(ScalableVideoController& structure) 34 : structure_controller_(structure) {} 35 GenerateFrames(int num_temporal_units)36 std::vector<GenericFrameInfo> GenerateFrames(int num_temporal_units) { 37 std::vector<GenericFrameInfo> frames; 38 GenerateFrames(num_temporal_units, frames); 39 return frames; 40 } 41 void GenerateFrames(int num_temporal_units, 42 std::vector<GenericFrameInfo>& frames); 43 44 // Returns false and ADD_FAILUREs for frames with invalid references. 45 // In particular validates no frame frame reference to frame before frames[0]. 46 // In error messages frames are indexed starting with 0. 47 bool FrameReferencesAreValid( 48 rtc::ArrayView<const GenericFrameInfo> frames) const; 49 50 private: 51 ScalableVideoController& structure_controller_; 52 FrameDependenciesCalculator frame_deps_calculator_; 53 ChainDiffCalculator chain_diff_calculator_; 54 int64_t frame_id_ = 0; 55 }; 56 57 } // namespace webrtc 58 59 #endif // MODULES_VIDEO_CODING_SVC_SCALABILITY_STRUCTURE_TEST_HELPERS_H_ 60