1
|
1 /*
|
|
2 * mpeg2_internal.h
|
36
|
3 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
|
1
|
4 *
|
|
5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
|
|
6 *
|
|
7 * mpeg2dec is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * mpeg2dec is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20 */
|
|
21
|
36
|
22 /* macroblock modes */
|
1
|
23 #define MACROBLOCK_INTRA 1
|
|
24 #define MACROBLOCK_PATTERN 2
|
|
25 #define MACROBLOCK_MOTION_BACKWARD 4
|
|
26 #define MACROBLOCK_MOTION_FORWARD 8
|
|
27 #define MACROBLOCK_QUANT 16
|
|
28 #define DCT_TYPE_INTERLACED 32
|
36
|
29 /* motion_type */
|
1
|
30 #define MOTION_TYPE_MASK (3*64)
|
|
31 #define MOTION_TYPE_BASE 64
|
|
32 #define MC_FIELD (1*64)
|
|
33 #define MC_FRAME (2*64)
|
|
34 #define MC_16X8 (2*64)
|
|
35 #define MC_DMV (3*64)
|
|
36
|
36
|
37 /* picture structure */
|
1
|
38 #define TOP_FIELD 1
|
|
39 #define BOTTOM_FIELD 2
|
|
40 #define FRAME_PICTURE 3
|
|
41
|
36
|
42 /* picture coding type */
|
1
|
43 #define I_TYPE 1
|
|
44 #define P_TYPE 2
|
|
45 #define B_TYPE 3
|
|
46 #define D_TYPE 4
|
|
47
|
|
48 typedef struct motion_s {
|
|
49 uint8_t * ref[2][3];
|
|
50 int pmv[2][2];
|
|
51 int f_code[2];
|
|
52 } motion_t;
|
|
53
|
36
|
54 typedef struct vo_frame_s {
|
|
55 uint8_t * base[3]; /* pointer to 3 planes */
|
|
56 void (* copy) (struct vo_frame_s * frame, uint8_t ** src);
|
|
57 void* vo;
|
5468
|
58 void* mpi;
|
5515
|
59 #ifdef MPEG12_POSTPROC
|
|
60 #define MPEG2_MBC 120
|
|
61 #define MPEG2_MBR 72
|
|
62 int quant_store[MPEG2_MBR+1][MPEG2_MBC+1];
|
|
63 #endif
|
|
64
|
79
|
65 // int slice;
|
36
|
66 // void (* field) (struct vo_frame_s * frame, int flags);
|
|
67 // void (* draw) (struct vo_frame_s * frame);
|
|
68 // vo_instance_t * instance;
|
|
69 } vo_frame_t;
|
1
|
70
|
36
|
71 typedef struct picture_s {
|
|
72 /* first, state that carries information from one macroblock to the */
|
|
73 /* next inside a slice, and is never used outside of slice_process() */
|
|
74
|
|
75 /* DCT coefficients - should be kept aligned ! */
|
|
76 int16_t DCTblock[64];
|
|
77
|
|
78 /* bit parsing stuff */
|
|
79 uint32_t bitstream_buf; /* current 32 bit working set of buffer */
|
|
80 int bitstream_bits; /* used bits in working set */
|
|
81 uint8_t * bitstream_ptr; /* buffer with stream data */
|
|
82
|
|
83 /* Motion vectors */
|
|
84 /* The f_ and b_ correspond to the forward and backward motion */
|
|
85 /* predictors */
|
1
|
86 motion_t b_motion;
|
|
87 motion_t f_motion;
|
|
88
|
36
|
89 /* predictor for DC coefficients in intra blocks */
|
1
|
90 int16_t dc_dct_pred[3];
|
|
91
|
36
|
92 int quantizer_scale; /* remove */
|
|
93 int current_field; /* remove */
|
49
|
94 int v_offset; /* remove */
|
36
|
95
|
|
96
|
|
97 /* now non-slice-specific information */
|
|
98
|
|
99 /* sequence header stuff */
|
|
100 uint8_t intra_quantizer_matrix [64];
|
|
101 uint8_t non_intra_quantizer_matrix [64];
|
|
102
|
|
103 /* The width and height of the picture snapped to macroblock units */
|
|
104 int coded_picture_width;
|
|
105 int coded_picture_height;
|
|
106
|
|
107 /* picture header stuff */
|
|
108
|
|
109 /* what type of picture this is (I, P, B, D) */
|
|
110 int picture_coding_type;
|
|
111
|
|
112 /* picture coding extension stuff */
|
|
113
|
|
114 /* quantization factor for intra dc coefficients */
|
|
115 int intra_dc_precision;
|
|
116 /* top/bottom/both fields */
|
|
117 int picture_structure;
|
|
118 /* bool to indicate all predictions are frame based */
|
|
119 int frame_pred_frame_dct;
|
|
120 /* bool to indicate whether intra blocks have motion vectors */
|
|
121 /* (for concealment) */
|
|
122 int concealment_motion_vectors;
|
|
123 /* bit to indicate which quantization table to use */
|
|
124 int q_scale_type;
|
|
125 /* bool to use different vlc tables */
|
|
126 int intra_vlc_format;
|
|
127 /* used for DMV MC */
|
|
128 int top_field_first;
|
|
129
|
|
130 /* stuff derived from bitstream */
|
|
131
|
|
132 /* pointer to the zigzag scan we're supposed to be using */
|
|
133 uint8_t * scan;
|
|
134
|
|
135 struct vo_frame_s * current_frame;
|
|
136 struct vo_frame_s * forward_reference_frame;
|
|
137 struct vo_frame_s * backward_reference_frame;
|
5468
|
138 struct vo_frame_s * temp_frame; // B frame
|
36
|
139
|
|
140 int second_field;
|
|
141
|
|
142 int mpeg1;
|
|
143
|
|
144 /* these things are not needed by the decoder */
|
|
145 /* this is a temporary interface, we will build a better one later. */
|
|
146 int aspect_ratio_information;
|
|
147 int frame_rate_code;
|
|
148 int progressive_sequence;
|
|
149 int repeat_first_field;
|
|
150 int progressive_frame;
|
|
151 int bitrate;
|
|
152
|
|
153 // added by A'rpi/ESP-team
|
|
154 int display_picture_width;
|
|
155 int display_picture_height;
|
|
156 int pp_options;
|
2196
|
157 int display_time;
|
79
|
158
|
|
159 struct vo_frame_s * display_frame;
|
|
160 int slice;
|
|
161
|
36
|
162 } picture_t;
|
1
|
163
|
|
164 typedef struct mpeg2_config_s {
|
36
|
165 /* Bit flags that enable various things */
|
1
|
166 uint32_t flags;
|
|
167 } mpeg2_config_t;
|
|
168
|
36
|
169 /* The only global variable, */
|
|
170 /* the config struct */
|
1
|
171 extern mpeg2_config_t config;
|
|
172
|
|
173
|
|
174
|
36
|
175 /* slice.c */
|
1
|
176 void header_state_init (picture_t * picture);
|
|
177 int header_process_picture_header (picture_t * picture, uint8_t * buffer);
|
|
178 int header_process_sequence_header (picture_t * picture, uint8_t * buffer);
|
|
179 int header_process_extension (picture_t * picture, uint8_t * buffer);
|
|
180
|
36
|
181 /* idct.c */
|
1
|
182 void idct_init (void);
|
|
183
|
36
|
184 /* idct_mlib.c */
|
1
|
185 void idct_block_copy_mlib (int16_t * block, uint8_t * dest, int stride);
|
|
186 void idct_block_add_mlib (int16_t * block, uint8_t * dest, int stride);
|
|
187
|
36
|
188 /* idct_mmx.c */
|
1
|
189 void idct_block_copy_mmxext (int16_t *block, uint8_t * dest, int stride);
|
|
190 void idct_block_add_mmxext (int16_t *block, uint8_t * dest, int stride);
|
|
191 void idct_block_copy_mmx (int16_t *block, uint8_t * dest, int stride);
|
|
192 void idct_block_add_mmx (int16_t *block, uint8_t * dest, int stride);
|
|
193 void idct_mmx_init (void);
|
|
194
|
36
|
195 /* motion_comp.c */
|
1
|
196 void motion_comp_init (void);
|
|
197
|
|
198 typedef struct mc_functions_s
|
|
199 {
|
|
200 void (* put [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t);
|
|
201 void (* avg [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t);
|
|
202 } mc_functions_t;
|
|
203
|
|
204 #define MOTION_COMP_EXTERN(x) mc_functions_t mc_functions_##x = \
|
|
205 { \
|
|
206 {MC_put_16_##x, MC_put_x16_##x, MC_put_y16_##x, MC_put_xy16_##x, \
|
|
207 MC_put_8_##x, MC_put_x8_##x, MC_put_y8_##x, MC_put_xy8_##x}, \
|
|
208 {MC_avg_16_##x, MC_avg_x16_##x, MC_avg_y16_##x, MC_avg_xy16_##x, \
|
|
209 MC_avg_8_##x, MC_avg_x8_##x, MC_avg_y8_##x, MC_avg_xy8_##x} \
|
|
210 };
|
|
211
|
|
212 extern mc_functions_t mc_functions_c;
|
|
213 extern mc_functions_t mc_functions_mmx;
|
|
214 extern mc_functions_t mc_functions_mmxext;
|
|
215 extern mc_functions_t mc_functions_3dnow;
|
|
216 extern mc_functions_t mc_functions_mlib;
|
|
217
|
36
|
218 /* slice.c */
|
1
|
219 int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
|
|
220
|
36
|
221 /* stats.c */
|
1
|
222 void stats_header (uint8_t code, uint8_t * buffer);
|
41
|
223
|
1291
|
224 void mpeg2_allocate_image_buffers(picture_t * picture);
|
2050
|
225 void mpeg2_free_image_buffers (picture_t * picture);
|
1291
|
226
|
|
227
|