27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
****************************************************************************/ |
****************************************************************************/ |
30 |
|
|
31 |
/***************************************************************************** |
/***************************************************************************** |
32 |
* |
* |
33 |
* History |
* History |
37 |
* - 22.12.2001 API change: added xvid_init() - Isibaar |
* - 22.12.2001 API change: added xvid_init() - Isibaar |
38 |
* - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
* - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
39 |
* |
* |
40 |
* $Id: xvid.c,v 1.23 2002-06-26 15:59:51 ia64p Exp $ |
* $Id: xvid.c,v 1.33.2.17 2002-12-09 10:47:05 suxen_drol Exp $ |
41 |
* |
* |
42 |
****************************************************************************/ |
****************************************************************************/ |
43 |
|
|
49 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
50 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
51 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
52 |
|
#include "image/reduced.h" |
53 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
54 |
|
#include "utils/mbfunctions.h" |
55 |
#include "quant/quant_h263.h" |
#include "quant/quant_h263.h" |
56 |
#include "quant/quant_mpeg4.h" |
#include "quant/quant_mpeg4.h" |
57 |
|
#include "motion/motion.h" |
58 |
#include "motion/sad.h" |
#include "motion/sad.h" |
59 |
#include "utils/emms.h" |
#include "utils/emms.h" |
60 |
#include "utils/timer.h" |
#include "utils/timer.h" |
61 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
62 |
|
|
63 |
|
#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 |
/***************************************************************************** |
/***************************************************************************** |
131 |
* XviD Init Entry point |
* XviD Init Entry point |
132 |
* |
* |
141 |
* |
* |
142 |
****************************************************************************/ |
****************************************************************************/ |
143 |
|
|
144 |
int |
|
145 |
xvid_init(void *handle, |
static |
146 |
int opt, |
int xvid_init_init(XVID_INIT_PARAM * init_param) |
|
void *param1, |
|
|
void *param2) |
|
147 |
{ |
{ |
148 |
int cpu_flags; |
int cpu_flags; |
|
XVID_INIT_PARAM *init_param; |
|
|
|
|
|
init_param = (XVID_INIT_PARAM *) param1; |
|
149 |
|
|
150 |
/* Inform the client the API version */ |
/* Inform the client the API version */ |
151 |
init_param->api_version = API_VERSION; |
init_param->api_version = API_VERSION; |
153 |
/* Inform the client the core build - unused because we're still alpha */ |
/* Inform the client the core build - unused because we're still alpha */ |
154 |
init_param->core_build = 1000; |
init_param->core_build = 1000; |
155 |
|
|
|
if ((init_param->cpu_flags & XVID_CPU_CHKONLY)) |
|
|
{ |
|
|
init_param->cpu_flags = check_cpu_features(); |
|
|
return XVID_ERR_OK; |
|
|
} |
|
|
|
|
156 |
/* Do we have to force CPU features ? */ |
/* Do we have to force CPU features ? */ |
157 |
if ((init_param->cpu_flags & XVID_CPU_FORCE) > 0) { |
if ((init_param->cpu_flags & XVID_CPU_FORCE)) { |
158 |
|
|
159 |
cpu_flags = init_param->cpu_flags; |
cpu_flags = init_param->cpu_flags; |
160 |
|
|
161 |
} else { |
} else { |
162 |
|
|
163 |
cpu_flags = check_cpu_features(); |
cpu_flags = check_cpu_features(); |
164 |
|
|
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 |
init_param->cpu_flags = cpu_flags; |
init_param->cpu_flags = cpu_flags; |
177 |
|
return XVID_ERR_OK; |
178 |
} |
} |
179 |
|
|
180 |
|
init_param->cpu_flags = cpu_flags; |
181 |
|
|
182 |
|
|
183 |
/* Initialize the function pointers */ |
/* Initialize the function pointers */ |
184 |
idct_int32_init(); |
idct_int32_init(); |
185 |
init_vlc_tables(); |
init_vlc_tables(); |
213 |
transfer_16to8add = transfer_16to8add_c; |
transfer_16to8add = transfer_16to8add_c; |
214 |
transfer8x8_copy = transfer8x8_copy_c; |
transfer8x8_copy = transfer8x8_copy_c; |
215 |
|
|
216 |
|
/* Interlacing functions */ |
217 |
|
MBFieldTest = MBFieldTest_c; |
218 |
|
|
219 |
/* Image interpolation related functions */ |
/* Image interpolation related functions */ |
220 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
221 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
222 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
223 |
|
|
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 |
|
|
228 |
|
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 |
|
/* reduced resoltuion */ |
239 |
|
|
240 |
|
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
241 |
|
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; |
242 |
|
#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 |
|
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
250 |
|
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; |
251 |
|
|
252 |
/* Initialize internal colorspace transformation tables */ |
/* Initialize internal colorspace transformation tables */ |
253 |
colorspace_init(); |
colorspace_init(); |
254 |
|
|
255 |
/* All colorspace transformation functions User Format->YV12 */ |
/* All colorspace transformation functions User Format->YV12 */ |
256 |
|
yv12_to_yv12 = yv12_to_yv12_c; |
257 |
rgb555_to_yv12 = rgb555_to_yv12_c; |
rgb555_to_yv12 = rgb555_to_yv12_c; |
258 |
rgb565_to_yv12 = rgb565_to_yv12_c; |
rgb565_to_yv12 = rgb565_to_yv12_c; |
259 |
rgb24_to_yv12 = rgb24_to_yv12_c; |
bgr_to_yv12 = bgr_to_yv12_c; |
260 |
rgb32_to_yv12 = rgb32_to_yv12_c; |
bgra_to_yv12 = bgra_to_yv12_c; |
261 |
yuv_to_yv12 = yuv_to_yv12_c; |
abgr_to_yv12 = abgr_to_yv12_c; |
262 |
|
rgba_to_yv12 = rgba_to_yv12_c; |
263 |
yuyv_to_yv12 = yuyv_to_yv12_c; |
yuyv_to_yv12 = yuyv_to_yv12_c; |
264 |
uyvy_to_yv12 = uyvy_to_yv12_c; |
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 |
|
|
276 |
/* All colorspace transformation functions YV12->User format */ |
/* All colorspace transformation functions YV12->User format */ |
277 |
yv12_to_rgb555 = yv12_to_rgb555_c; |
yv12_to_rgb555 = yv12_to_rgb555_c; |
278 |
yv12_to_rgb565 = yv12_to_rgb565_c; |
yv12_to_rgb565 = yv12_to_rgb565_c; |
279 |
yv12_to_rgb24 = yv12_to_rgb24_c; |
yv12_to_bgr = yv12_to_bgr_c; |
280 |
yv12_to_rgb32 = yv12_to_rgb32_c; |
yv12_to_bgra = yv12_to_bgra_c; |
281 |
yv12_to_yuv = yv12_to_yuv_c; |
yv12_to_abgr = yv12_to_abgr_c; |
282 |
|
yv12_to_rgba = yv12_to_rgba_c; |
283 |
yv12_to_yuyv = yv12_to_yuyv_c; |
yv12_to_yuyv = yv12_to_yuyv_c; |
284 |
yv12_to_uyvy = yv12_to_uyvy_c; |
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 |
|
|
295 |
/* Functions used in motion estimation algorithms */ |
/* Functions used in motion estimation algorithms */ |
296 |
calc_cbp = calc_cbp_c; |
calc_cbp = calc_cbp_c; |
297 |
sad16 = sad16_c; |
sad16 = sad16_c; |
|
sad16bi = sad16bi_c; |
|
298 |
sad8 = sad8_c; |
sad8 = sad8_c; |
299 |
|
sad16bi = sad16bi_c; |
300 |
|
sad8bi = sad8bi_c; |
301 |
dev16 = dev16_c; |
dev16 = dev16_c; |
302 |
|
sad16v = sad16v_c; |
303 |
|
|
304 |
|
// Halfpel8_Refine = Halfpel8_Refine_c; |
305 |
|
|
306 |
#ifdef ARCH_X86 |
#ifdef ARCH_X86 |
307 |
|
|
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 |
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
317 |
|
|
318 |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
319 |
fdct = fdct_mmx; |
fdct = fdct_mmx; |
320 |
idct = idct_mmx; |
idct = idct_mmx; |
321 |
|
|
|
/* To restore FPU context after mmx use */ |
|
|
emms = emms_mmx; |
|
|
|
|
322 |
/* Quantization related functions */ |
/* Quantization related functions */ |
323 |
quant_intra = quant_intra_mmx; |
quant_intra = quant_intra_mmx; |
324 |
dequant_intra = dequant_intra_mmx; |
dequant_intra = dequant_intra_mmx; |
338 |
transfer_16to8add = transfer_16to8add_mmx; |
transfer_16to8add = transfer_16to8add_mmx; |
339 |
transfer8x8_copy = transfer8x8_copy_mmx; |
transfer8x8_copy = transfer8x8_copy_mmx; |
340 |
|
|
341 |
|
/* Interlacing Functions */ |
342 |
|
MBFieldTest = MBFieldTest_mmx; |
343 |
|
|
344 |
/* Image Interpolation related functions */ |
/* Image Interpolation related functions */ |
345 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
346 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
347 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
348 |
|
|
349 |
/* Image RGB->YV12 related functions */ |
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; |
350 |
rgb24_to_yv12 = rgb24_to_yv12_mmx; |
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; |
351 |
rgb32_to_yv12 = rgb32_to_yv12_mmx; |
|
352 |
yuv_to_yv12 = yuv_to_yv12_mmx; |
interpolate8x8_avg2 = interpolate8x8_avg2_mmx; |
353 |
|
interpolate8x8_avg4 = interpolate8x8_avg4_mmx; |
354 |
|
|
355 |
|
/* 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 |
|
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx; |
360 |
|
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx; |
361 |
|
|
362 |
|
/* 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 |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
367 |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
368 |
|
|
369 |
/* Image YV12->RGB related functions */ |
/* image output yv12_to_xxx related functions */ |
370 |
yv12_to_rgb24 = yv12_to_rgb24_mmx; |
yv12_to_bgr = yv12_to_bgr_mmx; |
371 |
yv12_to_rgb32 = yv12_to_rgb32_mmx; |
yv12_to_bgra = yv12_to_bgra_mmx; |
372 |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
373 |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
374 |
|
|
375 |
|
yv12_to_yuyvi = yv12_to_yuyvi_mmx; |
376 |
|
yv12_to_uyvyi = yv12_to_uyvyi_mmx; |
377 |
|
|
378 |
/* Motion estimation related functions */ |
/* Motion estimation related functions */ |
379 |
calc_cbp = calc_cbp_mmx; |
calc_cbp = calc_cbp_mmx; |
380 |
sad16 = sad16_mmx; |
sad16 = sad16_mmx; |
381 |
sad8 = sad8_mmx; |
sad8 = sad8_mmx; |
382 |
|
sad16bi = sad16bi_mmx; |
383 |
|
sad8bi = sad8bi_mmx; |
384 |
dev16 = dev16_mmx; |
dev16 = dev16_mmx; |
385 |
|
sad16v = sad16v_mmx; |
386 |
|
|
387 |
|
} |
388 |
|
|
389 |
|
/* 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 |
|
|
396 |
|
yuyv_to_yv12 = yuyv_to_yv12_3dn; |
397 |
|
uyvy_to_yv12 = uyvy_to_yv12_3dn; |
398 |
} |
} |
399 |
|
|
400 |
|
|
401 |
if ((cpu_flags & XVID_CPU_MMXEXT) > 0) { |
if ((cpu_flags & XVID_CPU_MMXEXT) > 0) { |
402 |
|
|
403 |
/* Inverse DCT */ |
/* Inverse DCT */ |
408 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
409 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
410 |
|
|
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 |
|
|
415 |
|
/* Quantization */ |
416 |
|
dequant_intra = dequant_intra_xmm; |
417 |
|
dequant_inter = dequant_inter_xmm; |
418 |
|
|
419 |
/* Buffer transfer */ |
/* Buffer transfer */ |
420 |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
421 |
|
|
422 |
/* Colorspace transformation */ |
/* Colorspace transformation */ |
423 |
yuv_to_yv12 = yuv_to_yv12_xmm; |
yv12_to_yv12 = yv12_to_yv12_xmm; |
424 |
|
yuyv_to_yv12 = yuyv_to_yv12_xmm; |
425 |
|
uyvy_to_yv12 = uyvy_to_yv12_xmm; |
426 |
|
|
427 |
/* ME functions */ |
/* ME functions */ |
428 |
sad16 = sad16_xmm; |
sad16 = sad16_xmm; |
429 |
sad8 = sad8_xmm; |
sad8 = sad8_xmm; |
430 |
|
sad16bi = sad16bi_xmm; |
431 |
|
sad8bi = sad8bi_xmm; |
432 |
dev16 = dev16_xmm; |
dev16 = dev16_xmm; |
433 |
|
sad16v = sad16v_xmm; |
434 |
} |
} |
435 |
|
|
436 |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
444 |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
445 |
#ifdef EXPERIMENTAL_SSE2_CODE |
#ifdef EXPERIMENTAL_SSE2_CODE |
446 |
|
|
447 |
|
calc_cbp = calc_cbp_sse2; |
448 |
|
|
449 |
/* Quantization */ |
/* Quantization */ |
450 |
quant_intra = quant_intra_sse2; |
quant_intra = quant_intra_sse2; |
451 |
dequant_intra = dequant_intra_sse2; |
dequant_intra = dequant_intra_sse2; |
453 |
dequant_inter = dequant_inter_sse2; |
dequant_inter = dequant_inter_sse2; |
454 |
|
|
455 |
/* ME */ |
/* ME */ |
|
calc_cbp = calc_cbp_sse2; |
|
456 |
sad16 = sad16_sse2; |
sad16 = sad16_sse2; |
457 |
dev16 = dev16_sse2; |
dev16 = dev16_sse2; |
458 |
|
|
476 |
sad16bi = sad16bi_ia64; |
sad16bi = sad16bi_ia64; |
477 |
sad8 = sad8_ia64; |
sad8 = sad8_ia64; |
478 |
dev16 = dev16_ia64; |
dev16 = dev16_ia64; |
479 |
|
// Halfpel8_Refine = Halfpel8_Refine_ia64; |
480 |
quant_intra = quant_intra_ia64; |
quant_intra = quant_intra_ia64; |
481 |
dequant_intra = dequant_intra_ia64; |
dequant_intra = dequant_intra_ia64; |
482 |
quant_inter = quant_inter_ia64; |
quant_inter = quant_inter_ia64; |
508 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
509 |
} |
} |
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
static int |
514 |
|
xvid_init_convert(XVID_INIT_CONVERTINFO* convert) |
515 |
|
{ |
516 |
|
// const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); |
517 |
|
const int width = convert->width; |
518 |
|
const int height = convert->height; |
519 |
|
const int width2 = convert->width/2; |
520 |
|
const int height2 = convert->height/2; |
521 |
|
IMAGE img; |
522 |
|
|
523 |
|
switch (convert->input.colorspace & ~XVID_CSP_VFLIP) |
524 |
|
{ |
525 |
|
case XVID_CSP_YV12 : |
526 |
|
img.y = convert->input.y; |
527 |
|
img.v = (uint8_t*)convert->input.y + width*height; |
528 |
|
img.u = (uint8_t*)convert->input.y + width*height + width2*height2; |
529 |
|
image_output(&img, width, height, width, |
530 |
|
convert->output.y, convert->output.y_stride, |
531 |
|
convert->output.colorspace, convert->interlacing); |
532 |
|
break; |
533 |
|
|
534 |
|
default : |
535 |
|
return XVID_ERR_FORMAT; |
536 |
|
} |
537 |
|
|
538 |
|
|
539 |
|
emms(); |
540 |
|
return XVID_ERR_OK; |
541 |
|
} |
542 |
|
|
543 |
|
|
544 |
|
int |
545 |
|
xvid_init(void *handle, |
546 |
|
int opt, |
547 |
|
void *param1, |
548 |
|
void *param2) |
549 |
|
{ |
550 |
|
switch(opt) |
551 |
|
{ |
552 |
|
case XVID_INIT_INIT : |
553 |
|
return xvid_init_init((XVID_INIT_PARAM*)param1); |
554 |
|
|
555 |
|
case XVID_INIT_CONVERT : |
556 |
|
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
557 |
|
|
558 |
|
default : |
559 |
|
return XVID_ERR_FAIL; |
560 |
|
} |
561 |
|
} |
562 |
|
|
563 |
/***************************************************************************** |
/***************************************************************************** |
564 |
* XviD Native decoder entry point |
* XviD Native decoder entry point |
565 |
* |
* |
578 |
{ |
{ |
579 |
switch (opt) { |
switch (opt) { |
580 |
case XVID_DEC_DECODE: |
case XVID_DEC_DECODE: |
581 |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1); |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2); |
582 |
|
|
583 |
case XVID_DEC_CREATE: |
case XVID_DEC_CREATE: |
584 |
return decoder_create((XVID_DEC_PARAM *) param1); |
return decoder_create((XVID_DEC_PARAM *) param1); |
610 |
{ |
{ |
611 |
switch (opt) { |
switch (opt) { |
612 |
case XVID_ENC_ENCODE: |
case XVID_ENC_ENCODE: |
613 |
#ifdef BFRAMES |
|
614 |
if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
615 |
return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
616 |
(XVID_ENC_STATS *) param2); |
(XVID_ENC_STATS *) param2); |
617 |
else |
else |
|
#endif |
|
618 |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
619 |
(XVID_ENC_STATS *) param2); |
(XVID_ENC_STATS *) param2); |
620 |
|
|