• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   int EncodeFlags(uint32_t timestamp) override;
28 
29   bool ConfigureBitrates(int bitrate_kbit,
30                          int max_bitrate_kbit,
31                          int framerate,
32                          vpx_codec_enc_cfg_t* cfg) override;
33 
34   void PopulateCodecSpecific(bool base_layer_sync,
35                              CodecSpecificInfoVP8* vp8_info,
36                              uint32_t timestamp) override;
37 
FrameEncoded(unsigned int size,uint32_t timestamp,int qp)38   void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {}
39 
UpdateConfiguration(vpx_codec_enc_cfg_t * cfg)40   bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override { return false; }
41 
42   int CurrentLayerId() const override;
43 
44  private:
45   enum TemporalReferences {
46     // For 1 layer case: reference all (last, golden, and alt ref), but only
47     // update last.
48     kTemporalUpdateLastRefAll = 12,
49     // First base layer frame for 3 temporal layers, which updates last and
50     // golden with alt ref dependency.
51     kTemporalUpdateLastAndGoldenRefAltRef = 11,
52     // First enhancement layer with alt ref dependency.
53     kTemporalUpdateGoldenRefAltRef = 10,
54     // First enhancement layer with alt ref dependency.
55     kTemporalUpdateGoldenWithoutDependencyRefAltRef = 9,
56     // Base layer with alt ref dependency.
57     kTemporalUpdateLastRefAltRef = 8,
58     // Highest enhacement layer without dependency on golden with alt ref
59     // dependency.
60     kTemporalUpdateNoneNoRefGoldenRefAltRef = 7,
61     // Second layer and last frame in cycle, for 2 layers.
62     kTemporalUpdateNoneNoRefAltref = 6,
63     // Highest enhancement layer.
64     kTemporalUpdateNone = 5,
65     // Second enhancement layer.
66     kTemporalUpdateAltref = 4,
67     // Second enhancement layer without dependency on previous frames in
68     // the second enhancement layer.
69     kTemporalUpdateAltrefWithoutDependency = 3,
70     // First enhancement layer.
71     kTemporalUpdateGolden = 2,
72     // First enhancement layer without dependency on previous frames in
73     // the first enhancement layer.
74     kTemporalUpdateGoldenWithoutDependency = 1,
75     // Base layer.
76     kTemporalUpdateLast = 0,
77   };
78   enum { kMaxTemporalPattern = 16 };
79 
80   int number_of_temporal_layers_;
81   int temporal_ids_length_;
82   int temporal_ids_[kMaxTemporalPattern];
83   int temporal_pattern_length_;
84   TemporalReferences temporal_pattern_[kMaxTemporalPattern];
85   uint8_t tl0_pic_idx_;
86   uint8_t pattern_idx_;
87   uint32_t timestamp_;
88   bool last_base_layer_sync_;
89 };
90 
91 }  // namespace webrtc
92 #endif  // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
93