xine-lib  1.2.10
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
picture_s::limit_y
unsigned int limit_y
Definition: mpeg2_internal.h:97
picture_s::load_intra_quantizer_matrix
int load_intra_quantizer_matrix
Definition: mpeg2_internal.h:119
picture_s::q_scale_type
int q_scale_type
Definition: mpeg2_internal.h:149
mpeg2_scan_norm
uint8_t mpeg2_scan_norm[64]
Definition: header.c:55
picture_s::picture_structure
int picture_structure
Definition: mpeg2_internal.h:142
mpeg2_header_extension
int mpeg2_header_extension(picture_t *picture, uint8_t *buffer)
Definition: header.c:316
motion_t
Definition: mpeg2_internal.h:53
mpeg2_idct_mmx_init
void mpeg2_idct_mmx_init(void)
picture_s::transfer_characteristics
uint32_t transfer_characteristics
Definition: mpeg2_internal.h:185
picture_s::intra_dc_precision
int intra_dc_precision
Definition: mpeg2_internal.h:140
mpeg2_idct_add
void(* mpeg2_idct_add)(int16_t *block, uint8_t *dest, int stride)
Definition: idct.c:60
mpeg2_idct_copy
void(* mpeg2_idct_copy)(int16_t *block, uint8_t *dest, int stride)
Definition: idct.c:59
picture_s::current_frame
struct vo_frame_s * current_frame
Definition: mpeg2_internal.h:160
mpeg2_scan_alt
uint8_t mpeg2_scan_alt[64]
Definition: header.c:68
mpeg2_mc_3dnow
mpeg2_mc_t mpeg2_mc_3dnow
picture_s::display_height
unsigned int display_height
Definition: mpeg2_internal.h:127
mpeg2_zero_block_mmx
void mpeg2_zero_block_mmx(int16_t *block)
picture_s::limit_y_8
unsigned int limit_y_8
Definition: mpeg2_internal.h:96
mpeg2_cpu_state_init
void mpeg2_cpu_state_init(uint32_t mm_accel)
Definition: cpu_state.c:171
picture_s::pitches
int pitches[3]
Definition: mpeg2_internal.h:92
picture_s::low_delay
int low_delay
Definition: mpeg2_internal.h:135
mpeg2_cpu_state_save
void(* mpeg2_cpu_state_save)(cpu_state_t *state)
Definition: cpu_state.c:33
mpeg2_idct_mlib
void mpeg2_idct_mlib(int16_t *block)
mpeg2_mc_mmx
mpeg2_mc_t mpeg2_mc_mmx
mpeg2_idct_add_mlib
void mpeg2_idct_add_mlib(int16_t *block, uint8_t *dest, int stride)
mpeg2_idct_init
void mpeg2_idct_init(uint32_t mm_accel)
Definition: idct.c:281
picture_s::colour_primatives
uint32_t colour_primatives
Definition: mpeg2_internal.h:184
mpeg2_idct_altivec_init
void mpeg2_idct_altivec_init(void)
mpeg2_zero_block
void(* mpeg2_zero_block)(int16_t *block)
Definition: idct.c:62
picture_s::drop_frame_flag
uint32_t drop_frame_flag
Definition: mpeg2_internal.h:189
picture_s::time_code_seconds
uint32_t time_code_seconds
Definition: mpeg2_internal.h:192
picture_s::display_width
unsigned int display_width
Definition: mpeg2_internal.h:127
picture_s::current_field
int current_field
Definition: mpeg2_internal.h:109
mpeg2_idct_add_mmxext
void mpeg2_idct_add_mmxext(int16_t *block, uint8_t *dest, int stride)
picture_s::broken_link
uint32_t broken_link
Definition: mpeg2_internal.h:195
picture_s::frame_rate_ext_n
int frame_rate_ext_n
Definition: mpeg2_internal.h:198
picture_s::time_code_hours
uint32_t time_code_hours
Definition: mpeg2_internal.h:190
mpeg2_mc_c
mpeg2_mc_t mpeg2_mc_c
cpu_state_t
struct cpu_state_s cpu_state_t
picture_s::matrix_coefficients
uint32_t matrix_coefficients
Definition: mpeg2_internal.h:186
picture_s::progressive_sequence
int progressive_sequence
Definition: mpeg2_internal.h:177
mpeg2_cpu_state_restore
void(* mpeg2_cpu_state_restore)(cpu_state_t *state)
Definition: cpu_state.c:34
mpeg2_mc
mpeg2_mc_t mpeg2_mc
Definition: motion_comp.c:32
mpeg2_idct_copy_altivec
void mpeg2_idct_copy_altivec(signed short *block, unsigned char *dest, int stride)
picture_s::mc
xine_macroblocks_t * mc
Definition: mpeg2_internal.h:76
mpeg2_header_state_init
void mpeg2_header_state_init(picture_t *picture)
Definition: header.c:112
mpeg2_idct_mmxext
void mpeg2_idct_mmxext(int16_t *block)
picture_s::XvMC_dct_type
int XvMC_dct_type
Definition: mpeg2_internal.h:84
mpeg2_mc_t
struct mpeg2_mc_s mpeg2_mc_t
picture_t
Definition: vdpau_mpeg12.c:113
picture_s::repeat_first_field
int repeat_first_field
Definition: mpeg2_internal.h:178
motion_s::pmv
int pmv[2][2]
Definition: mpeg2_internal.h:64
xine_macroblock_s
Definition: accel_xvmc.h:34
mpeg2_mc_mmxext
mpeg2_mc_t mpeg2_mc_mmxext
picture_s::mpeg1
int mpeg1
Definition: mpeg2_internal.h:168
picture_s::second_field
int second_field
Definition: mpeg2_internal.h:166
picture_s::XvMC_y
int XvMC_y
Definition: mpeg2_internal.h:80
video_out.h
picture_s::display_vertical_size
uint32_t display_vertical_size
Definition: mpeg2_internal.h:188
mpeg2_header_sequence
int mpeg2_header_sequence(picture_t *picture, uint8_t *buffer)
Definition: header.c:119
picture_s::DCTblock
int16_t DCTblock[64]
Definition: mpeg2_internal.h:73
picture_s::quantizer_scale
int quantizer_scale
Definition: mpeg2_internal.h:108
picture_s::forward_reference_frame
struct vo_frame_s * forward_reference_frame
Definition: mpeg2_internal.h:161
mpeg2_slice
void mpeg2_slice(picture_t *picture, int code, uint8_t *buffer)
Definition: slice.c:1623
picture_s::frame_height
int frame_height
Definition: mpeg2_internal.h:164
mpeg2_idct_copy_mmx
void mpeg2_idct_copy_mmx(int16_t *block, uint8_t *dest, int stride)
mpeg2_stats
void mpeg2_stats(int code, uint8_t *buffer)
Definition: stats.c:270
mpeg2_mc_s::put
void(* put[8])(uint8_t *dst, uint8_t *, int32_t, int32_t)
Definition: mpeg2_internal.h:267
mpeg2_mc_s::avg
void(* avg[8])(uint8_t *dst, uint8_t *, int32_t, int32_t)
Definition: mpeg2_internal.h:268
cpu_state_t
Definition: mpeg2_internal.h:221
picture_s::frame_width
int frame_width
Definition: mpeg2_internal.h:164
picture_s::XvMC_motion_type
int XvMC_motion_type
Definition: mpeg2_internal.h:81
mpeg2_mc_t
Definition: mpeg2_internal.h:284
mpeg2_idct_add_altivec
void mpeg2_idct_add_altivec(signed short *block, unsigned char *dest, int stride)
picture_s::b_motion
motion_t b_motion
Definition: mpeg2_internal.h:102
motion_s::f_code
int f_code[2]
Definition: mpeg2_internal.h:65
picture_s::intra_quantizer_matrix
uint8_t intra_quantizer_matrix[64]
Definition: mpeg2_internal.h:117
picture_t
struct picture_s picture_t
picture_s::dest
uint8_t * dest[3]
Definition: mpeg2_internal.h:91
picture_s::frame_rate_ext_d
int frame_rate_ext_d
Definition: mpeg2_internal.h:199
picture_s::colour_description
uint32_t colour_description
Definition: mpeg2_internal.h:183
picture_s::XvMC_mb_type
int XvMC_mb_type
Definition: mpeg2_internal.h:77
picture_s::intra_vlc_format
int intra_vlc_format
Definition: mpeg2_internal.h:151
picture_s::dmv_offset
int dmv_offset
Definition: mpeg2_internal.h:110
picture_s
Definition: mpeg2_internal.h:68
picture_s::saved_aspect_ratio
int saved_aspect_ratio
Definition: mpeg2_internal.h:175
picture_s::bitstream_bits
int bitstream_bits
Definition: mpeg2_internal.h:88
picture_s::XvMC_x
int XvMC_x
Definition: mpeg2_internal.h:79
picture_s::frame_centre_horizontal_offset
int32_t frame_centre_horizontal_offset
Definition: mpeg2_internal.h:180
mpeg2_idct_copy_mmxext
void mpeg2_idct_copy_mmxext(int16_t *block, uint8_t *dest, int stride)
mpeg2_mc_vis
mpeg2_mc_t mpeg2_mc_vis
mpeg2_mc_altivec
mpeg2_mc_t mpeg2_mc_altivec
accel_xvmc.h
picture_s::bitstream_buf
uint32_t bitstream_buf
Definition: mpeg2_internal.h:87
picture_s::XvMC_cbp
int XvMC_cbp
Definition: mpeg2_internal.h:83
picture_s::dc_dct_pred
int16_t dc_dct_pred[3]
Definition: mpeg2_internal.h:106
mpeg2_header_picture
int mpeg2_header_picture(picture_t *picture, uint8_t *buffer)
Definition: header.c:400
picture_s::coded_picture_height
int coded_picture_height
Definition: mpeg2_internal.h:124
picture_s::time_code_pictures
uint32_t time_code_pictures
Definition: mpeg2_internal.h:193
code
char code
Definition: xmllexer.c:606
mpeg2_mc_mlib
mpeg2_mc_t mpeg2_mc_mlib
picture_s::concealment_motion_vectors
int concealment_motion_vectors
Definition: mpeg2_internal.h:147
cpu_state_s
Definition: mpeg2_internal.h:203
picture_s::display_horizontal_size
uint32_t display_horizontal_size
Definition: mpeg2_internal.h:187
picture_s::frame_rate_code
int frame_rate_code
Definition: mpeg2_internal.h:176
picture_s::limit_y_16
unsigned int limit_y_16
Definition: mpeg2_internal.h:95
picture_s::time_code_minutes
uint32_t time_code_minutes
Definition: mpeg2_internal.h:191
mpeg2_idct_mmx
void mpeg2_idct_mmx(int16_t *block)
mpeg2_mc_s
Definition: mpeg2_internal.h:266
picture_s::coded_picture_width
int coded_picture_width
Definition: mpeg2_internal.h:123
mpeg2_idct_add_mmx
void mpeg2_idct_add_mmx(int16_t *block, uint8_t *dest, int stride)
picture_s::f_motion
motion_t f_motion
Definition: mpeg2_internal.h:103
mpeg2_mc_init
void mpeg2_mc_init(uint32_t mm_accel)
Definition: motion_comp.c:34
picture_s::frame_pred_frame_dct
int frame_pred_frame_dct
Definition: mpeg2_internal.h:144
mpeg2_idct_copy_mlib_non_ieee
void mpeg2_idct_copy_mlib_non_ieee(int16_t *block, uint8_t *dest, int stride)
picture_s::XvMC_mv_field_sel
int XvMC_mv_field_sel[2][2]
Definition: mpeg2_internal.h:78
mpeg2_idct
void(* mpeg2_idct)(int16_t *block)
Definition: idct.c:61
mpeg2_header_group_of_pictures
int mpeg2_header_group_of_pictures(picture_t *picture, uint8_t *buffer)
Definition: header.c:371
picture_s::progressive_frame
int progressive_frame
Definition: mpeg2_internal.h:179
picture_s::skip_non_intra_dct
int skip_non_intra_dct
Definition: mpeg2_internal.h:170
picture_s::bitrate
int bitrate
Definition: mpeg2_internal.h:197
picture_s::vbv_delay
int vbv_delay
Definition: mpeg2_internal.h:134
motion_s::ref
uint8_t * ref[2][3]
Definition: mpeg2_internal.h:62
motion_s
Definition: mpeg2_internal.h:61
picture_s::offset
int offset
Definition: mpeg2_internal.h:93
vo_frame_s
Definition: video_out.h:59
mpeg2_idct_add_mlib_non_ieee
void mpeg2_idct_add_mlib_non_ieee(int16_t *block, uint8_t *dest, int stride)
picture_s::video_format
uint32_t video_format
Definition: mpeg2_internal.h:182
motion_t
struct motion_s motion_t
picture_s::bitstream_ptr
uint8_t * bitstream_ptr
Definition: mpeg2_internal.h:89
picture_s::closed_gop
uint32_t closed_gop
Definition: mpeg2_internal.h:194
picture_s::limit_x
unsigned int limit_x
Definition: mpeg2_internal.h:94
picture_s::load_non_intra_quantizer_matrix
int load_non_intra_quantizer_matrix
Definition: mpeg2_internal.h:120
picture_s::aspect_ratio_information
int aspect_ratio_information
Definition: mpeg2_internal.h:174
motion_s::ref2
uint8_t ** ref2[2]
Definition: mpeg2_internal.h:63
picture_s::scan
uint8_t * scan
Definition: mpeg2_internal.h:158
picture_s::non_intra_quantizer_matrix
uint8_t non_intra_quantizer_matrix[64]
Definition: mpeg2_internal.h:118
picture_s::picture_coding_type
int picture_coding_type
Definition: mpeg2_internal.h:132
picture_s::backward_reference_frame
struct vo_frame_s * backward_reference_frame
Definition: mpeg2_internal.h:162
picture_s::top_field_first
int top_field_first
Definition: mpeg2_internal.h:153
cpu_state_s::dummy
int dummy
Definition: mpeg2_internal.h:207
picture_s::XvMC_dmvector
int XvMC_dmvector[2]
Definition: mpeg2_internal.h:82
picture_s::frame_centre_vertical_offset
int32_t frame_centre_vertical_offset
Definition: mpeg2_internal.h:181
picture_s::v_offset
unsigned int v_offset
Definition: mpeg2_internal.h:111