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_L2T2_KEY_SHIFT_H_ 11 #define MODULES_VIDEO_CODING_SVC_SCALABILITY_STRUCTURE_L2T2_KEY_SHIFT_H_ 12 13 #include <vector> 14 15 #include "api/transport/rtp/dependency_descriptor.h" 16 #include "api/video/video_bitrate_allocation.h" 17 #include "common_video/generic_frame_descriptor/generic_frame_info.h" 18 #include "modules/video_coding/svc/scalable_video_controller.h" 19 20 namespace webrtc { 21 22 // S1T1 0 0 23 // / / / 24 // S1T0 0---0---0 25 // | ... 26 // S0T1 | 0 0 27 // | / / 28 // S0T0 0-0---0-- 29 // Time-> 0 1 2 3 4 30 class ScalabilityStructureL2T2KeyShift : public ScalableVideoController { 31 public: 32 ~ScalabilityStructureL2T2KeyShift() override; 33 34 StreamLayersConfig StreamConfig() const override; 35 FrameDependencyStructure DependencyStructure() const override; 36 37 std::vector<LayerFrameConfig> NextFrameConfig(bool restart) override; 38 GenericFrameInfo OnEncodeDone(const LayerFrameConfig& config) override; 39 void OnRatesUpdated(const VideoBitrateAllocation& bitrates) override; 40 41 private: 42 enum FramePattern { 43 kKey, 44 kDelta0, 45 kDelta1, 46 }; 47 48 static constexpr int kNumSpatialLayers = 2; 49 static constexpr int kNumTemporalLayers = 2; 50 DecodeTargetIsActive(int sid,int tid)51 bool DecodeTargetIsActive(int sid, int tid) const { 52 return active_decode_targets_[sid * kNumTemporalLayers + tid]; 53 } SetDecodeTargetIsActive(int sid,int tid,bool value)54 void SetDecodeTargetIsActive(int sid, int tid, bool value) { 55 active_decode_targets_.set(sid * kNumTemporalLayers + tid, value); 56 } 57 58 FramePattern next_pattern_ = kKey; 59 std::bitset<32> active_decode_targets_ = 0b1111; 60 }; 61 62 } // namespace webrtc 63 64 #endif // MODULES_VIDEO_CODING_SVC_SCALABILITY_STRUCTURE_L2T2_KEY_SHIFT_H_ 65