dvb_filter.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. #ifndef _DVB_FILTER_H_
  21. #define _DVB_FILTER_H_
  22. #include <linux/slab.h>
  23. #include "demux.h"
  24. typedef int (dvb_filter_pes2ts_cb_t) (void *, unsigned char *);
  25. struct dvb_filter_pes2ts {
  26. unsigned char buf[188];
  27. unsigned char cc;
  28. dvb_filter_pes2ts_cb_t *cb;
  29. void *priv;
  30. };
  31. void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid,
  32. dvb_filter_pes2ts_cb_t *cb, void *priv);
  33. int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes,
  34. int len, int payload_start);
  35. #define PROG_STREAM_MAP 0xBC
  36. #define PRIVATE_STREAM1 0xBD
  37. #define PADDING_STREAM 0xBE
  38. #define PRIVATE_STREAM2 0xBF
  39. #define AUDIO_STREAM_S 0xC0
  40. #define AUDIO_STREAM_E 0xDF
  41. #define VIDEO_STREAM_S 0xE0
  42. #define VIDEO_STREAM_E 0xEF
  43. #define ECM_STREAM 0xF0
  44. #define EMM_STREAM 0xF1
  45. #define DSM_CC_STREAM 0xF2
  46. #define ISO13522_STREAM 0xF3
  47. #define PROG_STREAM_DIR 0xFF
  48. #define DVB_PICTURE_START 0x00
  49. #define DVB_USER_START 0xb2
  50. #define DVB_SEQUENCE_HEADER 0xb3
  51. #define DVB_SEQUENCE_ERROR 0xb4
  52. #define DVB_EXTENSION_START 0xb5
  53. #define DVB_SEQUENCE_END 0xb7
  54. #define DVB_GOP_START 0xb8
  55. #define DVB_EXCEPT_SLICE 0xb0
  56. #define SEQUENCE_EXTENSION 0x01
  57. #define SEQUENCE_DISPLAY_EXTENSION 0x02
  58. #define PICTURE_CODING_EXTENSION 0x08
  59. #define QUANT_MATRIX_EXTENSION 0x03
  60. #define PICTURE_DISPLAY_EXTENSION 0x07
  61. #define I_FRAME 0x01
  62. #define B_FRAME 0x02
  63. #define P_FRAME 0x03
  64. /* Initialize sequence_data */
  65. #define INIT_HORIZONTAL_SIZE 720
  66. #define INIT_VERTICAL_SIZE 576
  67. #define INIT_ASPECT_RATIO 0x02
  68. #define INIT_FRAME_RATE 0x03
  69. #define INIT_DISP_HORIZONTAL_SIZE 540
  70. #define INIT_DISP_VERTICAL_SIZE 576
  71. //flags2
  72. #define PTS_DTS_FLAGS 0xC0
  73. #define ESCR_FLAG 0x20
  74. #define ES_RATE_FLAG 0x10
  75. #define DSM_TRICK_FLAG 0x08
  76. #define ADD_CPY_FLAG 0x04
  77. #define PES_CRC_FLAG 0x02
  78. #define PES_EXT_FLAG 0x01
  79. //pts_dts flags
  80. #define PTS_ONLY 0x80
  81. #define PTS_DTS 0xC0
  82. #define TS_SIZE 188
  83. #define TRANS_ERROR 0x80
  84. #define PAY_START 0x40
  85. #define TRANS_PRIO 0x20
  86. #define PID_MASK_HI 0x1F
  87. //flags
  88. #define TRANS_SCRMBL1 0x80
  89. #define TRANS_SCRMBL2 0x40
  90. #define ADAPT_FIELD 0x20
  91. #define PAYLOAD 0x10
  92. #define COUNT_MASK 0x0F
  93. // adaptation flags
  94. #define DISCON_IND 0x80
  95. #define RAND_ACC_IND 0x40
  96. #define ES_PRI_IND 0x20
  97. #define PCR_FLAG 0x10
  98. #define OPCR_FLAG 0x08
  99. #define SPLICE_FLAG 0x04
  100. #define TRANS_PRIV 0x02
  101. #define ADAP_EXT_FLAG 0x01
  102. // adaptation extension flags
  103. #define LTW_FLAG 0x80
  104. #define PIECE_RATE 0x40
  105. #define SEAM_SPLICE 0x20
  106. #define MAX_PLENGTH 0xFFFF
  107. #define MMAX_PLENGTH (256*MAX_PLENGTH)
  108. #ifndef IPACKS
  109. #define IPACKS 2048
  110. #endif
  111. struct ipack {
  112. int size;
  113. int found;
  114. u8 *buf;
  115. u8 cid;
  116. u32 plength;
  117. u8 plen[2];
  118. u8 flag1;
  119. u8 flag2;
  120. u8 hlength;
  121. u8 pts[5];
  122. u16 *pid;
  123. int mpeg;
  124. u8 check;
  125. int which;
  126. int done;
  127. void *data;
  128. void (*func)(u8 *buf, int size, void *priv);
  129. int count;
  130. int repack_subids;
  131. };
  132. struct dvb_video_info {
  133. u32 horizontal_size;
  134. u32 vertical_size;
  135. u32 aspect_ratio;
  136. u32 framerate;
  137. u32 video_format;
  138. u32 bit_rate;
  139. u32 comp_bit_rate;
  140. u32 vbv_buffer_size;
  141. s16 vbv_delay;
  142. u32 CSPF;
  143. u32 off;
  144. };
  145. #define OFF_SIZE 4
  146. #define FIRST_FIELD 0
  147. #define SECOND_FIELD 1
  148. #define VIDEO_FRAME_PICTURE 0x03
  149. struct mpg_picture {
  150. int channel;
  151. struct dvb_video_info vinfo;
  152. u32 *sequence_gop_header;
  153. u32 *picture_header;
  154. s32 time_code;
  155. int low_delay;
  156. int closed_gop;
  157. int broken_link;
  158. int sequence_header_flag;
  159. int gop_flag;
  160. int sequence_end_flag;
  161. u8 profile_and_level;
  162. s32 picture_coding_parameter;
  163. u32 matrix[32];
  164. s8 matrix_change_flag;
  165. u8 picture_header_parameter;
  166. /* bit 0 - 2: bwd f code
  167. bit 3 : fpb vector
  168. bit 4 - 6: fwd f code
  169. bit 7 : fpf vector */
  170. int mpeg1_flag;
  171. int progressive_sequence;
  172. int sequence_display_extension_flag;
  173. u32 sequence_header_data;
  174. s16 last_frame_centre_horizontal_offset;
  175. s16 last_frame_centre_vertical_offset;
  176. u32 pts[2]; /* [0] 1st field, [1] 2nd field */
  177. int top_field_first;
  178. int repeat_first_field;
  179. int progressive_frame;
  180. int bank;
  181. int forward_bank;
  182. int backward_bank;
  183. int compress;
  184. s16 frame_centre_horizontal_offset[OFF_SIZE];
  185. /* [0-2] 1st field, [3] 2nd field */
  186. s16 frame_centre_vertical_offset[OFF_SIZE];
  187. /* [0-2] 1st field, [3] 2nd field */
  188. s16 temporal_reference[2];
  189. /* [0] 1st field, [1] 2nd field */
  190. s8 picture_coding_type[2];
  191. /* [0] 1st field, [1] 2nd field */
  192. s8 picture_structure[2];
  193. /* [0] 1st field, [1] 2nd field */
  194. s8 picture_display_extension_flag[2];
  195. /* [0] 1st field, [1] 2nd field */
  196. /* picture_display_extenion() 0:no 1:exit*/
  197. s8 pts_flag[2];
  198. /* [0] 1st field, [1] 2nd field */
  199. };
  200. struct dvb_audio_info {
  201. int layer;
  202. u32 bit_rate;
  203. u32 frequency;
  204. u32 mode;
  205. u32 mode_extension ;
  206. u32 emphasis;
  207. u32 framesize;
  208. u32 off;
  209. };
  210. int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr);
  211. #endif