Debian Codegraph @

src/demuxer/ES_hevc.h

raw
1 /*
2 * Copyright (C) 2013-2021 Jean-Luc Barrière
3 * Copyright (C) 2005-2014 Team Kodi (https://kodi.tv)
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSE.md for more information.
7 */
8
9 #ifndef ES_HEVC_H
10 #define ES_HEVC_H
11
12 #include "elementaryStream.h"
13
14 namespace TSDemux
15 {
16 class ES_hevc : public ElementaryStream
17 {
18 private:
19 typedef struct hevc_private
20 {
21 struct PPS
22 {
23 int sps;
24 int dependent_slice_segments_enabled_flag;
25 } pps[64];
26
27 struct VCL_NAL
28 {
29 int pic_parameter_set_id; // slice
30 unsigned int first_slice_segment_in_pic_flag;
31 unsigned int nal_unit_type;
32 } vcl_nal;
33
34 } hevc_private_t;
35
36 typedef struct HDR_NAL_t
37 {
38 unsigned nal_unit_type;
39 unsigned nuh_layer_id;
40 unsigned nuh_temporal_id;
41 } HDR_NAL;
42
43 typedef struct mpeg_rational_s {
44 int num;
45 int den;
46 } mpeg_rational_t;
47
48 enum
49 {
50 NAL_TRAIL_N = 0x00, // Coded slice segment of trailing picture
51 NAL_TRAIL_R = 0x01, // Coded slice segment of trailing picture
52 NAL_TSA_N = 0x02, // Coded slice segment of TSA picture
53 NAL_TSA_R = 0x03, // Coded slice segment of TSA picture
54 NAL_STSA_N = 0x04, // Coded slice segment of STSA picture
55 NAL_STSA_R = 0x05, // Coded slice segment of STSA picture
56 NAL_RADL_N = 0x06, // Coded slice segment of RADL picture
57 NAL_RADL_R = 0x07, // Coded slice segment of RADL picture
58 NAL_RASL_N = 0x08, // Coded slice segment of RASL picture
59 NAL_RASL_R = 0x09, // Coded slice segment of RASL picture
60
61 NAL_BLA_W_LP = 0x10, // Coded slice segment of a BLA picture
62 NAL_CRA_NUT = 0x15, // Coded slice segment of a CRA picture
63 NAL_RSV_IRAP_VCL22 = 0x16, // Reserved IRAP VCL NAL unit types
64 NAL_RSV_IRAP_VCL23 = 0x17, // Reserved IRAP VCL NAL unit types
65
66 NAL_VPS_NUT = 0x20, // Video Parameter SET
67 NAL_SPS_NUT = 0x21, // Sequence Parameter Set
68 NAL_PPS_NUT = 0x22, // Picture Parameter Set
69 NAL_AUD_NUT = 0x23, // Access Unit Delimiter
70 NAL_EOS_NUT = 0x24, // End of Sequence
71 NAL_EOB_NUT = 0x25, // End of Bitstream
72 NAL_FD_NUT = 0x26, // Filler Data
73 NAL_PFX_SEI_NUT = 0x27, // Supplemental Enhancement Information
74 NAL_SFX_SEI_NUT = 0x28, // Supplemental Enhancement Information
75
76 };
77
78 uint32_t m_StartCode;
79 int m_LastStartPos;
80 bool m_NeedSPS;
81 bool m_NeedPPS;
82 int m_Width;
83 int m_Height;
84 int m_FpsScale;
85 mpeg_rational_t m_PixelAspect;
86 hevc_private_t m_streamData;
87 int64_t m_DTS;
88 int64_t m_PTS;
89 bool m_Interlaced;
90
91 void Parse_HEVC(int buf_ptr, unsigned int NumBytesInNalUnit, bool &complete);
92 void Parse_PPS(uint8_t *buf, int len);
93 void Parse_SLH(uint8_t *buf, int len, HDR_NAL hdr, hevc_private::VCL_NAL &vcl);
94 void Parse_SPS(uint8_t *buf, int len, HDR_NAL hdr);
95 bool IsFirstVclNal(hevc_private::VCL_NAL &vcl);
96
97 public:
98 ES_hevc(uint16_t pes_pid);
99 virtual ~ES_hevc();
100
101 virtual void Parse(STREAM_PKT* pkt);
102 virtual void Reset();
103 };
104
105 }
106
107 #endif /* ES_HEVC_H */
108