3 * PACKETIZED ELEMENTARY STREAM
5 * Copyright (C) 1998 Thomas Mirlacher
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * The author may be reached as dent@cosy.sbg.ac.at, or
22 * Thomas Mirlacher, Jakob-Haringerstr. 2, A-5020 Salzburg,
25 *------------------------------------------------------------
32 #include <sys/types.h>
34 #if BYTE_ORDER == BIG_ENDIAN
35 #define PES_START_CODE_PREFIX_RAW 0x000010
37 #define PES_START_CODE_PREFIX_RAW 0x010000
40 #define PES_START_CODE_PREFIX 0x010000
43 u_int start_code_prefix
: 24; // 000001
45 u_char pes_packet_length_hi
: 8;
46 u_char pes_packet_length_lo
: 8;
52 #if BYTE_ORDER == BIG_ENDIAN
53 u_char start_code_prefix
: 2; /* 0x02 */
54 u_char pes_scrambling_control
: 2;
55 u_char pes_priority
: 1;
56 u_char data_alignment_indicator
: 1;
58 u_char original_or_copy
: 1;
60 u_char pts_dts_flags
: 2;
62 u_char es_rate_flag
: 1;
63 u_char dsm_trick_mode_flag
: 1;
64 u_char additional_copy_info_flag
: 1;
65 u_char pes_crc_flag
: 1;
66 u_char pes_extension_flag
: 1;
68 u_char original_or_copy
: 1;
70 u_char data_alignment_indicator
: 1;
71 u_char pes_priority
: 1;
72 u_char pes_scrambling_control
: 2;
73 u_char start_code_prefix
: 2; /* 0x02 */
75 u_char pes_extension_flag
: 1;
76 u_char pes_crc_flag
: 1;
77 u_char additional_copy_info_flag
: 1;
78 u_char dsm_trick_mode_flag
: 1;
79 u_char es_rate_flag
: 1;
81 u_char pts_dts_flags
: 2;
84 u_char pes_header_data_length
: 8;
87 #define PES_FLAG_LEN 3
89 //TODO: check ENIANs and comvert pts stuff into bytes
91 struct pts_dts_flags_2_struct
{
92 #if BYTE_ORDER == BIG_ENDIAN
93 u_char marker_bit0
: 1;
95 u_char
: 4; /* has to be 0010b */
97 u_char
: 4; /* has to be 0010b */
99 u_char marker_bit0
: 1;
102 u_short pts_29_15
: 15;
103 u_char marker_bit1
: 1;
105 u_short pts_14_0
: 15;
106 u_char marker_bit2
: 1;
109 struct PTS_DTS_flags_3__struct
{
110 u_char
: 4; /* has to be 0011b */
111 u_char pts_32_30
: 3;
112 u_char marker_bit0
: 1;
114 u_short pts_29_15
: 15;
115 u_char marker_bit1
: 1;
117 u_short pts_14_0
: 15;
118 u_char marker_bit2
: 1;
120 u_char
: 2; /* has to be 0001b */
121 u_char dtp_32_30
: 3;
122 u_char marker_bit3
: 1;
123 u_short dtp_29_15
: 15;
124 u_char marker_bit4
: 1;
125 u_short dtp_14_0
: 15;
126 u_char marker_bit5
: 1;
129 struct escr_flag_struct
{
131 u_char escr_base_32_30
: 3;
132 u_char marker_bit0
: 1;
133 u_short escr_base_29_15
: 15;
134 u_char marker_bit1
: 1;
135 u_short escr_base_14_0
: 15;
136 u_char marker_bit2
: 1;
137 u_short escr_extension
: 9;
138 u_char marker_bit3
: 1;
141 struct es_rate_flag_struct
{
142 u_char marker_bit0
: 1;
144 u_char marker_bit1
: 1;
147 struct dsm_trick_mode_flag_struct
{
148 u_char trick_mode_control
: 3;
152 u_char intra_slice_refresh
: 1;
153 u_char frequency_truncation
: 2;
157 u_char rep_cntrl
: 5;
167 u_char intra_slice_refresh
: 1;
168 u_char frequency_truncation
: 2;
172 u_char rep_cntrli
: 5;
177 struct additional_copy_info_flag_struct
{
178 u_char marker_bit
: 1;
179 u_char additional_copy_info
: 7;
182 struct pes_crc_flag_struct
{
183 u_short previous_pes_packet_crc
: 16;
186 struct pes_extension_flag_struct
{
187 u_char pes_private_data_flag
: 1;
188 u_char pack_header_field_flag
: 1;
189 u_char program_packet_sequence_counter_flag
: 1;
190 u_char psdt_buffer_flag
: 1;
192 u_char pes_extension_flag_2
: 1;
193 /* DENT: tjo ... just continue here to fill structs in ... */
196 #define STREAM_PROGRAM_MAP 0xBC
197 #define STREAM_PRIVATE_1 0xBD
198 #define STREAM_PRIVATE_2 0xBF
199 #define STREAM_PADDING 0xBE
200 #define STREAM_AUDIO 0xBC // 110X XXXX
201 #define STREAM_VIDEO 0xE0 // 1110 XXXX
202 #define STREAM_ECM 0xF0
203 #define STREAM_EMM 0xF1
204 #define STREAM_DSMCC 0xF2
205 #define STREAM_ITU_A 0xF4
206 #define STREAM_ITU_B 0xF5
207 #define STREAM_ITU_C 0xF6
208 #define STREAM_ITU_D 0xF7
209 #define STREAM_ITU_E 0xF8
210 #define STREAM_MASK_AUDIO 0xE0
211 #define STREAM_REST_AUDIO 0xC0
212 #define STREAM_MASK_VIDEO 0xF0
213 #define STREAM_REST_VIDEO 0xE0