Parent Directory | Revision Log
Revision 648 - (view) (download)
1 : | edgomez | 202 | /***************************************************************************** |
2 : | Isibaar | 3 | * |
3 : | edgomez | 202 | * XVID MPEG-4 VIDEO CODEC |
4 : | * - Encoder header - | ||
5 : | Isibaar | 3 | * |
6 : | edgomez | 603 | * Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
7 : | edgomez | 399 | * |
8 : | edgomez | 648 | * This file is part of XviD, a free MPEG-4 video encoder/decoder |
9 : | Isibaar | 3 | * |
10 : | edgomez | 648 | * XviD is free software; you can redistribute it and/or modify it |
11 : | * under the terms of the GNU General Public License as published by | ||
12 : | * the Free Software Foundation; either version 2 of the License, or | ||
13 : | edgomez | 202 | * (at your option) any later version. |
14 : | Isibaar | 3 | * |
15 : | edgomez | 202 | * This program is distributed in the hope that it will be useful, |
16 : | edgomez | 648 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 : | edgomez | 202 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 : | * GNU General Public License for more details. | ||
19 : | * | ||
20 : | * You should have received a copy of the GNU General Public License | ||
21 : | edgomez | 648 | * along with this program; if not, write to the Free Software |
22 : | edgomez | 202 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 : | * | ||
24 : | edgomez | 648 | * Under section 8 of the GNU General Public License, the copyright |
25 : | * holders of XVID explicitly forbid distribution in the following | ||
26 : | * countries: | ||
27 : | edgomez | 404 | * |
28 : | edgomez | 648 | * - Japan |
29 : | * - United States of America | ||
30 : | * | ||
31 : | * Linking XviD statically or dynamically with other modules is making a | ||
32 : | * combined work based on XviD. Thus, the terms and conditions of the | ||
33 : | * GNU General Public License cover the whole combination. | ||
34 : | * | ||
35 : | * As a special exception, the copyright holders of XviD give you | ||
36 : | * permission to link XviD with independent modules that communicate with | ||
37 : | * XviD solely through the VFW1.1 and DShow interfaces, regardless of the | ||
38 : | * license terms of these independent modules, and to copy and distribute | ||
39 : | * the resulting combined work under terms of your choice, provided that | ||
40 : | * every copy of the combined work is accompanied by a complete copy of | ||
41 : | * the source code of XviD (the version of XviD used to produce the | ||
42 : | * combined work), being distributed under the terms of the GNU General | ||
43 : | * Public License plus this exception. An independent module is a module | ||
44 : | * which is not derived from or based on XviD. | ||
45 : | * | ||
46 : | * Note that people who make modified versions of XviD are not obligated | ||
47 : | * to grant this special exception for their modified versions; it is | ||
48 : | * their choice whether to do so. The GNU General Public License gives | ||
49 : | * permission to release a modified version without this exception; this | ||
50 : | * exception also makes it possible to release a modified version which | ||
51 : | * carries forward this exception. | ||
52 : | * | ||
53 : | * $Id: encoder.h,v 1.24 2002-11-16 23:38:16 edgomez Exp $ | ||
54 : | * | ||
55 : | edgomez | 202 | ****************************************************************************/ |
56 : | Isibaar | 3 | |
57 : | #ifndef _ENCODER_H_ | ||
58 : | #define _ENCODER_H_ | ||
59 : | |||
60 : | #include "xvid.h" | ||
61 : | #include "portab.h" | ||
62 : | #include "global.h" | ||
63 : | #include "image/image.h" | ||
64 : | edgomez | 188 | #include "utils/ratecontrol.h" |
65 : | Isibaar | 3 | |
66 : | edgomez | 202 | /***************************************************************************** |
67 : | * Constants | ||
68 : | ****************************************************************************/ | ||
69 : | |||
70 : | /* Quatization type */ | ||
71 : | Isibaar | 3 | #define H263_QUANT 0 |
72 : | #define MPEG4_QUANT 1 | ||
73 : | |||
74 : | edgomez | 202 | /* Indicates no quantizer changes in INTRA_Q/INTER_Q modes */ |
75 : | #define NO_CHANGE 64 | ||
76 : | Isibaar | 3 | |
77 : | edgomez | 202 | /***************************************************************************** |
78 : | * Types | ||
79 : | ****************************************************************************/ | ||
80 : | Isibaar | 3 | |
81 : | edgomez | 202 | typedef int bool; |
82 : | Isibaar | 3 | |
83 : | typedef enum | ||
84 : | { | ||
85 : | edgomez | 188 | I_VOP = 0, |
86 : | P_VOP = 1, | ||
87 : | suxen_drol | 136 | B_VOP = 2 |
88 : | Isibaar | 3 | } |
89 : | VOP_TYPE; | ||
90 : | |||
91 : | edgomez | 202 | /***************************************************************************** |
92 : | * Structures | ||
93 : | ****************************************************************************/ | ||
94 : | Isibaar | 3 | |
95 : | typedef struct | ||
96 : | { | ||
97 : | edgomez | 188 | uint32_t width; |
98 : | uint32_t height; | ||
99 : | Isibaar | 3 | |
100 : | uint32_t edged_width; | ||
101 : | uint32_t edged_height; | ||
102 : | uint32_t mb_width; | ||
103 : | uint32_t mb_height; | ||
104 : | |||
105 : | suxen_drol | 152 | /* frame rate increment & base */ |
106 : | uint32_t fincr; | ||
107 : | uint32_t fbase; | ||
108 : | |||
109 : | suxen_drol | 295 | #ifdef _SMP |
110 : | int num_threads; | ||
111 : | #endif | ||
112 : | |||
113 : | edgomez | 188 | /* rounding type; alternate 0-1 after each interframe */ |
114 : | Isibaar | 3 | /* 1 <= fixed_code <= 4 |
115 : | automatically adjusted using motion vector statistics inside | ||
116 : | edgomez | 195 | */ |
117 : | Isibaar | 3 | |
118 : | suxen_drol | 136 | /* vars that not "quite" frame independant */ |
119 : | uint32_t m_quant_type; | ||
120 : | uint32_t m_rounding_type; | ||
121 : | uint32_t m_fcode; | ||
122 : | |||
123 : | edgomez | 195 | HINTINFO *hint; |
124 : | suxen_drol | 136 | |
125 : | suxen_drol | 152 | uint32_t m_seconds; |
126 : | uint32_t m_ticks; | ||
127 : | |||
128 : | edgomez | 195 | } |
129 : | MBParam; | ||
130 : | suxen_drol | 136 | |
131 : | |||
132 : | typedef struct | ||
133 : | { | ||
134 : | edgomez | 188 | uint32_t quant; |
135 : | edgomez | 195 | uint32_t motion_flags; |
136 : | Isibaar | 3 | uint32_t global_flags; |
137 : | h | 101 | |
138 : | suxen_drol | 136 | VOP_TYPE coding_type; |
139 : | edgomez | 188 | uint32_t rounding_type; |
140 : | uint32_t fcode; | ||
141 : | suxen_drol | 136 | uint32_t bcode; |
142 : | Isibaar | 3 | |
143 : | suxen_drol | 152 | uint32_t seconds; |
144 : | uint32_t ticks; | ||
145 : | suxen_drol | 136 | |
146 : | IMAGE image; | ||
147 : | |||
148 : | edgomez | 195 | MACROBLOCK *mbs; |
149 : | suxen_drol | 136 | |
150 : | edgomez | 195 | } |
151 : | FRAMEINFO; | ||
152 : | suxen_drol | 136 | |
153 : | Isibaar | 3 | typedef struct |
154 : | { | ||
155 : | edgomez | 188 | int iTextBits; |
156 : | float fMvPrevSigma; | ||
157 : | int iMvSum; | ||
158 : | int iMvCount; | ||
159 : | Isibaar | 3 | int kblks; |
160 : | int mblks; | ||
161 : | int ublks; | ||
162 : | } | ||
163 : | Statistics; | ||
164 : | |||
165 : | |||
166 : | |||
167 : | typedef struct | ||
168 : | { | ||
169 : | edgomez | 188 | MBParam mbParam; |
170 : | Isibaar | 3 | |
171 : | edgomez | 188 | int iFrameNum; |
172 : | int iMaxKeyInterval; | ||
173 : | Isibaar | 3 | int bitrate; |
174 : | |||
175 : | // images | ||
176 : | |||
177 : | edgomez | 195 | FRAMEINFO *current; |
178 : | FRAMEINFO *reference; | ||
179 : | suxen_drol | 136 | |
180 : | suxen_drol | 229 | #ifdef _DEBUG_PSNR |
181 : | Isibaar | 113 | IMAGE sOriginal; |
182 : | #endif | ||
183 : | edgomez | 188 | IMAGE vInterH; |
184 : | IMAGE vInterV; | ||
185 : | IMAGE vInterHV; | ||
186 : | Isibaar | 3 | |
187 : | edgomez | 188 | Statistics sStat; |
188 : | RateControl rate_control; | ||
189 : | Isibaar | 3 | } |
190 : | Encoder; | ||
191 : | |||
192 : | edgomez | 202 | /***************************************************************************** |
193 : | * Inline functions | ||
194 : | ****************************************************************************/ | ||
195 : | Isibaar | 3 | |
196 : | edgomez | 195 | static __inline uint8_t |
197 : | get_fcode(uint16_t sr) | ||
198 : | Isibaar | 3 | { |
199 : | edgomez | 188 | if (sr <= 16) |
200 : | Isibaar | 3 | return 1; |
201 : | |||
202 : | edgomez | 195 | else if (sr <= 32) |
203 : | Isibaar | 3 | return 2; |
204 : | |||
205 : | edgomez | 188 | else if (sr <= 64) |
206 : | Isibaar | 3 | return 3; |
207 : | |||
208 : | edgomez | 188 | else if (sr <= 128) |
209 : | Isibaar | 3 | return 4; |
210 : | |||
211 : | edgomez | 188 | else if (sr <= 256) |
212 : | Isibaar | 3 | return 5; |
213 : | |||
214 : | edgomez | 188 | else if (sr <= 512) |
215 : | Isibaar | 3 | return 6; |
216 : | |||
217 : | edgomez | 188 | else if (sr <= 1024) |
218 : | Isibaar | 3 | return 7; |
219 : | |||
220 : | edgomez | 188 | else |
221 : | Isibaar | 3 | return 0; |
222 : | } | ||
223 : | |||
224 : | edgomez | 202 | |
225 : | /***************************************************************************** | ||
226 : | * Prototypes | ||
227 : | ****************************************************************************/ | ||
228 : | |||
229 : | void init_encoder(uint32_t cpu_flags); | ||
230 : | |||
231 : | int encoder_create(XVID_ENC_PARAM * pParam); | ||
232 : | int encoder_destroy(Encoder * pEnc); | ||
233 : | int encoder_encode(Encoder * pEnc, | ||
234 : | XVID_ENC_FRAME * pFrame, | ||
235 : | XVID_ENC_STATS * pResult); | ||
236 : | |||
237 : | suxen_drol | 229 | int encoder_encode_bframes(Encoder * pEnc, |
238 : | XVID_ENC_FRAME * pFrame, | ||
239 : | XVID_ENC_STATS * pResult); | ||
240 : | |||
241 : | edgomez | 202 | #endif |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |