1 | /* |
2 | * dvb_filter.h |
3 | * |
4 | * Copyright (C) 2003 Convergence GmbH |
5 | * |
6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public License |
8 | * as published by the Free Software Foundation; either version 2.1 |
9 | * of the License, or (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | */ |
16 | |
17 | #ifndef _DVB_FILTER_H_ |
18 | #define _DVB_FILTER_H_ |
19 | |
20 | #include <linux/slab.h> |
21 | |
22 | #include <media/demux.h> |
23 | |
24 | typedef int (dvb_filter_pes2ts_cb_t) (void *, unsigned char *); |
25 | |
26 | struct dvb_filter_pes2ts { |
27 | unsigned char buf[188]; |
28 | unsigned char cc; |
29 | dvb_filter_pes2ts_cb_t *cb; |
30 | void *priv; |
31 | }; |
32 | |
33 | void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid, |
34 | dvb_filter_pes2ts_cb_t *cb, void *priv); |
35 | |
36 | int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes, |
37 | int len, int payload_start); |
38 | |
39 | |
40 | #define PROG_STREAM_MAP 0xBC |
41 | #define PRIVATE_STREAM1 0xBD |
42 | #define PADDING_STREAM 0xBE |
43 | #define PRIVATE_STREAM2 0xBF |
44 | #define AUDIO_STREAM_S 0xC0 |
45 | #define AUDIO_STREAM_E 0xDF |
46 | #define VIDEO_STREAM_S 0xE0 |
47 | #define VIDEO_STREAM_E 0xEF |
48 | #define ECM_STREAM 0xF0 |
49 | #define EMM_STREAM 0xF1 |
50 | #define DSM_CC_STREAM 0xF2 |
51 | #define ISO13522_STREAM 0xF3 |
52 | #define PROG_STREAM_DIR 0xFF |
53 | |
54 | #define DVB_PICTURE_START 0x00 |
55 | #define DVB_USER_START 0xb2 |
56 | #define 0xb3 |
57 | #define DVB_SEQUENCE_ERROR 0xb4 |
58 | #define DVB_EXTENSION_START 0xb5 |
59 | #define DVB_SEQUENCE_END 0xb7 |
60 | #define DVB_GOP_START 0xb8 |
61 | #define DVB_EXCEPT_SLICE 0xb0 |
62 | |
63 | #define SEQUENCE_EXTENSION 0x01 |
64 | #define SEQUENCE_DISPLAY_EXTENSION 0x02 |
65 | #define PICTURE_CODING_EXTENSION 0x08 |
66 | #define QUANT_MATRIX_EXTENSION 0x03 |
67 | #define PICTURE_DISPLAY_EXTENSION 0x07 |
68 | |
69 | #define I_FRAME 0x01 |
70 | #define B_FRAME 0x02 |
71 | #define P_FRAME 0x03 |
72 | |
73 | /* Initialize sequence_data */ |
74 | #define INIT_HORIZONTAL_SIZE 720 |
75 | #define INIT_VERTICAL_SIZE 576 |
76 | #define INIT_ASPECT_RATIO 0x02 |
77 | #define INIT_FRAME_RATE 0x03 |
78 | #define INIT_DISP_HORIZONTAL_SIZE 540 |
79 | #define INIT_DISP_VERTICAL_SIZE 576 |
80 | |
81 | |
82 | //flags2 |
83 | #define PTS_DTS_FLAGS 0xC0 |
84 | #define ESCR_FLAG 0x20 |
85 | #define ES_RATE_FLAG 0x10 |
86 | #define DSM_TRICK_FLAG 0x08 |
87 | #define ADD_CPY_FLAG 0x04 |
88 | #define PES_CRC_FLAG 0x02 |
89 | #define PES_EXT_FLAG 0x01 |
90 | |
91 | //pts_dts flags |
92 | #define PTS_ONLY 0x80 |
93 | #define PTS_DTS 0xC0 |
94 | |
95 | #define TS_SIZE 188 |
96 | #define TRANS_ERROR 0x80 |
97 | #define PAY_START 0x40 |
98 | #define TRANS_PRIO 0x20 |
99 | #define PID_MASK_HI 0x1F |
100 | //flags |
101 | #define TRANS_SCRMBL1 0x80 |
102 | #define TRANS_SCRMBL2 0x40 |
103 | #define ADAPT_FIELD 0x20 |
104 | #define PAYLOAD 0x10 |
105 | #define COUNT_MASK 0x0F |
106 | |
107 | // adaptation flags |
108 | #define DISCON_IND 0x80 |
109 | #define RAND_ACC_IND 0x40 |
110 | #define ES_PRI_IND 0x20 |
111 | #define PCR_FLAG 0x10 |
112 | #define OPCR_FLAG 0x08 |
113 | #define SPLICE_FLAG 0x04 |
114 | #define TRANS_PRIV 0x02 |
115 | #define ADAP_EXT_FLAG 0x01 |
116 | |
117 | // adaptation extension flags |
118 | #define LTW_FLAG 0x80 |
119 | #define PIECE_RATE 0x40 |
120 | #define SEAM_SPLICE 0x20 |
121 | |
122 | |
123 | #define MAX_PLENGTH 0xFFFF |
124 | #define MMAX_PLENGTH (256*MAX_PLENGTH) |
125 | |
126 | #ifndef IPACKS |
127 | #define IPACKS 2048 |
128 | #endif |
129 | |
130 | struct ipack { |
131 | int size; |
132 | int found; |
133 | u8 *buf; |
134 | u8 cid; |
135 | u32 plength; |
136 | u8 plen[2]; |
137 | u8 flag1; |
138 | u8 flag2; |
139 | u8 hlength; |
140 | u8 pts[5]; |
141 | u16 *pid; |
142 | int mpeg; |
143 | u8 check; |
144 | int which; |
145 | int done; |
146 | void *data; |
147 | void (*func)(u8 *buf, int size, void *priv); |
148 | int count; |
149 | int repack_subids; |
150 | }; |
151 | |
152 | struct dvb_video_info { |
153 | u32 horizontal_size; |
154 | u32 vertical_size; |
155 | u32 aspect_ratio; |
156 | u32 framerate; |
157 | u32 video_format; |
158 | u32 bit_rate; |
159 | u32 comp_bit_rate; |
160 | u32 vbv_buffer_size; |
161 | s16 vbv_delay; |
162 | u32 CSPF; |
163 | u32 off; |
164 | }; |
165 | |
166 | #define OFF_SIZE 4 |
167 | #define FIRST_FIELD 0 |
168 | #define SECOND_FIELD 1 |
169 | #define VIDEO_FRAME_PICTURE 0x03 |
170 | |
171 | struct mpg_picture { |
172 | int channel; |
173 | struct dvb_video_info vinfo; |
174 | u32 *; |
175 | u32 *; |
176 | s32 time_code; |
177 | int low_delay; |
178 | int closed_gop; |
179 | int broken_link; |
180 | int ; |
181 | int gop_flag; |
182 | int sequence_end_flag; |
183 | |
184 | u8 profile_and_level; |
185 | s32 picture_coding_parameter; |
186 | u32 matrix[32]; |
187 | s8 matrix_change_flag; |
188 | |
189 | u8 ; |
190 | /* bit 0 - 2: bwd f code |
191 | bit 3 : fpb vector |
192 | bit 4 - 6: fwd f code |
193 | bit 7 : fpf vector */ |
194 | |
195 | int mpeg1_flag; |
196 | int progressive_sequence; |
197 | int sequence_display_extension_flag; |
198 | u32 ; |
199 | s16 last_frame_centre_horizontal_offset; |
200 | s16 last_frame_centre_vertical_offset; |
201 | |
202 | u32 pts[2]; /* [0] 1st field, [1] 2nd field */ |
203 | int top_field_first; |
204 | int repeat_first_field; |
205 | int progressive_frame; |
206 | int bank; |
207 | int forward_bank; |
208 | int backward_bank; |
209 | int compress; |
210 | s16 frame_centre_horizontal_offset[OFF_SIZE]; |
211 | /* [0-2] 1st field, [3] 2nd field */ |
212 | s16 frame_centre_vertical_offset[OFF_SIZE]; |
213 | /* [0-2] 1st field, [3] 2nd field */ |
214 | s16 temporal_reference[2]; |
215 | /* [0] 1st field, [1] 2nd field */ |
216 | |
217 | s8 picture_coding_type[2]; |
218 | /* [0] 1st field, [1] 2nd field */ |
219 | s8 picture_structure[2]; |
220 | /* [0] 1st field, [1] 2nd field */ |
221 | s8 picture_display_extension_flag[2]; |
222 | /* [0] 1st field, [1] 2nd field */ |
223 | /* picture_display_extenion() 0:no 1:exit*/ |
224 | s8 pts_flag[2]; |
225 | /* [0] 1st field, [1] 2nd field */ |
226 | }; |
227 | |
228 | struct dvb_audio_info { |
229 | int layer; |
230 | u32 bit_rate; |
231 | u32 frequency; |
232 | u32 mode; |
233 | u32 mode_extension ; |
234 | u32 emphasis; |
235 | u32 framesize; |
236 | u32 off; |
237 | }; |
238 | |
239 | int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr); |
240 | |
241 | |
242 | #endif |
243 | |