[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 603 - (view) (download)

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 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 : edgomez 603 * $Id: encoder.h,v 1.23 2002-10-19 11:41:11 edgomez Exp $
32 : edgomez 404 *
33 : edgomez 202 ****************************************************************************/
34 : Isibaar 3
35 :     #ifndef _ENCODER_H_
36 :     #define _ENCODER_H_
37 :    
38 :     #include "xvid.h"
39 :     #include "portab.h"
40 :     #include "global.h"
41 :     #include "image/image.h"
42 : edgomez 188 #include "utils/ratecontrol.h"
43 : Isibaar 3
44 : edgomez 202 /*****************************************************************************
45 :     * Constants
46 :     ****************************************************************************/
47 :    
48 :     /* Quatization type */
49 : Isibaar 3 #define H263_QUANT 0
50 :     #define MPEG4_QUANT 1
51 :    
52 : edgomez 202 /* Indicates no quantizer changes in INTRA_Q/INTER_Q modes */
53 :     #define NO_CHANGE 64
54 : Isibaar 3
55 : edgomez 202 /*****************************************************************************
56 :     * Types
57 :     ****************************************************************************/
58 : Isibaar 3
59 : edgomez 202 typedef int bool;
60 : Isibaar 3
61 :     typedef enum
62 :     {
63 : edgomez 188 I_VOP = 0,
64 :     P_VOP = 1,
65 : suxen_drol 136 B_VOP = 2
66 : Isibaar 3 }
67 :     VOP_TYPE;
68 :    
69 : edgomez 202 /*****************************************************************************
70 :     * Structures
71 :     ****************************************************************************/
72 : Isibaar 3
73 :     typedef struct
74 :     {
75 : edgomez 188 uint32_t width;
76 :     uint32_t height;
77 : Isibaar 3
78 :     uint32_t edged_width;
79 :     uint32_t edged_height;
80 :     uint32_t mb_width;
81 :     uint32_t mb_height;
82 :    
83 : suxen_drol 152 /* frame rate increment & base */
84 :     uint32_t fincr;
85 :     uint32_t fbase;
86 :    
87 : suxen_drol 295 #ifdef _SMP
88 :     int num_threads;
89 :     #endif
90 :    
91 : edgomez 188 /* rounding type; alternate 0-1 after each interframe */
92 : Isibaar 3 /* 1 <= fixed_code <= 4
93 :     automatically adjusted using motion vector statistics inside
94 : edgomez 195 */
95 : Isibaar 3
96 : suxen_drol 136 /* vars that not "quite" frame independant */
97 :     uint32_t m_quant_type;
98 :     uint32_t m_rounding_type;
99 :     uint32_t m_fcode;
100 :    
101 : edgomez 195 HINTINFO *hint;
102 : suxen_drol 136
103 : suxen_drol 152 uint32_t m_seconds;
104 :     uint32_t m_ticks;
105 :    
106 : edgomez 195 }
107 :     MBParam;
108 : suxen_drol 136
109 :    
110 :     typedef struct
111 :     {
112 : edgomez 188 uint32_t quant;
113 : edgomez 195 uint32_t motion_flags;
114 : Isibaar 3 uint32_t global_flags;
115 : h 101
116 : suxen_drol 136 VOP_TYPE coding_type;
117 : edgomez 188 uint32_t rounding_type;
118 :     uint32_t fcode;
119 : suxen_drol 136 uint32_t bcode;
120 : Isibaar 3
121 : suxen_drol 152 uint32_t seconds;
122 :     uint32_t ticks;
123 : suxen_drol 136
124 :     IMAGE image;
125 :    
126 : edgomez 195 MACROBLOCK *mbs;
127 : suxen_drol 136
128 : edgomez 195 }
129 :     FRAMEINFO;
130 : suxen_drol 136
131 : Isibaar 3 typedef struct
132 :     {
133 : edgomez 188 int iTextBits;
134 :     float fMvPrevSigma;
135 :     int iMvSum;
136 :     int iMvCount;
137 : Isibaar 3 int kblks;
138 :     int mblks;
139 :     int ublks;
140 :     }
141 :     Statistics;
142 :    
143 :    
144 :    
145 :     typedef struct
146 :     {
147 : edgomez 188 MBParam mbParam;
148 : Isibaar 3
149 : edgomez 188 int iFrameNum;
150 :     int iMaxKeyInterval;
151 : Isibaar 3 int bitrate;
152 :    
153 :     // images
154 :    
155 : edgomez 195 FRAMEINFO *current;
156 :     FRAMEINFO *reference;
157 : suxen_drol 136
158 : suxen_drol 229 #ifdef _DEBUG_PSNR
159 : Isibaar 113 IMAGE sOriginal;
160 :     #endif
161 : edgomez 188 IMAGE vInterH;
162 :     IMAGE vInterV;
163 :     IMAGE vInterHV;
164 : Isibaar 3
165 : edgomez 188 Statistics sStat;
166 :     RateControl rate_control;
167 : Isibaar 3 }
168 :     Encoder;
169 :    
170 : edgomez 202 /*****************************************************************************
171 :     * Inline functions
172 :     ****************************************************************************/
173 : Isibaar 3
174 : edgomez 195 static __inline uint8_t
175 :     get_fcode(uint16_t sr)
176 : Isibaar 3 {
177 : edgomez 188 if (sr <= 16)
178 : Isibaar 3 return 1;
179 :    
180 : edgomez 195 else if (sr <= 32)
181 : Isibaar 3 return 2;
182 :    
183 : edgomez 188 else if (sr <= 64)
184 : Isibaar 3 return 3;
185 :    
186 : edgomez 188 else if (sr <= 128)
187 : Isibaar 3 return 4;
188 :    
189 : edgomez 188 else if (sr <= 256)
190 : Isibaar 3 return 5;
191 :    
192 : edgomez 188 else if (sr <= 512)
193 : Isibaar 3 return 6;
194 :    
195 : edgomez 188 else if (sr <= 1024)
196 : Isibaar 3 return 7;
197 :    
198 : edgomez 188 else
199 : Isibaar 3 return 0;
200 :     }
201 :    
202 : edgomez 202
203 :     /*****************************************************************************
204 :     * Prototypes
205 :     ****************************************************************************/
206 :    
207 :     void init_encoder(uint32_t cpu_flags);
208 :    
209 :     int encoder_create(XVID_ENC_PARAM * pParam);
210 :     int encoder_destroy(Encoder * pEnc);
211 :     int encoder_encode(Encoder * pEnc,
212 :     XVID_ENC_FRAME * pFrame,
213 :     XVID_ENC_STATS * pResult);
214 :    
215 : suxen_drol 229 int encoder_encode_bframes(Encoder * pEnc,
216 :     XVID_ENC_FRAME * pFrame,
217 :     XVID_ENC_STATS * pResult);
218 :    
219 : edgomez 202 #endif

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