[cvs] / xvidcore / src / xvid.c Repository:
ViewVC logotype

Annotation of /xvidcore/src/xvid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.42 - (view) (download)

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

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