Parent Directory | Revision Log
Revision 1.27.2.13 - (view) (download)
1 : | edgomez | 1.10 | /***************************************************************************** |
2 : | Isibaar | 1.1 | * |
3 : | edgomez | 1.10 | * XVID MPEG-4 VIDEO CODEC |
4 : | edgomez | 1.27.2.10 | * - Encoder related header - |
5 : | Isibaar | 1.1 | * |
6 : | edgomez | 1.27.2.10 | * Copyright(C) 2002-2003 Michael Militzer <isibaar@xvid.org> |
7 : | * 2002-2003 Peter Ross <pross@xvid.org> | ||
8 : | edgomez | 1.27 | * |
9 : | * This program 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 : | edgomez | 1.10 | * (at your option) any later version. |
13 : | Isibaar | 1.1 | * |
14 : | edgomez | 1.10 | * This program is distributed in the hope that it will be useful, |
15 : | edgomez | 1.27 | * but WITHOUT ANY WARRANTY ; without even the implied warranty of |
16 : | edgomez | 1.10 | * 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 : | edgomez | 1.27 | * along with this program ; if not, write to the Free Software |
21 : | edgomez | 1.10 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 : | * | ||
23 : | chl | 1.27.2.13 | * $Id: encoder.h,v 1.27.2.12 2003/08/02 15:08:24 edgomez Exp $ |
24 : | edgomez | 1.21 | * |
25 : | edgomez | 1.10 | ****************************************************************************/ |
26 : | Isibaar | 1.1 | |
27 : | #ifndef _ENCODER_H_ | ||
28 : | #define _ENCODER_H_ | ||
29 : | |||
30 : | #include "xvid.h" | ||
31 : | #include "portab.h" | ||
32 : | #include "global.h" | ||
33 : | |||
34 : | edgomez | 1.10 | /***************************************************************************** |
35 : | * Constants | ||
36 : | ****************************************************************************/ | ||
37 : | |||
38 : | /***************************************************************************** | ||
39 : | * Types | ||
40 : | ****************************************************************************/ | ||
41 : | Isibaar | 1.1 | |
42 : | edgomez | 1.10 | typedef int bool; |
43 : | Isibaar | 1.1 | |
44 : | edgomez | 1.10 | /***************************************************************************** |
45 : | * Structures | ||
46 : | ****************************************************************************/ | ||
47 : | Isibaar | 1.1 | |
48 : | typedef struct | ||
49 : | { | ||
50 : | suxen_drol | 1.27.2.1 | /* --- constants --- */ |
51 : | edgomez | 1.8 | uint32_t width; |
52 : | uint32_t height; | ||
53 : | Isibaar | 1.1 | |
54 : | uint32_t edged_width; | ||
55 : | uint32_t edged_height; | ||
56 : | uint32_t mb_width; | ||
57 : | uint32_t mb_height; | ||
58 : | |||
59 : | suxen_drol | 1.27.2.3 | int plugin_flags; |
60 : | |||
61 : | suxen_drol | 1.6 | /* frame rate increment & base */ |
62 : | chl | 1.27.2.13 | int32_t fincr; |
63 : | suxen_drol | 1.6 | uint32_t fbase; |
64 : | |||
65 : | suxen_drol | 1.27.2.7 | int profile; |
66 : | |||
67 : | edgomez | 1.27.2.12 | int global_flags; |
68 : | edgomez | 1.27 | int bquant_ratio; |
69 : | int bquant_offset; | ||
70 : | int frame_drop_ratio; | ||
71 : | |||
72 : | suxen_drol | 1.27.2.7 | int min_quant[3]; |
73 : | int max_quant[3]; | ||
74 : | |||
75 : | suxen_drol | 1.27.2.1 | #ifdef _SMP |
76 : | int num_threads; | ||
77 : | #endif | ||
78 : | |||
79 : | |||
80 : | edgomez | 1.27 | int iMaxKeyInterval; |
81 : | int max_bframes; | ||
82 : | |||
83 : | suxen_drol | 1.27.2.1 | /* --- inbetween vop stuff --- */ |
84 : | edgomez | 1.8 | /* rounding type; alternate 0-1 after each interframe */ |
85 : | Isibaar | 1.1 | /* 1 <= fixed_code <= 4 |
86 : | automatically adjusted using motion vector statistics inside | ||
87 : | edgomez | 1.9 | */ |
88 : | Isibaar | 1.1 | |
89 : | suxen_drol | 1.5 | /* vars that not "quite" frame independant */ |
90 : | uint32_t m_rounding_type; | ||
91 : | uint32_t m_fcode; | ||
92 : | edgomez | 1.27.2.12 | int vol_flags; |
93 : | suxen_drol | 1.5 | |
94 : | edgomez | 1.27 | int64_t m_stamp; |
95 : | } | ||
96 : | MBParam; | ||
97 : | |||
98 : | suxen_drol | 1.6 | |
99 : | edgomez | 1.27 | typedef struct |
100 : | { | ||
101 : | int iTextBits; | ||
102 : | int iMvSum; | ||
103 : | int iMvCount; | ||
104 : | int kblks; | ||
105 : | int mblks; | ||
106 : | int ublks; | ||
107 : | int gblks; | ||
108 : | edgomez | 1.9 | } |
109 : | edgomez | 1.27 | Statistics; |
110 : | suxen_drol | 1.5 | |
111 : | |||
112 : | suxen_drol | 1.27.2.1 | /* encoding queue */ |
113 : | suxen_drol | 1.5 | typedef struct |
114 : | { | ||
115 : | suxen_drol | 1.27.2.1 | xvid_enc_frame_t frame; |
116 : | unsigned char quant_intra_matrix[64]; | ||
117 : | unsigned char quant_inter_matrix[64]; | ||
118 : | IMAGE image; | ||
119 : | } QUEUEINFO; | ||
120 : | h | 1.3 | |
121 : | suxen_drol | 1.27.2.1 | |
122 : | typedef struct | ||
123 : | { | ||
124 : | suxen_drol | 1.27.2.3 | int frame_num; |
125 : | suxen_drol | 1.27.2.4 | int fincr; |
126 : | edgomez | 1.27.2.12 | int vol_flags; |
127 : | int vop_flags; | ||
128 : | int motion_flags; | ||
129 : | suxen_drol | 1.27.2.1 | |
130 : | int coding_type; | ||
131 : | uint32_t quant; | ||
132 : | edgomez | 1.8 | uint32_t rounding_type; |
133 : | uint32_t fcode; | ||
134 : | suxen_drol | 1.5 | uint32_t bcode; |
135 : | |||
136 : | suxen_drol | 1.6 | uint32_t seconds; |
137 : | uint32_t ticks; | ||
138 : | edgomez | 1.27 | int64_t stamp; |
139 : | suxen_drol | 1.5 | |
140 : | IMAGE image; | ||
141 : | |||
142 : | edgomez | 1.9 | MACROBLOCK *mbs; |
143 : | suxen_drol | 1.5 | |
144 : | edgomez | 1.27.2.9 | WARPPOINTS warp; /* as in bitstream */ |
145 : | GMC_DATA gmc_data; /* common data for all MBs */ | ||
146 : | chl | 1.27.2.11 | NEW_GMC_DATA new_gmc_data; /* common data for all MBs */ |
147 : | suxen_drol | 1.27.2.1 | |
148 : | int length; /* the encoded size of this frame */ | ||
149 : | edgomez | 1.27 | |
150 : | Statistics sStat; | ||
151 : | edgomez | 1.9 | } |
152 : | FRAMEINFO; | ||
153 : | Isibaar | 1.1 | |
154 : | |||
155 : | typedef struct | ||
156 : | { | ||
157 : | edgomez | 1.8 | MBParam mbParam; |
158 : | Isibaar | 1.1 | |
159 : | edgomez | 1.8 | int iFrameNum; |
160 : | Isibaar | 1.1 | int bitrate; |
161 : | suxen_drol | 1.27.2.7 | |
162 : | edgomez | 1.27.2.9 | /* zones */ |
163 : | suxen_drol | 1.27.2.7 | unsigned int num_zones; |
164 : | xvid_enc_zone_t * zones; | ||
165 : | suxen_drol | 1.27.2.2 | |
166 : | edgomez | 1.27.2.9 | /* plugins */ |
167 : | chl | 1.27.2.13 | int num_plugins; /* note: we store plugin flags in MBPARAM */ |
168 : | suxen_drol | 1.27.2.2 | xvid_enc_plugin_t * plugins; |
169 : | |||
170 : | edgomez | 1.27.2.9 | /* dquant */ |
171 : | suxen_drol | 1.27.2.2 | |
172 : | int * temp_dquants; | ||
173 : | Isibaar | 1.1 | |
174 : | edgomez | 1.27.2.9 | /* images */ |
175 : | Isibaar | 1.1 | |
176 : | edgomez | 1.9 | FRAMEINFO *current; |
177 : | FRAMEINFO *reference; | ||
178 : | suxen_drol | 1.5 | |
179 : | suxen_drol | 1.27.2.3 | IMAGE sOriginal; /* original image copy for i/p frames */ |
180 : | IMAGE sOriginal2; /* original image copy for b-frames */ | ||
181 : | edgomez | 1.8 | IMAGE vInterH; |
182 : | IMAGE vInterV; | ||
183 : | edgomez | 1.27 | IMAGE vInterVf; |
184 : | edgomez | 1.8 | IMAGE vInterHV; |
185 : | edgomez | 1.27 | IMAGE vInterHVf; |
186 : | |||
187 : | IMAGE vGMC; | ||
188 : | |||
189 : | /* image queue */ | ||
190 : | int queue_head; | ||
191 : | int queue_tail; | ||
192 : | int queue_size; | ||
193 : | suxen_drol | 1.27.2.1 | QUEUEINFO *queue; |
194 : | edgomez | 1.27 | |
195 : | /* bframe buffer */ | ||
196 : | int bframenum_head; | ||
197 : | int bframenum_tail; | ||
198 : | int flush_bframes; | ||
199 : | |||
200 : | FRAMEINFO **bframes; | ||
201 : | IMAGE f_refh; | ||
202 : | IMAGE f_refv; | ||
203 : | IMAGE f_refhv; | ||
204 : | suxen_drol | 1.27.2.1 | |
205 : | /* closed_gop fixup temporary storage */ | ||
206 : | int closed_bframenum; /* == -1 if there is no fixup intended */ | ||
207 : | QUEUEINFO closed_qframe; /* qFrame, only valid when >= 0 */ | ||
208 : | edgomez | 1.27 | |
209 : | int m_framenum; /* debug frame num counter; unlike iFrameNum, does not reset at ivop */ | ||
210 : | |||
211 : | float fMvPrevSigma; | ||
212 : | Isibaar | 1.1 | } |
213 : | Encoder; | ||
214 : | |||
215 : | edgomez | 1.10 | /***************************************************************************** |
216 : | * Inline functions | ||
217 : | ****************************************************************************/ | ||
218 : | edgomez | 1.9 | |
219 : | static __inline uint8_t | ||
220 : | get_fcode(uint16_t sr) | ||
221 : | Isibaar | 1.1 | { |
222 : | edgomez | 1.8 | if (sr <= 16) |
223 : | Isibaar | 1.1 | return 1; |
224 : | |||
225 : | edgomez | 1.9 | else if (sr <= 32) |
226 : | Isibaar | 1.1 | return 2; |
227 : | |||
228 : | edgomez | 1.8 | else if (sr <= 64) |
229 : | Isibaar | 1.1 | return 3; |
230 : | |||
231 : | edgomez | 1.8 | else if (sr <= 128) |
232 : | Isibaar | 1.1 | return 4; |
233 : | |||
234 : | edgomez | 1.8 | else if (sr <= 256) |
235 : | Isibaar | 1.1 | return 5; |
236 : | |||
237 : | edgomez | 1.8 | else if (sr <= 512) |
238 : | Isibaar | 1.1 | return 6; |
239 : | |||
240 : | edgomez | 1.8 | else if (sr <= 1024) |
241 : | Isibaar | 1.1 | return 7; |
242 : | |||
243 : | edgomez | 1.8 | else |
244 : | Isibaar | 1.1 | return 0; |
245 : | } | ||
246 : | |||
247 : | edgomez | 1.10 | |
248 : | /***************************************************************************** | ||
249 : | * Prototypes | ||
250 : | ****************************************************************************/ | ||
251 : | |||
252 : | void init_encoder(uint32_t cpu_flags); | ||
253 : | |||
254 : | suxen_drol | 1.27.2.6 | int enc_create(xvid_enc_create_t * create); |
255 : | suxen_drol | 1.27.2.1 | int enc_destroy(Encoder * pEnc); |
256 : | int enc_encode(Encoder * pEnc, | ||
257 : | xvid_enc_frame_t * pFrame, | ||
258 : | xvid_enc_stats_t * stats); | ||
259 : | edgomez | 1.10 | |
260 : | #endif |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |