VLC  4.0.0-dev
vlc_common.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_common.h: common definitions
3  * Collection of useful common types and macros definitions
4  *****************************************************************************
5  * Copyright (C) 1998-2011 VLC authors and VideoLAN
6  *
7  * Authors: Samuel Hocevar <sam@via.ecp.fr>
8  * Vincent Seguin <seguin@via.ecp.fr>
9  * Gildas Bazin <gbazin@videolan.org>
10  * RĂ©mi Denis-Courmont
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU Lesser General Public License as published by
14  * the Free Software Foundation; either version 2.1 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program; if not, write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26 
27 #ifndef VLC_COMMON_H
28 # define VLC_COMMON_H 1
29 
30 /**
31  * \defgroup vlc VLC plug-in programming interface
32  * \file
33  * \ingroup vlc
34  * This file is a collection of common definitions and types
35  */
36 
37 /*****************************************************************************
38  * Required vlc headers
39  *****************************************************************************/
40 #include "vlc_config.h"
41 
42 /*****************************************************************************
43  * Required system headers
44  *****************************************************************************/
45 #include <stdlib.h>
46 #include <stdarg.h>
47 
48 #include <string.h>
49 #include <stdio.h>
50 #include <inttypes.h>
51 #include <stddef.h>
52 
53 #ifndef __cplusplus
54 # include <stdbool.h>
55 #endif
56 
57 /**
58  * \defgroup cext C programming language extensions
59  * \ingroup vlc
60  *
61  * This section defines a number of macros and inline functions extending the
62  * C language. Most extensions are implemented by GCC and LLVM/Clang, and have
63  * unoptimized fallbacks for other C11/C++11 conforming compilers.
64  * @{
65  */
66 #ifdef __GNUC__
67 # define VLC_GCC_VERSION(maj,min) \
68  ((__GNUC__ > (maj)) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
69 #else
70 /** GCC version check */
71 # define VLC_GCC_VERSION(maj,min) (0)
72 #endif
73 
74 /* Try to fix format strings for all versions of mingw and mingw64 */
75 #if defined( _WIN32 ) && defined( __USE_MINGW_ANSI_STDIO )
76  #undef PRId64
77  #define PRId64 "lld"
78  #undef PRIi64
79  #define PRIi64 "lli"
80  #undef PRIu64
81  #define PRIu64 "llu"
82  #undef PRIo64
83  #define PRIo64 "llo"
84  #undef PRIx64
85  #define PRIx64 "llx"
86  #define snprintf __mingw_snprintf
87  #define vsnprintf __mingw_vsnprintf
88  #define swprintf _snwprintf
89 #endif
90 
91 /* Function attributes for compiler warnings */
92 #ifdef __GNUC__
93 # define VLC_DEPRECATED __attribute__((deprecated))
94 # if VLC_GCC_VERSION(6,0)
95 # define VLC_DEPRECATED_ENUM __attribute__((deprecated))
96 # else
97 # define VLC_DEPRECATED_ENUM
98 # endif
99 
100 # if defined( _WIN32 ) && !defined( __clang__ )
101 # define VLC_FORMAT(x,y) __attribute__ ((format(gnu_printf,x,y)))
102 # else
103 # define VLC_FORMAT(x,y) __attribute__ ((format(printf,x,y)))
104 # endif
105 # define VLC_FORMAT_ARG(x) __attribute__ ((format_arg(x)))
106 # define VLC_MALLOC __attribute__ ((malloc))
107 # define VLC_USED __attribute__ ((warn_unused_result))
108 
109 #else
110 /**
111  * Deprecated functions or compound members annotation
112  *
113  * Use this macro in front of a function declaration or compound member
114  * within a compound type declaration.
115  * The compiler may emit a warning every time the function or member is used.
116  *
117  * Use \ref VLC_DEPRECATED_ENUM instead for enumeration members.
118  */
119 # define VLC_DEPRECATED
120 
121 /**
122  * Deprecated enum member annotation
123  *
124  * Use this macro after an enumerated type member declaration.
125  * The compiler may emit a warning every time the enumeration member is used.
126  *
127  * See also \ref VLC_DEPRECATED.
128  */
129 # define VLC_DEPRECATED_ENUM
130 
131 /**
132  * String format function annotation
133  *
134  * Use this macro after a function prototype/declaration if the function
135  * expects a standard C format string. This helps compiler diagnostics.
136  *
137  * @param x the position (starting from 1) of the format string argument
138  * @param y the first position (also starting from 1) of the variable arguments
139  * following the format string (usually but not always \p x+1).
140  */
141 # define VLC_FORMAT(x,y)
142 
143 /**
144  * Format string translation function annotation
145  *
146  * Use this macro after a function prototype/declaration if the function
147  * expects a format string as input and returns another format string as output
148  * to another function.
149  *
150  * This is primarily intended for localization functions such as gettext().
151  */
152 # define VLC_FORMAT_ARG(x)
153 
154 /**
155  * Heap allocated result function annotation
156  *
157  * Use this macro to annotate a function that returns a pointer to memory that
158  * cannot alias any other valid pointer.
159  *
160  * This is primarily used for functions that return a pointer to heap-allocated
161  * memory, but it can be used for other applicable purposes.
162  *
163  * \warning Do not use this annotation if the returned pointer can in any way
164  * alias a valid pointer at the time the function exits. This could lead to
165  * very weird memory corruption bugs.
166  */
167 # define VLC_MALLOC
168 
169 /**
170  * Used result function annotation
171  *
172  * Use this macro to annotate a function whose result must be used.
173  *
174  * There are several cases where this is useful:
175  * - If a function has no side effects (or no useful side effects), such that
176  * the only useful purpose of calling said function is to obtain its
177  * return value.
178  * - If ignoring the function return value would lead to a resource leak
179  * (including but not limited to a memory leak).
180  * - If a function cannot be used correctly without checking its return value.
181  * For instance, if the function can fail at any time.
182  *
183  * The compiler may warn if the return value of a function call is ignored.
184  */
185 # define VLC_USED
186 #endif
187 
188 #if defined (__ELF__) || defined (__MACH__)
189 # define VLC_WEAK __attribute__((weak))
190 #else
191 /**
192  * Weak symbol annotation
193  *
194  * Use this macro before an external identifier \b definition to mark it as a
195  * weak symbol. A weak symbol can be overriden by another symbol of the same
196  * name at the link time.
197  */
198 # define VLC_WEAK
199 #endif
200 
201 /* Branch prediction */
202 #if defined (__GNUC__) || defined (__clang__)
203 # define likely(p) __builtin_expect(!!(p), 1)
204 # define unlikely(p) __builtin_expect(!!(p), 0)
205 # define unreachable() __builtin_unreachable()
206 #elif defined(_MSC_VER)
207 # define likely(p) (!!(p))
208 # define unlikely(p) (!!(p))
209 # define unreachable() (__assume(0))
210 #else
211 /**
212  * Predicted true condition
213  *
214  * This macro indicates that the condition is expected most often true.
215  * The compiler may optimize the code assuming that this condition is usually
216  * met.
217  */
218 # define likely(p) (!!(p))
219 
220 /**
221  * Predicted false condition
222  *
223  * This macro indicates that the condition is expected most often false.
224  * The compiler may optimize the code assuming that this condition is rarely
225  * met.
226  */
227 # define unlikely(p) (!!(p))
228 
229 /**
230  * Impossible branch
231  *
232  * This macro indicates that the branch cannot be reached at run-time, and
233  * represents undefined behaviour.
234  * The compiler may optimize the code assuming that the call flow will never
235  * logically reach the point where this macro is expanded.
236  *
237  * See also \ref vlc_assert_unreachable.
238  */
239 # define unreachable() ((void)0)
240 #endif
241 
242 /**
243  * Impossible branch assertion
244  *
245  * This macro asserts that the branch cannot be reached at run-time.
246  *
247  * If the branch is reached in a debug build, it will trigger an assertion
248  * failure and abnormal program termination.
249  *
250  * If the branch is reached in a non-debug build, this macro is equivalent to
251  * \ref unreachable and the behaviour is undefined.
252  */
253 #define vlc_assert_unreachable() (vlc_assert(!"unreachable"), unreachable())
254 
255 /**
256  * Run-time assertion
257  *
258  * This macro performs a run-time assertion if C assertions are enabled
259  * and the following preprocessor symbol is defined:
260  * @verbatim __LIBVLC__ @endverbatim
261  * That restriction ensures that assertions in public header files are not
262  * unwittingly <i>leaked</i> to externally-compiled plug-ins
263  * including those header files.
264  *
265  * Within the LibVLC code base, this is exactly the same as assert(), which can
266  * and probably should be used directly instead.
267  */
268 #ifdef __LIBVLC__
269 # define vlc_assert(pred) assert(pred)
270 #else
271 # define vlc_assert(pred) ((void)0)
272 #endif
273 
274 /* Linkage */
275 #ifdef __cplusplus
276 # define VLC_EXTERN extern "C"
277 #else
278 # define VLC_EXTERN
279 #endif
280 
281 #if defined (_WIN32) && defined (DLL_EXPORT)
282 # define VLC_EXPORT __declspec(dllexport)
283 #elif defined (__GNUC__)
284 # define VLC_EXPORT __attribute__((visibility("default")))
285 #else
286 # define VLC_EXPORT
287 #endif
288 
289 /**
290  * Exported API call annotation
291  *
292  * This macro is placed before a function declaration to indicate that the
293  * function is an API call of the LibVLC plugin API.
294  */
295 #define VLC_API VLC_EXTERN VLC_EXPORT
296 
297 /** @} */
298 
299 /*****************************************************************************
300  * Basic types definitions
301  *****************************************************************************/
302 /**
303  * The vlc_fourcc_t type.
304  *
305  * See http://www.webartz.com/fourcc/ for a very detailed list.
306  */
307 typedef uint32_t vlc_fourcc_t;
308 
309 #ifdef WORDS_BIGENDIAN
310 # define VLC_FOURCC( a, b, c, d ) \
311  ( ((uint32_t)d) | ( ((uint32_t)c) << 8 ) \
312  | ( ((uint32_t)b) << 16 ) | ( ((uint32_t)a) << 24 ) )
313 # define VLC_TWOCC( a, b ) \
314  ( (uint16_t)(b) | ( (uint16_t)(a) << 8 ) )
315 
316 #else
317 # define VLC_FOURCC( a, b, c, d ) \
318  ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \
319  | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) )
320 # define VLC_TWOCC( a, b ) \
321  ( (uint16_t)(a) | ( (uint16_t)(b) << 8 ) )
322 
323 #endif
324 
325 /**
326  * Translate a vlc_fourcc into its string representation. This function
327  * assumes there is enough room in psz_fourcc to store 4 characters in.
328  *
329  * \param fcc a vlc_fourcc_t
330  * \param psz_fourcc string to store string representation of vlc_fourcc in
331  */
332 static inline void vlc_fourcc_to_char( vlc_fourcc_t fcc, char *psz_fourcc )
333 {
334  memcpy( psz_fourcc, &fcc, 4 );
335 }
336 
337 /*****************************************************************************
338  * Classes declaration
339  *****************************************************************************/
340 
341 /* Internal types */
342 typedef struct vlc_object_t vlc_object_t;
343 typedef struct libvlc_int_t libvlc_int_t;
344 typedef struct date_t date_t;
345 
346 /* Playlist */
347 
351 
352 /* Modules */
353 typedef struct module_t module_t;
355 
357 
358 /* Input */
359 typedef struct input_item_t input_item_t;
362 typedef struct stream_t stream_t;
363 typedef struct stream_t demux_t;
364 typedef struct es_out_t es_out_t;
365 typedef struct es_out_id_t es_out_id_t;
366 typedef struct seekpoint_t seekpoint_t;
367 typedef struct info_t info_t;
370 
371 /* Format */
375 typedef struct es_format_t es_format_t;
377 typedef struct vlc_es_id_t vlc_es_id_t;
378 
379 /* Audio */
382 
383 /* Video */
386 
388 typedef struct picture_t picture_t;
389 
390 /* Subpictures */
391 typedef struct spu_t spu_t;
392 typedef struct subpicture_t subpicture_t;
394 
396 
397 /* Stream output */
399 
400 typedef struct sout_input_t sout_input_t;
402 
404 
405 typedef struct sout_mux_t sout_mux_t;
406 
408 
411 
412 /* Decoders */
413 typedef struct decoder_t decoder_t;
414 
415 /* Encoders */
416 typedef struct encoder_t encoder_t;
417 
418 /* Filters */
419 typedef struct filter_t filter_t;
420 
421 /* Network */
422 typedef struct vlc_url_t vlc_url_t;
423 
424 /* Misc */
426 
427 /* block */
428 typedef struct block_t block_t;
429 typedef struct block_fifo_t block_fifo_t;
430 
431 /* Hashing */
433 
434 /* XML */
435 typedef struct xml_t xml_t;
436 typedef struct xml_reader_t xml_reader_t;
437 
438 /* vod server */
439 typedef struct vod_t vod_t;
440 typedef struct vod_media_t vod_media_t;
441 
442 /* VLM */
443 typedef struct vlm_t vlm_t;
445 
446 /* misc */
447 typedef struct vlc_meta_t vlc_meta_t;
450 
451 /* Update */
452 typedef struct update_t update_t;
453 
454 /**
455  * VLC value structure
456  */
457 typedef union
458 {
459  int64_t i_int;
460  bool b_bool;
461  float f_float;
462  char * psz_string;
463  void * p_address;
464  struct { int32_t x; int32_t y; } coords;
465 
466 } vlc_value_t;
467 
468 /*****************************************************************************
469  * Error values (shouldn't be exposed)
470  *****************************************************************************/
471 /** No error */
472 #define VLC_SUCCESS (-0)
473 /** Unspecified error */
474 #define VLC_EGENERIC (-1)
475 /** Not enough memory */
476 #define VLC_ENOMEM (-2)
477 /** Timeout */
478 #define VLC_ETIMEOUT (-3)
479 /** Module not found */
480 #define VLC_ENOMOD (-4)
481 /** Object not found */
482 #define VLC_ENOOBJ (-5)
483 /** Variable not found */
484 #define VLC_ENOVAR (-6)
485 /** Bad variable value */
486 #define VLC_EBADVAR (-7)
487 /** Item not found */
488 #define VLC_ENOITEM (-8)
489 
490 /*****************************************************************************
491  * Variable callbacks: called when the value is modified
492  *****************************************************************************/
493 typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
494  char const *, /* variable name */
495  vlc_value_t, /* old value */
496  vlc_value_t, /* new value */
497  void * ); /* callback data */
498 
499 /*****************************************************************************
500  * List callbacks: called when elements are added/removed from the list
501  *****************************************************************************/
502 typedef int ( * vlc_list_callback_t ) ( vlc_object_t *, /* variable's object */
503  char const *, /* variable name */
504  int, /* VLC_VAR_* action */
505  vlc_value_t *, /* new/deleted value */
506  void *); /* callback data */
507 
508 /*****************************************************************************
509  * OS-specific headers and thread types
510  *****************************************************************************/
511 #if defined( _WIN32 )
512 # include <malloc.h>
513 # ifndef PATH_MAX
514 # define PATH_MAX MAX_PATH
515 # endif
516 # include <windows.h>
517 #endif
518 
519 #ifdef __APPLE__
520 #include <sys/syslimits.h>
521 #include <AvailabilityMacros.h>
522 #endif
523 
524 #ifdef __OS2__
525 # define OS2EMX_PLAIN_CHAR
526 # define INCL_BASE
527 # define INCL_PM
528 # include <os2safe.h>
529 # include <os2.h>
530 #endif
531 
532 #include "vlc_tick.h"
533 #include "vlc_threads.h"
534 
535 /**
536  * \defgroup intops Integer operations
537  * \ingroup cext
538  *
539  * Common integer functions.
540  * @{
541  */
542 /* __MAX and __MIN: self explanatory */
543 #ifndef __MAX
544 # define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
545 #endif
546 #ifndef __MIN
547 # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
548 #endif
549 
550 /* clip v in [min, max] */
551 #define VLC_CLIP(v, min, max) __MIN(__MAX((v), (min)), (max))
552 
553 /**
554  * Make integer v a multiple of align
555  *
556  * \note align must be a power of 2
557  */
558 VLC_USED
559 static inline size_t vlc_align(size_t v, size_t align)
560 {
561  return (v + (align - 1)) & ~(align - 1);
562 }
563 
564 #if defined(__clang__) && __has_attribute(diagnose_if)
565 static inline size_t vlc_align(size_t v, size_t align)
566  __attribute__((diagnose_if(((align & (align - 1)) || (align == 0)),
567  "align must be power of 2", "error")));
568 #endif
569 
570 /** Greatest common divisor */
571 VLC_USED
572 static inline int64_t GCD ( int64_t a, int64_t b )
573 {
574  while( b )
575  {
576  int64_t c = a % b;
577  a = b;
578  b = c;
579  }
580  return a;
581 }
582 
583 /* function imported from libavutil/common.h */
584 VLC_USED
585 static inline uint8_t clip_uint8_vlc( int32_t a )
586 {
587  if( a&(~255) ) return (-a)>>31;
588  else return a;
589 }
590 
591 /**
592  * \defgroup bitops Bit operations
593  * @{
594  */
595 
596 #define VLC_INT_FUNC(basename) \
597  VLC_INT_FUNC_TYPE(basename, unsigned, ) \
598  VLC_INT_FUNC_TYPE(basename, unsigned long, l) \
599  VLC_INT_FUNC_TYPE(basename, unsigned long long, ll)
600 
601 #if defined (__GNUC__) || defined (__clang__)
602 # define VLC_INT_FUNC_TYPE(basename,type,suffix) \
603 VLC_USED static inline int vlc_##basename##suffix(type x) \
604 { \
605  return __builtin_##basename##suffix(x); \
606 }
607 
609 #else
610 VLC_USED static inline int vlc_clzll(unsigned long long x)
611 {
612  int i = sizeof (x) * 8;
613 
614  while (x)
615  {
616  x >>= 1;
617  i--;
618  }
619  return i;
620 }
621 
622 VLC_USED static inline int vlc_clzl(unsigned long x)
623 {
624  return vlc_clzll(x) - ((sizeof (long long) - sizeof (long)) * 8);
625 }
626 
627 VLC_USED static inline int vlc_clz(unsigned x)
628 {
629  return vlc_clzll(x) - ((sizeof (long long) - sizeof (int)) * 8);
630 }
631 
632 VLC_USED static inline int vlc_ctz_generic(unsigned long long x)
633 {
634  unsigned i = sizeof (x) * 8;
635 
636  while (x)
637  {
638  x <<= 1;
639  i--;
640  }
641  return i;
642 }
643 
644 VLC_USED static inline int vlc_parity_generic(unsigned long long x)
645 {
646  for (unsigned i = 4 * sizeof (x); i > 0; i /= 2)
647  x ^= x >> i;
648  return x & 1;
649 }
650 
651 VLC_USED static inline int vlc_popcount_generic(unsigned long long x)
652 {
653  int count = 0;
654  while (x)
655  {
656  count += x & 1;
657  x = x >> 1;
658  }
659  return count;
660 }
661 
662 # define VLC_INT_FUNC_TYPE(basename,type,suffix) \
663 VLC_USED static inline int vlc_##basename##suffix(type x) \
664 { \
665  return vlc_##basename##_generic(x); \
666 }
667 #endif
668 
671 VLC_INT_FUNC(popcount)
672 
673 #ifndef __cplusplus
674 # define VLC_INT_GENERIC(func,x) \
675  _Generic((x), \
676  unsigned char: func(x), \
677  signed char: func(x), \
678  unsigned short: func(x), \
679  signed short: func(x), \
680  unsigned int: func(x), \
681  signed int: func(x), \
682  unsigned long: func##l(x), \
683  signed long: func##l(x), \
684  unsigned long long: func##ll(x), \
685  signed long long: func##ll(x))
686 
687 /**
688  * Count leading zeroes
689  *
690  * This function counts the number of consecutive zero (clear) bits
691  * down from the highest order bit in an unsigned integer.
692  *
693  * \param x a non-zero integer
694  * \note This macro assumes that CHAR_BIT equals 8.
695  * \warning By definition, the result depends on the (width of the) type of x.
696  * \return The number of leading zero bits in x.
697  */
698 # define clz(x) \
699  _Generic((x), \
700  unsigned char: (vlc_clz(x) - (sizeof (unsigned) - 1) * 8), \
701  unsigned short: (vlc_clz(x) \
702  - (sizeof (unsigned) - sizeof (unsigned short)) * 8), \
703  unsigned: vlc_clz(x), \
704  unsigned long: vlc_clzl(x), \
705  unsigned long long: vlc_clzll(x))
706 
707 /**
708  * Count trailing zeroes
709  *
710  * This function counts the number of consecutive zero bits
711  * up from the lowest order bit in an unsigned integer.
712  *
713  * \param x a non-zero integer
714  * \note This function assumes that CHAR_BIT equals 8.
715  * \return The number of trailing zero bits in x.
716  */
717 # define ctz(x) VLC_INT_GENERIC(vlc_ctz, x)
718 
719 /**
720  * Parity
721  *
722  * This function determines the parity of an integer.
723  * \retval 0 if x has an even number of set bits.
724  * \retval 1 if x has an odd number of set bits.
725  */
726 # define parity(x) VLC_INT_GENERIC(vlc_parity, x)
727 
728 /**
729  * Bit weight / population count
730  *
731  * This function counts the number of non-zero bits in an integer.
732  *
733  * \return The count of non-zero bits.
734  */
735 # define vlc_popcount(x) \
736  _Generic((x), \
737  signed char: vlc_popcount((unsigned char)(x)), \
738  signed short: vlc_popcount((unsigned short)(x)), \
739  default: VLC_INT_GENERIC(vlc_popcount ,x))
740 #else
741 VLC_USED static inline int vlc_popcount(unsigned char x)
742 {
743  return vlc_popcount((unsigned)x);
744 }
745 
746 VLC_USED static inline int vlc_popcount(unsigned short x)
747 {
748  return vlc_popcount((unsigned)x);
749 }
750 
751 VLC_USED static inline int vlc_popcount(unsigned long x)
752 {
753  return vlc_popcountl(x);
754 }
755 
756 VLC_USED static inline int vlc_popcount(unsigned long long x)
757 {
758  return vlc_popcountll(x);
759 }
760 #endif
761 
762 /** Byte swap (16 bits) */
764 static inline uint16_t vlc_bswap16(uint16_t x)
765 {
766  return (x << 8) | (x >> 8);
767 }
768 
769 /** Byte swap (32 bits) */
771 static inline uint32_t vlc_bswap32(uint32_t x)
772 {
773 #if defined (__GNUC__) || defined(__clang__)
774  return __builtin_bswap32 (x);
775 #else
776  return ((x & 0x000000FF) << 24)
777  | ((x & 0x0000FF00) << 8)
778  | ((x & 0x00FF0000) >> 8)
779  | ((x & 0xFF000000) >> 24);
780 #endif
781 }
782 
783 /** Byte swap (64 bits) */
785 static inline uint64_t vlc_bswap64(uint64_t x)
786 {
787 #if defined (__GNUC__) || defined(__clang__)
788  return __builtin_bswap64 (x);
789 #elif !defined (__cplusplus)
790  return ((x & 0x00000000000000FF) << 56)
791  | ((x & 0x000000000000FF00) << 40)
792  | ((x & 0x0000000000FF0000) << 24)
793  | ((x & 0x00000000FF000000) << 8)
794  | ((x & 0x000000FF00000000) >> 8)
795  | ((x & 0x0000FF0000000000) >> 24)
796  | ((x & 0x00FF000000000000) >> 40)
797  | ((x & 0xFF00000000000000) >> 56);
798 #else
799  return ((x & 0x00000000000000FFULL) << 56)
800  | ((x & 0x000000000000FF00ULL) << 40)
801  | ((x & 0x0000000000FF0000ULL) << 24)
802  | ((x & 0x00000000FF000000ULL) << 8)
803  | ((x & 0x000000FF00000000ULL) >> 8)
804  | ((x & 0x0000FF0000000000ULL) >> 24)
805  | ((x & 0x00FF000000000000ULL) >> 40)
806  | ((x & 0xFF00000000000000ULL) >> 56);
807 #endif
808 }
809 /** @} */
810 
811 /**
812  * \defgroup overflow Overflowing arithmetic
813  * @{
814  */
815 static inline bool uadd_overflow(unsigned a, unsigned b, unsigned *res)
816 {
817 #if VLC_GCC_VERSION(5,0) || defined(__clang__)
818  return __builtin_uadd_overflow(a, b, res);
819 #else
820  *res = a + b;
821  return (a + b) < a;
822 #endif
823 }
824 
825 static inline bool uaddl_overflow(unsigned long a, unsigned long b,
826  unsigned long *res)
827 {
828 #if VLC_GCC_VERSION(5,0) || defined(__clang__)
829  return __builtin_uaddl_overflow(a, b, res);
830 #else
831  *res = a + b;
832  return (a + b) < a;
833 #endif
834 }
835 
836 static inline bool uaddll_overflow(unsigned long long a, unsigned long long b,
837  unsigned long long *res)
838 {
839 #if VLC_GCC_VERSION(5,0) || defined(__clang__)
840  return __builtin_uaddll_overflow(a, b, res);
841 #else
842  *res = a + b;
843  return (a + b) < a;
844 #endif
845 }
846 
847 #ifndef __cplusplus
848 /**
849  * Overflowing addition
850  *
851  * Converts \p a and \p b to the type of \p *r.
852  * Then computes the sum of both conversions while checking for overflow.
853  * Finally stores the result in \p *r.
854  *
855  * \param a an integer
856  * \param b an integer
857  * \param r a pointer to an integer [OUT]
858  * \retval false The sum did not overflow.
859  * \retval true The sum overflowed.
860  */
861 # define add_overflow(a,b,r) \
862  _Generic(*(r), \
863  unsigned: uadd_overflow(a, b, (unsigned *)(r)), \
864  unsigned long: uaddl_overflow(a, b, (unsigned long *)(r)), \
865  unsigned long long: uaddll_overflow(a, b, (unsigned long long *)(r)))
866 #else
867 static inline bool add_overflow(unsigned a, unsigned b, unsigned *res)
868 {
869  return uadd_overflow(a, b, res);
870 }
871 
872 static inline bool add_overflow(unsigned long a, unsigned long b,
873  unsigned long *res)
874 {
875  return uaddl_overflow(a, b, res);
876 }
877 
878 static inline bool add_overflow(unsigned long long a, unsigned long long b,
879  unsigned long long *res)
880 {
881  return uaddll_overflow(a, b, res);
882 }
883 #endif
884 
885 #if !(VLC_GCC_VERSION(5,0) || defined(__clang__))
886 # include <limits.h>
887 #endif
888 
889 static inline bool umul_overflow(unsigned a, unsigned b, unsigned *res)
890 {
891 #if VLC_GCC_VERSION(5,0) || defined(__clang__)
892  return __builtin_umul_overflow(a, b, res);
893 #else
894  *res = a * b;
895  return b > 0 && a > (UINT_MAX / b);
896 #endif
897 }
898 
899 static inline bool umull_overflow(unsigned long a, unsigned long b,
900  unsigned long *res)
901 {
902 #if VLC_GCC_VERSION(5,0) || defined(__clang__)
903  return __builtin_umull_overflow(a, b, res);
904 #else
905  *res = a * b;
906  return b > 0 && a > (ULONG_MAX / b);
907 #endif
908 }
909 
910 static inline bool umulll_overflow(unsigned long long a, unsigned long long b,
911  unsigned long long *res)
912 {
913 #if VLC_GCC_VERSION(5,0) || defined(__clang__)
914  return __builtin_umulll_overflow(a, b, res);
915 #else
916  *res = a * b;
917  return b > 0 && a > (ULLONG_MAX / b);
918 #endif
919 }
920 
921 #ifndef __cplusplus
922 /**
923  * Overflowing multiplication
924  *
925  * Converts \p a and \p b to the type of \p *r.
926  * Then computes the product of both conversions while checking for overflow.
927  * Finally stores the result in \p *r.
928  *
929  * \param a an integer
930  * \param b an integer
931  * \param r a pointer to an integer [OUT]
932  * \retval false The product did not overflow.
933  * \retval true The product overflowed.
934  */
935 #define mul_overflow(a,b,r) \
936  _Generic(*(r), \
937  unsigned: umul_overflow(a, b, (unsigned *)(r)), \
938  unsigned long: umull_overflow(a, b, (unsigned long *)(r)), \
939  unsigned long long: umulll_overflow(a, b, (unsigned long long *)(r)))
940 #else
941 static inline bool mul_overflow(unsigned a, unsigned b, unsigned *res)
942 {
943  return umul_overflow(a, b, res);
944 }
945 
946 static inline bool mul_overflow(unsigned long a, unsigned long b,
947  unsigned long *res)
948 {
949  return umull_overflow(a, b, res);
950 }
951 
952 static inline bool mul_overflow(unsigned long long a, unsigned long long b,
953  unsigned long long *res)
954 {
955  return umulll_overflow(a, b, res);
956 }
957 #endif
958 /** @} */
959 /** @} */
960 
961 /* Free and set set the variable to NULL */
962 #define FREENULL(a) do { free( a ); a = NULL; } while(0)
963 
964 #define EMPTY_STR(str) (!str || !*str)
965 
966 #include <vlc_arrays.h>
967 
968 /* MSB (big endian)/LSB (little endian) conversions - network order is always
969  * MSB, and should be used for both network communications and files. */
970 
971 #ifdef WORDS_BIGENDIAN
972 # define hton16(i) ((uint16_t)(i))
973 # define hton32(i) ((uint32_t)(i))
974 # define hton64(i) ((uint64_t)(i))
975 #else
976 # define hton16(i) vlc_bswap16(i)
977 # define hton32(i) vlc_bswap32(i)
978 # define hton64(i) vlc_bswap64(i)
979 #endif
980 #define ntoh16(i) hton16(i)
981 #define ntoh32(i) hton32(i)
982 #define ntoh64(i) hton64(i)
983 
984 /** Reads 16 bits in network byte order */
986 static inline uint16_t U16_AT (const void *p)
987 {
988  uint16_t x;
989 
990  memcpy (&x, p, sizeof (x));
991  return ntoh16 (x);
992 }
993 
994 /** Reads 32 bits in network byte order */
996 static inline uint32_t U32_AT (const void *p)
997 {
998  uint32_t x;
999 
1000  memcpy (&x, p, sizeof (x));
1001  return ntoh32 (x);
1002 }
1003 
1004 /** Reads 64 bits in network byte order */
1006 static inline uint64_t U64_AT (const void *p)
1007 {
1008  uint64_t x;
1009 
1010  memcpy (&x, p, sizeof (x));
1011  return ntoh64 (x);
1012 }
1014 #define GetWBE(p) U16_AT(p)
1015 #define GetDWBE(p) U32_AT(p)
1016 #define GetQWBE(p) U64_AT(p)
1017 
1018 /** Reads 16 bits in little-endian order */
1020 static inline uint16_t GetWLE (const void *p)
1021 {
1022  uint16_t x;
1023 
1024  memcpy (&x, p, sizeof (x));
1025 #ifdef WORDS_BIGENDIAN
1026  x = vlc_bswap16 (x);
1027 #endif
1028  return x;
1029 }
1030 
1031 /** Reads 32 bits in little-endian order */
1033 static inline uint32_t GetDWLE (const void *p)
1034 {
1035  uint32_t x;
1036 
1037  memcpy (&x, p, sizeof (x));
1038 #ifdef WORDS_BIGENDIAN
1039  x = vlc_bswap32 (x);
1040 #endif
1041  return x;
1042 }
1043 
1044 /** Reads 64 bits in little-endian order */
1046 static inline uint64_t GetQWLE (const void *p)
1047 {
1048  uint64_t x;
1049 
1050  memcpy (&x, p, sizeof (x));
1051 #ifdef WORDS_BIGENDIAN
1052  x = vlc_bswap64 (x);
1053 #endif
1054  return x;
1055 }
1056 
1057 /** Writes 16 bits in network byte order */
1058 static inline void SetWBE (void *p, uint16_t w)
1059 {
1060  w = hton16 (w);
1061  memcpy (p, &w, sizeof (w));
1062 }
1063 
1064 /** Writes 32 bits in network byte order */
1065 static inline void SetDWBE (void *p, uint32_t dw)
1066 {
1067  dw = hton32 (dw);
1068  memcpy (p, &dw, sizeof (dw));
1069 }
1070 
1071 /** Writes 64 bits in network byte order */
1072 static inline void SetQWBE (void *p, uint64_t qw)
1073 {
1074  qw = hton64 (qw);
1075  memcpy (p, &qw, sizeof (qw));
1076 }
1077 
1078 /** Writes 16 bits in little endian order */
1079 static inline void SetWLE (void *p, uint16_t w)
1080 {
1081 #ifdef WORDS_BIGENDIAN
1082  w = vlc_bswap16 (w);
1083 #endif
1084  memcpy (p, &w, sizeof (w));
1085 }
1086 
1087 /** Writes 32 bits in little endian order */
1088 static inline void SetDWLE (void *p, uint32_t dw)
1089 {
1090 #ifdef WORDS_BIGENDIAN
1091  dw = vlc_bswap32 (dw);
1092 #endif
1093  memcpy (p, &dw, sizeof (dw));
1094 }
1095 
1096 /** Writes 64 bits in little endian order */
1097 static inline void SetQWLE (void *p, uint64_t qw)
1098 {
1099 #ifdef WORDS_BIGENDIAN
1100  qw = vlc_bswap64 (qw);
1101 #endif
1102  memcpy (p, &qw, sizeof (qw));
1103 }
1104 
1105 /* */
1106 #define VLC_UNUSED(x) (void)(x)
1107 
1108 /* Stuff defined in src/extras/libc.c */
1109 
1110 #if defined(_WIN32)
1111 /* several type definitions */
1112 # if defined( __MINGW32__ )
1113 # if !defined( _OFF_T_ )
1114  typedef long long _off_t;
1115  typedef _off_t off_t;
1116 # define _OFF_T_
1117 # else
1118 # ifdef off_t
1119 # undef off_t
1120 # endif
1121 # define off_t long long
1122 # endif
1123 # endif
1124 
1125 # ifndef O_NONBLOCK
1126 # define O_NONBLOCK 0
1127 # endif
1128 
1129 /* the mingw32 swab() and win32 _swab() prototypes expect a char* instead of a
1130  const void* */
1131 # define swab(a,b,c) swab((char*) (a), (char*) (b), (c))
1132 
1133 #endif /* _WIN32 */
1134 
1135 typedef struct {
1136  unsigned num, den;
1137 } vlc_rational_t;
1138 
1139 VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t );
1141 #define container_of(ptr, type, member) \
1142  ((type *)(((char *)(ptr)) - offsetof(type, member)))
1143 
1145 static inline void *vlc_alloc(size_t count, size_t size)
1146 {
1147  return mul_overflow(count, size, &size) ? NULL : malloc(size);
1148 }
1149 
1151 static inline void *vlc_reallocarray(void *ptr, size_t count, size_t size)
1152 {
1153  return mul_overflow(count, size, &size) ? NULL : realloc(ptr, size);
1154 }
1155 
1156 /*****************************************************************************
1157  * I18n stuff
1158  *****************************************************************************/
1159 VLC_API const char *vlc_gettext(const char *msgid) VLC_FORMAT_ARG(1);
1160 VLC_API const char *vlc_ngettext(const char *s, const char *p, unsigned long n)
1163 #define vlc_pgettext( ctx, id ) \
1164  vlc_pgettext_aux( ctx "\004" id, id )
1165 
1167 static inline const char *vlc_pgettext_aux( const char *ctx, const char *id )
1168 {
1169  const char *tr = vlc_gettext( ctx );
1170  return (tr == ctx) ? id : tr;
1171 }
1172 
1173 /*****************************************************************************
1174  * Loosy memory allocation functions. Do not use in new code.
1175  *****************************************************************************/
1176 static inline void *xmalloc(size_t len)
1177 {
1178  void *ptr = malloc(len);
1179  if (unlikely(ptr == NULL && len > 0))
1180  abort();
1181  return ptr;
1182 }
1184 static inline void *xrealloc(void *ptr, size_t len)
1185 {
1186  void *nptr = realloc(ptr, len);
1187  if (unlikely(nptr == NULL && len > 0))
1188  abort();
1189  return nptr;
1190 }
1192 static inline char *xstrdup (const char *str)
1193 {
1194  char *ptr = strdup (str);
1195  if (unlikely(ptr == NULL))
1196  abort ();
1197  return ptr;
1198 }
1199 
1200 /*****************************************************************************
1201  * libvlc features
1202  *****************************************************************************/
1203 VLC_API const char * VLC_CompileBy( void ) VLC_USED;
1204 VLC_API const char * VLC_CompileHost( void ) VLC_USED;
1205 VLC_API const char * VLC_Compiler( void ) VLC_USED;
1206 
1207 /*****************************************************************************
1208  * Additional vlc stuff
1209  *****************************************************************************/
1210 #include "vlc_messages.h"
1211 #include "vlc_objects.h"
1212 #include "vlc_variables.h"
1213 #include "vlc_configuration.h"
1214 
1215 #if defined( _WIN32 ) || defined( __OS2__ )
1216 # define DIR_SEP_CHAR '\\'
1217 # define DIR_SEP "\\"
1218 # define PATH_SEP_CHAR ';'
1219 # define PATH_SEP ";"
1220 #else
1221 # define DIR_SEP_CHAR '/'
1222 # define DIR_SEP "/"
1223 # define PATH_SEP_CHAR ':'
1224 # define PATH_SEP ":"
1225 #endif
1227 #define LICENSE_MSG \
1228  _("This program comes with NO WARRANTY, to the extent permitted by " \
1229  "law.\nYou may redistribute it under the terms of the GNU General " \
1230  "Public License;\nsee the file named COPYING for details.\n" \
1231  "Written by the VideoLAN team; see the AUTHORS file.\n")
1232 
1233 #endif /* !VLC_COMMON_H */
hton16
#define hton16(i)
Definition: vlc_common.h:975
count
size_t count
Definition: core.c:401
config_category_t
Definition: vlc_configuration.h:53
add_overflow
#define add_overflow(a, b, r)
Overflowing addition.
Definition: vlc_common.h:860
SetQWLE
static void SetQWLE(void *p, uint64_t qw)
Writes 64 bits in little endian order.
Definition: vlc_common.h:1096
input_attachment_t
Definition: vlc_input.h:159
vlc_clzll
static int vlc_clzll(unsigned long long x)
Definition: vlc_common.h:610
services_discovery_t
Main service discovery structure to build a SD module.
Definition: vlc_services_discovery.h:59
clz
#define clz(x)
Count leading zeroes.
Definition: vlc_common.h:697
VLC_FORMAT_ARG
#define VLC_FORMAT_ARG(x)
Format string translation function annotation.
Definition: vlc_common.h:152
libvlc_int_t
Definition: vlc_objects.h:114
unlikely
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:227
vlc_messages.h
vlc_gettext
const VLC_EXPORT char * vlc_gettext(const char *msgid)
In-tree plugins share their gettext domain with LibVLC.
Definition: textdomain.c:79
umulll_overflow
static bool umulll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res)
Definition: vlc_common.h:909
sout_stream_t
Definition: vlc_sout.h:184
addon_entry_t
Definition: vlc_addons.h:71
input_item_t
Describes an input and is used to spawn input_thread_t objects.
Definition: vlc_input_item.h:77
vlc_config.h
parity
#define parity(x)
Parity.
Definition: vlc_common.h:725
hton32
#define hton32(i)
Definition: vlc_common.h:976
sout_input_t
Definition: vlc_sout.h:140
vlc_value_t::p_address
void * p_address
Definition: vlc_common.h:463
VLC_INT_FUNC
#define VLC_INT_FUNC(basename)
Definition: vlc_common.h:596
video_format_t
video format description
Definition: vlc_es.h:350
ntoh64
#define ntoh64(i)
Definition: vlc_common.h:981
seekpoint_t
Definition: vlc_input.h:51
info_category_t
Definition: vlc_input_item.h:53
VLC_MALLOC
#define VLC_MALLOC
Heap allocated result function annotation.
Definition: vlc_common.h:167
xstrdup
static char * xstrdup(const char *str)
Definition: vlc_common.h:1191
decoder_t
Definition: vlc_codec.h:101
sout_packetizer_input_t
Definition: stream_output.c:158
input_stats_t
Definition: vlc_input_item.h:507
U64_AT
static uint64_t U64_AT(const void *p)
Reads 64 bits in network byte order.
Definition: vlc_common.h:1005
vlc_viewpoint_t
Viewpoints.
Definition: vlc_viewpoint.h:41
block_fifo_t
Internal state for block queues.
Definition: fifo.c:38
vlc_threads.h
vlc_bswap32
static uint32_t vlc_bswap32(uint32_t x)
Byte swap (32 bits)
Definition: vlc_common.h:770
vlc_fourcc_t
uint32_t vlc_fourcc_t
The vlc_fourcc_t type.
Definition: vlc_common.h:307
sout_access_out_t
Stream output access_output.
Definition: vlc_sout.h:53
vlc_ureduce
VLC_EXPORT bool vlc_ureduce(unsigned *, unsigned *, uint64_t, uint64_t, uint64_t)
vlc_ngettext
const VLC_EXPORT char * vlc_ngettext(const char *s, const char *p, unsigned long n)
Definition: textdomain.c:88
audio_format_t
audio format description
Definition: vlc_es.h:81
vlc_tick.h
picture_t
Video picture.
Definition: vlc_picture.h:120
U16_AT
static uint16_t U16_AT(const void *p)
Reads 16 bits in network byte order.
Definition: vlc_common.h:985
vlc_value_t::i_int
int64_t i_int
Definition: vlc_common.h:459
SetQWBE
static void SetQWBE(void *p, uint64_t qw)
Writes 64 bits in network byte order.
Definition: vlc_common.h:1071
vod_t
struct vod_t vod_t
Definition: vlc_common.h:439
vlc_callback_t
int(* vlc_callback_t)(vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void *)
Definition: vlc_common.h:493
vlc_clzl
static int vlc_clzl(unsigned long x)
Definition: vlc_common.h:622
vlc_meta_t
Definition: meta.c:39
vlc_bswap16
static uint16_t vlc_bswap16(uint16_t x)
Byte swap (16 bits)
Definition: vlc_common.h:763
uaddl_overflow
static bool uaddl_overflow(unsigned long a, unsigned long b, unsigned long *res)
Definition: vlc_common.h:824
video_palette_t
Definition: vlc_es.h:43
vlc_value_t::y
int32_t y
Definition: vlc_common.h:464
audio_output
Audio output object.
Definition: vlc_aout.h:141
vlc_value_t::b_bool
bool b_bool
Definition: vlc_common.h:460
es_out_t
Definition: vlc_es_out.h:143
SetDWBE
static void SetDWBE(void *p, uint32_t dw)
Writes 32 bits in network byte order.
Definition: vlc_common.h:1064
config_chain_t
Definition: vlc_configuration.h:331
module_t
Internal module descriptor.
Definition: modules.h:78
filter_t
Structure describing a filter.
Definition: vlc_filter.h:215
umull_overflow
static bool umull_overflow(unsigned long a, unsigned long b, unsigned long *res)
Definition: vlc_common.h:898
es_format_t
Definition: vlc_es.h:617
vlc_value_t::f_float
float f_float
Definition: vlc_common.h:461
vlm_t
Definition: vlm_internal.h:77
vlc_align
static size_t vlc_align(size_t v, size_t align)
Make integer v a multiple of align.
Definition: vlc_common.h:559
subpicture_t
Video subtitle.
Definition: vlc_subpicture.h:166
date_t
Timestamps without long-term rounding errors.
Definition: vlc_tick.h:226
spu_t
Subpicture unit descriptor.
Definition: vlc_spu.h:47
subs_format_t
subtitles format description
Definition: vlc_es.h:550
subpicture_region_t
Video subtitle region.
Definition: vlc_subpicture.h:59
encoder_t
Definition: vlc_codec.h:242
VLC_Compiler
const VLC_EXPORT char * VLC_Compiler(void)
Definition: version.c:45
SetDWLE
static void SetDWLE(void *p, uint32_t dw)
Writes 32 bits in little endian order.
Definition: vlc_common.h:1087
uadd_overflow
static bool uadd_overflow(unsigned a, unsigned b, unsigned *res)
Definition: vlc_common.h:814
SetWBE
static void SetWBE(void *p, uint16_t w)
Writes 16 bits in network byte order.
Definition: vlc_common.h:1057
input_source_t
Definition: input_internal.h:373
vlc_value_t::psz_string
char * psz_string
Definition: vlc_common.h:462
stream_t
stream_t definition
Definition: vlc_stream.h:46
vlc_ctz_generic
static int vlc_ctz_generic(unsigned long long x)
Definition: vlc_common.h:632
vlc_parity_generic
static int vlc_parity_generic(unsigned long long x)
Definition: vlc_common.h:644
SetWLE
static void SetWLE(void *p, uint16_t w)
Writes 16 bits in little endian order.
Definition: vlc_common.h:1078
sout_mux_t
Muxer structure.
Definition: vlc_sout.h:101
es_out_id_t
Definition: es_out.c:105
vlc_configuration.h
xml_t
Definition: vlc_xml.h:37
vlc_es_id_t
Opaque structure representing an ES (Elementary Stream) track.
Definition: es_out.c:94
vlc_rational_t
Definition: fourcc_gen.c:34
video_frame_format_t
video_format_t video_frame_format_t
Definition: vlc_common.h:387
VLC_CompileHost
const VLC_EXPORT char * VLC_CompileHost(void)
Definition: version.c:44
xmalloc
static void * xmalloc(size_t len)
Definition: vlc_common.h:1175
vlc_url_t
Definition: vlc_url.h:145
vlc_hash_md5_ctx
MD5 hash context.
Definition: vlc_hash.h:85
vlc_object_t
VLC object common members.
Definition: vlc_objects.h:43
vlc_pgettext_aux
static const char * vlc_pgettext_aux(const char *ctx, const char *id)
Definition: vlc_common.h:1166
update_t
The update object.
Definition: update.h:158
clip_uint8_vlc
static uint8_t clip_uint8_vlc(int32_t a)
Definition: vlc_common.h:585
module_config_t
Configuration item.
Definition: vlc_configuration.h:76
iso639_lang_t
Definition: vlc_iso_lang.h:30
vlc_popcountl
static VLC_USED int vlc_popcountl(unsigned long x)
Definition: vlc_common.h:670
vlc_reallocarray
static void * vlc_reallocarray(void *ptr, size_t count, size_t size)
Definition: vlc_common.h:1150
VLC_API
#define VLC_API
Exported API call annotation.
Definition: vlc_common.h:295
strdup
char * strdup(const char *)
hton64
#define hton64(i)
Definition: vlc_common.h:977
image_handler_t
Definition: vlc_image.h:39
vlc_clz
static int vlc_clz(unsigned x)
Definition: vlc_common.h:627
vlc_renderer_item_t
Definition: renderer_discovery.c:34
ntoh32
#define ntoh32(i)
Definition: vlc_common.h:980
xrealloc
static void * xrealloc(void *ptr, size_t len)
Definition: vlc_common.h:1183
GetQWLE
static uint64_t GetQWLE(const void *p)
Reads 64 bits in little-endian order.
Definition: vlc_common.h:1045
xml_reader_t
Definition: vlc_xml.h:66
info_t
Definition: vlc_input_item.h:44
GCD
static int64_t GCD(int64_t a, int64_t b)
Greatest common divisor.
Definition: vlc_common.h:572
vlm_message_t
Definition: vlc_vlm.h:176
audio_sample_format_t
audio_format_t audio_sample_format_t
Definition: vlc_common.h:381
vlc_list_callback_t
int(* vlc_list_callback_t)(vlc_object_t *, char const *, int, vlc_value_t *, void *)
Definition: vlc_common.h:502
vlc_popcountll
static VLC_USED int vlc_popcountll(unsigned long long x)
Definition: vlc_common.h:670
vod_media_t
struct vod_media_t vod_media_t
Definition: vlc_common.h:440
U32_AT
static uint32_t U32_AT(const void *p)
Reads 32 bits in network byte order.
Definition: vlc_common.h:995
vlc_fourcc_to_char
static void vlc_fourcc_to_char(vlc_fourcc_t fcc, char *psz_fourcc)
Translate a vlc_fourcc into its string representation.
Definition: vlc_common.h:332
vlc_variables.h
session_descriptor_t
Definition: sap.c:48
vlc_arrays.h
mul_overflow
#define mul_overflow(a, b, r)
Overflowing multiplication.
Definition: vlc_common.h:934
vout_thread_t
Video output thread descriptor.
Definition: vlc_vout.h:55
vlc_bswap64
static uint64_t vlc_bswap64(uint64_t x)
Byte swap (64 bits)
Definition: vlc_common.h:784
uaddll_overflow
static bool uaddll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res)
Definition: vlc_common.h:835
input_item_node_t
Definition: vlc_input_item.h:194
vlc_alloc
static void * vlc_alloc(size_t count, size_t size)
Definition: vlc_common.h:1144
VLC_CompileBy
const VLC_EXPORT char * VLC_CompileBy(void)
Definition: version.c:43
vlc_popcount
#define vlc_popcount(x)
Bit weight / population count.
Definition: vlc_common.h:734
vlc_popcount_generic
static int vlc_popcount_generic(unsigned long long x)
Definition: vlc_common.h:651
VLC_USED
#define VLC_USED
Used result function annotation.
Definition: vlc_common.h:185
vlc_value_t
VLC value structure.
Definition: vlc_common.h:457
sout_instance_t
Stream output instance.
Definition: stream_output.h:33
ctz
#define ctz(x)
Count trailing zeroes.
Definition: vlc_common.h:716
block_t
Definition: vlc_block.h:117
GetDWLE
static uint32_t GetDWLE(const void *p)
Reads 32 bits in little-endian order.
Definition: vlc_common.h:1032
vlc_objects.h
umul_overflow
static bool umul_overflow(unsigned a, unsigned b, unsigned *res)
Definition: vlc_common.h:888
vlc_renderer_discovery_t
Definition: vlc_renderer_discovery.h:165
ntoh16
#define ntoh16(i)
Definition: vlc_common.h:979
GetWLE
static uint16_t GetWLE(const void *p)
Reads 16 bits in little-endian order.
Definition: vlc_common.h:1019
vlc_fourcc_t
uint32_t vlc_fourcc_t
Definition: fourcc_gen.c:33
p
#define p(t)