Parent Directory
|
Revision Log
Revision 1.33.2.19 - (view) (download)
1 : | edgomez | 1.16 | /***************************************************************************** |
2 : | edgomez | 1.17 | * |
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | * - Native API implementation - | ||
5 : | * | ||
6 : | * This program is an implementation of a part of one or more MPEG-4 | ||
7 : | * Video tools as specified in ISO/IEC 14496-2 standard. Those intending | ||
8 : | * to use this software module in hardware or software products are | ||
9 : | * advised that its use may infringe existing patents or copyrights, and | ||
10 : | * any such use would be at such party's own risk. The original | ||
11 : | * developer of this software module and his/her company, and subsequent | ||
12 : | * editors and their companies, will have no liability for use of this | ||
13 : | * software or modifications or derivatives thereof. | ||
14 : | * | ||
15 : | * This program is free software ; you can redistribute it and/or modify | ||
16 : | * it under the terms of the GNU General Public License as published by | ||
17 : | * the Free Software Foundation ; either version 2 of the License, or | ||
18 : | * (at your option) any later version. | ||
19 : | * | ||
20 : | * This program is distributed in the hope that it will be useful, | ||
21 : | * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
22 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 : | * GNU General Public License for more details. | ||
24 : | * | ||
25 : | * You should have received a copy of the GNU General Public License | ||
26 : | * along with this program ; if not, write to the Free Software | ||
27 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
28 : | * | ||
29 : | ****************************************************************************/ | ||
30 : | chenm001 | 1.29 | |
31 : | edgomez | 1.16 | /***************************************************************************** |
32 : | edgomez | 1.17 | * |
33 : | * History | ||
34 : | * | ||
35 : | suxen_drol | 1.21 | * - 23.06.2002 added XVID_CPU_CHKONLY |
36 : | edgomez | 1.17 | * - 17.03.2002 Added interpolate8x8_halfpel_hv_xmm |
37 : | * - 22.12.2001 API change: added xvid_init() - Isibaar | ||
38 : | * - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> | ||
39 : | * | ||
40 : | suxen_drol | 1.33.2.19 | * $Id: xvid.c,v 1.33.2.18 2002/12/19 00:37:56 Isibaar Exp $ |
41 : | edgomez | 1.17 | * |
42 : | ****************************************************************************/ | ||
43 : | Isibaar | 1.1 | |
44 : | #include "xvid.h" | ||
45 : | #include "decoder.h" | ||
46 : | #include "encoder.h" | ||
47 : | #include "bitstream/cbp.h" | ||
48 : | #include "dct/idct.h" | ||
49 : | #include "dct/fdct.h" | ||
50 : | #include "image/colorspace.h" | ||
51 : | #include "image/interpolate8x8.h" | ||
52 : | suxen_drol | 1.33.2.15 | #include "image/reduced.h" |
53 : | Isibaar | 1.1 | #include "utils/mem_transfer.h" |
54 : | h | 1.33.2.5 | #include "utils/mbfunctions.h" |
55 : | Isibaar | 1.1 | #include "quant/quant_h263.h" |
56 : | #include "quant/quant_mpeg4.h" | ||
57 : | ia64p | 1.30 | #include "motion/motion.h" |
58 : | Isibaar | 1.1 | #include "motion/sad.h" |
59 : | #include "utils/emms.h" | ||
60 : | #include "utils/timer.h" | ||
61 : | Isibaar | 1.9 | #include "bitstream/mbcoding.h" |
62 : | Isibaar | 1.1 | |
63 : | suxen_drol | 1.31 | #if defined(ARCH_X86) && defined(EXPERIMENTAL_SSE2_CODE) |
64 : | |||
65 : | #ifdef WIN32 | ||
66 : | #include <windows.h> | ||
67 : | #else | ||
68 : | #include <signal.h> | ||
69 : | #include <setjmp.h> | ||
70 : | #endif | ||
71 : | |||
72 : | |||
73 : | #ifndef WIN32 | ||
74 : | |||
75 : | static jmp_buf mark; | ||
76 : | |||
77 : | static void | ||
78 : | sigill_handler(int signal) | ||
79 : | { | ||
80 : | longjmp(mark, 1); | ||
81 : | } | ||
82 : | #endif | ||
83 : | |||
84 : | |||
85 : | /* | ||
86 : | calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled | ||
87 : | return values: | ||
88 : | -1 : could not determine | ||
89 : | 0 : SIGILL was *not* signalled | ||
90 : | 1 : SIGILL was signalled | ||
91 : | */ | ||
92 : | |||
93 : | int | ||
94 : | sigill_check(void (*func)()) | ||
95 : | { | ||
96 : | #ifdef WIN32 | ||
97 : | _try { | ||
98 : | func(); | ||
99 : | } | ||
100 : | _except(EXCEPTION_EXECUTE_HANDLER) { | ||
101 : | |||
102 : | if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION) | ||
103 : | return 1; | ||
104 : | } | ||
105 : | return 0; | ||
106 : | #else | ||
107 : | void * old_handler; | ||
108 : | int jmpret; | ||
109 : | |||
110 : | |||
111 : | old_handler = signal(SIGILL, sigill_handler); | ||
112 : | if (old_handler == SIG_ERR) | ||
113 : | { | ||
114 : | return -1; | ||
115 : | } | ||
116 : | |||
117 : | jmpret = setjmp(mark); | ||
118 : | if (jmpret == 0) | ||
119 : | { | ||
120 : | func(); | ||
121 : | } | ||
122 : | |||
123 : | signal(SIGILL, old_handler); | ||
124 : | |||
125 : | return jmpret; | ||
126 : | #endif | ||
127 : | } | ||
128 : | #endif | ||
129 : | |||
130 : | edgomez | 1.16 | /***************************************************************************** |
131 : | * XviD Init Entry point | ||
132 : | * | ||
133 : | * Well this function initialize all internal function pointers according | ||
134 : | * to the CPU features forced by the library client or autodetected (depending | ||
135 : | * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all | ||
136 : | * image colorspace transformation tables. | ||
137 : | * | ||
138 : | * Returned value : XVID_ERR_OK | ||
139 : | * + API_VERSION in the input XVID_INIT_PARAM structure | ||
140 : | * + core build " " " " " | ||
141 : | * | ||
142 : | ****************************************************************************/ | ||
143 : | |||
144 : | suxen_drol | 1.33.2.13 | |
145 : | static | ||
146 : | int xvid_init_init(XVID_INIT_PARAM * init_param) | ||
147 : | Isibaar | 1.1 | { |
148 : | int cpu_flags; | ||
149 : | |||
150 : | suxen_drol | 1.21 | /* Inform the client the API version */ |
151 : | init_param->api_version = API_VERSION; | ||
152 : | |||
153 : | /* Inform the client the core build - unused because we're still alpha */ | ||
154 : | init_param->core_build = 1000; | ||
155 : | |||
156 : | suxen_drol | 1.31 | /* Do we have to force CPU features ? */ |
157 : | if ((init_param->cpu_flags & XVID_CPU_FORCE)) { | ||
158 : | suxen_drol | 1.21 | |
159 : | Isibaar | 1.1 | cpu_flags = init_param->cpu_flags; |
160 : | suxen_drol | 1.31 | |
161 : | edgomez | 1.16 | } else { |
162 : | Isibaar | 1.1 | |
163 : | chenm001 | 1.29 | cpu_flags = check_cpu_features(); |
164 : | suxen_drol | 1.31 | |
165 : | #if defined(ARCH_X86) && defined(EXPERIMENTAL_SSE2_CODE) | ||
166 : | if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger)) | ||
167 : | cpu_flags &= ~XVID_CPU_SSE; | ||
168 : | |||
169 : | if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger)) | ||
170 : | cpu_flags &= ~XVID_CPU_SSE2; | ||
171 : | #endif | ||
172 : | } | ||
173 : | |||
174 : | if ((init_param->cpu_flags & XVID_CPU_CHKONLY)) | ||
175 : | { | ||
176 : | Isibaar | 1.1 | init_param->cpu_flags = cpu_flags; |
177 : | suxen_drol | 1.31 | return XVID_ERR_OK; |
178 : | Isibaar | 1.1 | } |
179 : | suxen_drol | 1.31 | |
180 : | init_param->cpu_flags = cpu_flags; | ||
181 : | |||
182 : | Isibaar | 1.1 | |
183 : | edgomez | 1.16 | /* Initialize the function pointers */ |
184 : | Isibaar | 1.1 | idct_int32_init(); |
185 : | Isibaar | 1.9 | init_vlc_tables(); |
186 : | |||
187 : | edgomez | 1.16 | /* Fixed Point Forward/Inverse DCT transformations */ |
188 : | Isibaar | 1.1 | fdct = fdct_int32; |
189 : | idct = idct_int32; | ||
190 : | |||
191 : | edgomez | 1.16 | /* Only needed on PPC Altivec archs */ |
192 : | canard | 1.10 | sadInit = 0; |
193 : | edgomez | 1.15 | |
194 : | edgomez | 1.16 | /* Restore FPU context : emms_c is a nop functions */ |
195 : | Isibaar | 1.1 | emms = emms_c; |
196 : | |||
197 : | edgomez | 1.16 | /* Quantization functions */ |
198 : | quant_intra = quant_intra_c; | ||
199 : | Isibaar | 1.1 | dequant_intra = dequant_intra_c; |
200 : | edgomez | 1.16 | quant_inter = quant_inter_c; |
201 : | Isibaar | 1.1 | dequant_inter = dequant_inter_c; |
202 : | |||
203 : | edgomez | 1.16 | quant4_intra = quant4_intra_c; |
204 : | Isibaar | 1.1 | dequant4_intra = dequant4_intra_c; |
205 : | edgomez | 1.16 | quant4_inter = quant4_inter_c; |
206 : | Isibaar | 1.1 | dequant4_inter = dequant4_inter_c; |
207 : | |||
208 : | edgomez | 1.16 | /* Block transfer related functions */ |
209 : | Isibaar | 1.1 | transfer_8to16copy = transfer_8to16copy_c; |
210 : | transfer_16to8copy = transfer_16to8copy_c; | ||
211 : | edgomez | 1.16 | transfer_8to16sub = transfer_8to16sub_c; |
212 : | suxen_drol | 1.11 | transfer_8to16sub2 = transfer_8to16sub2_c; |
213 : | edgomez | 1.16 | transfer_16to8add = transfer_16to8add_c; |
214 : | transfer8x8_copy = transfer8x8_copy_c; | ||
215 : | Isibaar | 1.1 | |
216 : | h | 1.33.2.5 | /* Interlacing functions */ |
217 : | MBFieldTest = MBFieldTest_c; | ||
218 : | |||
219 : | edgomez | 1.16 | /* Image interpolation related functions */ |
220 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; | ||
221 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; | ||
222 : | Isibaar | 1.1 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
223 : | Isibaar | 1.33.2.8 | |
224 : | interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c; | ||
225 : | interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c; | ||
226 : | interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c; | ||
227 : | Isibaar | 1.1 | |
228 : | Isibaar | 1.33.2.6 | interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c; |
229 : | interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c; | ||
230 : | interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c; | ||
231 : | |||
232 : | interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c; | ||
233 : | interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c; | ||
234 : | |||
235 : | interpolate8x8_avg2 = interpolate8x8_avg2_c; | ||
236 : | interpolate8x8_avg4 = interpolate8x8_avg4_c; | ||
237 : | |||
238 : | suxen_drol | 1.33.2.15 | /* reduced resoltuion */ |
239 : | |||
240 : | suxen_drol | 1.33.2.17 | copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
241 : | add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; | ||
242 : | suxen_drol | 1.33.2.15 | #ifdef ARCH_X86 |
243 : | vfilter_31 = xvid_VFilter_31_x86; | ||
244 : | hfilter_31 = xvid_HFilter_31_x86; | ||
245 : | #else | ||
246 : | vfilter_31 = xvid_VFilter_31_C; | ||
247 : | hfilter_31 = xvid_HFilter_31_C; | ||
248 : | #endif | ||
249 : | suxen_drol | 1.33.2.17 | filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
250 : | filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; | ||
251 : | suxen_drol | 1.33.2.15 | |
252 : | edgomez | 1.16 | /* Initialize internal colorspace transformation tables */ |
253 : | Isibaar | 1.1 | colorspace_init(); |
254 : | |||
255 : | edgomez | 1.16 | /* All colorspace transformation functions User Format->YV12 */ |
256 : | suxen_drol | 1.33.2.11 | yv12_to_yv12 = yv12_to_yv12_c; |
257 : | rgb555_to_yv12 = rgb555_to_yv12_c; | ||
258 : | rgb565_to_yv12 = rgb565_to_yv12_c; | ||
259 : | bgr_to_yv12 = bgr_to_yv12_c; | ||
260 : | bgra_to_yv12 = bgra_to_yv12_c; | ||
261 : | abgr_to_yv12 = abgr_to_yv12_c; | ||
262 : | rgba_to_yv12 = rgba_to_yv12_c; | ||
263 : | yuyv_to_yv12 = yuyv_to_yv12_c; | ||
264 : | uyvy_to_yv12 = uyvy_to_yv12_c; | ||
265 : | |||
266 : | rgb555i_to_yv12 = rgb555i_to_yv12_c; | ||
267 : | rgb565i_to_yv12 = rgb565i_to_yv12_c; | ||
268 : | bgri_to_yv12 = bgri_to_yv12_c; | ||
269 : | bgrai_to_yv12 = bgrai_to_yv12_c; | ||
270 : | abgri_to_yv12 = abgri_to_yv12_c; | ||
271 : | rgbai_to_yv12 = rgbai_to_yv12_c; | ||
272 : | yuyvi_to_yv12 = yuyvi_to_yv12_c; | ||
273 : | uyvyi_to_yv12 = uyvyi_to_yv12_c; | ||
274 : | |||
275 : | Isibaar | 1.1 | |
276 : | edgomez | 1.16 | /* All colorspace transformation functions YV12->User format */ |
277 : | suxen_drol | 1.33.2.11 | yv12_to_rgb555 = yv12_to_rgb555_c; |
278 : | yv12_to_rgb565 = yv12_to_rgb565_c; | ||
279 : | yv12_to_bgr = yv12_to_bgr_c; | ||
280 : | yv12_to_bgra = yv12_to_bgra_c; | ||
281 : | yv12_to_abgr = yv12_to_abgr_c; | ||
282 : | yv12_to_rgba = yv12_to_rgba_c; | ||
283 : | yv12_to_yuyv = yv12_to_yuyv_c; | ||
284 : | yv12_to_uyvy = yv12_to_uyvy_c; | ||
285 : | |||
286 : | yv12_to_rgb555i = yv12_to_rgb555i_c; | ||
287 : | yv12_to_rgb565i = yv12_to_rgb565i_c; | ||
288 : | yv12_to_bgri = yv12_to_bgri_c; | ||
289 : | yv12_to_bgrai = yv12_to_bgrai_c; | ||
290 : | yv12_to_abgri = yv12_to_abgri_c; | ||
291 : | yv12_to_rgbai = yv12_to_rgbai_c; | ||
292 : | yv12_to_yuyvi = yv12_to_yuyvi_c; | ||
293 : | yv12_to_uyvyi = yv12_to_uyvyi_c; | ||
294 : | Isibaar | 1.1 | |
295 : | edgomez | 1.16 | /* Functions used in motion estimation algorithms */ |
296 : | Isibaar | 1.1 | calc_cbp = calc_cbp_c; |
297 : | edgomez | 1.16 | sad16 = sad16_c; |
298 : | suxen_drol | 1.33 | sad8 = sad8_c; |
299 : | edgomez | 1.16 | sad16bi = sad16bi_c; |
300 : | suxen_drol | 1.33 | sad8bi = sad8bi_c; |
301 : | edgomez | 1.16 | dev16 = dev16_c; |
302 : | chl | 1.33.2.1 | sad16v = sad16v_c; |
303 : | suxen_drol | 1.33 | |
304 : | chl | 1.33.2.1 | // Halfpel8_Refine = Halfpel8_Refine_c; |
305 : | Isibaar | 1.1 | |
306 : | #ifdef ARCH_X86 | ||
307 : | suxen_drol | 1.33.2.11 | |
308 : | if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || | ||
309 : | (cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || | ||
310 : | (cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2)) | ||
311 : | { | ||
312 : | /* Restore FPU context : emms_c is a nop functions */ | ||
313 : | emms = emms_mmx; | ||
314 : | } | ||
315 : | |||
316 : | edgomez | 1.15 | if ((cpu_flags & XVID_CPU_MMX) > 0) { |
317 : | edgomez | 1.16 | |
318 : | /* Forward and Inverse Discrete Cosine Transformation functions */ | ||
319 : | Isibaar | 1.1 | fdct = fdct_mmx; |
320 : | idct = idct_mmx; | ||
321 : | |||
322 : | edgomez | 1.16 | /* Quantization related functions */ |
323 : | quant_intra = quant_intra_mmx; | ||
324 : | Isibaar | 1.1 | dequant_intra = dequant_intra_mmx; |
325 : | edgomez | 1.16 | quant_inter = quant_inter_mmx; |
326 : | Isibaar | 1.1 | dequant_inter = dequant_inter_mmx; |
327 : | |||
328 : | edgomez | 1.16 | quant4_intra = quant4_intra_mmx; |
329 : | Isibaar | 1.1 | dequant4_intra = dequant4_intra_mmx; |
330 : | edgomez | 1.16 | quant4_inter = quant4_inter_mmx; |
331 : | Isibaar | 1.1 | dequant4_inter = dequant4_inter_mmx; |
332 : | |||
333 : | edgomez | 1.16 | /* Block related functions */ |
334 : | Isibaar | 1.1 | transfer_8to16copy = transfer_8to16copy_mmx; |
335 : | transfer_16to8copy = transfer_16to8copy_mmx; | ||
336 : | edgomez | 1.16 | transfer_8to16sub = transfer_8to16sub_mmx; |
337 : | edgomez | 1.22 | transfer_8to16sub2 = transfer_8to16sub2_mmx; |
338 : | edgomez | 1.16 | transfer_16to8add = transfer_16to8add_mmx; |
339 : | transfer8x8_copy = transfer8x8_copy_mmx; | ||
340 : | edgomez | 1.22 | |
341 : | h | 1.33.2.5 | /* Interlacing Functions */ |
342 : | MBFieldTest = MBFieldTest_mmx; | ||
343 : | edgomez | 1.16 | |
344 : | /* Image Interpolation related functions */ | ||
345 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; | ||
346 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; | ||
347 : | Isibaar | 1.1 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
348 : | Isibaar | 1.33.2.6 | |
349 : | interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; | ||
350 : | interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; | ||
351 : | |||
352 : | Isibaar | 1.33.2.14 | interpolate8x8_avg2 = interpolate8x8_avg2_mmx; |
353 : | Isibaar | 1.33.2.6 | interpolate8x8_avg4 = interpolate8x8_avg4_mmx; |
354 : | Isibaar | 1.1 | |
355 : | suxen_drol | 1.33.2.15 | /* reduced resolution */ |
356 : | copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx; | ||
357 : | add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx; | ||
358 : | hfilter_31 = xvid_HFilter_31_mmx; | ||
359 : | suxen_drol | 1.33.2.17 | filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx; |
360 : | filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx; | ||
361 : | suxen_drol | 1.33.2.15 | |
362 : | suxen_drol | 1.33.2.11 | /* image input xxx_to_yv12 related functions */ |
363 : | yv12_to_yv12 = yv12_to_yv12_mmx; | ||
364 : | bgr_to_yv12 = bgr_to_yv12_mmx; | ||
365 : | bgra_to_yv12 = bgra_to_yv12_mmx; | ||
366 : | edgomez | 1.16 | yuyv_to_yv12 = yuyv_to_yv12_mmx; |
367 : | uyvy_to_yv12 = uyvy_to_yv12_mmx; | ||
368 : | Isibaar | 1.1 | |
369 : | suxen_drol | 1.33.2.11 | /* image output yv12_to_xxx related functions */ |
370 : | yv12_to_bgr = yv12_to_bgr_mmx; | ||
371 : | yv12_to_bgra = yv12_to_bgra_mmx; | ||
372 : | edgomez | 1.16 | yv12_to_yuyv = yv12_to_yuyv_mmx; |
373 : | yv12_to_uyvy = yv12_to_uyvy_mmx; | ||
374 : | suxen_drol | 1.33.2.11 | |
375 : | yv12_to_yuyvi = yv12_to_yuyvi_mmx; | ||
376 : | yv12_to_uyvyi = yv12_to_uyvyi_mmx; | ||
377 : | Isibaar | 1.1 | |
378 : | edgomez | 1.16 | /* Motion estimation related functions */ |
379 : | Isibaar | 1.1 | calc_cbp = calc_cbp_mmx; |
380 : | edgomez | 1.16 | sad16 = sad16_mmx; |
381 : | sad8 = sad8_mmx; | ||
382 : | suxen_drol | 1.33 | sad16bi = sad16bi_mmx; |
383 : | sad8bi = sad8bi_mmx; | ||
384 : | edgomez | 1.16 | dev16 = dev16_mmx; |
385 : | Isibaar | 1.33.2.2 | sad16v = sad16v_mmx; |
386 : | Isibaar | 1.1 | |
387 : | } | ||
388 : | |||
389 : | suxen_drol | 1.33 | /* these 3dnow functions are faster than mmx, but slower than xmm. */ |
390 : | if ((cpu_flags & XVID_CPU_3DNOW) > 0) { | ||
391 : | |||
392 : | /* ME functions */ | ||
393 : | sad16bi = sad16bi_3dn; | ||
394 : | sad8bi = sad8bi_3dn; | ||
395 : | suxen_drol | 1.33.2.11 | |
396 : | yuyv_to_yv12 = yuyv_to_yv12_3dn; | ||
397 : | uyvy_to_yv12 = uyvy_to_yv12_3dn; | ||
398 : | suxen_drol | 1.33 | } |
399 : | |||
400 : | |||
401 : | edgomez | 1.15 | if ((cpu_flags & XVID_CPU_MMXEXT) > 0) { |
402 : | edgomez | 1.16 | |
403 : | /* Inverse DCT */ | ||
404 : | Isibaar | 1.1 | idct = idct_xmm; |
405 : | edgomez | 1.16 | |
406 : | /* Interpolation */ | ||
407 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_xmm; | ||
408 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; | ||
409 : | h | 1.3 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
410 : | suxen_drol | 1.33.2.15 | |
411 : | /* reduced resolution */ | ||
412 : | copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm; | ||
413 : | add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm; | ||
414 : | Isibaar | 1.25 | |
415 : | chenm001 | 1.29 | /* Quantization */ |
416 : | Isibaar | 1.33.2.18 | quant4_intra = quant4_intra_xmm; |
417 : | quant4_inter = quant4_inter_xmm; | ||
418 : | |||
419 : | chenm001 | 1.29 | dequant_intra = dequant_intra_xmm; |
420 : | dequant_inter = dequant_inter_xmm; | ||
421 : | |||
422 : | edgomez | 1.19 | /* Buffer transfer */ |
423 : | transfer_8to16sub2 = transfer_8to16sub2_xmm; | ||
424 : | edgomez | 1.16 | |
425 : | /* Colorspace transformation */ | ||
426 : | suxen_drol | 1.33.2.11 | yv12_to_yv12 = yv12_to_yv12_xmm; |
427 : | yuyv_to_yv12 = yuyv_to_yv12_xmm; | ||
428 : | Isibaar | 1.33.2.12 | uyvy_to_yv12 = uyvy_to_yv12_xmm; |
429 : | Isibaar | 1.1 | |
430 : | edgomez | 1.16 | /* ME functions */ |
431 : | Isibaar | 1.1 | sad16 = sad16_xmm; |
432 : | suxen_drol | 1.33 | sad8 = sad8_xmm; |
433 : | chenm001 | 1.29 | sad16bi = sad16bi_xmm; |
434 : | suxen_drol | 1.33 | sad8bi = sad8bi_xmm; |
435 : | Isibaar | 1.1 | dev16 = dev16_xmm; |
436 : | chl | 1.33.2.1 | sad16v = sad16v_xmm; |
437 : | Isibaar | 1.1 | } |
438 : | |||
439 : | edgomez | 1.15 | if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
440 : | edgomez | 1.16 | |
441 : | /* Interpolation */ | ||
442 : | Isibaar | 1.1 | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
443 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dn; | ||
444 : | h | 1.4 | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
445 : | Isibaar | 1.1 | } |
446 : | Isibaar | 1.33.2.18 | |
447 : | if ((cpu_flags & XVID_CPU_3DNOWEXT) > 0) { | ||
448 : | |||
449 : | /* Inverse DCT */ | ||
450 : | idct = idct_3dne; | ||
451 : | |||
452 : | /* Buffer transfer */ | ||
453 : | transfer_8to16copy = transfer_8to16copy_3dne; | ||
454 : | transfer_16to8copy = transfer_16to8copy_3dne; | ||
455 : | transfer_8to16sub = transfer_8to16sub_3dne; | ||
456 : | transfer_8to16sub2 = transfer_8to16sub2_3dne; | ||
457 : | transfer_16to8add = transfer_16to8add_3dne; | ||
458 : | transfer8x8_copy = transfer8x8_copy_3dne; | ||
459 : | |||
460 : | /* Quantization */ | ||
461 : | dequant4_intra = dequant4_intra_3dne; | ||
462 : | dequant4_inter = dequant4_inter_3dne; | ||
463 : | quant_intra = quant_intra_3dne; | ||
464 : | quant_inter = quant_inter_3dne; | ||
465 : | dequant_intra = dequant_intra_3dne; | ||
466 : | dequant_inter = dequant_inter_3dne; | ||
467 : | |||
468 : | /* ME functions */ | ||
469 : | calc_cbp = calc_cbp_3dne; | ||
470 : | sad16 = sad16_3dne; | ||
471 : | sad8 = sad8_3dne; | ||
472 : | sad16bi = sad16bi_3dne; | ||
473 : | sad8bi = sad8bi_3dne; | ||
474 : | dev16 = dev16_3dne; | ||
475 : | |||
476 : | /* Interpolation */ | ||
477 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dne; | ||
478 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dne; | ||
479 : | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne; | ||
480 : | } | ||
481 : | |||
482 : | Isibaar | 1.1 | |
483 : | edgomez | 1.15 | if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
484 : | Isibaar | 1.14 | #ifdef EXPERIMENTAL_SSE2_CODE |
485 : | edgomez | 1.16 | |
486 : | chenm001 | 1.29 | calc_cbp = calc_cbp_sse2; |
487 : | |||
488 : | edgomez | 1.16 | /* Quantization */ |
489 : | quant_intra = quant_intra_sse2; | ||
490 : | Isibaar | 1.14 | dequant_intra = dequant_intra_sse2; |
491 : | edgomez | 1.16 | quant_inter = quant_inter_sse2; |
492 : | Isibaar | 1.14 | dequant_inter = dequant_inter_sse2; |
493 : | h | 1.13 | |
494 : | edgomez | 1.16 | /* ME */ |
495 : | sad16 = sad16_sse2; | ||
496 : | dev16 = dev16_sse2; | ||
497 : | |||
498 : | /* Forward and Inverse DCT */ | ||
499 : | idct = idct_sse2; | ||
500 : | Isibaar | 1.14 | fdct = fdct_sse2; |
501 : | #endif | ||
502 : | h | 1.12 | } |
503 : | edgomez | 1.16 | |
504 : | Isibaar | 1.1 | #endif |
505 : | Isibaar | 1.18 | |
506 : | #ifdef ARCH_IA64 | ||
507 : | if ((cpu_flags & XVID_CPU_IA64) > 0) { //use assembler routines? | ||
508 : | idct_ia64_init(); | ||
509 : | fdct = fdct_ia64; | ||
510 : | idct = idct_ia64; //not yet working, crashes | ||
511 : | interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64; | ||
512 : | interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64; | ||
513 : | interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64; | ||
514 : | sad16 = sad16_ia64; | ||
515 : | sad16bi = sad16bi_ia64; | ||
516 : | sad8 = sad8_ia64; | ||
517 : | dev16 = dev16_ia64; | ||
518 : | chl | 1.33.2.1 | // Halfpel8_Refine = Halfpel8_Refine_ia64; |
519 : | Isibaar | 1.18 | quant_intra = quant_intra_ia64; |
520 : | dequant_intra = dequant_intra_ia64; | ||
521 : | quant_inter = quant_inter_ia64; | ||
522 : | dequant_inter = dequant_inter_ia64; | ||
523 : | transfer_8to16copy = transfer_8to16copy_ia64; | ||
524 : | transfer_16to8copy = transfer_16to8copy_ia64; | ||
525 : | transfer_8to16sub = transfer_8to16sub_ia64; | ||
526 : | transfer_8to16sub2 = transfer_8to16sub2_ia64; | ||
527 : | transfer_16to8add = transfer_16to8add_ia64; | ||
528 : | transfer8x8_copy = transfer8x8_copy_ia64; | ||
529 : | DEBUG("Using IA-64 assembler routines.\n"); | ||
530 : | } | ||
531 : | #endif | ||
532 : | edgomez | 1.16 | |
533 : | canard | 1.5 | #ifdef ARCH_PPC |
534 : | canard | 1.6 | #ifdef ARCH_PPC_ALTIVEC |
535 : | calc_cbp = calc_cbp_altivec; | ||
536 : | canard | 1.7 | fdct = fdct_altivec; |
537 : | idct = idct_altivec; | ||
538 : | canard | 1.10 | sadInit = sadInit_altivec; |
539 : | canard | 1.8 | sad16 = sad16_altivec; |
540 : | sad8 = sad8_altivec; | ||
541 : | dev16 = dev16_altivec; | ||
542 : | canard | 1.6 | #else |
543 : | canard | 1.5 | calc_cbp = calc_cbp_ppc; |
544 : | canard | 1.6 | #endif |
545 : | canard | 1.5 | #endif |
546 : | Isibaar | 1.1 | |
547 : | return XVID_ERR_OK; | ||
548 : | suxen_drol | 1.33.2.13 | } |
549 : | |||
550 : | |||
551 : | |||
552 : | static int | ||
553 : | xvid_init_convert(XVID_INIT_CONVERTINFO* convert) | ||
554 : | { | ||
555 : | suxen_drol | 1.33.2.16 | // const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); |
556 : | suxen_drol | 1.33.2.13 | const int width = convert->width; |
557 : | const int height = convert->height; | ||
558 : | const int width2 = convert->width/2; | ||
559 : | const int height2 = convert->height/2; | ||
560 : | IMAGE img; | ||
561 : | |||
562 : | switch (convert->input.colorspace & ~XVID_CSP_VFLIP) | ||
563 : | { | ||
564 : | case XVID_CSP_YV12 : | ||
565 : | img.y = convert->input.y; | ||
566 : | img.v = (uint8_t*)convert->input.y + width*height; | ||
567 : | img.u = (uint8_t*)convert->input.y + width*height + width2*height2; | ||
568 : | image_output(&img, width, height, width, | ||
569 : | convert->output.y, convert->output.y_stride, | ||
570 : | convert->output.colorspace, convert->interlacing); | ||
571 : | break; | ||
572 : | |||
573 : | default : | ||
574 : | return XVID_ERR_FORMAT; | ||
575 : | } | ||
576 : | |||
577 : | |||
578 : | emms(); | ||
579 : | return XVID_ERR_OK; | ||
580 : | } | ||
581 : | |||
582 : | |||
583 : | suxen_drol | 1.33.2.19 | |
584 : | void fill8(uint8_t * block, int size, int value) | ||
585 : | { | ||
586 : | int i; | ||
587 : | for (i = 0; i < size; i++) | ||
588 : | block[i] = value; | ||
589 : | } | ||
590 : | |||
591 : | void fill16(int16_t * block, int size, int value) | ||
592 : | { | ||
593 : | int i; | ||
594 : | for (i = 0; i < size; i++) | ||
595 : | block[i] = value; | ||
596 : | } | ||
597 : | |||
598 : | #define RANDOM(min,max) min + (rand() % (max-min)) | ||
599 : | |||
600 : | void random8(uint8_t * block, int size, int min, int max) | ||
601 : | { | ||
602 : | int i; | ||
603 : | for (i = 0; i < size; i++) | ||
604 : | block[i] = RANDOM(min,max); | ||
605 : | } | ||
606 : | |||
607 : | void random16(int16_t * block, int size, int min, int max) | ||
608 : | { | ||
609 : | int i; | ||
610 : | for (i = 0; i < size; i++) | ||
611 : | block[i] = RANDOM(min,max); | ||
612 : | } | ||
613 : | |||
614 : | int compare16(const int16_t * blockA, const int16_t * blockB, int size) | ||
615 : | { | ||
616 : | int i; | ||
617 : | for (i = 0; i < size; i++) | ||
618 : | if (blockA[i] != blockB[i]) | ||
619 : | return 1; | ||
620 : | |||
621 : | return 0; | ||
622 : | } | ||
623 : | |||
624 : | |||
625 : | |||
626 : | int test_h263_intra(quanth263_intraFunc * funcA, quanth263_intraFunc * funcB, | ||
627 : | const char * nameA, const char * nameB, | ||
628 : | int min, int max) | ||
629 : | { | ||
630 : | int q,i; | ||
631 : | int64_t timeSTART; | ||
632 : | int64_t timeA = 0; | ||
633 : | int64_t timeB = 0; | ||
634 : | DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE); | ||
635 : | DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); | ||
636 : | DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); | ||
637 : | |||
638 : | for (q = 1; q <= 31; q++) /* quantizer */ | ||
639 : | { | ||
640 : | for (i = min; i < max; i++) /* input coeff */ | ||
641 : | { | ||
642 : | fill16(arrayX, 64, i); | ||
643 : | |||
644 : | timeSTART = read_counter(); | ||
645 : | funcA(arrayA, arrayX, q, q); | ||
646 : | timeA += read_counter() - timeSTART; | ||
647 : | |||
648 : | timeSTART = read_counter(); | ||
649 : | funcB(arrayB, arrayX, q, q); | ||
650 : | timeB += read_counter() - timeSTART; | ||
651 : | |||
652 : | if (compare16(arrayA, arrayB, 64)) | ||
653 : | { | ||
654 : | printf("%s/%s error: q=%i, i=%i\n", nameA?nameA:"?", nameB?nameB:"?", q, i); | ||
655 : | return 0; | ||
656 : | } | ||
657 : | } | ||
658 : | } | ||
659 : | |||
660 : | if (nameA) printf("%s:\t%I64i\n", nameA, timeA); | ||
661 : | if (nameB) printf("%s:\t%I64i\n", nameB, timeB); | ||
662 : | |||
663 : | return 0; | ||
664 : | } | ||
665 : | |||
666 : | int test_h263_inter(quanth263_interFunc * funcA, quanth263_interFunc * funcB, | ||
667 : | const char * nameA, const char * nameB, | ||
668 : | int min, int max) | ||
669 : | { | ||
670 : | int q,i; | ||
671 : | int64_t timeSTART; | ||
672 : | int64_t timeA = 0; | ||
673 : | int64_t timeB = 0; | ||
674 : | DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE); | ||
675 : | DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); | ||
676 : | DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); | ||
677 : | |||
678 : | for (q = 1; q <= 31; q++) /* quantizer */ | ||
679 : | { | ||
680 : | for (i = min; i < max; i++) /* input coeff */ | ||
681 : | { | ||
682 : | fill16(arrayX, 64, i); | ||
683 : | |||
684 : | timeSTART = read_counter(); | ||
685 : | funcA(arrayA, arrayX, q); | ||
686 : | timeA += read_counter() - timeSTART; | ||
687 : | |||
688 : | timeSTART = read_counter(); | ||
689 : | funcB(arrayB, arrayX, q); | ||
690 : | timeB += read_counter() - timeSTART; | ||
691 : | |||
692 : | if (compare16(arrayA, arrayB, 64)) | ||
693 : | { | ||
694 : | printf("%s/%s error: q=%i, i=%i\n", nameA?nameA:"?", nameB?nameB:"?", q, i); | ||
695 : | return 0; | ||
696 : | } | ||
697 : | } | ||
698 : | } | ||
699 : | |||
700 : | if (nameA) printf("%s:\t%I64i\n", nameA, timeA); | ||
701 : | if (nameB) printf("%s:\t%I64i\n", nameB, timeB); | ||
702 : | |||
703 : | return 0; | ||
704 : | } | ||
705 : | |||
706 : | |||
707 : | |||
708 : | int xvid_init_test() | ||
709 : | { | ||
710 : | int cpu_flags; | ||
711 : | |||
712 : | printf("xvid_init_test\n"); | ||
713 : | |||
714 : | #if defined(ARCH_X86) | ||
715 : | cpu_flags = check_cpu_features(); | ||
716 : | |||
717 : | emms_mmx(); | ||
718 : | |||
719 : | printf("--- quant intra ---\n"); | ||
720 : | if (cpu_flags & XVID_CPU_MMX) | ||
721 : | test_h263_intra(quant_intra_c, quant_intra_mmx, "c", "mmx", -2048, 2047); | ||
722 : | if (cpu_flags & XVID_CPU_3DNOWEXT) | ||
723 : | test_h263_intra(quant_intra_c, quant_intra_3dne, NULL, "3dne", -2048, 2047); | ||
724 : | if (cpu_flags & XVID_CPU_SSE2) | ||
725 : | test_h263_intra(quant_intra_c, quant_intra_sse2, NULL, "sse2", -2048, 2047); | ||
726 : | |||
727 : | printf("\n--- quant inter ---\n"); | ||
728 : | if (cpu_flags & XVID_CPU_MMX) | ||
729 : | test_h263_inter(quant_inter_c, quant_inter_mmx, "c", "mmx", -2048, 2047); | ||
730 : | if (cpu_flags & XVID_CPU_3DNOWEXT) | ||
731 : | test_h263_inter(quant_inter_c, quant_inter_3dne, NULL, "3dne", -2048, 2047); | ||
732 : | if (cpu_flags & XVID_CPU_SSE2) | ||
733 : | test_h263_inter(quant_inter_c, quant_inter_sse2, NULL, "sse2", -2048, 2047); | ||
734 : | |||
735 : | printf("\n--- dequan intra ---\n"); | ||
736 : | if (cpu_flags & XVID_CPU_MMX) | ||
737 : | test_h263_intra(dequant_intra_c, dequant_intra_mmx, "c", "mmx", -256, 255); | ||
738 : | if (cpu_flags & XVID_CPU_MMXEXT) | ||
739 : | test_h263_intra(dequant_intra_c, dequant_intra_xmm, NULL, "xmm", -256, 255); | ||
740 : | if (cpu_flags & XVID_CPU_3DNOWEXT) | ||
741 : | test_h263_intra(dequant_intra_c, dequant_intra_3dne, NULL, "3dne", -256, 255); | ||
742 : | if (cpu_flags & XVID_CPU_SSE2) | ||
743 : | test_h263_intra(dequant_intra_c, dequant_intra_sse2, NULL, "sse2", -256, 255); | ||
744 : | |||
745 : | printf("\n--- dequant inter ---\n"); | ||
746 : | if (cpu_flags & XVID_CPU_MMX) | ||
747 : | test_h263_inter((quanth263_interFunc*)dequant_inter_c, | ||
748 : | (quanth263_interFunc*)dequant_inter_mmx, "c", "mmx", -256, 255); | ||
749 : | |||
750 : | if (cpu_flags & XVID_CPU_MMXEXT) | ||
751 : | test_h263_inter((quanth263_interFunc*)dequant_inter_c, | ||
752 : | (quanth263_interFunc*)dequant_inter_xmm, NULL, "xmm", -256, 255); | ||
753 : | if (cpu_flags & XVID_CPU_3DNOWEXT) | ||
754 : | test_h263_inter((quanth263_interFunc*)dequant_inter_c, | ||
755 : | (quanth263_interFunc*)dequant_inter_3dne, NULL, "3dne", -256, 255); | ||
756 : | if (cpu_flags & XVID_CPU_SSE2) | ||
757 : | test_h263_inter((quanth263_interFunc*)dequant_inter_c, | ||
758 : | (quanth263_interFunc*)dequant_inter_sse2, NULL, "sse2", -256, 255); | ||
759 : | |||
760 : | printf("\n--- quant4_intra ---\n"); | ||
761 : | if (cpu_flags & XVID_CPU_MMX) | ||
762 : | test_h263_intra((quanth263_intraFunc*)quant4_intra_c, | ||
763 : | (quanth263_intraFunc*)quant4_intra_mmx, "c", "mmx", -2048, 2047); | ||
764 : | if (cpu_flags & XVID_CPU_MMXEXT) | ||
765 : | test_h263_intra((quanth263_intraFunc*)quant4_intra_c, | ||
766 : | (quanth263_intraFunc*)quant4_intra_xmm, NULL, "xmm", -2048, 2047); | ||
767 : | |||
768 : | printf("\n--- quant4_inter ---\n"); | ||
769 : | if (cpu_flags & XVID_CPU_MMX) | ||
770 : | test_h263_inter((quanth263_interFunc*)quant4_inter_c, | ||
771 : | (quanth263_interFunc*)quant4_inter_mmx, "c", "mmx", -2048, 2047); | ||
772 : | if (cpu_flags & XVID_CPU_MMXEXT) | ||
773 : | test_h263_inter((quanth263_interFunc*)quant4_inter_c, | ||
774 : | (quanth263_interFunc*)quant4_inter_xmm, NULL, "xmm", -2048, 2047); | ||
775 : | |||
776 : | |||
777 : | printf("\n--- dequant4_intra ---\n"); | ||
778 : | if (cpu_flags & XVID_CPU_MMX) | ||
779 : | test_h263_intra((quanth263_intraFunc*)dequant4_intra_c, | ||
780 : | (quanth263_intraFunc*)dequant4_intra_mmx, "c", "mmx", -256, 255); | ||
781 : | if (cpu_flags & XVID_CPU_3DNOWEXT) | ||
782 : | test_h263_intra((quanth263_intraFunc*)dequant4_intra_c, | ||
783 : | (quanth263_intraFunc*)dequant4_intra_3dne, NULL, "sse2", -256, 255); | ||
784 : | |||
785 : | printf("\n--- dequant4_inter ---\n"); | ||
786 : | if (cpu_flags & XVID_CPU_MMX) | ||
787 : | test_h263_inter((quanth263_interFunc*)dequant4_inter_c, | ||
788 : | (quanth263_interFunc*)dequant4_inter_mmx, "c", "mmx", -256, 255); | ||
789 : | if (cpu_flags & XVID_CPU_3DNOWEXT) | ||
790 : | test_h263_inter((quanth263_interFunc*)dequant4_inter_c, | ||
791 : | (quanth263_interFunc*)dequant4_inter_3dne, NULL, "sse2", -256, 255); | ||
792 : | |||
793 : | emms_mmx(); | ||
794 : | |||
795 : | #endif | ||
796 : | |||
797 : | return XVID_ERR_OK; | ||
798 : | } | ||
799 : | |||
800 : | |||
801 : | suxen_drol | 1.33.2.13 | int |
802 : | xvid_init(void *handle, | ||
803 : | int opt, | ||
804 : | void *param1, | ||
805 : | void *param2) | ||
806 : | { | ||
807 : | switch(opt) | ||
808 : | { | ||
809 : | case XVID_INIT_INIT : | ||
810 : | return xvid_init_init((XVID_INIT_PARAM*)param1); | ||
811 : | |||
812 : | case XVID_INIT_CONVERT : | ||
813 : | return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); | ||
814 : | suxen_drol | 1.33.2.19 | |
815 : | case XVID_INIT_TEST : | ||
816 : | return xvid_init_test(); | ||
817 : | suxen_drol | 1.33.2.13 | |
818 : | default : | ||
819 : | return XVID_ERR_FAIL; | ||
820 : | } | ||
821 : | Isibaar | 1.1 | } |
822 : | |||
823 : | edgomez | 1.16 | /***************************************************************************** |
824 : | * XviD Native decoder entry point | ||
825 : | * | ||
826 : | * This function is just a wrapper to all the option cases. | ||
827 : | * | ||
828 : | * Returned values : XVID_ERR_FAIL when opt is invalid | ||
829 : | * else returns the wrapped function result | ||
830 : | * | ||
831 : | ****************************************************************************/ | ||
832 : | |||
833 : | edgomez | 1.15 | int |
834 : | xvid_decore(void *handle, | ||
835 : | int opt, | ||
836 : | void *param1, | ||
837 : | void *param2) | ||
838 : | Isibaar | 1.1 | { |
839 : | edgomez | 1.15 | switch (opt) { |
840 : | case XVID_DEC_DECODE: | ||
841 : | suxen_drol | 1.33.2.11 | return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2); |
842 : | edgomez | 1.15 | |
843 : | case XVID_DEC_CREATE: | ||
844 : | chenm001 | 1.29 | return decoder_create((XVID_DEC_PARAM *) param1); |
845 : | edgomez | 1.15 | |
846 : | case XVID_DEC_DESTROY: | ||
847 : | return decoder_destroy((DECODER *) handle); | ||
848 : | Isibaar | 1.1 | |
849 : | default: | ||
850 : | edgomez | 1.15 | return XVID_ERR_FAIL; |
851 : | } | ||
852 : | Isibaar | 1.1 | } |
853 : | |||
854 : | edgomez | 1.16 | |
855 : | /***************************************************************************** | ||
856 : | * XviD Native encoder entry point | ||
857 : | * | ||
858 : | * This function is just a wrapper to all the option cases. | ||
859 : | * | ||
860 : | * Returned values : XVID_ERR_FAIL when opt is invalid | ||
861 : | * else returns the wrapped function result | ||
862 : | * | ||
863 : | ****************************************************************************/ | ||
864 : | Isibaar | 1.1 | |
865 : | edgomez | 1.15 | int |
866 : | xvid_encore(void *handle, | ||
867 : | int opt, | ||
868 : | void *param1, | ||
869 : | void *param2) | ||
870 : | Isibaar | 1.1 | { |
871 : | edgomez | 1.15 | switch (opt) { |
872 : | case XVID_ENC_ENCODE: | ||
873 : | chl | 1.33.2.10 | |
874 : | suxen_drol | 1.20 | if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
875 : | return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, | ||
876 : | (XVID_ENC_STATS *) param2); | ||
877 : | else | ||
878 : | edgomez | 1.15 | return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
879 : | (XVID_ENC_STATS *) param2); | ||
880 : | |||
881 : | case XVID_ENC_CREATE: | ||
882 : | return encoder_create((XVID_ENC_PARAM *) param1); | ||
883 : | |||
884 : | case XVID_ENC_DESTROY: | ||
885 : | return encoder_destroy((Encoder *) handle); | ||
886 : | Isibaar | 1.1 | |
887 : | default: | ||
888 : | edgomez | 1.15 | return XVID_ERR_FAIL; |
889 : | } | ||
890 : | Isibaar | 1.1 | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |