comparison libmpeg2/mpeg2_internal.h @ 36:846535ace7a2

libmpeg2-0.2.0 merge
author arpi_esp
date Sun, 04 Mar 2001 21:01:54 +0000
parents 3b5f5d1c5041
children 0d76b2b962ad
comparison
equal deleted inserted replaced
35:25f148e9890a 36:846535ace7a2
1 #include <inttypes.h>
2 /* 1 /*
3 * mpeg2_internal.h 2 * mpeg2_internal.h
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> 3 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5 * 4 *
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * 6 *
8 * mpeg2dec is free software; you can redistribute it and/or modify 7 * mpeg2dec is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
18 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 20 */
22 21
23 // hack mode - temporary 22 /* macroblock modes */
24 // 0 = decode B pictures in a small slice buffer, display slice per slice
25 // 1 = decode in a frame buffer, display slice per slice
26 // 2 = decode in a frame buffer, display whole frames
27 #define HACK_MODE 0
28
29 // macroblock modes
30 #define MACROBLOCK_INTRA 1 23 #define MACROBLOCK_INTRA 1
31 #define MACROBLOCK_PATTERN 2 24 #define MACROBLOCK_PATTERN 2
32 #define MACROBLOCK_MOTION_BACKWARD 4 25 #define MACROBLOCK_MOTION_BACKWARD 4
33 #define MACROBLOCK_MOTION_FORWARD 8 26 #define MACROBLOCK_MOTION_FORWARD 8
34 #define MACROBLOCK_QUANT 16 27 #define MACROBLOCK_QUANT 16
35 #define DCT_TYPE_INTERLACED 32 28 #define DCT_TYPE_INTERLACED 32
36 // motion_type 29 /* motion_type */
37 #define MOTION_TYPE_MASK (3*64) 30 #define MOTION_TYPE_MASK (3*64)
38 #define MOTION_TYPE_BASE 64 31 #define MOTION_TYPE_BASE 64
39 #define MC_FIELD (1*64) 32 #define MC_FIELD (1*64)
40 #define MC_FRAME (2*64) 33 #define MC_FRAME (2*64)
41 #define MC_16X8 (2*64) 34 #define MC_16X8 (2*64)
42 #define MC_DMV (3*64) 35 #define MC_DMV (3*64)
43 36
44 //picture structure 37 /* picture structure */
45 #define TOP_FIELD 1 38 #define TOP_FIELD 1
46 #define BOTTOM_FIELD 2 39 #define BOTTOM_FIELD 2
47 #define FRAME_PICTURE 3 40 #define FRAME_PICTURE 3
48 41
49 //picture coding type 42 /* picture coding type */
50 #define I_TYPE 1 43 #define I_TYPE 1
51 #define P_TYPE 2 44 #define P_TYPE 2
52 #define B_TYPE 3 45 #define B_TYPE 3
53 #define D_TYPE 4 46 #define D_TYPE 4
54
55 //The picture struct contains all of the top level state
56 //information (ie everything except slice and macroblock
57 //state)
58 typedef struct picture_s {
59 //-- sequence header stuff --
60 uint8_t intra_quantizer_matrix [64];
61 uint8_t non_intra_quantizer_matrix [64];
62
63 //The width and height of the picture snapped to macroblock units
64 int coded_picture_width;
65 int coded_picture_height;
66
67 //-- picture header stuff --
68
69 //what type of picture this is (I,P,or B) D from MPEG-1 isn't supported
70 int picture_coding_type;
71
72 //-- picture coding extension stuff --
73
74 //quantization factor for motion vectors
75 int f_code[2][2];
76 //quantization factor for intra dc coefficients
77 int intra_dc_precision;
78 //top/bottom/both fields
79 int picture_structure;
80 //bool to indicate all predictions are frame based
81 int frame_pred_frame_dct;
82 //bool to indicate whether intra blocks have motion vectors
83 // (for concealment)
84 int concealment_motion_vectors;
85 //bit to indicate which quantization table to use
86 int q_scale_type;
87 //bool to use different vlc tables
88 int intra_vlc_format;
89
90 //last macroblock in the picture
91 int last_mba;
92 //width of picture in macroblocks
93 int mb_width;
94
95 //stuff derived from bitstream
96
97 //pointer to the zigzag scan we're supposed to be using
98 uint8_t * scan;
99
100 //Pointer to the current planar frame buffer (Y,Cr,CB)
101 uint8_t * current_frame[3];
102 //storage for reference frames plus a b-frame
103 uint8_t * forward_reference_frame[3];
104 uint8_t * backward_reference_frame[3];
105 uint8_t * throwaway_frame[3];
106 uint8_t * pp_frame[3]; // postprocess
107 //uint8_t * throwaway_frame;
108
109 int pp_options; // postprocess
110
111 int second_field;
112
113 // MPEG1 - testing
114 uint8_t mpeg1;
115
116 //these things are not needed by the decoder
117 //NOTICE : this is a temporary interface, we will build a better one later.
118 int aspect_ratio_information;
119 int frame_rate_code;
120 int progressive_sequence;
121 int top_field_first; // this one is actually used for DMV MC
122 int repeat_first_field;
123 int progressive_frame;
124 // added by A'rpi/ESP-team:
125 int repeat_count;
126 int bitrate;
127 int frame_rate;
128 int display_picture_width;
129 int display_picture_height;
130 } picture_t;
131 47
132 typedef struct motion_s { 48 typedef struct motion_s {
133 uint8_t * ref[2][3]; 49 uint8_t * ref[2][3];
134 int pmv[2][2]; 50 int pmv[2][2];
135 int f_code[2]; 51 int f_code[2];
136 } motion_t; 52 } motion_t;
137 53
138 // state that is carried from one macroblock to the next inside of a same slice 54 typedef struct vo_frame_s {
139 typedef struct slice_s { 55 uint8_t * base[3]; /* pointer to 3 planes */
140 // bit parsing stuff 56 void (* copy) (struct vo_frame_s * frame, uint8_t ** src);
141 uint32_t bitstream_buf; // current 32 bit working set of buffer 57 void* vo;
142 int bitstream_bits; // used bits in working set 58 int slice;
143 uint8_t * bitstream_ptr; // buffer with stream data 59 // void (* field) (struct vo_frame_s * frame, int flags);
144 60 // void (* draw) (struct vo_frame_s * frame);
145 //Motion vectors 61 // vo_instance_t * instance;
146 //The f_ and b_ correspond to the forward and backward motion 62 } vo_frame_t;
147 //predictors 63
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 */
148 motion_t b_motion; 79 motion_t b_motion;
149 motion_t f_motion; 80 motion_t f_motion;
150 81
151 // predictor for DC coefficients in intra blocks 82 /* predictor for DC coefficients in intra blocks */
152 int16_t dc_dct_pred[3]; 83 int16_t dc_dct_pred[3];
153 84
154 uint16_t quantizer_scale; // remove 85 int quantizer_scale; /* remove */
155 } slice_t; 86 int current_field; /* remove */
87
88
89 /* now non-slice-specific information */
90
91 /* sequence header stuff */
92 uint8_t intra_quantizer_matrix [64];
93 uint8_t non_intra_quantizer_matrix [64];
94
95 /* The width and height of the picture snapped to macroblock units */
96 int coded_picture_width;
97 int coded_picture_height;
98
99 /* picture header stuff */
100
101 /* what type of picture this is (I, P, B, D) */
102 int picture_coding_type;
103
104 /* picture coding extension stuff */
105
106 /* quantization factor for motion vectors */
107 int f_code[2][2];
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;
132
133 int second_field;
134
135 int mpeg1;
136
137 /* these things are not needed by the decoder */
138 /* this is a temporary interface, we will build a better one later. */
139 int aspect_ratio_information;
140 int frame_rate_code;
141 int progressive_sequence;
142 int repeat_first_field;
143 int progressive_frame;
144 int bitrate;
145
146 // added by A'rpi/ESP-team
147 int display_picture_width;
148 int display_picture_height;
149 int pp_options;
150 int repeat_count;
151 } picture_t;
156 152
157 typedef struct mpeg2_config_s { 153 typedef struct mpeg2_config_s {
158 //Bit flags that enable various things 154 /* Bit flags that enable various things */
159 uint32_t flags; 155 uint32_t flags;
160 } mpeg2_config_t; 156 } mpeg2_config_t;
161 157
162 //The only global variable, 158 /* The only global variable, */
163 //the config struct 159 /* the config struct */
164 extern mpeg2_config_t config; 160 extern mpeg2_config_t config;
165 161
166 162
167 163
168 // slice.c 164 /* slice.c */
169 void header_state_init (picture_t * picture); 165 void header_state_init (picture_t * picture);
170 int header_process_picture_header (picture_t * picture, uint8_t * buffer); 166 int header_process_picture_header (picture_t * picture, uint8_t * buffer);
171 int header_process_sequence_header (picture_t * picture, uint8_t * buffer); 167 int header_process_sequence_header (picture_t * picture, uint8_t * buffer);
172 int header_process_extension (picture_t * picture, uint8_t * buffer); 168 int header_process_extension (picture_t * picture, uint8_t * buffer);
173 169
174 // idct.c 170 /* idct.c */
175 void idct_init (void); 171 void idct_init (void);
176 172
177 // idct_mlib.c 173 /* idct_mlib.c */
178 void idct_block_copy_mlib (int16_t * block, uint8_t * dest, int stride); 174 void idct_block_copy_mlib (int16_t * block, uint8_t * dest, int stride);
179 void idct_block_add_mlib (int16_t * block, uint8_t * dest, int stride); 175 void idct_block_add_mlib (int16_t * block, uint8_t * dest, int stride);
180 176
181 // idct_mmx.c 177 /* idct_mmx.c */
182 void idct_block_copy_mmxext (int16_t *block, uint8_t * dest, int stride); 178 void idct_block_copy_mmxext (int16_t *block, uint8_t * dest, int stride);
183 void idct_block_add_mmxext (int16_t *block, uint8_t * dest, int stride); 179 void idct_block_add_mmxext (int16_t *block, uint8_t * dest, int stride);
184 void idct_block_copy_mmx (int16_t *block, uint8_t * dest, int stride); 180 void idct_block_copy_mmx (int16_t *block, uint8_t * dest, int stride);
185 void idct_block_add_mmx (int16_t *block, uint8_t * dest, int stride); 181 void idct_block_add_mmx (int16_t *block, uint8_t * dest, int stride);
186 void idct_mmx_init (void); 182 void idct_mmx_init (void);
187 183
188 // motion_comp.c 184 /* motion_comp.c */
189 void motion_comp_init (void); 185 void motion_comp_init (void);
190 186
191 typedef struct mc_functions_s 187 typedef struct mc_functions_s
192 { 188 {
193 void (* put [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t); 189 void (* put [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t);
206 extern mc_functions_t mc_functions_mmx; 202 extern mc_functions_t mc_functions_mmx;
207 extern mc_functions_t mc_functions_mmxext; 203 extern mc_functions_t mc_functions_mmxext;
208 extern mc_functions_t mc_functions_3dnow; 204 extern mc_functions_t mc_functions_3dnow;
209 extern mc_functions_t mc_functions_mlib; 205 extern mc_functions_t mc_functions_mlib;
210 206
211 // slice.c 207 /* slice.c */
212 int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer); 208 int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
213 209
214 // stats.c 210 /* stats.c */
215 void stats_header (uint8_t code, uint8_t * buffer); 211 void stats_header (uint8_t code, uint8_t * buffer);
216
217 #define MBC 45
218 #define MBR 36
219 extern int quant_store[MBR+1][MBC+1]; // [Review]
220