trunk 20080912
[gitenigma.git] / include / lib / dvb / lowlevel / pes.h
blob95411d3277cb15d8b36084a782d29424226b88c5
2 /*
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,
23 * Austria
25 *------------------------------------------------------------
29 #ifndef __PES_H__
30 #define __PES_H__
32 #include <sys/types.h>
34 #if BYTE_ORDER == BIG_ENDIAN
35 #define PES_START_CODE_PREFIX_RAW 0x000010
36 #else
37 #define PES_START_CODE_PREFIX_RAW 0x010000
38 #endif
40 #define PES_START_CODE_PREFIX 0x010000
42 typedef struct {
43 u_int start_code_prefix : 24; // 000001
44 u_char stream_id : 8;
45 u_char pes_packet_length_hi : 8;
46 u_char pes_packet_length_lo : 8;
47 } pes_hdr_t;
49 #define PES_HDR_LEN 6
51 typedef struct {
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;
57 u_char copyright : 1;
58 u_char original_or_copy : 1;
60 u_char pts_dts_flags : 2;
61 u_char escr_flag : 1;
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;
67 #else
68 u_char original_or_copy : 1;
69 u_char copyright : 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;
80 u_char escr_flag : 1;
81 u_char pts_dts_flags : 2;
82 #endif
84 u_char pes_header_data_length : 8;
85 } pes_flag_t;
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;
94 u_char pts_32_30 : 3;
95 u_char : 4; /* has to be 0010b */
96 #else
97 u_char : 4; /* has to be 0010b */
98 u_char pts_32_30 : 3;
99 u_char marker_bit0 : 1;
100 #endif
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 {
130 u_char : 2;
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;
143 u_int es_rate : 22;
144 u_char marker_bit1 : 1;
147 struct dsm_trick_mode_flag_struct {
148 u_char trick_mode_control : 3;
149 union {
150 struct {
151 u_char field_id : 2;
152 u_char intra_slice_refresh : 1;
153 u_char frequency_truncation : 2;
154 } fast_forward;
156 struct {
157 u_char rep_cntrl : 5;
158 } slow_motion;
160 struct {
161 u_char field_id : 2;
162 u_char : 3;
163 } freeze_frame;
165 struct {
166 u_char field_id : 2;
167 u_char intra_slice_refresh : 1;
168 u_char frequency_truncation : 2;
169 } fast_reverse;
171 struct {
172 u_char rep_cntrli : 5;
173 } slow_reverse;
174 } mode;
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;
191 u_char : 3;
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
215 #endif