Parent Directory
|
Revision Log
Revision 1.21 - (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 : | edgomez | 1.21 | * $Id$ |
32 : | * | ||
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 : | h | 1.2 | IMAGE vInterVf; |
164 : | edgomez | 1.8 | IMAGE vInterHV; |
165 : | h | 1.2 | IMAGE vInterHVf; |
166 : | suxen_drol | 1.11 | |
167 : | edgomez | 1.8 | Statistics sStat; |
168 : | RateControl rate_control; | ||
169 : | Isibaar | 1.1 | } |
170 : | Encoder; | ||
171 : | |||
172 : | edgomez | 1.10 | /***************************************************************************** |
173 : | * Inline functions | ||
174 : | ****************************************************************************/ | ||
175 : | edgomez | 1.9 | |
176 : | static __inline uint8_t | ||
177 : | get_fcode(uint16_t sr) | ||
178 : | Isibaar | 1.1 | { |
179 : | edgomez | 1.8 | if (sr <= 16) |
180 : | Isibaar | 1.1 | return 1; |
181 : | |||
182 : | edgomez | 1.9 | else if (sr <= 32) |
183 : | Isibaar | 1.1 | return 2; |
184 : | |||
185 : | edgomez | 1.8 | else if (sr <= 64) |
186 : | Isibaar | 1.1 | return 3; |
187 : | |||
188 : | edgomez | 1.8 | else if (sr <= 128) |
189 : | Isibaar | 1.1 | return 4; |
190 : | |||
191 : | edgomez | 1.8 | else if (sr <= 256) |
192 : | Isibaar | 1.1 | return 5; |
193 : | |||
194 : | edgomez | 1.8 | else if (sr <= 512) |
195 : | Isibaar | 1.1 | return 6; |
196 : | |||
197 : | edgomez | 1.8 | else if (sr <= 1024) |
198 : | Isibaar | 1.1 | return 7; |
199 : | |||
200 : | edgomez | 1.8 | else |
201 : | Isibaar | 1.1 | return 0; |
202 : | } | ||
203 : | |||
204 : | edgomez | 1.10 | |
205 : | /***************************************************************************** | ||
206 : | * Prototypes | ||
207 : | ****************************************************************************/ | ||
208 : | |||
209 : | void init_encoder(uint32_t cpu_flags); | ||
210 : | |||
211 : | int encoder_create(XVID_ENC_PARAM * pParam); | ||
212 : | int encoder_destroy(Encoder * pEnc); | ||
213 : | int encoder_encode(Encoder * pEnc, | ||
214 : | suxen_drol | 1.11 | XVID_ENC_FRAME * pFrame, |
215 : | XVID_ENC_STATS * pResult); | ||
216 : | |||
217 : | int encoder_encode_bframes(Encoder * pEnc, | ||
218 : | edgomez | 1.10 | XVID_ENC_FRAME * pFrame, |
219 : | XVID_ENC_STATS * pResult); | ||
220 : | |||
221 : | #endif |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |