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

Annotation of /trunk/xvidcore/src/encoder.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 399 - (view) (download)

1 : edgomez 202 /*****************************************************************************
2 : Isibaar 3 *
3 : edgomez 202 * XVID MPEG-4 VIDEO CODEC
4 :     * - Encoder header -
5 : Isibaar 3 *
6 : edgomez 399 * Copyright(C) 2002 Michael Militzer
7 :     *
8 : edgomez 202 * This program is an implementation of a part of one or more MPEG-4
9 :     * Video tools as specified in ISO/IEC 14496-2 standard. Those intending
10 :     * to use this software module in hardware or software products are
11 :     * advised that its use may infringe existing patents or copyrights, and
12 :     * any such use would be at such party's own risk. The original
13 :     * developer of this software module and his/her company, and subsequent
14 :     * editors and their companies, will have no liability for use of this
15 :     * software or modifications or derivatives thereof.
16 : Isibaar 3 *
17 : edgomez 202 * This program is free software ; you can redistribute it and/or modify
18 :     * it under the terms of the GNU General Public License as published by
19 :     * the Free Software Foundation ; either version 2 of the License, or
20 :     * (at your option) any later version.
21 : Isibaar 3 *
22 : edgomez 202 * This program is distributed in the hope that it will be useful,
23 :     * but WITHOUT ANY WARRANTY ; without even the implied warranty of
24 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 :     * GNU General Public License for more details.
26 :     *
27 :     * You should have received a copy of the GNU General Public License
28 :     * along with this program ; if not, write to the Free Software
29 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 :     *
31 :     ****************************************************************************/
32 : Isibaar 3
33 :     #ifndef _ENCODER_H_
34 :     #define _ENCODER_H_
35 :    
36 :     #include "xvid.h"
37 :     #include "portab.h"
38 :     #include "global.h"
39 :     #include "image/image.h"
40 : edgomez 188 #include "utils/ratecontrol.h"
41 : Isibaar 3
42 : edgomez 202 /*****************************************************************************
43 :     * Constants
44 :     ****************************************************************************/
45 :    
46 :     /* Quatization type */
47 : Isibaar 3 #define H263_QUANT 0
48 :     #define MPEG4_QUANT 1
49 :    
50 : edgomez 202 /* Indicates no quantizer changes in INTRA_Q/INTER_Q modes */
51 :     #define NO_CHANGE 64
52 : Isibaar 3
53 : edgomez 202 /*****************************************************************************
54 :     * Types
55 :     ****************************************************************************/
56 : Isibaar 3
57 : edgomez 202 typedef int bool;
58 : Isibaar 3
59 :     typedef enum
60 :     {
61 : edgomez 188 I_VOP = 0,
62 :     P_VOP = 1,
63 : suxen_drol 136 B_VOP = 2
64 : Isibaar 3 }
65 :     VOP_TYPE;
66 :    
67 : edgomez 202 /*****************************************************************************
68 :     * Structures
69 :     ****************************************************************************/
70 : Isibaar 3
71 :     typedef struct
72 :     {
73 : edgomez 188 uint32_t width;
74 :     uint32_t height;
75 : Isibaar 3
76 :     uint32_t edged_width;
77 :     uint32_t edged_height;
78 :     uint32_t mb_width;
79 :     uint32_t mb_height;
80 :    
81 : suxen_drol 152 /* frame rate increment & base */
82 :     uint32_t fincr;
83 :     uint32_t fbase;
84 :    
85 : suxen_drol 295 #ifdef _SMP
86 :     int num_threads;
87 :     #endif
88 :    
89 : suxen_drol 164 #ifdef BFRAMES
90 :     int max_bframes;
91 :     #endif
92 :    
93 : edgomez 188 /* rounding type; alternate 0-1 after each interframe */
94 : Isibaar 3 /* 1 <= fixed_code <= 4
95 :     automatically adjusted using motion vector statistics inside
96 : edgomez 195 */
97 : Isibaar 3
98 : suxen_drol 136 /* vars that not "quite" frame independant */
99 :     uint32_t m_quant_type;
100 :     uint32_t m_rounding_type;
101 :     uint32_t m_fcode;
102 :    
103 : edgomez 195 HINTINFO *hint;
104 : suxen_drol 136
105 : suxen_drol 152 uint32_t m_seconds;
106 :     uint32_t m_ticks;
107 :    
108 : edgomez 195 }
109 :     MBParam;
110 : suxen_drol 136
111 :    
112 :     typedef struct
113 :     {
114 : edgomez 188 uint32_t quant;
115 : edgomez 195 uint32_t motion_flags;
116 : Isibaar 3 uint32_t global_flags;
117 : h 101
118 : suxen_drol 136 VOP_TYPE coding_type;
119 : edgomez 188 uint32_t rounding_type;
120 :     uint32_t fcode;
121 : suxen_drol 136 uint32_t bcode;
122 : Isibaar 3
123 : suxen_drol 152 uint32_t seconds;
124 :     uint32_t ticks;
125 : suxen_drol 136
126 :     IMAGE image;
127 :    
128 : edgomez 195 MACROBLOCK *mbs;
129 : suxen_drol 136
130 : edgomez 195 }
131 :     FRAMEINFO;
132 : suxen_drol 136
133 : Isibaar 3 typedef struct
134 :     {
135 : edgomez 188 int iTextBits;
136 :     float fMvPrevSigma;
137 :     int iMvSum;
138 :     int iMvCount;
139 : Isibaar 3 int kblks;
140 :     int mblks;
141 :     int ublks;
142 :     }
143 :     Statistics;
144 :    
145 :    
146 :    
147 :     typedef struct
148 :     {
149 : edgomez 188 MBParam mbParam;
150 : Isibaar 3
151 : edgomez 188 int iFrameNum;
152 :     int iMaxKeyInterval;
153 : Isibaar 3 int bitrate;
154 :    
155 :     // images
156 :    
157 : edgomez 195 FRAMEINFO *current;
158 :     FRAMEINFO *reference;
159 : suxen_drol 136
160 : suxen_drol 229 #ifdef _DEBUG_PSNR
161 : Isibaar 113 IMAGE sOriginal;
162 :     #endif
163 : edgomez 188 IMAGE vInterH;
164 :     IMAGE vInterV;
165 : h 83 IMAGE vInterVf;
166 : edgomez 188 IMAGE vInterHV;
167 : h 83 IMAGE vInterHVf;
168 : Isibaar 3
169 : suxen_drol 152 #ifdef BFRAMES
170 :     /* constants */
171 : suxen_drol 234 int global;
172 : suxen_drol 152 int bquant_ratio;
173 : suxen_drol 324 int frame_drop_ratio;
174 : suxen_drol 229
175 :     /* image queue */
176 :     int queue_head;
177 :     int queue_tail;
178 :     int queue_size;
179 :     IMAGE *queue;
180 :    
181 :     /* bframe buffer */
182 : suxen_drol 152 int bframenum_head;
183 :     int bframenum_tail;
184 :     int flush_bframes;
185 :    
186 : edgomez 195 FRAMEINFO **bframes;
187 : edgomez 188 IMAGE f_refh;
188 :     IMAGE f_refv;
189 :     IMAGE f_refhv;
190 : suxen_drol 238 int bframenum_dx50bvop;
191 : chl 317
192 :     int last_pframe;
193 : chl 366 int last_sync;
194 : chl 317 int time_pp;
195 : suxen_drol 234 int m_framenum; /* debug frame num counter; unlike iFrameNum, does not reset at ivop */
196 : suxen_drol 152 #endif
197 : suxen_drol 229
198 : edgomez 188 Statistics sStat;
199 :     RateControl rate_control;
200 : Isibaar 3 }
201 :     Encoder;
202 :    
203 : edgomez 202 /*****************************************************************************
204 :     * Inline functions
205 :     ****************************************************************************/
206 : Isibaar 3
207 : edgomez 195 static __inline uint8_t
208 :     get_fcode(uint16_t sr)
209 : Isibaar 3 {
210 : edgomez 188 if (sr <= 16)
211 : Isibaar 3 return 1;
212 :    
213 : edgomez 195 else if (sr <= 32)
214 : Isibaar 3 return 2;
215 :    
216 : edgomez 188 else if (sr <= 64)
217 : Isibaar 3 return 3;
218 :    
219 : edgomez 188 else if (sr <= 128)
220 : Isibaar 3 return 4;
221 :    
222 : edgomez 188 else if (sr <= 256)
223 : Isibaar 3 return 5;
224 :    
225 : edgomez 188 else if (sr <= 512)
226 : Isibaar 3 return 6;
227 :    
228 : edgomez 188 else if (sr <= 1024)
229 : Isibaar 3 return 7;
230 :    
231 : edgomez 188 else
232 : Isibaar 3 return 0;
233 :     }
234 :    
235 : edgomez 202
236 :     /*****************************************************************************
237 :     * Prototypes
238 :     ****************************************************************************/
239 :    
240 :     void init_encoder(uint32_t cpu_flags);
241 :    
242 :     int encoder_create(XVID_ENC_PARAM * pParam);
243 :     int encoder_destroy(Encoder * pEnc);
244 :     int encoder_encode(Encoder * pEnc,
245 :     XVID_ENC_FRAME * pFrame,
246 :     XVID_ENC_STATS * pResult);
247 :    
248 : suxen_drol 229 int encoder_encode_bframes(Encoder * pEnc,
249 :     XVID_ENC_FRAME * pFrame,
250 :     XVID_ENC_STATS * pResult);
251 :    
252 : edgomez 202 #endif

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