Debian Codegraph @

src/demuxer/ES_h264.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_H264_H
10 #define ES_H264_H
11
12 #include "elementaryStream.h"
13
14 namespace TSDemux
15 {
16 class ES_h264 : public ElementaryStream
17 {
18 private:
19 typedef struct h264_private
20 {
21 struct SPS
22 {
23 int frame_duration;
24 int cbpsize;
25 int pic_order_cnt_type;
26 int frame_mbs_only_flag;
27 int log2_max_frame_num;
28 int log2_max_pic_order_cnt_lsb;
29 int delta_pic_order_always_zero_flag;
30 } sps[256];
31
32 struct PPS
33 {
34 int sps;
35 int pic_order_present_flag;
36 } pps[256];
37
38 struct VCL_NAL
39 {
40 int frame_num; // slice
41 int pic_parameter_set_id; // slice
42 int field_pic_flag; // slice
43 int bottom_field_flag; // slice
44 int delta_pic_order_cnt_bottom; // slice
45 int delta_pic_order_cnt_0; // slice
46 int delta_pic_order_cnt_1; // slice
47 int pic_order_cnt_lsb; // slice
48 int idr_pic_id; // slice
49 int nal_unit_type;
50 int nal_ref_idc; // start code
51 int pic_order_cnt_type; // sps
52 } vcl_nal;
53
54 } h264_private_t;
55
56 typedef struct mpeg_rational_s {
57 int num;
58 int den;
59 } mpeg_rational_t;
60
61 enum
62 {
63 NAL_SLH = 0x01, // Slice Header
64 NAL_SEI = 0x06, // Supplemental Enhancement Information
65 NAL_SPS = 0x07, // Sequence Parameter Set
66 NAL_PPS = 0x08, // Picture Parameter Set
67 NAL_AUD = 0x09, // Access Unit Delimiter
68 NAL_END_SEQ = 0x0A // End of Sequence
69 };
70
71 uint32_t m_StartCode;
72 bool m_NeedIFrame;
73 bool m_NeedSPS;
74 bool m_NeedPPS;
75 int m_Width;
76 int m_Height;
77 int m_FpsScale;
78 mpeg_rational_t m_PixelAspect;
79 h264_private m_streamData;
80 int m_vbvDelay; /* -1 if CBR */
81 int m_vbvSize; /* Video buffer size (in bytes) */
82 int64_t m_DTS;
83 int64_t m_PTS;
84 bool m_Interlaced;
85
86 int Parse_H264(uint32_t startcode, int buf_ptr, bool &complete);
87 bool Parse_PPS(uint8_t *buf, int len);
88 bool Parse_SLH(uint8_t *buf, int len, h264_private::VCL_NAL &vcl);
89 bool Parse_SPS(uint8_t *buf, int len);
90 bool IsFirstVclNal(h264_private::VCL_NAL &vcl);
91
92 public:
93 ES_h264(uint16_t pes_pid);
94 virtual ~ES_h264();
95
96 virtual void Parse(STREAM_PKT* pkt);
97 virtual void Reset();
98 };
99 }
100
101 #endif /* ES_H264_H */