Parent Directory | Revision Log
Revision 1.26 - (view) (download)
1 : | edgomez | 1.10 | /***************************************************************************** |
2 : | Isibaar | 1.1 | * |
3 : | edgomez | 1.10 | * XVID MPEG-4 VIDEO CODEC |
4 : | * - Encoder header - | ||
5 : | Isibaar | 1.1 | * |
6 : | edgomez | 1.23 | * Copyright(C) 2002 Michael Militzer <isibaar@xvid.org> |
7 : | edgomez | 1.19 | * |
8 : | edgomez | 1.24 | * This file is part of XviD, a free MPEG-4 video encoder/decoder |
9 : | * | ||
10 : | * 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 | 1.10 | * (at your option) any later version. |
14 : | Isibaar | 1.1 | * |
15 : | edgomez | 1.10 | * This program is distributed in the hope that it will be useful, |
16 : | edgomez | 1.24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 : | edgomez | 1.10 | * 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 | 1.24 | * along with this program; if not, write to the Free Software |
22 : | edgomez | 1.10 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 : | * | ||
24 : | edgomez | 1.24 | * Under section 8 of the GNU General Public License, the copyright |
25 : | * holders of XVID explicitly forbid distribution in the following | ||
26 : | * countries: | ||
27 : | * | ||
28 : | * - 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 : | suxen_drol | 1.26 | * $Id: encoder.h,v 1.25 2002/11/26 23:44:10 edgomez Exp $ |
54 : | edgomez | 1.21 | * |
55 : | edgomez | 1.10 | ****************************************************************************/ |
56 : | Isibaar | 1.1 | |
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 | 1.8 | #include "utils/ratecontrol.h" |
65 : | Isibaar | 1.1 | |
66 : | edgomez | 1.10 | /***************************************************************************** |
67 : | * Constants | ||
68 : | ****************************************************************************/ | ||
69 : | |||
70 : | /* Quatization type */ | ||
71 : | Isibaar | 1.1 | #define H263_QUANT 0 |
72 : | #define MPEG4_QUANT 1 | ||
73 : | |||
74 : | edgomez | 1.10 | /* Indicates no quantizer changes in INTRA_Q/INTER_Q modes */ |
75 : | #define NO_CHANGE 64 | ||
76 : | Isibaar | 1.1 | |
77 : | edgomez | 1.10 | /***************************************************************************** |
78 : | * Types | ||
79 : | ****************************************************************************/ | ||
80 : | Isibaar | 1.1 | |
81 : | edgomez | 1.10 | typedef int bool; |
82 : | Isibaar | 1.1 | |
83 : | typedef enum | ||
84 : | { | ||
85 : | edgomez | 1.8 | I_VOP = 0, |
86 : | P_VOP = 1, | ||
87 : | suxen_drol | 1.5 | B_VOP = 2 |
88 : | Isibaar | 1.1 | } |
89 : | VOP_TYPE; | ||
90 : | |||
91 : | edgomez | 1.10 | /***************************************************************************** |
92 : | * Structures | ||
93 : | ****************************************************************************/ | ||
94 : | Isibaar | 1.1 | |
95 : | typedef struct | ||
96 : | { | ||
97 : | edgomez | 1.8 | uint32_t width; |
98 : | uint32_t height; | ||
99 : | Isibaar | 1.1 | |
100 : | uint32_t edged_width; | ||
101 : | uint32_t edged_height; | ||
102 : | uint32_t mb_width; | ||
103 : | uint32_t mb_height; | ||
104 : | |||
105 : | suxen_drol | 1.6 | /* frame rate increment & base */ |
106 : | uint32_t fincr; | ||
107 : | uint32_t fbase; | ||
108 : | |||
109 : | edgomez | 1.8 | /* rounding type; alternate 0-1 after each interframe */ |
110 : | Isibaar | 1.1 | /* 1 <= fixed_code <= 4 |
111 : | automatically adjusted using motion vector statistics inside | ||
112 : | edgomez | 1.9 | */ |
113 : | Isibaar | 1.1 | |
114 : | suxen_drol | 1.5 | /* vars that not "quite" frame independant */ |
115 : | uint32_t m_quant_type; | ||
116 : | uint32_t m_rounding_type; | ||
117 : | uint32_t m_fcode; | ||
118 : | |||
119 : | edgomez | 1.9 | HINTINFO *hint; |
120 : | suxen_drol | 1.5 | |
121 : | suxen_drol | 1.6 | uint32_t m_seconds; |
122 : | uint32_t m_ticks; | ||
123 : | |||
124 : | edgomez | 1.9 | } |
125 : | MBParam; | ||
126 : | suxen_drol | 1.5 | |
127 : | |||
128 : | typedef struct | ||
129 : | { | ||
130 : | edgomez | 1.8 | uint32_t quant; |
131 : | edgomez | 1.9 | uint32_t motion_flags; |
132 : | Isibaar | 1.1 | uint32_t global_flags; |
133 : | h | 1.3 | |
134 : | suxen_drol | 1.5 | VOP_TYPE coding_type; |
135 : | edgomez | 1.8 | uint32_t rounding_type; |
136 : | uint32_t fcode; | ||
137 : | suxen_drol | 1.5 | uint32_t bcode; |
138 : | |||
139 : | suxen_drol | 1.6 | uint32_t seconds; |
140 : | uint32_t ticks; | ||
141 : | suxen_drol | 1.5 | |
142 : | IMAGE image; | ||
143 : | |||
144 : | edgomez | 1.9 | MACROBLOCK *mbs; |
145 : | suxen_drol | 1.5 | |
146 : | edgomez | 1.9 | } |
147 : | FRAMEINFO; | ||
148 : | Isibaar | 1.1 | |
149 : | typedef struct | ||
150 : | { | ||
151 : | edgomez | 1.8 | int iTextBits; |
152 : | float fMvPrevSigma; | ||
153 : | int iMvSum; | ||
154 : | int iMvCount; | ||
155 : | Isibaar | 1.1 | int kblks; |
156 : | int mblks; | ||
157 : | int ublks; | ||
158 : | } | ||
159 : | Statistics; | ||
160 : | |||
161 : | |||
162 : | |||
163 : | typedef struct | ||
164 : | { | ||
165 : | edgomez | 1.8 | MBParam mbParam; |
166 : | Isibaar | 1.1 | |
167 : | edgomez | 1.8 | int iFrameNum; |
168 : | int iMaxKeyInterval; | ||
169 : | Isibaar | 1.1 | int bitrate; |
170 : | |||
171 : | edgomez | 1.25 | /* images */ |
172 : | Isibaar | 1.1 | |
173 : | edgomez | 1.9 | FRAMEINFO *current; |
174 : | FRAMEINFO *reference; | ||
175 : | suxen_drol | 1.5 | |
176 : | suxen_drol | 1.11 | #ifdef _DEBUG_PSNR |
177 : | Isibaar | 1.4 | IMAGE sOriginal; |
178 : | #endif | ||
179 : | edgomez | 1.8 | IMAGE vInterH; |
180 : | IMAGE vInterV; | ||
181 : | IMAGE vInterHV; | ||
182 : | suxen_drol | 1.11 | |
183 : | edgomez | 1.8 | Statistics sStat; |
184 : | RateControl rate_control; | ||
185 : | Isibaar | 1.1 | } |
186 : | Encoder; | ||
187 : | |||
188 : | edgomez | 1.10 | /***************************************************************************** |
189 : | * Inline functions | ||
190 : | ****************************************************************************/ | ||
191 : | edgomez | 1.9 | |
192 : | static __inline uint8_t | ||
193 : | get_fcode(uint16_t sr) | ||
194 : | Isibaar | 1.1 | { |
195 : | edgomez | 1.8 | if (sr <= 16) |
196 : | Isibaar | 1.1 | return 1; |
197 : | |||
198 : | edgomez | 1.9 | else if (sr <= 32) |
199 : | Isibaar | 1.1 | return 2; |
200 : | |||
201 : | edgomez | 1.8 | else if (sr <= 64) |
202 : | Isibaar | 1.1 | return 3; |
203 : | |||
204 : | edgomez | 1.8 | else if (sr <= 128) |
205 : | Isibaar | 1.1 | return 4; |
206 : | |||
207 : | edgomez | 1.8 | else if (sr <= 256) |
208 : | Isibaar | 1.1 | return 5; |
209 : | |||
210 : | edgomez | 1.8 | else if (sr <= 512) |
211 : | Isibaar | 1.1 | return 6; |
212 : | |||
213 : | edgomez | 1.8 | else if (sr <= 1024) |
214 : | Isibaar | 1.1 | return 7; |
215 : | |||
216 : | edgomez | 1.8 | else |
217 : | Isibaar | 1.1 | return 0; |
218 : | } | ||
219 : | |||
220 : | edgomez | 1.10 | |
221 : | /***************************************************************************** | ||
222 : | * Prototypes | ||
223 : | ****************************************************************************/ | ||
224 : | |||
225 : | void init_encoder(uint32_t cpu_flags); | ||
226 : | |||
227 : | int encoder_create(XVID_ENC_PARAM * pParam); | ||
228 : | int encoder_destroy(Encoder * pEnc); | ||
229 : | int encoder_encode(Encoder * pEnc, | ||
230 : | suxen_drol | 1.11 | XVID_ENC_FRAME * pFrame, |
231 : | XVID_ENC_STATS * pResult); | ||
232 : | |||
233 : | int encoder_encode_bframes(Encoder * pEnc, | ||
234 : | edgomez | 1.10 | XVID_ENC_FRAME * pFrame, |
235 : | XVID_ENC_STATS * pResult); | ||
236 : | |||
237 : | #endif |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |