Parent Directory
|
Revision Log
Revision 686 -
(view)
(download)
Original Path: trunk/xvidcore/src/encoder.h
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 : | suxen_drol | 686 | * $Id: encoder.h,v 1.26 2002-11-28 07:27:37 suxen_drol Exp $ |
54 : | edgomez | 648 | * |
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 : | edgomez | 188 | /* rounding type; alternate 0-1 after each interframe */ |
110 : | Isibaar | 3 | /* 1 <= fixed_code <= 4 |
111 : | automatically adjusted using motion vector statistics inside | ||
112 : | edgomez | 195 | */ |
113 : | Isibaar | 3 | |
114 : | suxen_drol | 136 | /* 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 | 195 | HINTINFO *hint; |
120 : | suxen_drol | 136 | |
121 : | suxen_drol | 152 | uint32_t m_seconds; |
122 : | uint32_t m_ticks; | ||
123 : | |||
124 : | edgomez | 195 | } |
125 : | MBParam; | ||
126 : | suxen_drol | 136 | |
127 : | |||
128 : | typedef struct | ||
129 : | { | ||
130 : | edgomez | 188 | uint32_t quant; |
131 : | edgomez | 195 | uint32_t motion_flags; |
132 : | Isibaar | 3 | uint32_t global_flags; |
133 : | h | 101 | |
134 : | suxen_drol | 136 | VOP_TYPE coding_type; |
135 : | edgomez | 188 | uint32_t rounding_type; |
136 : | uint32_t fcode; | ||
137 : | suxen_drol | 136 | uint32_t bcode; |
138 : | Isibaar | 3 | |
139 : | suxen_drol | 152 | uint32_t seconds; |
140 : | uint32_t ticks; | ||
141 : | suxen_drol | 136 | |
142 : | IMAGE image; | ||
143 : | |||
144 : | edgomez | 195 | MACROBLOCK *mbs; |
145 : | suxen_drol | 136 | |
146 : | edgomez | 195 | } |
147 : | FRAMEINFO; | ||
148 : | suxen_drol | 136 | |
149 : | Isibaar | 3 | typedef struct |
150 : | { | ||
151 : | edgomez | 188 | int iTextBits; |
152 : | float fMvPrevSigma; | ||
153 : | int iMvSum; | ||
154 : | int iMvCount; | ||
155 : | Isibaar | 3 | int kblks; |
156 : | int mblks; | ||
157 : | int ublks; | ||
158 : | } | ||
159 : | Statistics; | ||
160 : | |||
161 : | |||
162 : | |||
163 : | typedef struct | ||
164 : | { | ||
165 : | edgomez | 188 | MBParam mbParam; |
166 : | Isibaar | 3 | |
167 : | edgomez | 188 | int iFrameNum; |
168 : | int iMaxKeyInterval; | ||
169 : | Isibaar | 3 | int bitrate; |
170 : | |||
171 : | edgomez | 677 | /* images */ |
172 : | Isibaar | 3 | |
173 : | edgomez | 195 | FRAMEINFO *current; |
174 : | FRAMEINFO *reference; | ||
175 : | suxen_drol | 136 | |
176 : | suxen_drol | 229 | #ifdef _DEBUG_PSNR |
177 : | Isibaar | 113 | IMAGE sOriginal; |
178 : | #endif | ||
179 : | edgomez | 188 | IMAGE vInterH; |
180 : | IMAGE vInterV; | ||
181 : | IMAGE vInterHV; | ||
182 : | Isibaar | 3 | |
183 : | edgomez | 188 | Statistics sStat; |
184 : | RateControl rate_control; | ||
185 : | Isibaar | 3 | } |
186 : | Encoder; | ||
187 : | |||
188 : | edgomez | 202 | /***************************************************************************** |
189 : | * Inline functions | ||
190 : | ****************************************************************************/ | ||
191 : | Isibaar | 3 | |
192 : | edgomez | 195 | static __inline uint8_t |
193 : | get_fcode(uint16_t sr) | ||
194 : | Isibaar | 3 | { |
195 : | edgomez | 188 | if (sr <= 16) |
196 : | Isibaar | 3 | return 1; |
197 : | |||
198 : | edgomez | 195 | else if (sr <= 32) |
199 : | Isibaar | 3 | return 2; |
200 : | |||
201 : | edgomez | 188 | else if (sr <= 64) |
202 : | Isibaar | 3 | return 3; |
203 : | |||
204 : | edgomez | 188 | else if (sr <= 128) |
205 : | Isibaar | 3 | return 4; |
206 : | |||
207 : | edgomez | 188 | else if (sr <= 256) |
208 : | Isibaar | 3 | return 5; |
209 : | |||
210 : | edgomez | 188 | else if (sr <= 512) |
211 : | Isibaar | 3 | return 6; |
212 : | |||
213 : | edgomez | 188 | else if (sr <= 1024) |
214 : | Isibaar | 3 | return 7; |
215 : | |||
216 : | edgomez | 188 | else |
217 : | Isibaar | 3 | return 0; |
218 : | } | ||
219 : | |||
220 : | edgomez | 202 | |
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 : | XVID_ENC_FRAME * pFrame, | ||
231 : | XVID_ENC_STATS * pResult); | ||
232 : | |||
233 : | suxen_drol | 229 | int encoder_encode_bframes(Encoder * pEnc, |
234 : | XVID_ENC_FRAME * pFrame, | ||
235 : | XVID_ENC_STATS * pResult); | ||
236 : | |||
237 : | edgomez | 202 | #endif |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |