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