Parent Directory | Revision Log
Revision 1107 - (view) (download)
1 : | edgomez | 202 | /***************************************************************************** |
2 : | Isibaar | 3 | * |
3 : | edgomez | 202 | * XVID MPEG-4 VIDEO CODEC |
4 : | edgomez | 1054 | * - Encoder related header - |
5 : | Isibaar | 3 | * |
6 : | edgomez | 1054 | * Copyright(C) 2002-2003 Michael Militzer <isibaar@xvid.org> |
7 : | * 2002-2003 Peter Ross <pross@xvid.org> | ||
8 : | edgomez | 399 | * |
9 : | edgomez | 851 | * This program is free software ; you can redistribute it and/or modify |
10 : | * it under the terms of the GNU General Public License as published by | ||
11 : | * the Free Software Foundation ; either version 2 of the License, or | ||
12 : | edgomez | 202 | * (at your option) any later version. |
13 : | Isibaar | 3 | * |
14 : | edgomez | 202 | * This program is distributed in the hope that it will be useful, |
15 : | edgomez | 851 | * but WITHOUT ANY WARRANTY ; without even the implied warranty of |
16 : | edgomez | 202 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 : | * GNU General Public License for more details. | ||
18 : | * | ||
19 : | * You should have received a copy of the GNU General Public License | ||
20 : | edgomez | 851 | * along with this program ; if not, write to the Free Software |
21 : | edgomez | 202 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 : | * | ||
23 : | edgomez | 1107 | * $Id: encoder.h,v 1.27.2.12 2003-08-02 15:08:24 edgomez Exp $ |
24 : | edgomez | 404 | * |
25 : | edgomez | 202 | ****************************************************************************/ |
26 : | Isibaar | 3 | |
27 : | #ifndef _ENCODER_H_ | ||
28 : | #define _ENCODER_H_ | ||
29 : | |||
30 : | #include "xvid.h" | ||
31 : | #include "portab.h" | ||
32 : | #include "global.h" | ||
33 : | |||
34 : | edgomez | 202 | /***************************************************************************** |
35 : | * Constants | ||
36 : | ****************************************************************************/ | ||
37 : | |||
38 : | /***************************************************************************** | ||
39 : | * Types | ||
40 : | ****************************************************************************/ | ||
41 : | Isibaar | 3 | |
42 : | edgomez | 202 | typedef int bool; |
43 : | Isibaar | 3 | |
44 : | edgomez | 202 | /***************************************************************************** |
45 : | * Structures | ||
46 : | ****************************************************************************/ | ||
47 : | Isibaar | 3 | |
48 : | typedef struct | ||
49 : | { | ||
50 : | suxen_drol | 890 | /* --- constants --- */ |
51 : | edgomez | 188 | uint32_t width; |
52 : | uint32_t height; | ||
53 : | Isibaar | 3 | |
54 : | uint32_t edged_width; | ||
55 : | uint32_t edged_height; | ||
56 : | uint32_t mb_width; | ||
57 : | uint32_t mb_height; | ||
58 : | |||
59 : | suxen_drol | 920 | int plugin_flags; |
60 : | |||
61 : | suxen_drol | 152 | /* frame rate increment & base */ |
62 : | uint32_t fincr; | ||
63 : | uint32_t fbase; | ||
64 : | |||
65 : | suxen_drol | 1014 | int profile; |
66 : | |||
67 : | edgomez | 1107 | int global_flags; |
68 : | edgomez | 851 | int bquant_ratio; |
69 : | int bquant_offset; | ||
70 : | int frame_drop_ratio; | ||
71 : | |||
72 : | suxen_drol | 1014 | int min_quant[3]; |
73 : | int max_quant[3]; | ||
74 : | |||
75 : | suxen_drol | 890 | #ifdef _SMP |
76 : | int num_threads; | ||
77 : | #endif | ||
78 : | |||
79 : | |||
80 : | edgomez | 851 | int iMaxKeyInterval; |
81 : | int max_bframes; | ||
82 : | |||
83 : | suxen_drol | 890 | /* --- inbetween vop stuff --- */ |
84 : | edgomez | 188 | /* rounding type; alternate 0-1 after each interframe */ |
85 : | Isibaar | 3 | /* 1 <= fixed_code <= 4 |
86 : | automatically adjusted using motion vector statistics inside | ||
87 : | edgomez | 195 | */ |
88 : | Isibaar | 3 | |
89 : | suxen_drol | 136 | /* vars that not "quite" frame independant */ |
90 : | uint32_t m_rounding_type; | ||
91 : | uint32_t m_fcode; | ||
92 : | edgomez | 1107 | int vol_flags; |
93 : | suxen_drol | 136 | |
94 : | edgomez | 851 | int64_t m_stamp; |
95 : | edgomez | 195 | } |
96 : | MBParam; | ||
97 : | suxen_drol | 136 | |
98 : | |||
99 : | typedef struct | ||
100 : | { | ||
101 : | edgomez | 851 | int iTextBits; |
102 : | int iMvSum; | ||
103 : | int iMvCount; | ||
104 : | int kblks; | ||
105 : | int mblks; | ||
106 : | int ublks; | ||
107 : | int gblks; | ||
108 : | } | ||
109 : | Statistics; | ||
110 : | |||
111 : | |||
112 : | suxen_drol | 890 | /* encoding queue */ |
113 : | edgomez | 851 | typedef struct |
114 : | { | ||
115 : | suxen_drol | 890 | xvid_enc_frame_t frame; |
116 : | unsigned char quant_intra_matrix[64]; | ||
117 : | unsigned char quant_inter_matrix[64]; | ||
118 : | IMAGE image; | ||
119 : | } QUEUEINFO; | ||
120 : | |||
121 : | |||
122 : | typedef struct | ||
123 : | { | ||
124 : | suxen_drol | 920 | int frame_num; |
125 : | suxen_drol | 925 | int fincr; |
126 : | edgomez | 1107 | int vol_flags; |
127 : | int vop_flags; | ||
128 : | int motion_flags; | ||
129 : | suxen_drol | 890 | |
130 : | int coding_type; | ||
131 : | edgomez | 188 | uint32_t quant; |
132 : | uint32_t rounding_type; | ||
133 : | uint32_t fcode; | ||
134 : | suxen_drol | 136 | uint32_t bcode; |
135 : | Isibaar | 3 | |
136 : | suxen_drol | 152 | uint32_t seconds; |
137 : | uint32_t ticks; | ||
138 : | edgomez | 851 | int64_t stamp; |
139 : | suxen_drol | 136 | |
140 : | IMAGE image; | ||
141 : | |||
142 : | edgomez | 195 | MACROBLOCK *mbs; |
143 : | suxen_drol | 136 | |
144 : | edgomez | 1053 | WARPPOINTS warp; /* as in bitstream */ |
145 : | GMC_DATA gmc_data; /* common data for all MBs */ | ||
146 : | chl | 1077 | NEW_GMC_DATA new_gmc_data; /* common data for all MBs */ |
147 : | suxen_drol | 890 | |
148 : | int length; /* the encoded size of this frame */ | ||
149 : | edgomez | 851 | |
150 : | Statistics sStat; | ||
151 : | edgomez | 195 | } |
152 : | FRAMEINFO; | ||
153 : | suxen_drol | 136 | |
154 : | Isibaar | 3 | |
155 : | typedef struct | ||
156 : | { | ||
157 : | edgomez | 188 | MBParam mbParam; |
158 : | Isibaar | 3 | |
159 : | edgomez | 188 | int iFrameNum; |
160 : | Isibaar | 3 | int bitrate; |
161 : | |||
162 : | edgomez | 1053 | /* zones */ |
163 : | suxen_drol | 1014 | unsigned int num_zones; |
164 : | xvid_enc_zone_t * zones; | ||
165 : | |||
166 : | edgomez | 1053 | /* plugins */ |
167 : | suxen_drol | 926 | unsigned int num_plugins; /* note: we store plugin flags in MBPARAM */ |
168 : | suxen_drol | 919 | xvid_enc_plugin_t * plugins; |
169 : | |||
170 : | edgomez | 1053 | /* dquant */ |
171 : | suxen_drol | 919 | |
172 : | int * temp_dquants; | ||
173 : | |||
174 : | edgomez | 1053 | /* images */ |
175 : | Isibaar | 3 | |
176 : | edgomez | 195 | FRAMEINFO *current; |
177 : | FRAMEINFO *reference; | ||
178 : | suxen_drol | 136 | |
179 : | suxen_drol | 920 | IMAGE sOriginal; /* original image copy for i/p frames */ |
180 : | IMAGE sOriginal2; /* original image copy for b-frames */ | ||
181 : | edgomez | 188 | IMAGE vInterH; |
182 : | IMAGE vInterV; | ||
183 : | edgomez | 851 | IMAGE vInterVf; |
184 : | edgomez | 188 | IMAGE vInterHV; |
185 : | edgomez | 851 | IMAGE vInterHVf; |
186 : | Isibaar | 3 | |
187 : | edgomez | 851 | IMAGE vGMC; |
188 : | |||
189 : | /* image queue */ | ||
190 : | int queue_head; | ||
191 : | int queue_tail; | ||
192 : | int queue_size; | ||
193 : | suxen_drol | 890 | QUEUEINFO *queue; |
194 : | edgomez | 851 | |
195 : | /* bframe buffer */ | ||
196 : | int bframenum_head; | ||
197 : | int bframenum_tail; | ||
198 : | int flush_bframes; | ||
199 : | |||
200 : | FRAMEINFO **bframes; | ||
201 : | IMAGE f_refh; | ||
202 : | IMAGE f_refv; | ||
203 : | IMAGE f_refhv; | ||
204 : | |||
205 : | suxen_drol | 890 | /* closed_gop fixup temporary storage */ |
206 : | int closed_bframenum; /* == -1 if there is no fixup intended */ | ||
207 : | QUEUEINFO closed_qframe; /* qFrame, only valid when >= 0 */ | ||
208 : | |||
209 : | edgomez | 851 | int m_framenum; /* debug frame num counter; unlike iFrameNum, does not reset at ivop */ |
210 : | |||
211 : | float fMvPrevSigma; | ||
212 : | Isibaar | 3 | } |
213 : | Encoder; | ||
214 : | |||
215 : | edgomez | 202 | /***************************************************************************** |
216 : | * Inline functions | ||
217 : | ****************************************************************************/ | ||
218 : | Isibaar | 3 | |
219 : | edgomez | 195 | static __inline uint8_t |
220 : | get_fcode(uint16_t sr) | ||
221 : | Isibaar | 3 | { |
222 : | edgomez | 188 | if (sr <= 16) |
223 : | Isibaar | 3 | return 1; |
224 : | |||
225 : | edgomez | 195 | else if (sr <= 32) |
226 : | Isibaar | 3 | return 2; |
227 : | |||
228 : | edgomez | 188 | else if (sr <= 64) |
229 : | Isibaar | 3 | return 3; |
230 : | |||
231 : | edgomez | 188 | else if (sr <= 128) |
232 : | Isibaar | 3 | return 4; |
233 : | |||
234 : | edgomez | 188 | else if (sr <= 256) |
235 : | Isibaar | 3 | return 5; |
236 : | |||
237 : | edgomez | 188 | else if (sr <= 512) |
238 : | Isibaar | 3 | return 6; |
239 : | |||
240 : | edgomez | 188 | else if (sr <= 1024) |
241 : | Isibaar | 3 | return 7; |
242 : | |||
243 : | edgomez | 188 | else |
244 : | Isibaar | 3 | return 0; |
245 : | } | ||
246 : | |||
247 : | edgomez | 202 | |
248 : | /***************************************************************************** | ||
249 : | * Prototypes | ||
250 : | ****************************************************************************/ | ||
251 : | |||
252 : | void init_encoder(uint32_t cpu_flags); | ||
253 : | |||
254 : | suxen_drol | 948 | int enc_create(xvid_enc_create_t * create); |
255 : | suxen_drol | 890 | int enc_destroy(Encoder * pEnc); |
256 : | int enc_encode(Encoder * pEnc, | ||
257 : | xvid_enc_frame_t * pFrame, | ||
258 : | xvid_enc_stats_t * stats); | ||
259 : | edgomez | 202 | |
260 : | #endif |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |