summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpeg2_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg2_internal.h')
-rw-r--r--apps/plugins/mpegplayer/mpeg2_internal.h300
1 files changed, 300 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/mpeg2_internal.h b/apps/plugins/mpegplayer/mpeg2_internal.h
new file mode 100644
index 0000000000..850456b1f8
--- /dev/null
+++ b/apps/plugins/mpegplayer/mpeg2_internal.h
@@ -0,0 +1,300 @@
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>
5 *
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * See http://libmpeg2.sourceforge.net/ for updates.
8 *
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.
13 *
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.
18 *
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
22 */
23
24/* macroblock modes */
25#define MACROBLOCK_INTRA 1
26#define MACROBLOCK_PATTERN 2
27#define MACROBLOCK_MOTION_BACKWARD 4
28#define MACROBLOCK_MOTION_FORWARD 8
29#define MACROBLOCK_QUANT 16
30#define DCT_TYPE_INTERLACED 32
31/* motion_type */
32#define MOTION_TYPE_SHIFT 6
33#define MC_FIELD 1
34#define MC_FRAME 2
35#define MC_16X8 2
36#define MC_DMV 3
37
38/* picture structure */
39#define TOP_FIELD 1
40#define BOTTOM_FIELD 2
41#define FRAME_PICTURE 3
42
43/* picture coding type */
44#define I_TYPE 1
45#define P_TYPE 2
46#define B_TYPE 3
47#define D_TYPE 4
48
49typedef void mpeg2_mc_fct (uint8_t *, const uint8_t *, int, int);
50
51typedef struct {
52 uint8_t * ref[2][3];
53 uint8_t ** ref2[2];
54 int pmv[2][2];
55 int f_code[2];
56} motion_t;
57
58typedef void motion_parser_t (mpeg2_decoder_t * decoder,
59 motion_t * motion,
60 mpeg2_mc_fct * const * table);
61
62struct mpeg2_decoder_s {
63 /* first, state that carries information from one macroblock to the */
64 /* next inside a slice, and is never used outside of mpeg2_slice() */
65
66 /* bit parsing stuff */
67 uint32_t bitstream_buf; /* current 32 bit working set */
68 int bitstream_bits; /* used bits in working set */
69 const uint8_t * bitstream_ptr; /* buffer with stream data */
70
71 uint8_t * dest[3];
72
73 int offset;
74 int stride;
75 int uv_stride;
76 int slice_stride;
77 int slice_uv_stride;
78 int stride_frame;
79 unsigned int limit_x;
80 unsigned int limit_y_16;
81 unsigned int limit_y_8;
82 unsigned int limit_y;
83
84 /* Motion vectors */
85 /* The f_ and b_ correspond to the forward and backward motion */
86 /* predictors */
87 motion_t b_motion;
88 motion_t f_motion;
89 motion_parser_t * motion_parser[5];
90
91 /* predictor for DC coefficients in intra blocks */
92 int16_t dc_dct_pred[3];
93
94 /* DCT coefficients */
95 int16_t DCTblock[64] ATTR_ALIGN(64);
96
97 uint8_t * picture_dest[3];
98 void (* convert) (void * convert_id, uint8_t * const * src,
99 unsigned int v_offset);
100 void * convert_id;
101
102 int dmv_offset;
103 unsigned int v_offset;
104
105 /* now non-slice-specific information */
106
107 /* sequence header stuff */
108 uint16_t * quantizer_matrix[4];
109 uint16_t (* chroma_quantizer[2])[64];
110 uint16_t quantizer_prescale[4][32][64];
111
112 /* The width and height of the picture snapped to macroblock units */
113 int width;
114 int height;
115 int vertical_position_extension;
116 int chroma_format;
117
118 /* picture header stuff */
119
120 /* what type of picture this is (I, P, B, D) */
121 int coding_type;
122
123 /* picture coding extension stuff */
124
125 /* quantization factor for intra dc coefficients */
126 int intra_dc_precision;
127 /* top/bottom/both fields */
128 int picture_structure;
129 /* bool to indicate all predictions are frame based */
130 int frame_pred_frame_dct;
131 /* bool to indicate whether intra blocks have motion vectors */
132 /* (for concealment) */
133 int concealment_motion_vectors;
134 /* bool to use different vlc tables */
135 int intra_vlc_format;
136 /* used for DMV MC */
137 int top_field_first;
138
139 /* stuff derived from bitstream */
140
141 /* pointer to the zigzag scan we're supposed to be using */
142 const uint8_t * scan;
143
144 int second_field;
145
146 int mpeg1;
147};
148
149typedef struct {
150 mpeg2_fbuf_t fbuf;
151} fbuf_alloc_t;
152
153struct mpeg2dec_s {
154 mpeg2_decoder_t decoder;
155
156 mpeg2_info_t info;
157
158 uint32_t shift;
159 int is_display_initialized;
160 mpeg2_state_t (* action) (struct mpeg2dec_s * mpeg2dec);
161 mpeg2_state_t state;
162 uint32_t ext_state;
163
164 /* allocated in init - gcc has problems allocating such big structures */
165 uint8_t * chunk_buffer;
166 /* pointer to start of the current chunk */
167 uint8_t * chunk_start;
168 /* pointer to current position in chunk_buffer */
169 uint8_t * chunk_ptr;
170 /* last start code ? */
171 uint8_t code;
172
173 /* picture tags */
174 uint32_t tag_current, tag2_current, tag_previous, tag2_previous;
175 int num_tags;
176 int bytes_since_tag;
177
178 int first;
179 int alloc_index_user;
180 int alloc_index;
181 uint8_t first_decode_slice;
182 uint8_t nb_decode_slices;
183
184 unsigned int user_data_len;
185
186 mpeg2_sequence_t new_sequence;
187 mpeg2_sequence_t sequence;
188 mpeg2_gop_t new_gop;
189 mpeg2_gop_t gop;
190 mpeg2_picture_t new_picture;
191 mpeg2_picture_t pictures[4];
192 mpeg2_picture_t * picture;
193 /*const*/ mpeg2_fbuf_t * fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */
194
195 fbuf_alloc_t fbuf_alloc[3];
196 int custom_fbuf;
197
198 uint8_t * yuv_buf[3][3];
199 int yuv_index;
200 mpeg2_convert_t * convert;
201 void * convert_arg;
202 unsigned int convert_id_size;
203 int convert_stride;
204 void (* convert_start) (void * id, const mpeg2_fbuf_t * fbuf,
205 const mpeg2_picture_t * picture,
206 const mpeg2_gop_t * gop);
207
208 uint8_t * buf_start;
209 uint8_t * buf_end;
210
211 int16_t display_offset_x, display_offset_y;
212
213 int copy_matrix;
214 int8_t q_scale_type, scaled[4];
215 uint8_t quantizer_matrix[4][64];
216 uint8_t new_quantizer_matrix[4][64];
217};
218
219typedef struct {
220#ifdef ARCH_PPC
221 uint8_t regv[12*16];
222#endif
223 int dummy;
224} cpu_state_t;
225
226/* cpu_accel.c */
227uint32_t mpeg2_detect_accel (void);
228
229/* cpu_state.c */
230void mpeg2_cpu_state_init (uint32_t accel);
231
232/* decode.c */
233mpeg2_state_t mpeg2_seek_header (mpeg2dec_t * mpeg2dec);
234mpeg2_state_t mpeg2_parse_header (mpeg2dec_t * mpeg2dec);
235
236/* header.c */
237void mpeg2_header_state_init (mpeg2dec_t * mpeg2dec);
238void mpeg2_reset_info (mpeg2_info_t * info);
239int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec);
240int mpeg2_header_gop (mpeg2dec_t * mpeg2dec);
241mpeg2_state_t mpeg2_header_picture_start (mpeg2dec_t * mpeg2dec);
242int mpeg2_header_picture (mpeg2dec_t * mpeg2dec);
243int mpeg2_header_extension (mpeg2dec_t * mpeg2dec);
244int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec);
245void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec);
246void mpeg2_header_gop_finalize (mpeg2dec_t * mpeg2dec);
247void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec, uint32_t accels);
248mpeg2_state_t mpeg2_header_slice_start (mpeg2dec_t * mpeg2dec);
249mpeg2_state_t mpeg2_header_end (mpeg2dec_t * mpeg2dec);
250void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int b_type);
251
252/* idct.c */
253void mpeg2_idct_init (uint32_t accel);
254
255/* idct_mmx.c */
256void mpeg2_idct_copy_mmxext (int16_t * block, uint8_t * dest, int stride);
257void mpeg2_idct_add_mmxext (int last, int16_t * block,
258 uint8_t * dest, int stride);
259void mpeg2_idct_copy_mmx (int16_t * block, uint8_t * dest, int stride);
260void mpeg2_idct_add_mmx (int last, int16_t * block,
261 uint8_t * dest, int stride);
262void mpeg2_idct_mmx_init (void);
263
264/* idct_altivec.c */
265void mpeg2_idct_copy_altivec (int16_t * block, uint8_t * dest, int stride);
266void mpeg2_idct_add_altivec (int last, int16_t * block,
267 uint8_t * dest, int stride);
268void mpeg2_idct_altivec_init (void);
269
270/* idct_alpha.c */
271void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, int stride);
272void mpeg2_idct_add_mvi (int last, int16_t * block,
273 uint8_t * dest, int stride);
274void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, int stride);
275void mpeg2_idct_add_alpha (int last, int16_t * block,
276 uint8_t * dest, int stride);
277void mpeg2_idct_alpha_init (void);
278
279/* motion_comp.c */
280void mpeg2_mc_init (uint32_t accel);
281
282typedef struct {
283 mpeg2_mc_fct * put [8];
284 mpeg2_mc_fct * avg [8];
285} mpeg2_mc_t;
286
287#define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \
288 {MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
289 MC_put_o_8_##x, MC_put_x_8_##x, MC_put_y_8_##x, MC_put_xy_8_##x}, \
290 {MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \
291 MC_avg_o_8_##x, MC_avg_x_8_##x, MC_avg_y_8_##x, MC_avg_xy_8_##x} \
292};
293
294extern mpeg2_mc_t mpeg2_mc_c;
295extern mpeg2_mc_t mpeg2_mc_mmx;
296extern mpeg2_mc_t mpeg2_mc_mmxext;
297extern mpeg2_mc_t mpeg2_mc_3dnow;
298extern mpeg2_mc_t mpeg2_mc_altivec;
299extern mpeg2_mc_t mpeg2_mc_alpha;
300extern mpeg2_mc_t mpeg2_mc_vis;