1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * 3 * Use of this source code is governed by a BSD-style license 4 * that can be found in the LICENSE file in the root of the source 5 * tree. An additional intellectual property rights grant can be found 6 * in the file PATENTS. All contributing project authors may 7 * be found in the AUTHORS file in the root of the source tree. 8 */ 9 /* 10 * This file defines classes for doing temporal layers with VP8. 11 */ 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 14 15 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 16 17 namespace webrtc { 18 19 class DefaultTemporalLayers : public TemporalLayers { 20 public: 21 DefaultTemporalLayers(int number_of_temporal_layers, 22 uint8_t initial_tl0_pic_idx); ~DefaultTemporalLayers()23 virtual ~DefaultTemporalLayers() {} 24 25 // Returns the recommended VP8 encode flags needed. May refresh the decoder 26 // and/or update the reference buffers. 27 virtual int EncodeFlags(uint32_t timestamp); 28 29 virtual bool ConfigureBitrates(int bitrate_kbit, 30 int max_bitrate_kbit, 31 int framerate, 32 vpx_codec_enc_cfg_t* cfg); 33 34 virtual void PopulateCodecSpecific(bool base_layer_sync, 35 CodecSpecificInfoVP8* vp8_info, 36 uint32_t timestamp); 37 FrameEncoded(unsigned int size,uint32_t timestamp)38 virtual void FrameEncoded(unsigned int size, uint32_t timestamp) {} 39 40 virtual int CurrentLayerId() const; 41 42 private: 43 enum TemporalReferences { 44 // For 1 layer case: reference all (last, golden, and alt ref), but only 45 // update last. 46 kTemporalUpdateLastRefAll = 12, 47 // First base layer frame for 3 temporal layers, which updates last and 48 // golden with alt ref dependency. 49 kTemporalUpdateLastAndGoldenRefAltRef = 11, 50 // First enhancement layer with alt ref dependency. 51 kTemporalUpdateGoldenRefAltRef = 10, 52 // First enhancement layer with alt ref dependency. 53 kTemporalUpdateGoldenWithoutDependencyRefAltRef = 9, 54 // Base layer with alt ref dependency. 55 kTemporalUpdateLastRefAltRef = 8, 56 // Highest enhacement layer without dependency on golden with alt ref 57 // dependency. 58 kTemporalUpdateNoneNoRefGoldenRefAltRef = 7, 59 // Second layer and last frame in cycle, for 2 layers. 60 kTemporalUpdateNoneNoRefAltref = 6, 61 // Highest enhancement layer. 62 kTemporalUpdateNone = 5, 63 // Second enhancement layer. 64 kTemporalUpdateAltref = 4, 65 // Second enhancement layer without dependency on previous frames in 66 // the second enhancement layer. 67 kTemporalUpdateAltrefWithoutDependency = 3, 68 // First enhancement layer. 69 kTemporalUpdateGolden = 2, 70 // First enhancement layer without dependency on previous frames in 71 // the first enhancement layer. 72 kTemporalUpdateGoldenWithoutDependency = 1, 73 // Base layer. 74 kTemporalUpdateLast = 0, 75 }; 76 enum { kMaxTemporalPattern = 16 }; 77 78 int number_of_temporal_layers_; 79 int temporal_ids_length_; 80 int temporal_ids_[kMaxTemporalPattern]; 81 int temporal_pattern_length_; 82 TemporalReferences temporal_pattern_[kMaxTemporalPattern]; 83 uint8_t tl0_pic_idx_; 84 uint8_t pattern_idx_; 85 uint32_t timestamp_; 86 bool last_base_layer_sync_; 87 }; 88 89 } // namespace webrtc 90 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 91