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

Annotation of /xvidcore/src/encoder.h

Parent Directory Parent Directory | Revision Log Revision Log


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

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