File: decoding_state.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (89 lines) | stat: -rw-r--r-- 3,163 bytes parent folder | download | duplicates (23)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef MODULES_VIDEO_CODING_DEPRECATED_DECODING_STATE_H_
#define MODULES_VIDEO_CODING_DEPRECATED_DECODING_STATE_H_

#include <cstdint>
#include <map>
#include <set>
#include <vector>

namespace webrtc {

// Forward declarations
struct NaluInfo;
class VCMFrameBuffer;
class VCMPacket;

class VCMDecodingState {
 public:
  // The max number of bits used to reference back
  // to a previous frame when using flexible mode.
  static const uint16_t kNumRefBits = 7;
  static const uint16_t kFrameDecodedLength = 1 << kNumRefBits;

  VCMDecodingState();
  ~VCMDecodingState();
  // Check for old frame
  bool IsOldFrame(const VCMFrameBuffer* frame) const;
  // Check for old packet
  bool IsOldPacket(const VCMPacket* packet) const;
  // Check for frame continuity based on current decoded state. Use best method
  // possible, i.e. temporal info, picture ID or sequence number.
  bool ContinuousFrame(const VCMFrameBuffer* frame) const;
  void SetState(const VCMFrameBuffer* frame);
  void CopyFrom(const VCMDecodingState& state);
  bool UpdateEmptyFrame(const VCMFrameBuffer* frame);
  // Update the sequence number if the timestamp matches current state and the
  // sequence number is higher than the current one. This accounts for packets
  // arriving late.
  void UpdateOldPacket(const VCMPacket* packet);
  void SetSeqNum(uint16_t new_seq_num);
  void Reset();
  uint32_t time_stamp() const;
  uint16_t sequence_num() const;
  // Return true if at initial state.
  bool in_initial_state() const;
  // Return true when sync is on - decode all layers.
  bool full_sync() const;

 private:
  void UpdateSyncState(const VCMFrameBuffer* frame);
  // Designated continuity functions
  bool ContinuousPictureId(int picture_id) const;
  bool ContinuousSeqNum(uint16_t seq_num) const;
  bool ContinuousLayer(int temporal_id, int tl0_pic_id) const;
  bool ContinuousFrameRefs(const VCMFrameBuffer* frame) const;
  bool UsingPictureId(const VCMFrameBuffer* frame) const;
  bool UsingFlexibleMode(const VCMFrameBuffer* frame) const;
  bool AheadOfFramesDecodedClearedTo(uint16_t index) const;
  bool HaveSpsAndPps(const std::vector<NaluInfo>& nalus) const;

  // Keep state of last decoded frame.
  // TODO(mikhal/stefan): create designated classes to handle these types.
  uint16_t sequence_num_;
  uint32_t time_stamp_;
  int picture_id_;
  int temporal_id_;
  int tl0_pic_id_;
  bool full_sync_;  // Sync flag when temporal layers are used.
  bool in_initial_state_;

  // Used to check references in flexible mode.
  bool frame_decoded_[kFrameDecodedLength];
  uint16_t frame_decoded_cleared_to_;
  std::set<int> received_sps_;
  std::map<int, int> received_pps_;
};

}  // namespace webrtc

#endif  // MODULES_VIDEO_CODING_DEPRECATED_DECODING_STATE_H_