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

Annotation of /xvidcore/src/encoder.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (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.19 * Copyright(C) 2002 Michael Militzer
7 :     *
8 : edgomez 1.10 * 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 1.1 *
17 : edgomez 1.10 * 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 1.1 *
22 : edgomez 1.10 * 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 1.1
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 1.8 #include "utils/ratecontrol.h"
41 : Isibaar 1.1
42 : edgomez 1.10 /*****************************************************************************
43 :     * Constants
44 :     ****************************************************************************/
45 :    
46 :     /* Quatization type */
47 : Isibaar 1.1 #define H263_QUANT 0
48 :     #define MPEG4_QUANT 1
49 :    
50 : edgomez 1.10 /* Indicates no quantizer changes in INTRA_Q/INTER_Q modes */
51 :     #define NO_CHANGE 64
52 : Isibaar 1.1
53 : edgomez 1.10 /*****************************************************************************
54 :     * Types
55 :     ****************************************************************************/
56 : Isibaar 1.1
57 : edgomez 1.10 typedef int bool;
58 : Isibaar 1.1
59 :     typedef enum
60 :     {
61 : edgomez 1.8 I_VOP = 0,
62 :     P_VOP = 1,
63 : suxen_drol 1.5 B_VOP = 2
64 : Isibaar 1.1 }
65 :     VOP_TYPE;
66 :    
67 : edgomez 1.10 /*****************************************************************************
68 :     * Structures
69 :     ****************************************************************************/
70 : Isibaar 1.1
71 :     typedef struct
72 :     {
73 : edgomez 1.8 uint32_t width;
74 :     uint32_t height;
75 : Isibaar 1.1
76 :     uint32_t edged_width;
77 :     uint32_t edged_height;
78 :     uint32_t mb_width;
79 :     uint32_t mb_height;
80 :    
81 : suxen_drol 1.6 /* frame rate increment & base */
82 :     uint32_t fincr;
83 :     uint32_t fbase;
84 : suxen_drol 1.14
85 :     #ifdef _SMP
86 :     int num_threads;
87 :     #endif
88 : suxen_drol 1.6
89 : suxen_drol 1.7 #ifdef BFRAMES
90 :     int max_bframes;
91 :     #endif
92 :    
93 : edgomez 1.8 /* rounding type; alternate 0-1 after each interframe */
94 : Isibaar 1.1 /* 1 <= fixed_code <= 4
95 :     automatically adjusted using motion vector statistics inside
96 : edgomez 1.9 */
97 : Isibaar 1.1
98 : suxen_drol 1.5 /* 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 1.9 HINTINFO *hint;
104 : suxen_drol 1.5
105 : suxen_drol 1.6 uint32_t m_seconds;
106 :     uint32_t m_ticks;
107 :    
108 : edgomez 1.9 }
109 :     MBParam;
110 : suxen_drol 1.5
111 :    
112 :     typedef struct
113 :     {
114 : edgomez 1.8 uint32_t quant;
115 : edgomez 1.9 uint32_t motion_flags;
116 : Isibaar 1.1 uint32_t global_flags;
117 : h 1.3
118 : suxen_drol 1.5 VOP_TYPE coding_type;
119 : edgomez 1.8 uint32_t rounding_type;
120 :     uint32_t fcode;
121 : suxen_drol 1.5 uint32_t bcode;
122 :    
123 : suxen_drol 1.6 uint32_t seconds;
124 :     uint32_t ticks;
125 : suxen_drol 1.5
126 :     IMAGE image;
127 :    
128 : edgomez 1.9 MACROBLOCK *mbs;
129 : suxen_drol 1.5
130 : edgomez 1.9 }
131 :     FRAMEINFO;
132 : Isibaar 1.1
133 :     typedef struct
134 :     {
135 : edgomez 1.8 int iTextBits;
136 :     float fMvPrevSigma;
137 :     int iMvSum;
138 :     int iMvCount;
139 : Isibaar 1.1 int kblks;
140 :     int mblks;
141 :     int ublks;
142 :     }
143 :     Statistics;
144 :    
145 :    
146 :    
147 :     typedef struct
148 :     {
149 : edgomez 1.8 MBParam mbParam;
150 : Isibaar 1.1
151 : edgomez 1.8 int iFrameNum;
152 :     int iMaxKeyInterval;
153 : Isibaar 1.1 int bitrate;
154 :    
155 :     // images
156 :    
157 : edgomez 1.9 FRAMEINFO *current;
158 :     FRAMEINFO *reference;
159 : suxen_drol 1.5
160 : suxen_drol 1.11 #ifdef _DEBUG_PSNR
161 : Isibaar 1.4 IMAGE sOriginal;
162 :     #endif
163 : edgomez 1.8 IMAGE vInterH;
164 :     IMAGE vInterV;
165 : h 1.2 IMAGE vInterVf;
166 : edgomez 1.8 IMAGE vInterHV;
167 : h 1.2 IMAGE vInterHVf;
168 : Isibaar 1.1
169 : suxen_drol 1.6 #ifdef BFRAMES
170 :     /* constants */
171 : suxen_drol 1.12 int global;
172 : suxen_drol 1.6 int bquant_ratio;
173 : suxen_drol 1.16 int frame_drop_ratio;
174 : suxen_drol 1.11
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 1.6 int bframenum_head;
183 :     int bframenum_tail;
184 :     int flush_bframes;
185 :    
186 : edgomez 1.9 FRAMEINFO **bframes;
187 : edgomez 1.8 IMAGE f_refh;
188 :     IMAGE f_refv;
189 :     IMAGE f_refhv;
190 : suxen_drol 1.13 int bframenum_dx50bvop;
191 : chl 1.15
192 :     int last_pframe;
193 : chl 1.17 int last_sync;
194 : chl 1.15 int time_pp;
195 : suxen_drol 1.12 int m_framenum; /* debug frame num counter; unlike iFrameNum, does not reset at ivop */
196 : suxen_drol 1.6 #endif
197 : suxen_drol 1.11
198 : edgomez 1.8 Statistics sStat;
199 :     RateControl rate_control;
200 : Isibaar 1.1 }
201 :     Encoder;
202 :    
203 : edgomez 1.10 /*****************************************************************************
204 :     * Inline functions
205 :     ****************************************************************************/
206 : edgomez 1.9
207 :     static __inline uint8_t
208 :     get_fcode(uint16_t sr)
209 : Isibaar 1.1 {
210 : edgomez 1.8 if (sr <= 16)
211 : Isibaar 1.1 return 1;
212 :    
213 : edgomez 1.9 else if (sr <= 32)
214 : Isibaar 1.1 return 2;
215 :    
216 : edgomez 1.8 else if (sr <= 64)
217 : Isibaar 1.1 return 3;
218 :    
219 : edgomez 1.8 else if (sr <= 128)
220 : Isibaar 1.1 return 4;
221 :    
222 : edgomez 1.8 else if (sr <= 256)
223 : Isibaar 1.1 return 5;
224 :    
225 : edgomez 1.8 else if (sr <= 512)
226 : Isibaar 1.1 return 6;
227 :    
228 : edgomez 1.8 else if (sr <= 1024)
229 : Isibaar 1.1 return 7;
230 :    
231 : edgomez 1.8 else
232 : Isibaar 1.1 return 0;
233 :     }
234 :    
235 : edgomez 1.10
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 : suxen_drol 1.11 XVID_ENC_FRAME * pFrame,
246 :     XVID_ENC_STATS * pResult);
247 :    
248 :     int encoder_encode_bframes(Encoder * pEnc,
249 : edgomez 1.10 XVID_ENC_FRAME * pFrame,
250 :     XVID_ENC_STATS * pResult);
251 :    
252 :     #endif

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