xine-lib: xine-lib-1.2.12/include/xine/xineutils.h Source File

xine-lib 1.2.12

xineutils.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2000-2022 the xine project
3 *
4 * This file is part of xine, a free video player.
5 *
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.
10 *
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.
15 *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 */
20#ifndef XINEUTILS_H
21#define XINEUTILS_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <stdlib.h>
28#include <string.h>
29#include <stdarg.h>
30#include <stddef.h>
31#include <pthread.h>
32
33#ifdef WIN32
34#else
35# include <sys/time.h>
36#endif
37#include <xine/os_types.h>
38#include <xine/attributes.h>
39#include <xine/compat.h>
40#include <xine/xmlparser.h>
41#include <xine/xine_buffer.h>
42#include <xine/configfile.h>
43#include <xine/list.h>
44#include <xine/array.h>
45#include <xine/sorted_array.h>
46
47#include <stdio.h>
48#include <string.h>
49
50/*
51 * Mark exported data symbols for link engine library clients with older
52 * Win32 compilers
53 */
54#if defined(WIN32) && !defined(XINE_LIBRARY_COMPILE)
55# define DL_IMPORT __declspec(dllimport)
56# define extern DL_IMPORT extern
57#endif
58
59
60/* Amiga style doubly linked lists, taken from TJtools.
61 * Most compilers will support the straightforward aliasing safe version.
62 * For others, try that "volatile" hack. */
63
64 typedef struct dnode_st {
65 struct dnode_st *next, *prev;
66} dnode_t;
67
68#ifdef HAVE_NAMELESS_STRUCT_IN_UNION
69# define DLIST_H(l) (&(l)->h)
70# define DLIST_T(l) (&(l)->t)
71typedef union {
72 struct { dnode_t *head, *null, *tail; };
73 struct { dnode_t h; dnode_t *dummy1; };
74 struct { dnode_t *dummy2; dnode_t t; };
75} dlist_t;
76#else
77# define DLIST_H(l) ((void *)(&(l)->head))
78# define DLIST_T(l) ((void *)(&(l)->null))
79 typedef struct {
80 dnode_t * volatile head;
81 dnode_t *null;
82 dnode_t * volatile tail;
83} dlist_t;
84#endif
85
86#define DLIST_IS_EMPTY(l) ((l)->head == DLIST_T(l))
87
88#define DLIST_REMOVE(n) { \
89 dnode_t *dl_rm_this = n; \
90 dnode_t *dl_rm_prev = dl_rm_this->prev; \
91 dnode_t *dl_rm_next = dl_rm_this->next; \
92 dl_rm_next->prev = dl_rm_prev; \
93 dl_rm_prev->next = dl_rm_next; \
94}
95
96#define DLIST_ADD_HEAD(n,l) { \
97 dlist_t *dl_ah_list = l; \
98 dnode_t *dl_ah_node = n; \
99 dnode_t *dl_ah_head = dl_ah_list->head; \
100 dl_ah_node->next = dl_ah_head; \
101 dl_ah_node->prev = DLIST_H(dl_ah_list); \
102 dl_ah_list->head = dl_ah_node; \
103 dl_ah_head->prev = dl_ah_node; \
104}
105
106#define DLIST_ADD_TAIL(n,l) { \
107 dlist_t *dl_at_list = l; \
108 dnode_t *dl_at_node = n; \
109 dnode_t *dl_at_tail = dl_at_list->tail; \
110 dl_at_node->next = DLIST_T(dl_at_list); \
111 dl_at_node->prev = dl_at_tail; \
112 dl_at_tail->next = dl_at_node; \
113 dl_at_list->tail = dl_at_node; \
114}
115
116#define DLIST_INSERT(n,h) { \
117 dnode_t *dl_i_node = n; \
118 dnode_t *dl_i_here = h; \
119 dnode_t *dl_i_prev = dl_i_here->prev; \
120 dl_i_prev->next = dl_i_node; \
121 dl_i_here->prev = dl_i_node; \
122 dl_i_node->next = dl_i_here; \
123 dl_i_node->prev = dl_i_prev; \
124}
125
126#define DLIST_INIT(l) { \
127 dlist_t *dl_in_list = l; \
128 dl_in_list->head = DLIST_T(dl_in_list); \
129 dl_in_list->null = NULL; \
130 dl_in_list->tail = DLIST_H(dl_in_list); }
131
132
133 /*
134 * debugable mutexes
135 */
136
137 typedef struct {
138 pthread_mutex_t mutex;
139 char id[80];
140 char *locked_by;
141 } xine_mutex_t;
142
143 int xine_mutex_init (xine_mutex_t *mutex, const pthread_mutexattr_t *mutexattr,
144 const char *id) XINE_PROTECTED;
145
146 int xine_mutex_lock (xine_mutex_t *mutex, const char *who) XINE_PROTECTED;
147 int xine_mutex_unlock (xine_mutex_t *mutex, const char *who) XINE_PROTECTED;
148 int xine_mutex_destroy (xine_mutex_t *mutex) XINE_PROTECTED;
149
150
151
152 /* CPU Acceleration */
153
154/*
155 * The type of an value that fits in an MMX register (note that long
156 * long constant values MUST be suffixed by LL and unsigned long long
157 * values by ULL, lest they be truncated by the compiler)
158 */
159
160/* generic accelerations */
161#define MM_ACCEL_MLIB 0x00000001
162
163/* x86 accelerations */
164#define MM_ACCEL_X86_MMX 0x80000000
165#define MM_ACCEL_X86_3DNOW 0x40000000
166#define MM_ACCEL_X86_MMXEXT 0x20000000
167#define MM_ACCEL_X86_SSE 0x10000000
168#define MM_ACCEL_X86_SSE2 0x08000000
169#define MM_ACCEL_X86_SSE3 0x04000000
170#define MM_ACCEL_X86_SSSE3 0x02000000
171#define MM_ACCEL_X86_SSE4 0x01000000
172#define MM_ACCEL_X86_SSE42 0x00800000
173#define MM_ACCEL_X86_AVX 0x00400000
174
175/* powerpc accelerations and features */
176#define MM_ACCEL_PPC_ALTIVEC 0x04000000
177#define MM_ACCEL_PPC_CACHE32 0x02000000
178
179/* SPARC accelerations */
180
181#define MM_ACCEL_SPARC_VIS 0x01000000
182#define MM_ACCEL_SPARC_VIS2 0x00800000
183
184/* x86 compat defines */
185#define MM_MMX MM_ACCEL_X86_MMX
186#define MM_3DNOW MM_ACCEL_X86_3DNOW
187#define MM_MMXEXT MM_ACCEL_X86_MMXEXT
188#define MM_SSE MM_ACCEL_X86_SSE
189#define MM_SSE2 MM_ACCEL_X86_SSE2
190
191uint32_t xine_mm_accel (void) XINE_CONST XINE_PROTECTED;
192
193int xine_cpu_count(void) XINE_CONST XINE_PROTECTED;
194
195
196 /* Optimized/fast memcpy */
197
198extern void *(* xine_fast_memcpy)(void *to, const void *from, size_t len) XINE_PROTECTED;
199
200/* len (usually) < 500, but not a build time constant. */
201#define xine_small_memcpy(xsm_to,xsm_from,xsm_len) memcpy (xsm_to, xsm_from, xsm_len)
202
203#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
204# if defined(ARCH_X86)
205# undef xine_small_memcpy
206static inline void *xine_small_memcpy (void *to, const void *from, size_t len) {
207 void *t2 = to;
208 size_t l2 = len;
209# if !defined(__clang__)
210 __asm__ __volatile__ (
211 "cld\n\trep movsb"
212 : "=S" (from), "=D" (t2), "=c" (l2), "=m" (*(struct {char foo[len];} *)to)
213 : "0" (from), "1" (t2), "2" (l2)
214 : "cc"
215 );
216# else /* clang dislikes virtual variable size struct */
217 __asm__ __volatile__ (
218 "cld\n\trep movsb"
219 : "=S" (from), "=D" (t2), "=c" (l2)
220 : "0" (from), "1" (t2), "2" (l2)
221 : "cc", "memory"
222 );
223# endif
224 (void)from;
225 (void)t2;
226 (void)l2;
227 return to;
228}
229# endif
230#endif
231
232/*
233 * Debug stuff
234 */
235/*
236 * profiling (unworkable in non DEBUG isn't defined)
237 */
238void xine_profiler_init (void) XINE_PROTECTED;
239int xine_profiler_allocate_slot (const char *label) XINE_PROTECTED;
240void xine_profiler_start_count (int id) XINE_PROTECTED;
241void xine_profiler_stop_count (int id) XINE_PROTECTED;
242void xine_profiler_print_results (void) XINE_PROTECTED;
243
244/*
245 * xine_container_of()
246 * calculate struct pointer from field pointer
247 */
248
249#if defined(__GNUC__)
250# define xine_container_of(ptr, type, member) \
251 ({ \
252 const typeof(((type *)0)->member) *__mptr = (ptr); \
253 (type *)(void *)((char *)__mptr - offsetof(type, member)); \
254 })
255#else
256# define xine_container_of(ptr, type, member) \
257 ((type *)(void *)((char *)(1 ? (ptr) : &((type *)0)->member) - offsetof(type, member)))
258#endif
259
260/*
261 * Allocate and clean memory size_t 'size', then return the pointer
262 * to the allocated memory.
263 */
264void *xine_xmalloc(size_t size) XINE_MALLOC XINE_DEPRECATED XINE_PROTECTED;
265
266void *xine_xcalloc(size_t nmemb, size_t size) XINE_MALLOC XINE_PROTECTED;
267
268/*
269 * Free allocated memory and set pointer to NULL
270 * @param ptr Pointer to the pointer to the memory block which should be freed.
271 */
272 static inline void _x_freep(void *ptr) {
273 void **p = (void **)ptr;
274 free (*p);
275 *p = NULL;
276}
277
278 static inline void _x_freep_wipe_string(char **pp) {
279 char *p = *pp;
280 while (p && *p)
281 *p++ = 0;
282 _x_freep(pp);
283}
284
285/*
286 * Copy blocks of memory.
287 */
288void *xine_memdup (const void *src, size_t length) XINE_PROTECTED;
289void *xine_memdup0 (const void *src, size_t length) XINE_PROTECTED;
290
295#ifndef XINE_MEM_ALIGN
296# define XINE_MEM_ALIGN 32
297#endif
298
299void *xine_mallocz_aligned (size_t size) XINE_PROTECTED XINE_MALLOC;
300void *xine_malloc_aligned (size_t size) XINE_PROTECTED XINE_MALLOC;
301void xine_free_aligned (void *ptr) XINE_PROTECTED;
302void *xine_realloc_aligned (void *ptr, size_t size) XINE_PROTECTED;
303#define xine_freep_aligned(xinefreepptr) do {xine_free_aligned (*(xinefreepptr)); *(xinefreepptr) = NULL; } while (0)
304
313size_t xine_base64_encode (uint8_t *from, char *to, size_t size) XINE_PROTECTED;
320size_t xine_base64_decode (const char *from, uint8_t *to) XINE_PROTECTED;
321
325uint32_t xine_crc32_ieee (uint32_t crc, const uint8_t *data, size_t len) XINE_PROTECTED;
326uint32_t xine_crc16_ansi (uint32_t crc, const uint8_t *data, size_t len) XINE_PROTECTED;
327
328/*
329 * Get user home directory.
330 */
331const char *xine_get_homedir(void) XINE_PROTECTED;
332
333#if defined(WIN32) || defined(__CYGWIN__)
334/*
335 * Get other xine directories.
336 */
337const char *xine_get_pluginroot(void) XINE_PROTECTED;
338const char *xine_get_plugindir(void) XINE_PROTECTED;
339const char *xine_get_fontdir(void) XINE_PROTECTED;
340const char *xine_get_localedir(void) XINE_PROTECTED;
341#endif
342
343/*
344 * Clean a string (remove spaces and '=' at the begin,
345 * and '\n', '\r' and spaces at the end.
346 */
347char *xine_chomp (char *str) XINE_PROTECTED;
348
349/*
350 * A thread-safe usecond sleep
351 */
352void xine_usec_sleep(unsigned usec) XINE_PROTECTED;
353
354/* compatibility macros */
355#define xine_strpbrk(S, ACCEPT) strpbrk((S), (ACCEPT))
356#define xine_strsep(STRINGP, DELIM) strsep((STRINGP), (DELIM))
357#define xine_setenv(NAME, VAL, XX) setenv((NAME), (VAL), (XX))
358
364char *xine_strcat_realloc (char **dest, const char *append) XINE_PROTECTED;
365
372 char *_x_asprintf(const char *format, ...) XINE_PROTECTED XINE_MALLOC XINE_FORMAT_PRINTF(1, 2);
373
378int xine_open_cloexec(const char *name, int flags) XINE_PROTECTED;
379
384int xine_create_cloexec(const char *name, int flags, mode_t mode) XINE_PROTECTED;
385
390int xine_socket_cloexec(int domain, int type, int protocol) XINE_PROTECTED;
391
392/*
393 * Color Conversion Utility Functions
394 * The following data structures and functions facilitate the conversion
395 * of RGB images to packed YUV (YUY2) images. There are also functions to
396 * convert from YUV9 -> YV12. All of the meaty details are written in
397 * color.c.
398 */
399
400typedef struct yuv_planes_s {
401
402 unsigned char *y;
403 unsigned char *u;
404 unsigned char *v;
405 unsigned int row_width; /* frame width */
406 unsigned int row_count; /* frame height */
407
408} yuv_planes_t;
409
410void init_yuv_conversion(void) XINE_PROTECTED;
411void init_yuv_planes(yuv_planes_t *yuv_planes, int width, int height) XINE_PROTECTED;
412void free_yuv_planes(yuv_planes_t *yuv_planes) XINE_PROTECTED;
413
414extern void (*yuv444_to_yuy2)
415 (const yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch) XINE_PROTECTED;
416extern void (*yuv9_to_yv12)
417 (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch,
418 const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch,
419 const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch,
420 int width, int height) XINE_PROTECTED;
421extern void (*yuv411_to_yv12)
422 (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch,
423 const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch,
424 const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch,
425 int width, int height) XINE_PROTECTED;
426extern void (*yv12_to_yuy2)
427 (const unsigned char *y_src, int y_src_pitch,
428 const unsigned char *u_src, int u_src_pitch,
429 const unsigned char *v_src, int v_src_pitch,
430 unsigned char *yuy2_map, int yuy2_pitch,
431 int width, int height, int progressive) XINE_PROTECTED;
432extern void (*yuy2_to_yv12)
433 (const unsigned char *yuy2_map, int yuy2_pitch,
434 unsigned char *y_dst, int y_dst_pitch,
435 unsigned char *u_dst, int u_dst_pitch,
436 unsigned char *v_dst, int v_dst_pitch,
437 int width, int height) XINE_PROTECTED;
438
439
440/* convert full range rgb to mpeg range yuv */
441#define SCALESHIFT 16
442#define SCALEFACTOR (1<<SCALESHIFT)
443#define CENTERSAMPLE 128
444
445/* new fast and more accurate macros. Simply recompile to use them */
446#define COMPUTE_Y(r, g, b) \
447 (unsigned char) \
448 ((y_r_table[r] + y_g_table[g] + y_b_table[b]) >> SCALESHIFT)
449#define COMPUTE_U(r, g, b) \
450 (unsigned char) \
451 ((u_r_table[r] + u_g_table[g] + uv_br_table[b]) >> SCALESHIFT)
452#define COMPUTE_V(r, g, b) \
453 (unsigned char) \
454 ((uv_br_table[r] + v_g_table[g] + v_b_table[b]) >> SCALESHIFT)
455
456/* Binaries using these old ones keep working,
457 and get the full vs mpeg range bug fixed transparently as well.
458#define COMPUTE_Y(r, g, b) \
459 (unsigned char) \
460 ((y_r_table[r] + y_g_table[g] + y_b_table[b]) / SCALEFACTOR)
461#define COMPUTE_U(r, g, b) \
462 (unsigned char) \
463 ((u_r_table[r] + u_g_table[g] + u_b_table[b]) / SCALEFACTOR + CENTERSAMPLE)
464#define COMPUTE_V(r, g, b) \
465 (unsigned char) \
466 ((v_r_table[r] + v_g_table[g] + v_b_table[b]) / SCALEFACTOR + CENTERSAMPLE)
467*/
468
469#define UNPACK_BGR15(packed_pixel, r, g, b) \
470 b = (packed_pixel & 0x7C00) >> 7; \
471 g = (packed_pixel & 0x03E0) >> 2; \
472 r = (packed_pixel & 0x001F) << 3;
473
474#define UNPACK_BGR16(packed_pixel, r, g, b) \
475 b = (packed_pixel & 0xF800) >> 8; \
476 g = (packed_pixel & 0x07E0) >> 3; \
477 r = (packed_pixel & 0x001F) << 3;
478
479#define UNPACK_RGB15(packed_pixel, r, g, b) \
480 r = (packed_pixel & 0x7C00) >> 7; \
481 g = (packed_pixel & 0x03E0) >> 2; \
482 b = (packed_pixel & 0x001F) << 3;
483
484#define UNPACK_RGB16(packed_pixel, r, g, b) \
485 r = (packed_pixel & 0xF800) >> 8; \
486 g = (packed_pixel & 0x07E0) >> 3; \
487 b = (packed_pixel & 0x001F) << 3;
488
489extern int y_r_table[256] XINE_PROTECTED;
490extern int y_g_table[256] XINE_PROTECTED;
491extern int y_b_table[256] XINE_PROTECTED;
492
493extern int uv_br_table[256] XINE_PROTECTED;
494
495extern int u_r_table[256] XINE_PROTECTED;
496extern int u_g_table[256] XINE_PROTECTED;
497extern int u_b_table[256] XINE_PROTECTED;
498
499extern int v_r_table[256] XINE_PROTECTED;
500extern int v_g_table[256] XINE_PROTECTED;
501extern int v_b_table[256] XINE_PROTECTED;
502
503/* TJ. direct sliced rgb -> yuy2 conversion */
504 typedef struct rgb2yuy2_s rgb2yuy2_t;
505extern rgb2yuy2_t *rgb2yuy2_alloc (int color_matrix, const char *format) XINE_PROTECTED;
506extern void rgb2yuy2_free (rgb2yuy2_t *rgb2yuy2) XINE_PROTECTED;
507 extern void rgb2yuy2_slice (rgb2yuy2_t *rgb2yuy2, const uint8_t *in, int ipitch, uint8_t *out, int opitch,
508 int width, int height) XINE_PROTECTED;
509extern void rgb2yuy2_palette (rgb2yuy2_t *rgb2yuy2, const uint8_t *pal, int num_colors, int bits_per_pixel)
510 XINE_PROTECTED;
511
512extern void rgb2yv12_slice (rgb2yuy2_t *rgb2yuy2, const uint8_t *src, int src_stride,
513 uint8_t *y_dst, int y_pitch,
514 uint8_t *u_dst, int u_pitch,
515 uint8_t *v_dst, int v_pitch,
516 int width, int height) XINE_PROTECTED;
517
518/* frame copying functions */
519extern void yv12_to_yv12
520 (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dst, int y_dst_pitch,
521 const unsigned char *u_src, int u_src_pitch, unsigned char *u_dst, int u_dst_pitch,
522 const unsigned char *v_src, int v_src_pitch, unsigned char *v_dst, int v_dst_pitch,
523 int width, int height) XINE_PROTECTED;
524extern void yuy2_to_yuy2
525 (const unsigned char *src, int src_pitch,
526 unsigned char *dst, int dst_pitch,
527 int width, int height) XINE_PROTECTED;
528
529 void _x_nv12_to_yv12(const uint8_t *y_src, int y_src_pitch,
530 const uint8_t *uv_src, int uv_src_pitch,
531 uint8_t *y_dst, int y_dst_pitch,
532 uint8_t *u_dst, int u_dst_pitch,
533 uint8_t *v_dst, int v_dst_pitch,
534 int width, int height) XINE_PROTECTED;
535void _x_yv12_to_nv12(const uint8_t *y_src, int y_src_pitch,
536 const uint8_t *u_src, int u_src_pitch,
537 const uint8_t *v_src, int v_src_pitch,
538 uint8_t *y_dst, int y_dst_pitch,
539 uint8_t *uv_dst, int uv_dst_pitch,
540 int width, int height) XINE_PROTECTED;
541void _x_yuy2_to_nv12(const uint8_t *src_yuy2_map, int yuy2_pitch,
542 uint8_t *y_dst, int y_dst_pitch,
543 uint8_t *uv_dst, int uv_dst_pitch,
544 int width, int height) XINE_PROTECTED;
545
546
547/* print a hexdump of the given data */
548void xine_hexdump (const void *buf, int length) XINE_PROTECTED;
549
550/*
551 * Optimization macros for conditions
552 * Taken from the FIASCO L4 microkernel sources
553 */
554#if !defined(__GNUC__) || __GNUC__ < 3
555# define EXPECT_TRUE(x) (x)
556# define EXPECT_FALSE(x) (x)
557#else
558# define EXPECT_TRUE(x) __builtin_expect((x),1)
559# define EXPECT_FALSE(x) __builtin_expect((x),0)
560#endif
561
562#ifdef NDEBUG
563#define _x_assert(exp) \
564 do { \
565 if (!(exp)) \
566 fprintf(stderr, "assert: %s:%d: %s: Assertion `%s' failed.\n", \
567 __FILE__, __LINE__, __XINE_FUNCTION__, #exp); \
568 } while(0)
569#else
570#define _x_assert(exp) \
571 do { \
572 if (!(exp)) { \
573 fprintf(stderr, "assert: %s:%d: %s: Assertion `%s' failed.\n", \
574 __FILE__, __LINE__, __XINE_FUNCTION__, #exp); \
575 abort(); \
576 } \
577 } while(0)
578#endif
579
580 XINE_DEPRECATED static inline void _x_abort_is_deprecated(void) {}
581#define _x_abort() \
582 do { \
583 fprintf(stderr, "abort: %s:%d: %s: Aborting.\n", \
584 __FILE__, __LINE__, __XINE_FUNCTION__); \
585 abort(); \
586 _x_abort_is_deprecated(); \
587 } while(0)
588
589
590/****** logging with xine **********************************/
591
592#ifndef LOG_MODULE
593 #define LOG_MODULE __FILE__
594#endif /* LOG_MODULE */
595
596#define LOG_MODULE_STRING printf("%s: ", LOG_MODULE );
597
598#ifdef LOG_VERBOSE
599 #define LONG_LOG_MODULE_STRING \
600 printf("%s: (%s:%d) ", LOG_MODULE, __XINE_FUNCTION__, __LINE__ );
601#else
602 #define LONG_LOG_MODULE_STRING LOG_MODULE_STRING
603#endif /* LOG_VERBOSE */
604
605#ifdef LOG
606 #if defined(__GNUC__) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
607 #define lprintf(fmt, args...) \
608 do { \
609 LONG_LOG_MODULE_STRING \
610 printf(fmt, ##args); \
611 fflush(stdout); \
612 } while(0)
613 #else /* __GNUC__ */
614 #ifdef _MSC_VER
615 #define lprintf(fmtargs) \
616 do { \
617 LONG_LOG_MODULE_STRING \
618 printf("%s", fmtargs); \
619 fflush(stdout); \
620 } while(0)
621 #else /* _MSC_VER */
622 #define lprintf(...) \
623 do { \
624 LONG_LOG_MODULE_STRING \
625 printf(__VA_ARGS__); \
626 fflush(stdout); \
627 } while(0)
628 #endif /* _MSC_VER */
629 #endif /* __GNUC__ */
630#else /* LOG */
631 #if defined(DEBUG) && defined(XINE_COMPILE)
632 XINE_FORMAT_PRINTF(1, 2) static inline void lprintf(const char * fmt, ...) { (void)fmt; }
633 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
634 #define lprintf(...) do {} while(0)
635 #elif defined(__GNUC__)
636 #define lprintf(fmt, args...) do {} while(0)
637 #elif defined(_MSC_VER)
638void __inline lprintf(const char * fmt, ...) {}
639 #else
640 #define lprintf(...) do {} while(0)
641 #endif
642#endif /* LOG */
643
644#if defined(__GNUC__) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
645 #define llprintf(cat, fmt, args...) \
646 do{ \
647 if(cat){ \
648 LONG_LOG_MODULE_STRING \
649 printf( fmt, ##args ); \
650 } \
651 }while(0)
652#else
653#ifdef _MSC_VER
654 #define llprintf(cat, fmtargs) \
655 do{ \
656 if(cat){ \
657 LONG_LOG_MODULE_STRING \
658 printf( "%s", fmtargs ); \
659 } \
660 }while(0)
661#else
662 #define llprintf(cat, ...) \
663 do{ \
664 if(cat){ \
665 LONG_LOG_MODULE_STRING \
666 printf( __VA_ARGS__ ); \
667 } \
668 }while(0)
669#endif /* _MSC_VER */
670#endif /* __GNUC__ */
671
672#if defined(__GNUC__) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
673 #define xprintf(xine, verbose, fmt, args...) \
674 do { \
675 if((xine) && (xine)->verbosity >= verbose){ \
676 xine_log(xine, XINE_LOG_TRACE, fmt, ##args); \
677 } \
678 } while(0)
679#else
680#ifdef _MSC_VER
681void xine_xprintf(xine_t *xine, int verbose, const char *fmt, ...);
682 #define xprintf xine_xprintf
683#else
684 #define xprintf(xine, verbose, ...) \
685 do { \
686 if((xine) && (xine)->verbosity >= verbose){ \
687 xine_log(xine, XINE_LOG_TRACE, __VA_ARGS__); \
688 } \
689 } while(0)
690#endif /* _MSC_VER */
691#endif /* __GNUC__ */
692
693/* time measuring macros for profiling tasks */
694
695#ifdef DEBUG
696# define XINE_PROFILE(function) \
697 do { \
698 struct timeval current_time; \
699 double dtime; \
700 gettimeofday(&current_time, NULL); \
701 dtime = -(current_time.tv_sec + (current_time.tv_usec / 1000000.0)); \
702 function; \
703 gettimeofday(&current_time, NULL); \
704 dtime += current_time.tv_sec + (current_time.tv_usec / 1000000.0); \
705 printf("%s: (%s:%d) took %lf seconds\n", \
706 LOG_MODULE, __XINE_FUNCTION__, __LINE__, dtime); \
707 } while(0)
708# define XINE_PROFILE_ACCUMULATE(function) \
709 do { \
710 struct timeval current_time; \
711 static double dtime = 0; \
712 gettimeofday(&current_time, NULL); \
713 dtime -= current_time.tv_sec + (current_time.tv_usec / 1000000.0); \
714 function; \
715 gettimeofday(&current_time, NULL); \
716 dtime += current_time.tv_sec + (current_time.tv_usec / 1000000.0); \
717 printf("%s: (%s:%d) took %lf seconds\n", \
718 LOG_MODULE, __XINE_FUNCTION__, __LINE__, dtime); \
719 } while(0)
720#else
721# define XINE_PROFILE(function) function
722# define XINE_PROFILE_ACCUMULATE(function) function
723#endif /* DEBUG */
724
728char *xine_get_system_encoding(void) XINE_MALLOC XINE_PROTECTED;
729
730/*
731 * guess default encoding for the subtitles
732 */
733const char *xine_guess_spu_encoding(void) XINE_PROTECTED;
734
735/*
736 * use the best clock reference (API compatible with gettimeofday)
737 * note: it will be a monotonic clock, if available.
738 */
739struct timezone;
740int xine_monotonic_clock(struct timeval *tv, struct timezone *tz) XINE_PROTECTED;
741
745void _x_report_video_fourcc (xine_t *, const char *module, uint32_t) XINE_PROTECTED;
746void _x_report_audio_format_tag (xine_t *, const char *module, uint32_t) XINE_PROTECTED;
747
752#define XINE_FAST_STRING 1
754size_t xine_fast_string_need (size_t max_strlen) XINE_PROTECTED;
756size_t xine_fast_string_max (char *fast_string) XINE_PROTECTED;
758char *xine_fast_string_init (char *buf, size_t bsize) XINE_PROTECTED;
762char *xine_fast_string_set (char *fast_string, const char *text, size_t tsize) XINE_PROTECTED;
766int xine_fast_string_cmp (char *fast_string1, char *fast_string2);
768void xine_fast_string_free (char **fast_string) XINE_PROTECTED;
769
770/* don't harm following code */
771#ifdef extern
772# undef extern
773#endif
774
775#ifdef __cplusplus
776}
777#endif
778
779#endif
array.h
compat.h
configfile.h
height
unsigned int height
Definition: gfontrle.c:5
width
unsigned int width
Definition: gfontrle.c:4
attributes.h
XINE_DEPRECATED
#define XINE_DEPRECATED
Definition: attributes.h:87
XINE_MALLOC
#define XINE_MALLOC
Definition: attributes.h:141
XINE_PROTECTED
#define XINE_PROTECTED
Definition: attributes.h:75
XINE_FORMAT_PRINTF
#define XINE_FORMAT_PRINTF(fmt, var)
Definition: attributes.h:129
XINE_CONST
#define XINE_CONST
Definition: attributes.h:153
list.h
os_types.h
sorted_array.h
dlist_t
Definition: xineutils.h:79
dlist_t::head
dnode_t *volatile head
Definition: xineutils.h:80
dlist_t::tail
dnode_t *volatile tail
Definition: xineutils.h:82
dlist_t::null
dnode_t * null
Definition: xineutils.h:81
dnode_st
Definition: xineutils.h:64
dnode_st::next
struct dnode_st * next
Definition: xineutils.h:65
dnode_st::prev
struct dnode_st * prev
Definition: xineutils.h:65
rgb2yuy2_s
Definition: color.c:1752
rgb2yuy2_s::fmt
int fmt
Definition: color.c:1758
xine_mutex_t
Definition: xineutils.h:137
xine_mutex_t::locked_by
char * locked_by
Definition: xineutils.h:140
xine_mutex_t::mutex
pthread_mutex_t mutex
Definition: xineutils.h:138
xine_s
Definition: xine_internal.h:80
yuv_planes_s
Definition: xineutils.h:400
yuv_planes_s::u
unsigned char * u
Definition: xineutils.h:403
yuv_planes_s::row_width
unsigned int row_width
Definition: xineutils.h:405
yuv_planes_s::row_count
unsigned int row_count
Definition: xineutils.h:406
yuv_planes_s::y
unsigned char * y
Definition: xineutils.h:402
yuv_planes_s::v
unsigned char * v
Definition: xineutils.h:404
name
const char * name
Definition: xine.c:1569
type
_xine_arg_type_t type
Definition: xine.c:1568
xine_buffer.h
NULL
NULL
Definition: xine_plugin.c:78
mode
enable disable number of frames of telecine pattern sync required before mode change make frames evenly spaced for film mode(24 fps)" ) PARAM_ITEM( POST_PARAM_TYPE_BOOL
free_yuv_planes
void free_yuv_planes(yuv_planes_t *yuv_planes)
Definition: color.c:140
xine_profiler_stop_count
void xine_profiler_stop_count(int id)
Definition: monitor.c:98
rgb2yv12_slice
void rgb2yv12_slice(rgb2yuy2_t *rgb2yuy2, const uint8_t *src, int src_stride, uint8_t *y_dst, int y_pitch, uint8_t *u_dst, int u_pitch, uint8_t *v_dst, int v_pitch, int width, int height)
Definition: color.c:2231
init_yuv_conversion
void init_yuv_conversion(void)
Definition: color.c:1686
xine_fast_string_init
char * xine_fast_string_init(char *buf, size_t bsize)
Definition: utils.c:1174
yuv_planes_t
struct yuv_planes_s yuv_planes_t
xine_fast_string_need
size_t xine_fast_string_need(size_t max_strlen)
Definition: utils.c:1169
xine_xmalloc
void * xine_xmalloc(size_t size) XINE_DEPRECATED
Allocate and clean memory size_t 'size', then return the pointer to the allocated memory.
Definition: utils.c:271
xine_base64_encode
size_t xine_base64_encode(uint8_t *from, char *to, size_t size)
Definition: utils.c:918
dnode_t
struct dnode_st dnode_t
xine_profiler_init
void xine_profiler_init(void)
Definition: monitor.c:47
xine_open_cloexec
char int xine_open_cloexec(const char *name, int flags)
Definition: utils.c:815
xine_strcat_realloc
char * xine_strcat_realloc(char **dest, const char *append)
Definition: utils.c:775
xine_crc32_ieee
uint32_t xine_crc32_ieee(uint32_t crc, const uint8_t *data, size_t len)
Definition: utils.c:998
xine_fast_string_free
void xine_fast_string_free(char **fast_string)
Definition: utils.c:1260
xine_mutex_unlock
int xine_mutex_unlock(xine_mutex_t *mutex, const char *who)
Definition: xine_mutex.c:71
_x_asprintf
char * _x_asprintf(const char *format,...) XINE_FORMAT_PRINTF(1
_x_report_video_fourcc
void _x_report_video_fourcc(xine_t *, const char *module, uint32_t)
Definition: buffer_types.c:615
xine_get_system_encoding
char * xine_get_system_encoding(void)
Definition: utils.c:646
xine_hexdump
void xine_hexdump(const void *buf, int length)
Definition: utils.c:576
xine_cpu_count
int xine_cpu_count(void) XINE_CONST
Definition: cpu_accel.c:496
_x_nv12_to_yv12
void _x_nv12_to_yv12(const uint8_t *y_src, int y_src_pitch, const uint8_t *uv_src, int uv_src_pitch, uint8_t *y_dst, int y_dst_pitch, uint8_t *u_dst, int u_dst_pitch, uint8_t *v_dst, int v_dst_pitch, int width, int height)
y_g_table
int y_g_table[256]
Definition: color.c:79
xine_create_cloexec
int xine_create_cloexec(const char *name, int flags, mode_t mode)
Definition: utils.c:826
xine_profiler_start_count
void xine_profiler_start_count(int id)
Definition: monitor.c:90
init_yuv_planes
void init_yuv_planes(yuv_planes_t *yuv_planes, int width, int height)
Definition: color.c:122
xine_guess_spu_encoding
const char * xine_guess_spu_encoding(void)
Definition: utils.c:694
y_r_table
int y_r_table[256]
Definition: color.c:78
xine_mutex_destroy
int xine_mutex_destroy(xine_mutex_t *mutex)
Definition: xine_mutex.c:78
v_r_table
int v_r_table[256]
Definition: color.c:90
xine_xcalloc
void * xine_xcalloc(size_t nmemb, size_t size)
Wrapper around calloc() function.
Definition: utils.c:296
yv12_to_yuy2
void(* yv12_to_yuy2)(const unsigned char *y_src, int y_src_pitch, const unsigned char *u_src, int u_src_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *yuy2_map, int yuy2_pitch, int width, int height, int progressive)
Definition: color.c:104
v_g_table
int v_g_table[256]
Definition: color.c:87
_x_freep
static void _x_freep(void *ptr)
Definition: xineutils.h:272
xine_memdup0
void * xine_memdup0(const void *src, size_t length)
Definition: utils.c:317
_x_freep_wipe_string
static void _x_freep_wipe_string(char **pp)
Definition: xineutils.h:278
rgb2yuy2_alloc
rgb2yuy2_t * rgb2yuy2_alloc(int color_matrix, const char *format)
Definition: color.c:1768
xine_fast_string_cmp
int xine_fast_string_cmp(char *fast_string1, char *fast_string2)
Definition: utils.c:1237
xine_socket_cloexec
int xine_socket_cloexec(int domain, int type, int protocol)
Definition: utils.c:837
xine_memdup
void * xine_memdup(const void *src, size_t length)
Definition: utils.c:308
xine_crc16_ansi
uint32_t xine_crc16_ansi(uint32_t crc, const uint8_t *data, size_t len)
Definition: utils.c:1071
xine_fast_string_set
char * xine_fast_string_set(char *fast_string, const char *text, size_t tsize)
Definition: utils.c:1193
xine_get_homedir
const char * xine_get_homedir(void)
Definition: utils.c:380
yuy2_to_yv12
void(* yuy2_to_yv12)(const unsigned char *yuy2_map, int yuy2_pitch, unsigned char *y_dst, int y_dst_pitch, unsigned char *u_dst, int u_dst_pitch, unsigned char *v_dst, int v_dst_pitch, int width, int height)
Definition: color.c:110
xine_mutex_lock
int xine_mutex_lock(xine_mutex_t *mutex, const char *who)
Definition: xine_mutex.c:46
xine_fast_string_max
size_t xine_fast_string_max(char *fast_string)
Definition: utils.c:1187
xine_malloc_aligned
void * xine_malloc_aligned(size_t size)
Definition: utils.c:869
xine_free_aligned
void xine_free_aligned(void *ptr)
Definition: utils.c:882
yuv9_to_yv12
void(* yuv9_to_yv12)(const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, int width, int height)
Definition: color.c:94
uv_br_table
int uv_br_table[256]
Definition: color.c:82
rgb2yuy2_free
void rgb2yuy2_free(rgb2yuy2_t *rgb2yuy2)
Definition: color.c:1943
v_b_table
int v_b_table[256]
Definition: color.c:86
xine_realloc_aligned
void * xine_realloc_aligned(void *ptr, size_t size)
Definition: utils.c:890
xine_mutex_init
int xine_mutex_init(xine_mutex_t *mutex, const pthread_mutexattr_t *mutexattr, const char *id)
Definition: xine_mutex.c:33
yuy2_to_yuy2
void yuy2_to_yuy2(const unsigned char *src, int src_pitch, unsigned char *dst, int dst_pitch, int width, int height)
Definition: copy.c:59
yv12_to_yv12
void yv12_to_yv12(const unsigned char *y_src, int y_src_pitch, unsigned char *y_dst, int y_dst_pitch, const unsigned char *u_src, int u_src_pitch, unsigned char *u_dst, int u_dst_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *v_dst, int v_dst_pitch, int width, int height)
Definition: copy.c:48
xine_small_memcpy
#define xine_small_memcpy(xsm_to, xsm_from, xsm_len)
Definition: xineutils.h:201
xine_profiler_print_results
void xine_profiler_print_results(void)
Definition: monitor.c:107
_x_yuy2_to_nv12
void _x_yuy2_to_nv12(const uint8_t *src_yuy2_map, int yuy2_pitch, uint8_t *y_dst, int y_dst_pitch, uint8_t *uv_dst, int uv_dst_pitch, int width, int height)
Definition: copy.c:120
_x_yv12_to_nv12
void _x_yv12_to_nv12(const uint8_t *y_src, int y_src_pitch, const uint8_t *u_src, int u_src_pitch, const uint8_t *v_src, int v_src_pitch, uint8_t *y_dst, int y_dst_pitch, uint8_t *uv_dst, int uv_dst_pitch, int width, int height)
Definition: copy.c:88
y_b_table
int y_b_table[256]
Definition: color.c:80
rgb2yuy2_slice
void rgb2yuy2_slice(rgb2yuy2_t *rgb2yuy2, const uint8_t *in, int ipitch, uint8_t *out, int opitch, int width, int height)
xine_profiler_allocate_slot
int xine_profiler_allocate_slot(const char *label)
Definition: monitor.c:53
u_r_table
int u_r_table[256]
Definition: color.c:84
yuv411_to_yv12
void(* yuv411_to_yv12)(const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, int width, int height)
Definition: color.c:99
u_b_table
int u_b_table[256]
Definition: color.c:89
xine_mm_accel
uint32_t xine_mm_accel(void) XINE_CONST
Definition: cpu_accel.c:390
xine_base64_decode
size_t xine_base64_decode(const char *from, uint8_t *to)
Definition: utils.c:943
u_g_table
int u_g_table[256]
Definition: color.c:85
lprintf
#define lprintf(...)
Definition: xineutils.h:640
xine_usec_sleep
void xine_usec_sleep(unsigned usec)
Definition: utils.c:546
rgb2yuy2_palette
void rgb2yuy2_palette(rgb2yuy2_t *rgb2yuy2, const uint8_t *pal, int num_colors, int bits_per_pixel)
Definition: color.c:1947
_x_abort_is_deprecated
static XINE_DEPRECATED void _x_abort_is_deprecated(void)
Definition: xineutils.h:580
xine_chomp
char * xine_chomp(char *str)
Definition: utils.c:525
xine_mallocz_aligned
void * xine_mallocz_aligned(size_t size)
Definition: utils.c:856
xine_monotonic_clock
int xine_monotonic_clock(struct timeval *tv, struct timezone *tz)
Definition: utils.c:727
_x_report_audio_format_tag
void _x_report_audio_format_tag(xine_t *, const char *module, uint32_t)
Definition: buffer_types.c:627
yuv444_to_yuy2
void(* yuv444_to_yuy2)(const yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch)
Definition: color.c:92
xmlparser.h