xine-lib  1.2.9
mpeg2_internal.h
Go to the documentation of this file.
1 /*
2  * mpeg2_internal.h
3  * Copyright (C) 2000-2002 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef MPEG2_INTERNAL_H
25 #define MPEG2_INTERNAL_H
26 
27 #include <xine/video_out.h>
28 #include "accel_xvmc.h"
29 
30 #ifdef ENABLE_ALTIVEC
31 #include <altivec.h>
32 #endif
33 
34 /* macroblock modes */
35 #define MACROBLOCK_INTRA XINE_MACROBLOCK_INTRA
36 #define MACROBLOCK_PATTERN XINE_MACROBLOCK_PATTERN
37 #define MACROBLOCK_MOTION_BACKWARD XINE_MACROBLOCK_MOTION_BACKWARD
38 #define MACROBLOCK_MOTION_FORWARD XINE_MACROBLOCK_MOTION_FORWARD
39 #define MACROBLOCK_QUANT XINE_MACROBLOCK_QUANT
40 #define DCT_TYPE_INTERLACED XINE_MACROBLOCK_DCT_TYPE_INTERLACED
41 
42 /* motion_type */
43 #define MOTION_TYPE_MASK (3*64)
44 #define MOTION_TYPE_BASE 64
45 #define MC_FIELD (1*64)
46 #define MC_FRAME (2*64)
47 #define MC_16X8 (2*64)
48 #define MC_DMV (3*64)
49 
50 /* picture structure */
51 #define TOP_FIELD VO_TOP_FIELD
52 #define BOTTOM_FIELD VO_BOTTOM_FIELD
53 #define FRAME_PICTURE VO_BOTH_FIELDS
54 
55 /* picture coding type (mpeg2 header) */
56 #define I_TYPE 1
57 #define P_TYPE 2
58 #define B_TYPE 3
59 #define D_TYPE 4
60 
61 typedef struct motion_s {
62  uint8_t * ref[2][3];
63  uint8_t ** ref2[2];
64  int pmv[2][2];
65  int f_code[2];
66 } motion_t;
67 
68 typedef struct picture_s {
69  /* first, state that carries information from one macroblock to the */
70  /* next inside a slice, and is never used outside of mpeg2_slice() */
71 
72  /* DCT coefficients - should be kept aligned ! */
73  int16_t DCTblock[64];
74 
75  /* XvMC DCT block and macroblock data for XvMC acceleration */
78  int XvMC_mv_field_sel[2][2];
79  int XvMC_x;
80  int XvMC_y;
82  int XvMC_dmvector[2];
83  int XvMC_cbp;
85 
86  /* bit parsing stuff */
87  uint32_t bitstream_buf; /* current 32 bit working set of buffer */
88  int bitstream_bits; /* used bits in working set */
89  uint8_t * bitstream_ptr; /* buffer with stream data */
90 
91  uint8_t * dest[3];
92  int pitches[3];
93  int offset;
94  unsigned int limit_x;
95  unsigned int limit_y_16;
96  unsigned int limit_y_8;
97  unsigned int limit_y;
98 
99  /* Motion vectors */
100  /* The f_ and b_ correspond to the forward and backward motion */
101  /* predictors */
104 
105  /* predictor for DC coefficients in intra blocks */
106  int16_t dc_dct_pred[3];
107 
108  int quantizer_scale; /* remove */
109  int current_field; /* remove */
110  int dmv_offset; /* remove */
111  unsigned int v_offset; /* remove */
112 
113 
114  /* now non-slice-specific information */
115 
116  /* sequence header stuff */
121 
122  /* The width and height of the picture snapped to macroblock units */
125 
126  /* The width and height as it appears on header sequence */
128 
129  /* picture header stuff */
130 
131  /* what type of picture this is (I, P, B, D) */
133 
136 
137  /* picture coding extension stuff */
138 
139  /* quantization factor for intra dc coefficients */
141  /* top/bottom/both fields */
143  /* bool to indicate all predictions are frame based */
145  /* bool to indicate whether intra blocks have motion vectors */
146  /* (for concealment) */
148  /* bit to indicate which quantization table to use */
150  /* bool to use different vlc tables */
152  /* used for DMV MC */
154 
155  /* stuff derived from bitstream */
156 
157  /* pointer to the zigzag scan we're supposed to be using */
158  uint8_t * scan;
159 
163 
165 
167 
168  int mpeg1;
169 
171 
172  /* these things are not needed by the decoder */
173  /* this is a temporary interface, we will build a better one later. */
182  uint32_t video_format;
189  uint32_t drop_frame_flag;
190  uint32_t time_code_hours;
194  uint32_t closed_gop;
195  uint32_t broken_link;
196 
197  int bitrate;
200 
201 } picture_t;
202 
203 typedef struct cpu_state_s {
204 #ifdef ARCH_PPC
205  uint8_t regv[12*16];
206 #endif
207  int dummy;
208 } cpu_state_t;
209 
210 /* cpu_state.c */
211 extern void (* mpeg2_cpu_state_save) (cpu_state_t * state);
212 extern void (* mpeg2_cpu_state_restore) (cpu_state_t * state);
213 void mpeg2_cpu_state_init (uint32_t mm_accel);
214 
215 /* header.c */
216 extern uint8_t mpeg2_scan_norm[64];
217 extern uint8_t mpeg2_scan_alt[64];
218 void mpeg2_header_state_init (picture_t * picture);
219 int mpeg2_header_picture (picture_t * picture, uint8_t * buffer);
220 int mpeg2_header_sequence (picture_t * picture, uint8_t * buffer);
221 int mpeg2_header_extension (picture_t * picture, uint8_t * buffer);
222 int mpeg2_header_group_of_pictures (picture_t * picture, uint8_t * buffer);
223 
224 /* idct.c */
225 extern void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
226 extern void (* mpeg2_idct_add) (int16_t * block, uint8_t * dest, int stride);
227 extern void (* mpeg2_idct) (int16_t * block);
228 extern void (* mpeg2_zero_block) (int16_t * block);
229 void mpeg2_idct_init (uint32_t mm_accel);
230 
231 /* idct_mlib.c */
232 void mpeg2_idct_add_mlib (int16_t * block, uint8_t * dest, int stride);
233 void mpeg2_idct_copy_mlib_non_ieee (int16_t * block, uint8_t * dest,
234  int stride);
235 void mpeg2_idct_add_mlib_non_ieee (int16_t * block, uint8_t * dest,
236  int stride);
237 void mpeg2_idct_mlib (int16_t * block);
238 
239 /* idct_mmx.c */
240 void mpeg2_idct_copy_mmxext (int16_t * block, uint8_t * dest, int stride);
241 void mpeg2_idct_add_mmxext (int16_t * block, uint8_t * dest, int stride);
242 void mpeg2_idct_mmxext (int16_t * block);
243 void mpeg2_idct_copy_mmx (int16_t * block, uint8_t * dest, int stride);
244 void mpeg2_idct_add_mmx (int16_t * block, uint8_t * dest, int stride);
245 void mpeg2_idct_mmx (int16_t * block);
246 void mpeg2_zero_block_mmx (int16_t * block);
247 void mpeg2_idct_mmx_init (void);
248 
249 /* idct_altivec.c */
250 # ifdef ENABLE_ALTIVEC
251 void mpeg2_idct_copy_altivec (vector signed short * block, unsigned char * dest,
252  int stride);
253 void mpeg2_idct_add_altivec (vector signed short * block, unsigned char * dest,
254  int stride);
255 # else /* ! ENABLE_ALTIVEC */
256 void mpeg2_idct_copy_altivec (signed short * block, unsigned char * dest,
257  int stride);
258 void mpeg2_idct_add_altivec (signed short * block, unsigned char * dest,
259  int stride);
260 # endif /* ENABLE_ALTIVEC */
261 void mpeg2_idct_altivec_init (void);
262 
263 /* motion_comp.c */
264 void mpeg2_mc_init (uint32_t mm_accel);
265 
266 typedef struct mpeg2_mc_s {
267  void (* put [8]) (uint8_t * dst, uint8_t *, int32_t, int32_t);
268  void (* avg [8]) (uint8_t * dst, uint8_t *, int32_t, int32_t);
269 } mpeg2_mc_t;
270 
271 #define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \
272  {MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
273  MC_put_o_8_##x, MC_put_x_8_##x, MC_put_y_8_##x, MC_put_xy_8_##x}, \
274  {MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \
275  MC_avg_o_8_##x, MC_avg_x_8_##x, MC_avg_y_8_##x, MC_avg_xy_8_##x} \
276 };
277 
278 extern mpeg2_mc_t mpeg2_mc;
279 extern mpeg2_mc_t mpeg2_mc_c;
280 extern mpeg2_mc_t mpeg2_mc_mmx;
285 extern mpeg2_mc_t mpeg2_mc_vis;
286 
287 /* slice.c */
288 void mpeg2_slice (picture_t * picture, int code, uint8_t * buffer);
289 
290 /* stats.c */
291 void mpeg2_stats (int code, uint8_t * buffer);
292 
293 
294 #endif
int intra_dc_precision
Definition: mpeg2_internal.h:140
struct picture_s picture_t
void mpeg2_idct_add_altivec(signed short *block, unsigned char *dest, int stride)
int picture_coding_type
Definition: mpeg2_internal.h:132
void mpeg2_idct_copy_mmx(int16_t *block, uint8_t *dest, int stride)
void mpeg2_header_state_init(picture_t *picture)
Definition: header.c:112
void(* mpeg2_cpu_state_save)(cpu_state_t *state)
Definition: cpu_state.c:33
uint32_t time_code_hours
Definition: mpeg2_internal.h:190
int picture_structure
Definition: mpeg2_internal.h:142
struct vo_frame_s * backward_reference_frame
Definition: mpeg2_internal.h:162
Definition: vdpau_mpeg12.c:113
void mpeg2_idct_add_mlib(int16_t *block, uint8_t *dest, int stride)
struct vo_frame_s * current_frame
Definition: mpeg2_internal.h:160
int progressive_sequence
Definition: mpeg2_internal.h:177
int load_intra_quantizer_matrix
Definition: mpeg2_internal.h:119
int top_field_first
Definition: mpeg2_internal.h:153
int32_t frame_centre_vertical_offset
Definition: mpeg2_internal.h:181
uint32_t colour_primatives
Definition: mpeg2_internal.h:184
Definition: mpeg2_internal.h:284
uint8_t mpeg2_scan_alt[64]
Definition: header.c:68
void mpeg2_idct_add_mmx(int16_t *block, uint8_t *dest, int stride)
int repeat_first_field
Definition: mpeg2_internal.h:178
int current_field
Definition: mpeg2_internal.h:109
uint32_t transfer_characteristics
Definition: mpeg2_internal.h:185
int XvMC_y
Definition: mpeg2_internal.h:80
unsigned int display_height
Definition: mpeg2_internal.h:127
int16_t DCTblock[64]
Definition: mpeg2_internal.h:73
int low_delay
Definition: mpeg2_internal.h:135
xine_macroblocks_t * mc
Definition: mpeg2_internal.h:76
mpeg2_mc_t mpeg2_mc_3dnow
int XvMC_dct_type
Definition: mpeg2_internal.h:84
unsigned int limit_y_8
Definition: mpeg2_internal.h:96
unsigned int display_width
Definition: mpeg2_internal.h:127
void mpeg2_idct_mmx_init(void)
void mpeg2_idct_copy_altivec(signed short *block, unsigned char *dest, int stride)
void(* put[8])(uint8_t *dst, uint8_t *, int32_t, int32_t)
Definition: mpeg2_internal.h:267
int frame_width
Definition: mpeg2_internal.h:164
int frame_rate_ext_n
Definition: mpeg2_internal.h:198
int second_field
Definition: mpeg2_internal.h:166
mpeg2_mc_t mpeg2_mc_altivec
Definition: mpeg2_internal.h:221
Definition: mpeg2_internal.h:68
int quantizer_scale
Definition: mpeg2_internal.h:108
mpeg2_mc_t mpeg2_mc_mmxext
uint32_t time_code_seconds
Definition: mpeg2_internal.h:192
void mpeg2_slice(picture_t *picture, int code, uint8_t *buffer)
Definition: slice.c:1619
void mpeg2_stats(int code, uint8_t *buffer)
Definition: stats.c:260
int frame_height
Definition: mpeg2_internal.h:164
int mpeg2_header_group_of_pictures(picture_t *picture, uint8_t *buffer)
Definition: header.c:371
void mpeg2_idct_copy_mlib_non_ieee(int16_t *block, uint8_t *dest, int stride)
uint32_t drop_frame_flag
Definition: mpeg2_internal.h:189
int XvMC_motion_type
Definition: mpeg2_internal.h:81
Definition: mpeg2_internal.h:61
uint8_t * dest[3]
Definition: mpeg2_internal.h:91
void(* mpeg2_idct_copy)(int16_t *block, uint8_t *dest, int stride)
Definition: idct.c:59
mpeg2_mc_t mpeg2_mc_c
Definition: motion_comp.c:145
void mpeg2_idct_copy_mmxext(int16_t *block, uint8_t *dest, int stride)
uint32_t broken_link
Definition: mpeg2_internal.h:195
void mpeg2_idct_mlib(int16_t *block)
mpeg2_mc_t mpeg2_mc_mmx
uint32_t matrix_coefficients
Definition: mpeg2_internal.h:186
int saved_aspect_ratio
Definition: mpeg2_internal.h:175
int mpeg2_header_extension(picture_t *picture, uint8_t *buffer)
Definition: header.c:316
int XvMC_x
Definition: mpeg2_internal.h:79
struct cpu_state_s cpu_state_t
int XvMC_mb_type
Definition: mpeg2_internal.h:77
uint32_t time_code_minutes
Definition: mpeg2_internal.h:191
mpeg2_mc_t mpeg2_mc
Definition: motion_comp.c:32
int coded_picture_height
Definition: mpeg2_internal.h:124
int mpeg1
Definition: mpeg2_internal.h:168
uint32_t display_vertical_size
Definition: mpeg2_internal.h:188
int pmv[2][2]
Definition: mpeg2_internal.h:64
void mpeg2_idct_add_mmxext(int16_t *block, uint8_t *dest, int stride)
void(* mpeg2_idct_add)(int16_t *block, uint8_t *dest, int stride)
Definition: idct.c:60
Definition: mpeg2_internal.h:203
int f_code[2]
Definition: mpeg2_internal.h:65
void mpeg2_idct_mmxext(int16_t *block)
void(* mpeg2_zero_block)(int16_t *block)
Definition: idct.c:62
int coded_picture_width
Definition: mpeg2_internal.h:123
motion_t b_motion
Definition: mpeg2_internal.h:102
struct vo_frame_s * forward_reference_frame
Definition: mpeg2_internal.h:161
void mpeg2_cpu_state_init(uint32_t mm_accel)
Definition: cpu_state.c:170
int mpeg2_header_picture(picture_t *picture, uint8_t *buffer)
Definition: header.c:400
int XvMC_cbp
Definition: mpeg2_internal.h:83
uint32_t bitstream_buf
Definition: mpeg2_internal.h:87
Definition: mpeg2_internal.h:53
void mpeg2_idct_altivec_init(void)
uint32_t display_horizontal_size
Definition: mpeg2_internal.h:187
void mpeg2_idct_mmx(int16_t *block)
Definition: video_out.h:60
int bitstream_bits
Definition: mpeg2_internal.h:88
uint32_t colour_description
Definition: mpeg2_internal.h:183
struct mpeg2_mc_s mpeg2_mc_t
int skip_non_intra_dct
Definition: mpeg2_internal.h:170
int offset
Definition: mpeg2_internal.h:93
uint8_t intra_quantizer_matrix[64]
Definition: mpeg2_internal.h:117
int progressive_frame
Definition: mpeg2_internal.h:179
int concealment_motion_vectors
Definition: mpeg2_internal.h:147
int intra_vlc_format
Definition: mpeg2_internal.h:151
uint32_t closed_gop
Definition: mpeg2_internal.h:194
void mpeg2_zero_block_mmx(int16_t *block)
int frame_rate_ext_d
Definition: mpeg2_internal.h:199
int dmv_offset
Definition: mpeg2_internal.h:110
int32_t frame_centre_horizontal_offset
Definition: mpeg2_internal.h:180
unsigned int limit_x
Definition: mpeg2_internal.h:94
int load_non_intra_quantizer_matrix
Definition: mpeg2_internal.h:120
int frame_rate_code
Definition: mpeg2_internal.h:176
uint8_t * ref[2][3]
Definition: mpeg2_internal.h:62
int vbv_delay
Definition: mpeg2_internal.h:134
struct motion_s motion_t
uint32_t time_code_pictures
Definition: mpeg2_internal.h:193
int mpeg2_header_sequence(picture_t *picture, uint8_t *buffer)
Definition: header.c:119
int dummy
Definition: mpeg2_internal.h:207
void mpeg2_idct_init(uint32_t mm_accel)
Definition: idct.c:281
int16_t dc_dct_pred[3]
Definition: mpeg2_internal.h:106
void mpeg2_idct_add_mlib_non_ieee(int16_t *block, uint8_t *dest, int stride)
void mpeg2_mc_init(uint32_t mm_accel)
Definition: motion_comp.c:34
int XvMC_mv_field_sel[2][2]
Definition: mpeg2_internal.h:78
void(* mpeg2_idct)(int16_t *block)
Definition: idct.c:61
Definition: accel_xvmc.h:38
uint8_t * bitstream_ptr
Definition: mpeg2_internal.h:89
int frame_pred_frame_dct
Definition: mpeg2_internal.h:144
uint8_t mpeg2_scan_norm[64]
Definition: header.c:55
int aspect_ratio_information
Definition: mpeg2_internal.h:174
unsigned int limit_y_16
Definition: mpeg2_internal.h:95
int XvMC_dmvector[2]
Definition: mpeg2_internal.h:82
unsigned int limit_y
Definition: mpeg2_internal.h:97
motion_t f_motion
Definition: mpeg2_internal.h:103
mpeg2_mc_t mpeg2_mc_mlib
char code
Definition: xmllexer.c:606
void(* mpeg2_cpu_state_restore)(cpu_state_t *state)
Definition: cpu_state.c:34
void(* avg[8])(uint8_t *dst, uint8_t *, int32_t, int32_t)
Definition: mpeg2_internal.h:268
uint32_t video_format
Definition: mpeg2_internal.h:182
mpeg2_mc_t mpeg2_mc_vis
uint8_t non_intra_quantizer_matrix[64]
Definition: mpeg2_internal.h:118
Definition: mpeg2_internal.h:266
unsigned int v_offset
Definition: mpeg2_internal.h:111
uint8_t * scan
Definition: mpeg2_internal.h:158
int bitrate
Definition: mpeg2_internal.h:197
int pitches[3]
Definition: mpeg2_internal.h:92
uint8_t ** ref2[2]
Definition: mpeg2_internal.h:63
int q_scale_type
Definition: mpeg2_internal.h:149