c278f3403a4a0a61a291b339f2d9fc48338678cf
2 * Copyright (C) 2000-2004 the xine project
4 * This file is part of xine, a free video player.
6 * xine is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * xine is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
41 # include "attributes.h"
42 //# include "compat.h"
43 //# include "xmlparser.h"
44 //# include "xine_buffer.h"
45 //# include "configfile.h"
47 //# include <xine/attributes.h>
48 //# include <xine/compat.h>
49 //# include <xine/xmlparser.h>
50 //# include <xine/xine_buffer.h>
51 //# include <xine/configfile.h>
54 //#ifdef HAVE_CONFIG_H
66 pthread_mutex_t mutex
;
71 int xine_mutex_init (xine_mutex_t
*mutex
, const pthread_mutexattr_t
*mutexattr
,
74 int xine_mutex_lock (xine_mutex_t
*mutex
, char *who
);
75 int xine_mutex_unlock (xine_mutex_t
*mutex
, char *who
);
76 int xine_mutex_destroy (xine_mutex_t
*mutex
);
80 /* CPU Acceleration */
83 * The type of an value that fits in an MMX register (note that long
84 * long constant values MUST be suffixed by LL and unsigned long long
85 * values by ULL, lest they be truncated by the compiler)
88 /* generic accelerations */
89 #define MM_ACCEL_MLIB 0x00000001
91 /* x86 accelerations */
92 #define MM_ACCEL_X86_MMX 0x80000000
93 #define MM_ACCEL_X86_3DNOW 0x40000000
94 #define MM_ACCEL_X86_MMXEXT 0x20000000
95 #define MM_ACCEL_X86_SSE 0x10000000
96 #define MM_ACCEL_X86_SSE2 0x08000000
97 /* powerpc accelerations */
98 #define MM_ACCEL_PPC_ALTIVEC 0x04000000
99 /* x86 compat defines */
100 #define MM_MMX MM_ACCEL_X86_MMX
101 #define MM_3DNOW MM_ACCEL_X86_3DNOW
102 #define MM_MMXEXT MM_ACCEL_X86_MMXEXT
103 #define MM_SSE MM_ACCEL_X86_SSE
104 #define MM_SSE2 MM_ACCEL_X86_SSE2
106 uint32_t xine_mm_accel (void);
108 #if defined(ARCH_X86) || defined(ARCH_X86_64)
111 int64_t q
; /* Quadword (64-bit) value */
112 uint64_t uq
; /* Unsigned Quadword */
113 int d
[2]; /* 2 Doubleword (32-bit) values */
114 unsigned int ud
[2]; /* 2 Unsigned Doubleword */
115 short w
[4]; /* 4 Word (16-bit) values */
116 unsigned short uw
[4]; /* 4 Unsigned Word */
117 char b
[8]; /* 8 Byte (8-bit) values */
118 unsigned char ub
[8]; /* 8 Unsigned Byte */
119 float s
[2]; /* Single-precision (32-bit) value */
120 } ATTR_ALIGN(8) mmx_t
; /* On an 8-byte (64-bit) boundary */
124 #define mmx_i2r(op,imm,reg) \
125 __asm__ __volatile__ (#op " %0, %%" #reg \
129 #define mmx_m2r(op,mem,reg) \
130 __asm__ __volatile__ (#op " %0, %%" #reg \
134 #define mmx_r2m(op,reg,mem) \
135 __asm__ __volatile__ (#op " %%" #reg ", %0" \
139 #define mmx_r2r(op,regs,regd) \
140 __asm__ __volatile__ (#op " %" #regs ", %" #regd)
143 #define emms() __asm__ __volatile__ ("emms")
145 #define movd_m2r(var,reg) mmx_m2r (movd, var, reg)
146 #define movd_r2m(reg,var) mmx_r2m (movd, reg, var)
147 #define movd_r2r(regs,regd) mmx_r2r (movd, regs, regd)
149 #define movq_m2r(var,reg) mmx_m2r (movq, var, reg)
150 #define movq_r2m(reg,var) mmx_r2m (movq, reg, var)
151 #define movq_r2r(regs,regd) mmx_r2r (movq, regs, regd)
153 #define packssdw_m2r(var,reg) mmx_m2r (packssdw, var, reg)
154 #define packssdw_r2r(regs,regd) mmx_r2r (packssdw, regs, regd)
155 #define packsswb_m2r(var,reg) mmx_m2r (packsswb, var, reg)
156 #define packsswb_r2r(regs,regd) mmx_r2r (packsswb, regs, regd)
158 #define packuswb_m2r(var,reg) mmx_m2r (packuswb, var, reg)
159 #define packuswb_r2r(regs,regd) mmx_r2r (packuswb, regs, regd)
161 #define paddb_m2r(var,reg) mmx_m2r (paddb, var, reg)
162 #define paddb_r2r(regs,regd) mmx_r2r (paddb, regs, regd)
163 #define paddd_m2r(var,reg) mmx_m2r (paddd, var, reg)
164 #define paddd_r2r(regs,regd) mmx_r2r (paddd, regs, regd)
165 #define paddw_m2r(var,reg) mmx_m2r (paddw, var, reg)
166 #define paddw_r2r(regs,regd) mmx_r2r (paddw, regs, regd)
168 #define paddsb_m2r(var,reg) mmx_m2r (paddsb, var, reg)
169 #define paddsb_r2r(regs,regd) mmx_r2r (paddsb, regs, regd)
170 #define paddsw_m2r(var,reg) mmx_m2r (paddsw, var, reg)
171 #define paddsw_r2r(regs,regd) mmx_r2r (paddsw, regs, regd)
173 #define paddusb_m2r(var,reg) mmx_m2r (paddusb, var, reg)
174 #define paddusb_r2r(regs,regd) mmx_r2r (paddusb, regs, regd)
175 #define paddusw_m2r(var,reg) mmx_m2r (paddusw, var, reg)
176 #define paddusw_r2r(regs,regd) mmx_r2r (paddusw, regs, regd)
178 #define pand_m2r(var,reg) mmx_m2r (pand, var, reg)
179 #define pand_r2r(regs,regd) mmx_r2r (pand, regs, regd)
181 #define pandn_m2r(var,reg) mmx_m2r (pandn, var, reg)
182 #define pandn_r2r(regs,regd) mmx_r2r (pandn, regs, regd)
184 #define pcmpeqb_m2r(var,reg) mmx_m2r (pcmpeqb, var, reg)
185 #define pcmpeqb_r2r(regs,regd) mmx_r2r (pcmpeqb, regs, regd)
186 #define pcmpeqd_m2r(var,reg) mmx_m2r (pcmpeqd, var, reg)
187 #define pcmpeqd_r2r(regs,regd) mmx_r2r (pcmpeqd, regs, regd)
188 #define pcmpeqw_m2r(var,reg) mmx_m2r (pcmpeqw, var, reg)
189 #define pcmpeqw_r2r(regs,regd) mmx_r2r (pcmpeqw, regs, regd)
191 #define pcmpgtb_m2r(var,reg) mmx_m2r (pcmpgtb, var, reg)
192 #define pcmpgtb_r2r(regs,regd) mmx_r2r (pcmpgtb, regs, regd)
193 #define pcmpgtd_m2r(var,reg) mmx_m2r (pcmpgtd, var, reg)
194 #define pcmpgtd_r2r(regs,regd) mmx_r2r (pcmpgtd, regs, regd)
195 #define pcmpgtw_m2r(var,reg) mmx_m2r (pcmpgtw, var, reg)
196 #define pcmpgtw_r2r(regs,regd) mmx_r2r (pcmpgtw, regs, regd)
198 #define pmaddwd_m2r(var,reg) mmx_m2r (pmaddwd, var, reg)
199 #define pmaddwd_r2r(regs,regd) mmx_r2r (pmaddwd, regs, regd)
201 #define pmulhw_m2r(var,reg) mmx_m2r (pmulhw, var, reg)
202 #define pmulhw_r2r(regs,regd) mmx_r2r (pmulhw, regs, regd)
204 #define pmullw_m2r(var,reg) mmx_m2r (pmullw, var, reg)
205 #define pmullw_r2r(regs,regd) mmx_r2r (pmullw, regs, regd)
207 #define por_m2r(var,reg) mmx_m2r (por, var, reg)
208 #define por_r2r(regs,regd) mmx_r2r (por, regs, regd)
210 #define pslld_i2r(imm,reg) mmx_i2r (pslld, imm, reg)
211 #define pslld_m2r(var,reg) mmx_m2r (pslld, var, reg)
212 #define pslld_r2r(regs,regd) mmx_r2r (pslld, regs, regd)
213 #define psllq_i2r(imm,reg) mmx_i2r (psllq, imm, reg)
214 #define psllq_m2r(var,reg) mmx_m2r (psllq, var, reg)
215 #define psllq_r2r(regs,regd) mmx_r2r (psllq, regs, regd)
216 #define psllw_i2r(imm,reg) mmx_i2r (psllw, imm, reg)
217 #define psllw_m2r(var,reg) mmx_m2r (psllw, var, reg)
218 #define psllw_r2r(regs,regd) mmx_r2r (psllw, regs, regd)
220 #define psrad_i2r(imm,reg) mmx_i2r (psrad, imm, reg)
221 #define psrad_m2r(var,reg) mmx_m2r (psrad, var, reg)
222 #define psrad_r2r(regs,regd) mmx_r2r (psrad, regs, regd)
223 #define psraw_i2r(imm,reg) mmx_i2r (psraw, imm, reg)
224 #define psraw_m2r(var,reg) mmx_m2r (psraw, var, reg)
225 #define psraw_r2r(regs,regd) mmx_r2r (psraw, regs, regd)
227 #define psrld_i2r(imm,reg) mmx_i2r (psrld, imm, reg)
228 #define psrld_m2r(var,reg) mmx_m2r (psrld, var, reg)
229 #define psrld_r2r(regs,regd) mmx_r2r (psrld, regs, regd)
230 #define psrlq_i2r(imm,reg) mmx_i2r (psrlq, imm, reg)
231 #define psrlq_m2r(var,reg) mmx_m2r (psrlq, var, reg)
232 #define psrlq_r2r(regs,regd) mmx_r2r (psrlq, regs, regd)
233 #define psrlw_i2r(imm,reg) mmx_i2r (psrlw, imm, reg)
234 #define psrlw_m2r(var,reg) mmx_m2r (psrlw, var, reg)
235 #define psrlw_r2r(regs,regd) mmx_r2r (psrlw, regs, regd)
237 #define psubb_m2r(var,reg) mmx_m2r (psubb, var, reg)
238 #define psubb_r2r(regs,regd) mmx_r2r (psubb, regs, regd)
239 #define psubd_m2r(var,reg) mmx_m2r (psubd, var, reg)
240 #define psubd_r2r(regs,regd) mmx_r2r (psubd, regs, regd)
241 #define psubw_m2r(var,reg) mmx_m2r (psubw, var, reg)
242 #define psubw_r2r(regs,regd) mmx_r2r (psubw, regs, regd)
244 #define psubsb_m2r(var,reg) mmx_m2r (psubsb, var, reg)
245 #define psubsb_r2r(regs,regd) mmx_r2r (psubsb, regs, regd)
246 #define psubsw_m2r(var,reg) mmx_m2r (psubsw, var, reg)
247 #define psubsw_r2r(regs,regd) mmx_r2r (psubsw, regs, regd)
249 #define psubusb_m2r(var,reg) mmx_m2r (psubusb, var, reg)
250 #define psubusb_r2r(regs,regd) mmx_r2r (psubusb, regs, regd)
251 #define psubusw_m2r(var,reg) mmx_m2r (psubusw, var, reg)
252 #define psubusw_r2r(regs,regd) mmx_r2r (psubusw, regs, regd)
254 #define punpckhbw_m2r(var,reg) mmx_m2r (punpckhbw, var, reg)
255 #define punpckhbw_r2r(regs,regd) mmx_r2r (punpckhbw, regs, regd)
256 #define punpckhdq_m2r(var,reg) mmx_m2r (punpckhdq, var, reg)
257 #define punpckhdq_r2r(regs,regd) mmx_r2r (punpckhdq, regs, regd)
258 #define punpckhwd_m2r(var,reg) mmx_m2r (punpckhwd, var, reg)
259 #define punpckhwd_r2r(regs,regd) mmx_r2r (punpckhwd, regs, regd)
261 #define punpcklbw_m2r(var,reg) mmx_m2r (punpcklbw, var, reg)
262 #define punpcklbw_r2r(regs,regd) mmx_r2r (punpcklbw, regs, regd)
263 #define punpckldq_m2r(var,reg) mmx_m2r (punpckldq, var, reg)
264 #define punpckldq_r2r(regs,regd) mmx_r2r (punpckldq, regs, regd)
265 #define punpcklwd_m2r(var,reg) mmx_m2r (punpcklwd, var, reg)
266 #define punpcklwd_r2r(regs,regd) mmx_r2r (punpcklwd, regs, regd)
268 #define pxor_m2r(var,reg) mmx_m2r (pxor, var, reg)
269 #define pxor_r2r(regs,regd) mmx_r2r (pxor, regs, regd)
272 /* 3DNOW extensions */
274 #define pavgusb_m2r(var,reg) mmx_m2r (pavgusb, var, reg)
275 #define pavgusb_r2r(regs,regd) mmx_r2r (pavgusb, regs, regd)
278 /* AMD MMX extensions - also available in intel SSE */
281 #define mmx_m2ri(op,mem,reg,imm) \
282 __asm__ __volatile__ (#op " %1, %0, %%" #reg \
284 : "X" (mem), "X" (imm))
285 #define mmx_r2ri(op,regs,regd,imm) \
286 __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \
290 #define mmx_fetch(mem,hint) \
291 __asm__ __volatile__ ("prefetch" #hint " %0" \
296 #define maskmovq(regs,maskreg) mmx_r2ri (maskmovq, regs, maskreg)
298 #define movntq_r2m(mmreg,var) mmx_r2m (movntq, mmreg, var)
300 #define pavgb_m2r(var,reg) mmx_m2r (pavgb, var, reg)
301 #define pavgb_r2r(regs,regd) mmx_r2r (pavgb, regs, regd)
302 #define pavgw_m2r(var,reg) mmx_m2r (pavgw, var, reg)
303 #define pavgw_r2r(regs,regd) mmx_r2r (pavgw, regs, regd)
305 #define pextrw_r2r(mmreg,reg,imm) mmx_r2ri (pextrw, mmreg, reg, imm)
307 #define pinsrw_r2r(reg,mmreg,imm) mmx_r2ri (pinsrw, reg, mmreg, imm)
309 #define pmaxsw_m2r(var,reg) mmx_m2r (pmaxsw, var, reg)
310 #define pmaxsw_r2r(regs,regd) mmx_r2r (pmaxsw, regs, regd)
312 #define pmaxub_m2r(var,reg) mmx_m2r (pmaxub, var, reg)
313 #define pmaxub_r2r(regs,regd) mmx_r2r (pmaxub, regs, regd)
315 #define pminsw_m2r(var,reg) mmx_m2r (pminsw, var, reg)
316 #define pminsw_r2r(regs,regd) mmx_r2r (pminsw, regs, regd)
318 #define pminub_m2r(var,reg) mmx_m2r (pminub, var, reg)
319 #define pminub_r2r(regs,regd) mmx_r2r (pminub, regs, regd)
321 #define pmovmskb(mmreg,reg) \
322 __asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg)
324 #define pmulhuw_m2r(var,reg) mmx_m2r (pmulhuw, var, reg)
325 #define pmulhuw_r2r(regs,regd) mmx_r2r (pmulhuw, regs, regd)
327 #define prefetcht0(mem) mmx_fetch (mem, t0)
328 #define prefetcht1(mem) mmx_fetch (mem, t1)
329 #define prefetcht2(mem) mmx_fetch (mem, t2)
330 #define prefetchnta(mem) mmx_fetch (mem, nta)
332 #define psadbw_m2r(var,reg) mmx_m2r (psadbw, var, reg)
333 #define psadbw_r2r(regs,regd) mmx_r2r (psadbw, regs, regd)
335 #define pshufw_m2r(var,reg,imm) mmx_m2ri(pshufw, var, reg, imm)
336 #define pshufw_r2r(regs,regd,imm) mmx_r2ri(pshufw, regs, regd, imm)
338 #define sfence() __asm__ __volatile__ ("sfence\n\t")
341 float sf
[4]; /* Single-precision (32-bit) value */
342 } ATTR_ALIGN(16) sse_t
; /* On a 16 byte (128-bit) boundary */
345 #define sse_i2r(op, imm, reg) \
346 __asm__ __volatile__ (#op " %0, %%" #reg \
350 #define sse_m2r(op, mem, reg) \
351 __asm__ __volatile__ (#op " %0, %%" #reg \
355 #define sse_r2m(op, reg, mem) \
356 __asm__ __volatile__ (#op " %%" #reg ", %0" \
360 #define sse_r2r(op, regs, regd) \
361 __asm__ __volatile__ (#op " %" #regs ", %" #regd)
363 #define sse_r2ri(op, regs, regd, imm) \
364 __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \
368 #define sse_m2ri(op, mem, reg, subop) \
369 __asm__ __volatile__ (#op " %0, %%" #reg ", " #subop \
374 #define movaps_m2r(var, reg) sse_m2r(movaps, var, reg)
375 #define movaps_r2m(reg, var) sse_r2m(movaps, reg, var)
376 #define movaps_r2r(regs, regd) sse_r2r(movaps, regs, regd)
378 #define movntps_r2m(xmmreg, var) sse_r2m(movntps, xmmreg, var)
380 #define movups_m2r(var, reg) sse_m2r(movups, var, reg)
381 #define movups_r2m(reg, var) sse_r2m(movups, reg, var)
382 #define movups_r2r(regs, regd) sse_r2r(movups, regs, regd)
384 #define movhlps_r2r(regs, regd) sse_r2r(movhlps, regs, regd)
386 #define movlhps_r2r(regs, regd) sse_r2r(movlhps, regs, regd)
388 #define movhps_m2r(var, reg) sse_m2r(movhps, var, reg)
389 #define movhps_r2m(reg, var) sse_r2m(movhps, reg, var)
391 #define movlps_m2r(var, reg) sse_m2r(movlps, var, reg)
392 #define movlps_r2m(reg, var) sse_r2m(movlps, reg, var)
394 #define movss_m2r(var, reg) sse_m2r(movss, var, reg)
395 #define movss_r2m(reg, var) sse_r2m(movss, reg, var)
396 #define movss_r2r(regs, regd) sse_r2r(movss, regs, regd)
398 #define shufps_m2r(var, reg, index) sse_m2ri(shufps, var, reg, index)
399 #define shufps_r2r(regs, regd, index) sse_r2ri(shufps, regs, regd, index)
401 #define cvtpi2ps_m2r(var, xmmreg) sse_m2r(cvtpi2ps, var, xmmreg)
402 #define cvtpi2ps_r2r(mmreg, xmmreg) sse_r2r(cvtpi2ps, mmreg, xmmreg)
404 #define cvtps2pi_m2r(var, mmreg) sse_m2r(cvtps2pi, var, mmreg)
405 #define cvtps2pi_r2r(xmmreg, mmreg) sse_r2r(cvtps2pi, mmreg, xmmreg)
407 #define cvttps2pi_m2r(var, mmreg) sse_m2r(cvttps2pi, var, mmreg)
408 #define cvttps2pi_r2r(xmmreg, mmreg) sse_r2r(cvttps2pi, mmreg, xmmreg)
410 #define cvtsi2ss_m2r(var, xmmreg) sse_m2r(cvtsi2ss, var, xmmreg)
411 #define cvtsi2ss_r2r(reg, xmmreg) sse_r2r(cvtsi2ss, reg, xmmreg)
413 #define cvtss2si_m2r(var, reg) sse_m2r(cvtss2si, var, reg)
414 #define cvtss2si_r2r(xmmreg, reg) sse_r2r(cvtss2si, xmmreg, reg)
416 #define cvttss2si_m2r(var, reg) sse_m2r(cvtss2si, var, reg)
417 #define cvttss2si_r2r(xmmreg, reg) sse_r2r(cvtss2si, xmmreg, reg)
419 #define movmskps(xmmreg, reg) \
420 __asm__ __volatile__ ("movmskps %" #xmmreg ", %" #reg)
422 #define addps_m2r(var, reg) sse_m2r(addps, var, reg)
423 #define addps_r2r(regs, regd) sse_r2r(addps, regs, regd)
425 #define addss_m2r(var, reg) sse_m2r(addss, var, reg)
426 #define addss_r2r(regs, regd) sse_r2r(addss, regs, regd)
428 #define subps_m2r(var, reg) sse_m2r(subps, var, reg)
429 #define subps_r2r(regs, regd) sse_r2r(subps, regs, regd)
431 #define subss_m2r(var, reg) sse_m2r(subss, var, reg)
432 #define subss_r2r(regs, regd) sse_r2r(subss, regs, regd)
434 #define mulps_m2r(var, reg) sse_m2r(mulps, var, reg)
435 #define mulps_r2r(regs, regd) sse_r2r(mulps, regs, regd)
437 #define mulss_m2r(var, reg) sse_m2r(mulss, var, reg)
438 #define mulss_r2r(regs, regd) sse_r2r(mulss, regs, regd)
440 #define divps_m2r(var, reg) sse_m2r(divps, var, reg)
441 #define divps_r2r(regs, regd) sse_r2r(divps, regs, regd)
443 #define divss_m2r(var, reg) sse_m2r(divss, var, reg)
444 #define divss_r2r(regs, regd) sse_r2r(divss, regs, regd)
446 #define rcpps_m2r(var, reg) sse_m2r(rcpps, var, reg)
447 #define rcpps_r2r(regs, regd) sse_r2r(rcpps, regs, regd)
449 #define rcpss_m2r(var, reg) sse_m2r(rcpss, var, reg)
450 #define rcpss_r2r(regs, regd) sse_r2r(rcpss, regs, regd)
452 #define rsqrtps_m2r(var, reg) sse_m2r(rsqrtps, var, reg)
453 #define rsqrtps_r2r(regs, regd) sse_r2r(rsqrtps, regs, regd)
455 #define rsqrtss_m2r(var, reg) sse_m2r(rsqrtss, var, reg)
456 #define rsqrtss_r2r(regs, regd) sse_r2r(rsqrtss, regs, regd)
458 #define sqrtps_m2r(var, reg) sse_m2r(sqrtps, var, reg)
459 #define sqrtps_r2r(regs, regd) sse_r2r(sqrtps, regs, regd)
461 #define sqrtss_m2r(var, reg) sse_m2r(sqrtss, var, reg)
462 #define sqrtss_r2r(regs, regd) sse_r2r(sqrtss, regs, regd)
464 #define andps_m2r(var, reg) sse_m2r(andps, var, reg)
465 #define andps_r2r(regs, regd) sse_r2r(andps, regs, regd)
467 #define andnps_m2r(var, reg) sse_m2r(andnps, var, reg)
468 #define andnps_r2r(regs, regd) sse_r2r(andnps, regs, regd)
470 #define orps_m2r(var, reg) sse_m2r(orps, var, reg)
471 #define orps_r2r(regs, regd) sse_r2r(orps, regs, regd)
473 #define xorps_m2r(var, reg) sse_m2r(xorps, var, reg)
474 #define xorps_r2r(regs, regd) sse_r2r(xorps, regs, regd)
476 #define maxps_m2r(var, reg) sse_m2r(maxps, var, reg)
477 #define maxps_r2r(regs, regd) sse_r2r(maxps, regs, regd)
479 #define maxss_m2r(var, reg) sse_m2r(maxss, var, reg)
480 #define maxss_r2r(regs, regd) sse_r2r(maxss, regs, regd)
482 #define minps_m2r(var, reg) sse_m2r(minps, var, reg)
483 #define minps_r2r(regs, regd) sse_r2r(minps, regs, regd)
485 #define minss_m2r(var, reg) sse_m2r(minss, var, reg)
486 #define minss_r2r(regs, regd) sse_r2r(minss, regs, regd)
488 #define cmpps_m2r(var, reg, op) sse_m2ri(cmpps, var, reg, op)
489 #define cmpps_r2r(regs, regd, op) sse_r2ri(cmpps, regs, regd, op)
491 #define cmpeqps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 0)
492 #define cmpeqps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 0)
494 #define cmpltps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 1)
495 #define cmpltps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 1)
497 #define cmpleps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 2)
498 #define cmpleps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 2)
500 #define cmpunordps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 3)
501 #define cmpunordps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 3)
503 #define cmpneqps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 4)
504 #define cmpneqps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 4)
506 #define cmpnltps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 5)
507 #define cmpnltps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 5)
509 #define cmpnleps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 6)
510 #define cmpnleps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 6)
512 #define cmpordps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 7)
513 #define cmpordps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 7)
515 #define cmpss_m2r(var, reg, op) sse_m2ri(cmpss, var, reg, op)
516 #define cmpss_r2r(regs, regd, op) sse_r2ri(cmpss, regs, regd, op)
518 #define cmpeqss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 0)
519 #define cmpeqss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 0)
521 #define cmpltss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 1)
522 #define cmpltss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 1)
524 #define cmpless_m2r(var, reg) sse_m2ri(cmpss, var, reg, 2)
525 #define cmpless_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 2)
527 #define cmpunordss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 3)
528 #define cmpunordss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 3)
530 #define cmpneqss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 4)
531 #define cmpneqss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 4)
533 #define cmpnltss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 5)
534 #define cmpnltss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 5)
536 #define cmpnless_m2r(var, reg) sse_m2ri(cmpss, var, reg, 6)
537 #define cmpnless_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 6)
539 #define cmpordss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 7)
540 #define cmpordss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 7)
542 #define comiss_m2r(var, reg) sse_m2r(comiss, var, reg)
543 #define comiss_r2r(regs, regd) sse_r2r(comiss, regs, regd)
545 #define ucomiss_m2r(var, reg) sse_m2r(ucomiss, var, reg)
546 #define ucomiss_r2r(regs, regd) sse_r2r(ucomiss, regs, regd)
548 #define unpcklps_m2r(var, reg) sse_m2r(unpcklps, var, reg)
549 #define unpcklps_r2r(regs, regd) sse_r2r(unpcklps, regs, regd)
551 #define unpckhps_m2r(var, reg) sse_m2r(unpckhps, var, reg)
552 #define unpckhps_r2r(regs, regd) sse_r2r(unpckhps, regs, regd)
554 #define fxrstor(mem) \
555 __asm__ __volatile__ ("fxrstor %0" \
559 #define fxsave(mem) \
560 __asm__ __volatile__ ("fxsave %0" \
564 #define stmxcsr(mem) \
565 __asm__ __volatile__ ("stmxcsr %0" \
569 #define ldmxcsr(mem) \
570 __asm__ __volatile__ ("ldmxcsr %0" \
577 /* Optimized/fast memcpy */
580 TODO : fix dll linkage problem for xine_fast_memcpy on win32
582 xine_fast_memcpy dll linkage is screwy here.
583 declaring as dllimport seems to fix the problem
584 but causes compiler warning with libxineutils
587 __declspec( dllimport
) extern void *(* xine_fast_memcpy
)(void *to
, const void *from
, size_t len
);
589 extern void *(* xine_fast_memcpy
)(void *to
, const void *from
, size_t len
);
592 #ifdef HAVE_XINE_INTERNAL_H
593 /* Benchmark available memcpy methods */
594 void xine_probe_fast_memcpy(xine_t
*xine
);
602 * profiling (unworkable in non DEBUG isn't defined)
604 void xine_profiler_init (void);
605 int xine_profiler_allocate_slot (char *label
);
606 void xine_profiler_start_count (int id
);
607 void xine_profiler_stop_count (int id
);
608 void xine_profiler_print_results (void);
611 * Allocate and clean memory size_t 'size', then return the pointer
612 * to the allocated memory.
614 #if !defined(__GNUC__) || __GNUC__ < 3
615 void *xine_xmalloc(size_t size
);
617 void *xine_xmalloc(size_t size
) __attribute__ ((__malloc__
));
621 * Same as above, but memory is aligned to 'alignement'.
622 * **base is used to return pointer to un-aligned memory, use
623 * this to free the mem chunk
625 void *xine_xmalloc_aligned(size_t alignment
, size_t size
, void **base
);
628 * Get user home directory.
630 const char *xine_get_homedir(void);
633 * Clean a string (remove spaces and '=' at the begin,
634 * and '\n', '\r' and spaces at the end.
636 char *xine_chomp (char *str
);
639 * A thread-safe usecond sleep
641 void xine_usec_sleep(unsigned usec
);
645 * Some string functions
649 void xine_strdupa(char *dest
, char *src
);
650 #define xine_strdupa(d, s) do { \
653 (d) = (char *) alloca(strlen((s)) + 1); \
658 /* Shamefully copied from glibc 2.2.3 */
660 #define xine_strpbrk strpbrk
662 static inline char *_private_strpbrk(const char *s
, const char *accept
) {
665 const char *a
= accept
;
674 #define xine_strpbrk _private_strpbrk
677 #if defined HAVE_STRSEP && !defined(_MSC_VER)
678 #define xine_strsep strsep
680 static inline char *_private_strsep(char **stringp
, const char *delim
) {
687 if(delim
[0] == '\0' || delim
[1] == '\0') {
695 else if(*begin
== '\0')
698 end
= strchr(begin
+ 1, ch
);
702 end
= xine_strpbrk(begin
, delim
);
713 #define xine_strsep _private_strsep
718 #define xine_setenv setenv
720 static inline void _private_setenv(const char *name
, const char *val
, int _xx
) {
721 int len
= strlen(name
) + strlen(val
) + 2;
724 sprintf(env
, "%s%c%s", name
, '=', val
);
727 #define xine_setenv _private_setenv
731 * Color Conversion Utility Functions
732 * The following data structures and functions facilitate the conversion
733 * of RGB images to packed YUV (YUY2) images. There are also functions to
734 * convert from YUV9 -> YV12. All of the meaty details are written in
738 typedef struct yuv_planes_s
{
743 unsigned int row_width
; /* frame width */
744 unsigned int row_count
; /* frame height */
748 void init_yuv_conversion(void);
749 void init_yuv_planes(yuv_planes_t
*yuv_planes
, int width
, int height
);
750 void free_yuv_planes(yuv_planes_t
*yuv_planes
);
752 extern void (*yuv444_to_yuy2
)
753 (yuv_planes_t
*yuv_planes
, unsigned char *yuy2_map
, int pitch
);
754 extern void (*yuv9_to_yv12
)
755 (unsigned char *y_src
, int y_src_pitch
, unsigned char *y_dest
, int y_dest_pitch
,
756 unsigned char *u_src
, int u_src_pitch
, unsigned char *u_dest
, int u_dest_pitch
,
757 unsigned char *v_src
, int v_src_pitch
, unsigned char *v_dest
, int v_dest_pitch
,
758 int width
, int height
);
759 extern void (*yuv411_to_yv12
)
760 (unsigned char *y_src
, int y_src_pitch
, unsigned char *y_dest
, int y_dest_pitch
,
761 unsigned char *u_src
, int u_src_pitch
, unsigned char *u_dest
, int u_dest_pitch
,
762 unsigned char *v_src
, int v_src_pitch
, unsigned char *v_dest
, int v_dest_pitch
,
763 int width
, int height
);
764 extern void (*yv12_to_yuy2
)
765 (unsigned char *y_src
, int y_src_pitch
,
766 unsigned char *u_src
, int u_src_pitch
,
767 unsigned char *v_src
, int v_src_pitch
,
768 unsigned char *yuy2_map
, int yuy2_pitch
,
769 int width
, int height
, int progressive
);
770 extern void (*yuy2_to_yv12
)
771 (unsigned char *yuy2_map
, int yuy2_pitch
,
772 unsigned char *y_dst
, int y_dst_pitch
,
773 unsigned char *u_dst
, int u_dst_pitch
,
774 unsigned char *v_dst
, int v_dst_pitch
,
775 int width
, int height
);
777 #define SCALEFACTOR 65536
778 #define CENTERSAMPLE 128
780 #define COMPUTE_Y(r, g, b) \
782 ((y_r_table[r] + y_g_table[g] + y_b_table[b]) / SCALEFACTOR)
783 #define COMPUTE_U(r, g, b) \
785 ((u_r_table[r] + u_g_table[g] + u_b_table[b]) / SCALEFACTOR + CENTERSAMPLE)
786 #define COMPUTE_V(r, g, b) \
788 ((v_r_table[r] + v_g_table[g] + v_b_table[b]) / SCALEFACTOR + CENTERSAMPLE)
790 #define UNPACK_BGR15(packed_pixel, r, g, b) \
791 b = (packed_pixel & 0x7C00) >> 7; \
792 g = (packed_pixel & 0x03E0) >> 2; \
793 r = (packed_pixel & 0x001F) << 3;
795 #define UNPACK_BGR16(packed_pixel, r, g, b) \
796 b = (packed_pixel & 0xF800) >> 8; \
797 g = (packed_pixel & 0x07E0) >> 3; \
798 r = (packed_pixel & 0x001F) << 3;
800 #define UNPACK_RGB15(packed_pixel, r, g, b) \
801 r = (packed_pixel & 0x7C00) >> 7; \
802 g = (packed_pixel & 0x03E0) >> 2; \
803 b = (packed_pixel & 0x001F) << 3;
805 #define UNPACK_RGB16(packed_pixel, r, g, b) \
806 r = (packed_pixel & 0xF800) >> 8; \
807 g = (packed_pixel & 0x07E0) >> 3; \
808 b = (packed_pixel & 0x001F) << 3;
810 extern int y_r_table
[256];
811 extern int y_g_table
[256];
812 extern int y_b_table
[256];
814 extern int u_r_table
[256];
815 extern int u_g_table
[256];
816 extern int u_b_table
[256];
818 extern int v_r_table
[256];
819 extern int v_g_table
[256];
820 extern int v_b_table
[256];
822 /* frame copying functions */
823 extern void yv12_to_yv12
824 (unsigned char *y_src
, int y_src_pitch
, unsigned char *y_dst
, int y_dst_pitch
,
825 unsigned char *u_src
, int u_src_pitch
, unsigned char *u_dst
, int u_dst_pitch
,
826 unsigned char *v_src
, int v_src_pitch
, unsigned char *v_dst
, int v_dst_pitch
,
827 int width
, int height
);
828 extern void yuy2_to_yuy2
829 (unsigned char *src
, int src_pitch
,
830 unsigned char *dst
, int dst_pitch
,
831 int width
, int height
);
833 /* print a hexdump of the given data */
834 void xine_hexdump (const char *buf
, int length
);
837 * Optimization macros for conditions
838 * Taken from the FIASCO L4 microkernel sources
840 #if !defined(__GNUC__) || __GNUC__ < 3
841 # define EXPECT_TRUE(x) (x)
842 # define EXPECT_FALSE(x) (x)
844 # define EXPECT_TRUE(x) __builtin_expect((x),1)
845 # define EXPECT_FALSE(x) __builtin_expect((x),0)
849 #define _x_assert(exp) \
852 fprintf(stderr, "assert: %s:%d: %s: Assertion `%s' failed.\n", \
853 __FILE__, __LINE__, __XINE_FUNCTION__, #exp); \
856 #define _x_assert(exp) \
859 fprintf(stderr, "assert: %s:%d: %s: Assertion `%s' failed.\n", \
860 __FILE__, __LINE__, __XINE_FUNCTION__, #exp); \
868 fprintf(stderr, "abort: %s:%d: %s: Aborting.\n", \
869 __FILE__, __LINE__, __XINE_FUNCTION__); \
874 /****** logging with xine **********************************/
877 #define LOG_MODULE __FILE__
878 #endif /* LOG_MODULE */
880 #define LOG_MODULE_STRING printf("%s: ", LOG_MODULE );
883 #define LONG_LOG_MODULE_STRING \
884 printf("%s: (%s:%d) ", LOG_MODULE, __XINE_FUNCTION__, __LINE__ );
886 #define LONG_LOG_MODULE_STRING LOG_MODULE_STRING
887 #endif /* LOG_VERBOSE */
891 #define lprintf(fmt, args...) \
893 LONG_LOG_MODULE_STRING \
894 printf(fmt, ##args); \
898 #define lprintf(fmtargs) \
900 LONG_LOG_MODULE_STRING \
901 printf("%s", fmtargs); \
904 #define lprintf(fmt, ...) \
906 LONG_LOG_MODULE_STRING \
907 printf(__VA_ARGS__); \
909 #endif /* _MSC_VER */
910 #endif /* __GNUC__ */
913 #define lprintf(fmt, args...) do {} while(0)
918 #define lprintf(...) do {} while(0)
919 #endif /* _MSC_VER */
920 #endif /* __GNUC__ */
924 #define llprintf(cat, fmt, args...) \
927 LONG_LOG_MODULE_STRING \
928 printf( fmt, ##args ); \
933 #define llprintf(cat, fmtargs) \
936 LONG_LOG_MODULE_STRING \
937 printf( "%s", fmtargs ); \
941 #define llprintf(cat, ...) \
944 LONG_LOG_MODULE_STRING \
945 printf( __VA_ARGS__ ); \
948 #endif /* _MSC_VER */
949 #endif /* __GNUC__ */
952 #define xprintf(xine, verbose, fmt, args...) \
954 if((xine) && (xine)->verbosity >= verbose){ \
955 xine_log(xine, XINE_LOG_TRACE, fmt, ##args); \
960 #define xprintf(xine, verbose, fmtargs) \
962 if((xine) && (xine)->verbosity >= verbose){ \
963 xine_log(xine, XINE_LOG_TRACE, fmtargs); \
967 #define xprintf(xine, verbose, ...) \
969 if((xine) && (xine)->verbosity >= verbose){ \
970 xine_log(xine, XINE_LOG_TRACE, __VA_ARGS__); \
973 #endif /* _MSC_VER */
974 #endif /* __GNUC__ */
976 /* time measuring macros for profiling tasks */
979 # define XINE_PROFILE(function) \
981 struct timeval current_time; \
983 gettimeofday(¤t_time, NULL); \
984 dtime = -(current_time.tv_sec + (current_time.tv_usec / 1000000.0)); \
986 gettimeofday(¤t_time, NULL); \
987 dtime += current_time.tv_sec + (current_time.tv_usec / 1000000.0); \
988 printf("%s: (%s:%d) took %lf seconds\n", \
989 LOG_MODULE, __XINE_FUNCTION__, __LINE__, dtime); \
991 # define XINE_PROFILE_ACCUMULATE(function) \
993 struct timeval current_time; \
994 static double dtime = 0; \
995 gettimeofday(¤t_time, NULL); \
996 dtime -= current_time.tv_sec + (current_time.tv_usec / 1000000.0); \
998 gettimeofday(¤t_time, NULL); \
999 dtime += current_time.tv_sec + (current_time.tv_usec / 1000000.0); \
1000 printf("%s: (%s:%d) took %lf seconds\n", \
1001 LOG_MODULE, __XINE_FUNCTION__, __LINE__, dtime); \
1004 # define XINE_PROFILE(function) function
1005 # define XINE_PROFILE_ACCUMULATE(function) function
1009 /******** double chained lists with builtin iterator *******/
1011 typedef struct xine_node_s
{
1013 struct xine_node_s
*next
, *prev
;
1024 xine_node_t
*first
, *last
, *cur
;
1030 xine_list_t
*xine_list_new (void);
1034 * dispose the whole list.
1035 * note: disposes _only_ the list structure, content must be free()d elsewhere
1037 void xine_list_free(xine_list_t
*l
);
1043 int xine_list_is_empty (xine_list_t
*l
);
1046 * return content of first entry in list.
1048 void *xine_list_first_content (xine_list_t
*l
);
1051 * return next content in list.
1053 void *xine_list_next_content (xine_list_t
*l
);
1056 * Return last content of list.
1058 void *xine_list_last_content (xine_list_t
*l
);
1061 * Return previous content of list.
1063 void *xine_list_prev_content (xine_list_t
*l
);
1066 * Append content to list, sorted by decreasing priority.
1068 void xine_list_append_priority_content (xine_list_t
*l
, void *content
, int priority
);
1071 * Append content to list.
1073 void xine_list_append_content (xine_list_t
*l
, void *content
);
1076 * Insert content in list.
1078 void xine_list_insert_content (xine_list_t
*l
, void *content
);
1081 * Remove current content in list.
1082 * note: removes only the list entry; content must be free()d elsewhere.
1084 void xine_list_delete_current (xine_list_t
*l
);
1086 #ifndef HAVE_BASENAME
1090 char *basename (char const *name
);