[cvs] / xvidcore / src / encoder.h Repository:
ViewVC logotype

Annotation of /xvidcore/src/encoder.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.25 - (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 : edgomez 1.25 * $Id: encoder.h,v 1.24 2002/11/16 23:38:16 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 : suxen_drol 1.14
109 :     #ifdef _SMP
110 :     int num_threads;
111 :     #endif
112 : suxen_drol 1.6
113 : edgomez 1.8 /* rounding type; alternate 0-1 after each interframe */
114 : Isibaar 1.1 /* 1 <= fixed_code <= 4
115 :     automatically adjusted using motion vector statistics inside
116 : edgomez 1.9 */
117 : Isibaar 1.1
118 : suxen_drol 1.5 /* 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 1.9 HINTINFO *hint;
124 : suxen_drol 1.5
125 : suxen_drol 1.6 uint32_t m_seconds;
126 :     uint32_t m_ticks;
127 :    
128 : edgomez 1.9 }
129 :     MBParam;
130 : suxen_drol 1.5
131 :    
132 :     typedef struct
133 :     {
134 : edgomez 1.8 uint32_t quant;
135 : edgomez 1.9 uint32_t motion_flags;
136 : Isibaar 1.1 uint32_t global_flags;
137 : h 1.3
138 : suxen_drol 1.5 VOP_TYPE coding_type;
139 : edgomez 1.8 uint32_t rounding_type;
140 :     uint32_t fcode;
141 : suxen_drol 1.5 uint32_t bcode;
142 :    
143 : suxen_drol 1.6 uint32_t seconds;
144 :     uint32_t ticks;
145 : suxen_drol 1.5
146 :     IMAGE image;
147 :    
148 : edgomez 1.9 MACROBLOCK *mbs;
149 : suxen_drol 1.5
150 : edgomez 1.9 }
151 :     FRAMEINFO;
152 : Isibaar 1.1
153 :     typedef struct
154 :     {
155 : edgomez 1.8 int iTextBits;
156 :     float fMvPrevSigma;
157 :     int iMvSum;
158 :     int iMvCount;
159 : Isibaar 1.1 int kblks;
160 :     int mblks;
161 :     int ublks;
162 :     }
163 :     Statistics;
164 :    
165 :    
166 :    
167 :     typedef struct
168 :     {
169 : edgomez 1.8 MBParam mbParam;
170 : Isibaar 1.1
171 : edgomez 1.8 int iFrameNum;
172 :     int iMaxKeyInterval;
173 : Isibaar 1.1 int bitrate;
174 :    
175 : edgomez 1.25 /* images */
176 : Isibaar 1.1
177 : edgomez 1.9 FRAMEINFO *current;
178 :     FRAMEINFO *reference;
179 : suxen_drol 1.5
180 : suxen_drol 1.11 #ifdef _DEBUG_PSNR
181 : Isibaar 1.4 IMAGE sOriginal;
182 :     #endif
183 : edgomez 1.8 IMAGE vInterH;
184 :     IMAGE vInterV;
185 :     IMAGE vInterHV;
186 : suxen_drol 1.11
187 : edgomez 1.8 Statistics sStat;
188 :     RateControl rate_control;
189 : Isibaar 1.1 }
190 :     Encoder;
191 :    
192 : edgomez 1.10 /*****************************************************************************
193 :     * Inline functions
194 :     ****************************************************************************/
195 : edgomez 1.9
196 :     static __inline uint8_t
197 :     get_fcode(uint16_t sr)
198 : Isibaar 1.1 {
199 : edgomez 1.8 if (sr <= 16)
200 : Isibaar 1.1 return 1;
201 :    
202 : edgomez 1.9 else if (sr <= 32)
203 : Isibaar 1.1 return 2;
204 :    
205 : edgomez 1.8 else if (sr <= 64)
206 : Isibaar 1.1 return 3;
207 :    
208 : edgomez 1.8 else if (sr <= 128)
209 : Isibaar 1.1 return 4;
210 :    
211 : edgomez 1.8 else if (sr <= 256)
212 : Isibaar 1.1 return 5;
213 :    
214 : edgomez 1.8 else if (sr <= 512)
215 : Isibaar 1.1 return 6;
216 :    
217 : edgomez 1.8 else if (sr <= 1024)
218 : Isibaar 1.1 return 7;
219 :    
220 : edgomez 1.8 else
221 : Isibaar 1.1 return 0;
222 :     }
223 :    
224 : edgomez 1.10
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 : suxen_drol 1.11 XVID_ENC_FRAME * pFrame,
235 :     XVID_ENC_STATS * pResult);
236 :    
237 :     int encoder_encode_bframes(Encoder * pEnc,
238 : edgomez 1.10 XVID_ENC_FRAME * pFrame,
239 :     XVID_ENC_STATS * pResult);
240 :    
241 :     #endif

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4