• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2018 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 
11 #ifndef MODULES_VIDEO_CODING_CODECS_VP8_INCLUDE_TEMPORAL_LAYERS_CHECKER_H_
12 #define MODULES_VIDEO_CODING_CODECS_VP8_INCLUDE_TEMPORAL_LAYERS_CHECKER_H_
13 
14 #include <stdint.h>
15 
16 #include <memory>
17 
18 #include "api/video_codecs/vp8_frame_config.h"
19 #include "api/video_codecs/vp8_temporal_layers.h"
20 
21 namespace webrtc {
22 
23 // Interface for a class that verifies correctness of temporal layer
24 // configurations (dependencies, sync flag, etc).
25 // Intended to be used in tests as well as with real apps in debug mode.
26 class TemporalLayersChecker {
27  public:
28   explicit TemporalLayersChecker(int num_temporal_layers);
~TemporalLayersChecker()29   virtual ~TemporalLayersChecker() {}
30 
31   virtual bool CheckTemporalConfig(bool frame_is_keyframe,
32                                    const Vp8FrameConfig& frame_config);
33 
34   static std::unique_ptr<TemporalLayersChecker> CreateTemporalLayersChecker(
35       Vp8TemporalLayersType type,
36       int num_temporal_layers);
37 
38  private:
39   struct BufferState {
BufferStateBufferState40     BufferState() : is_keyframe(true), temporal_layer(0), sequence_number(0) {}
41     bool is_keyframe;
42     uint8_t temporal_layer;
43     uint32_t sequence_number;
44   };
45   bool CheckAndUpdateBufferState(BufferState* state,
46                                  bool* need_sync,
47                                  bool frame_is_keyframe,
48                                  uint8_t temporal_layer,
49                                  Vp8FrameConfig::BufferFlags flags,
50                                  uint32_t sequence_number,
51                                  uint32_t* lowest_sequence_referenced);
52   BufferState last_;
53   BufferState arf_;
54   BufferState golden_;
55   int num_temporal_layers_;
56   uint32_t sequence_number_;
57   uint32_t last_sync_sequence_number_;
58   uint32_t last_tl0_sequence_number_;
59 };
60 
61 }  // namespace webrtc
62 
63 #endif  // MODULES_VIDEO_CODING_CODECS_VP8_INCLUDE_TEMPORAL_LAYERS_CHECKER_H_
64