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