Rearange menu of mpegplayer. Add new menu with "settings" and "quit", and remove...
[kugel-rb.git] / apps / plugins / mpegplayer / mpeg2_internal.h
blobcbc3e24a2d1bdc6583c476000cb8c55103197bc7
1 /*
2 * mpeg2_internal.h
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * See http://libmpeg2.sourceforge.net/ for updates.
9 * mpeg2dec is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * mpeg2dec is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * $Id$
24 * libmpeg2 sync history:
25 * 2008-07-01 - CVS revision 1.89
27 #ifndef MPEG2_INTERNAL_H
28 #define MPEG2_INTERNAL_H
30 #include "config.h" /* for Rockbox CPU_ #defines */
32 #define STATE_INTERNAL_NORETURN ((mpeg2_state_t)-1)
34 /* macroblock modes */
35 #define MACROBLOCK_INTRA 1
36 #define MACROBLOCK_PATTERN 2
37 #define MACROBLOCK_MOTION_BACKWARD 4
38 #define MACROBLOCK_MOTION_FORWARD 8
39 #define MACROBLOCK_QUANT 16
40 #define DCT_TYPE_INTERLACED 32
41 /* motion_type */
42 #define MOTION_TYPE_SHIFT 6
43 #define MC_FIELD 1
44 #define MC_FRAME 2
45 #define MC_16X8 2
46 #define MC_DMV 3
48 /* picture structure */
49 #define TOP_FIELD 1
50 #define BOTTOM_FIELD 2
51 #define FRAME_PICTURE 3
53 /* picture coding type */
54 #define I_TYPE 1
55 #define P_TYPE 2
56 #define B_TYPE 3
57 #define D_TYPE 4
59 typedef void mpeg2_mc_fct (uint8_t *, const uint8_t *, int, int);
61 typedef struct
63 uint8_t * ref[2][MPEG2_COMPONENTS];
64 uint8_t ** ref2[2];
65 int pmv[2][2];
66 int f_code[2];
67 } motion_t;
69 typedef void motion_parser_t(mpeg2_decoder_t * decoder,
70 motion_t * motion,
71 mpeg2_mc_fct * const * table);
73 struct mpeg2_decoder_s
75 /* first, state that carries information from one macroblock to the */
76 /* next inside a slice, and is never used outside of mpeg2_slice() */
78 /* bit parsing stuff */
79 uint32_t bitstream_buf; /* current 32 bit working set */
80 int bitstream_bits; /* used bits in working set */
81 const uint8_t * bitstream_ptr; /* buffer with stream data */
83 uint8_t * dest[MPEG2_COMPONENTS];
85 int offset;
86 int stride;
87 int uv_stride;
88 int slice_stride;
89 int slice_uv_stride;
90 int stride_frame;
91 unsigned int limit_x;
92 unsigned int limit_y_16;
93 unsigned int limit_y_8;
94 unsigned int limit_y;
96 /* Motion vectors */
97 /* The f_ and b_ correspond to the forward and backward motion */
98 /* predictors */
99 motion_t b_motion;
100 motion_t f_motion;
101 motion_parser_t * motion_parser[5];
103 /* predictor for DC coefficients in intra blocks */
104 int16_t dc_dct_pred[MPEG2_COMPONENTS];
106 /* DCT coefficients */
107 int16_t * ATTR_ALIGN(16) DCTblock; /* put buffer separately to have it in IRAM */
109 uint8_t * picture_dest[MPEG2_COMPONENTS];
110 void (* convert) (void * convert_id, uint8_t * const * src,
111 unsigned int v_offset);
112 void * convert_id;
114 int dmv_offset;
115 unsigned int v_offset;
117 /* now non-slice-specific information */
119 /* sequence header stuff */
120 uint16_t * quantizer_matrix[4];
121 uint16_t (* chroma_quantizer[2])[64];
122 uint16_t quantizer_prescale[4][32][64];
124 /* The width and height of the picture snapped to macroblock units */
125 int width;
126 int height;
127 int vertical_position_extension;
128 int chroma_format;
130 /* picture header stuff */
132 /* what type of picture this is (I, P, B, D) */
133 int coding_type;
135 /* picture coding extension stuff */
137 /* quantization factor for intra dc coefficients */
138 int intra_dc_precision;
139 /* top/bottom/both fields */
140 int picture_structure;
141 /* bool to indicate all predictions are frame based */
142 int frame_pred_frame_dct;
143 /* bool to indicate whether intra blocks have motion vectors */
144 /* (for concealment) */
145 int concealment_motion_vectors;
146 /* bool to use different vlc tables */
147 int intra_vlc_format;
148 /* used for DMV MC */
149 int top_field_first;
151 /* stuff derived from bitstream */
153 /* pointer to the zigzag scan we're supposed to be using */
154 const uint8_t * scan;
156 int second_field;
158 int mpeg1;
161 typedef struct
163 mpeg2_fbuf_t fbuf;
164 } fbuf_alloc_t;
166 struct mpeg2dec_s
168 mpeg2_decoder_t decoder;
170 mpeg2_info_t info;
172 uint32_t shift;
173 int is_display_initialized;
174 mpeg2_state_t (* action) (struct mpeg2dec_s * mpeg2dec);
175 mpeg2_state_t state;
176 uint32_t ext_state;
178 /* allocated in init - gcc has problems allocating such big structures */
179 uint8_t * ATTR_ALIGN(4) chunk_buffer;
180 /* pointer to start of the current chunk */
181 uint8_t * chunk_start;
182 /* pointer to current position in chunk_buffer */
183 uint8_t * chunk_ptr;
184 /* last start code ? */
185 uint8_t code;
187 /* picture tags */
188 uint32_t tag_current, tag2_current, tag_previous, tag2_previous;
189 int num_tags;
190 int bytes_since_tag;
192 int first;
193 int alloc_index_user;
194 int alloc_index;
195 uint8_t first_decode_slice;
196 uint8_t nb_decode_slices;
198 unsigned int user_data_len;
200 mpeg2_sequence_t new_sequence;
201 mpeg2_sequence_t sequence;
202 mpeg2_gop_t new_gop;
203 mpeg2_gop_t gop;
204 mpeg2_picture_t new_picture;
205 mpeg2_picture_t pictures[4];
206 mpeg2_picture_t * picture;
207 /*const*/ mpeg2_fbuf_t * fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */
209 fbuf_alloc_t fbuf_alloc[3];
210 int custom_fbuf;
212 uint8_t * yuv_buf[3][MPEG2_COMPONENTS];
213 int yuv_index;
214 mpeg2_convert_t * convert;
215 void * convert_arg;
216 unsigned int convert_id_size;
217 int convert_stride;
218 void (* convert_start) (void * id, const mpeg2_fbuf_t * fbuf,
219 const mpeg2_picture_t * picture,
220 const mpeg2_gop_t * gop);
222 uint8_t * buf_start;
223 uint8_t * buf_end;
225 int16_t display_offset_x, display_offset_y;
227 int copy_matrix;
228 int8_t q_scale_type, scaled[4];
229 uint8_t quantizer_matrix[4][64];
230 uint8_t new_quantizer_matrix[4][64];
233 /* decode.c */
234 mpeg2_state_t mpeg2_seek_header (mpeg2dec_t * mpeg2dec);
235 mpeg2_state_t mpeg2_parse_header (mpeg2dec_t * mpeg2dec);
237 /* header.c */
238 void mpeg2_header_state_init (mpeg2dec_t * mpeg2dec);
239 void mpeg2_reset_info (mpeg2_info_t * info);
240 int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec);
241 int mpeg2_header_gop (mpeg2dec_t * mpeg2dec);
242 int mpeg2_header_picture (mpeg2dec_t * mpeg2dec);
243 int mpeg2_header_extension (mpeg2dec_t * mpeg2dec);
244 int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec);
245 void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec);
246 void mpeg2_header_gop_finalize (mpeg2dec_t * mpeg2dec);
247 void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec);
248 mpeg2_state_t mpeg2_header_slice_start (mpeg2dec_t * mpeg2dec);
249 mpeg2_state_t mpeg2_header_end (mpeg2dec_t * mpeg2dec);
250 void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int b_type);
252 /* idct.c */
253 void mpeg2_idct_init (void);
254 void mpeg2_idct_copy(int16_t * block, uint8_t * dest,
255 const int stride);
256 void mpeg2_idct_add(const int last, int16_t * block,
257 uint8_t * dest, const int stride);
259 extern const uint8_t default_mpeg2_scan_norm[64];
260 extern const uint8_t default_mpeg2_scan_alt[64];
261 extern uint8_t mpeg2_scan_norm[64];
262 extern uint8_t mpeg2_scan_alt[64];
264 /* motion_comp.c */
265 void mpeg2_mc_init (void);
267 typedef struct
269 mpeg2_mc_fct * put [8];
270 mpeg2_mc_fct * avg [8];
271 } mpeg2_mc_t;
273 extern const mpeg2_mc_t mpeg2_mc;
275 #endif /* MPEG2_INTERNAL_H */