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;
|
79
|
59 // int slice;
|
36
|
60 // void (* field) (struct vo_frame_s * frame, int flags);
|
|
61 // void (* draw) (struct vo_frame_s * frame);
|
|
62 // vo_instance_t * instance;
|
|
63 } vo_frame_t;
|
1
|
64
|
36
|
65 typedef struct picture_s {
|
|
66 /* first, state that carries information from one macroblock to the */
|
|
67 /* next inside a slice, and is never used outside of slice_process() */
|
|
68
|
|
69 /* DCT coefficients - should be kept aligned ! */
|
|
70 int16_t DCTblock[64];
|
|
71
|
|
72 /* bit parsing stuff */
|
|
73 uint32_t bitstream_buf; /* current 32 bit working set of buffer */
|
|
74 int bitstream_bits; /* used bits in working set */
|
|
75 uint8_t * bitstream_ptr; /* buffer with stream data */
|
|
76
|
|
77 /* Motion vectors */
|
|
78 /* The f_ and b_ correspond to the forward and backward motion */
|
|
79 /* predictors */
|
1
|
80 motion_t b_motion;
|
|
81 motion_t f_motion;
|
|
82
|
36
|
83 /* predictor for DC coefficients in intra blocks */
|
1
|
84 int16_t dc_dct_pred[3];
|
|
85
|
36
|
86 int quantizer_scale; /* remove */
|
|
87 int current_field; /* remove */
|
49
|
88 int v_offset; /* remove */
|
36
|
89
|
|
90
|
|
91 /* now non-slice-specific information */
|
|
92
|
|
93 /* sequence header stuff */
|
|
94 uint8_t intra_quantizer_matrix [64];
|
|
95 uint8_t non_intra_quantizer_matrix [64];
|
|
96
|
|
97 /* The width and height of the picture snapped to macroblock units */
|
|
98 int coded_picture_width;
|
|
99 int coded_picture_height;
|
|
100
|
|
101 /* picture header stuff */
|
|
102
|
|
103 /* what type of picture this is (I, P, B, D) */
|
|
104 int picture_coding_type;
|
|
105
|
|
106 /* picture coding extension stuff */
|
|
107
|
|
108 /* quantization factor for intra dc coefficients */
|
|
109 int intra_dc_precision;
|
|
110 /* top/bottom/both fields */
|
|
111 int picture_structure;
|
|
112 /* bool to indicate all predictions are frame based */
|
|
113 int frame_pred_frame_dct;
|
|
114 /* bool to indicate whether intra blocks have motion vectors */
|
|
115 /* (for concealment) */
|
|
116 int concealment_motion_vectors;
|
|
117 /* bit to indicate which quantization table to use */
|
|
118 int q_scale_type;
|
|
119 /* bool to use different vlc tables */
|
|
120 int intra_vlc_format;
|
|
121 /* used for DMV MC */
|
|
122 int top_field_first;
|
|
123
|
|
124 /* stuff derived from bitstream */
|
|
125
|
|
126 /* pointer to the zigzag scan we're supposed to be using */
|
|
127 uint8_t * scan;
|
|
128
|
|
129 struct vo_frame_s * current_frame;
|
|
130 struct vo_frame_s * forward_reference_frame;
|
|
131 struct vo_frame_s * backward_reference_frame;
|
5468
|
132 struct vo_frame_s * temp_frame; // B frame
|
36
|
133
|
|
134 int second_field;
|
|
135
|
|
136 int mpeg1;
|
|
137
|
|
138 /* these things are not needed by the decoder */
|
|
139 /* this is a temporary interface, we will build a better one later. */
|
|
140 int aspect_ratio_information;
|
|
141 int frame_rate_code;
|
|
142 int progressive_sequence;
|
|
143 int repeat_first_field;
|
|
144 int progressive_frame;
|
|
145 int bitrate;
|
|
146
|
|
147 // added by A'rpi/ESP-team
|
|
148 int display_picture_width;
|
|
149 int display_picture_height;
|
|
150 int pp_options;
|
2196
|
151 int display_time;
|
79
|
152
|
|
153 struct vo_frame_s * display_frame;
|
|
154 int slice;
|
|
155
|
36
|
156 } picture_t;
|
1
|
157
|
|
158 typedef struct mpeg2_config_s {
|
36
|
159 /* Bit flags that enable various things */
|
1
|
160 uint32_t flags;
|
|
161 } mpeg2_config_t;
|
|
162
|
36
|
163 /* The only global variable, */
|
|
164 /* the config struct */
|
1
|
165 extern mpeg2_config_t config;
|
|
166
|
|
167
|
|
168
|
36
|
169 /* slice.c */
|
1
|
170 void header_state_init (picture_t * picture);
|
|
171 int header_process_picture_header (picture_t * picture, uint8_t * buffer);
|
|
172 int header_process_sequence_header (picture_t * picture, uint8_t * buffer);
|
|
173 int header_process_extension (picture_t * picture, uint8_t * buffer);
|
|
174
|
36
|
175 /* idct.c */
|
1
|
176 void idct_init (void);
|
|
177
|
36
|
178 /* idct_mlib.c */
|
1
|
179 void idct_block_copy_mlib (int16_t * block, uint8_t * dest, int stride);
|
|
180 void idct_block_add_mlib (int16_t * block, uint8_t * dest, int stride);
|
|
181
|
36
|
182 /* idct_mmx.c */
|
1
|
183 void idct_block_copy_mmxext (int16_t *block, uint8_t * dest, int stride);
|
|
184 void idct_block_add_mmxext (int16_t *block, uint8_t * dest, int stride);
|
|
185 void idct_block_copy_mmx (int16_t *block, uint8_t * dest, int stride);
|
|
186 void idct_block_add_mmx (int16_t *block, uint8_t * dest, int stride);
|
|
187 void idct_mmx_init (void);
|
|
188
|
36
|
189 /* motion_comp.c */
|
1
|
190 void motion_comp_init (void);
|
|
191
|
|
192 typedef struct mc_functions_s
|
|
193 {
|
|
194 void (* put [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t);
|
|
195 void (* avg [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t);
|
|
196 } mc_functions_t;
|
|
197
|
|
198 #define MOTION_COMP_EXTERN(x) mc_functions_t mc_functions_##x = \
|
|
199 { \
|
|
200 {MC_put_16_##x, MC_put_x16_##x, MC_put_y16_##x, MC_put_xy16_##x, \
|
|
201 MC_put_8_##x, MC_put_x8_##x, MC_put_y8_##x, MC_put_xy8_##x}, \
|
|
202 {MC_avg_16_##x, MC_avg_x16_##x, MC_avg_y16_##x, MC_avg_xy16_##x, \
|
|
203 MC_avg_8_##x, MC_avg_x8_##x, MC_avg_y8_##x, MC_avg_xy8_##x} \
|
|
204 };
|
|
205
|
|
206 extern mc_functions_t mc_functions_c;
|
|
207 extern mc_functions_t mc_functions_mmx;
|
|
208 extern mc_functions_t mc_functions_mmxext;
|
|
209 extern mc_functions_t mc_functions_3dnow;
|
|
210 extern mc_functions_t mc_functions_mlib;
|
|
211
|
36
|
212 /* slice.c */
|
1
|
213 int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
|
|
214
|
36
|
215 /* stats.c */
|
1
|
216 void stats_header (uint8_t code, uint8_t * buffer);
|
41
|
217
|
1291
|
218 void mpeg2_allocate_image_buffers(picture_t * picture);
|
2050
|
219 void mpeg2_free_image_buffers (picture_t * picture);
|
1291
|
220
|
|
221
|
41
|
222 #ifdef MPEG12_POSTPROC
|
2722
|
223 #define MPEG2_MBC 120
|
|
224 #define MPEG2_MBR 72
|
41
|
225 #endif
|