]> git.sesse.net Git - vlc/blob - include/common.h
fb4cb9b2ffd5cc5b9f5b3c11b9b174e14a3d8ea6
[vlc] / include / common.h
1 /*****************************************************************************
2  * common.h: common definitions
3  * (c)1998 VideoLAN
4  *****************************************************************************
5  * Collection of usefull common types and macros definitions
6  *****************************************************************************
7  * required headers:
8  *  config.h
9  *****************************************************************************/
10
11 /*****************************************************************************
12  * Basic types definitions
13  *****************************************************************************/
14
15 #include "int_types.h"
16
17 typedef u8                  byte_t;
18
19 /* Boolean type */
20 typedef int                 boolean_t;
21
22 /* Counter for statistics and profiling */
23 typedef unsigned long       count_t;
24
25 /*****************************************************************************
26  * Classes declaration
27  *****************************************************************************/
28
29 /* Interface */
30 struct intf_thread_s;
31 struct intf_sys_s;
32 struct intf_console_s;
33 struct intf_msg_s;
34 struct intf_channel_s;
35
36 typedef struct intf_thread_s *          p_intf_thread_t;
37 typedef struct intf_sys_s *             p_intf_sys_t;
38 typedef struct intf_console_s *         p_intf_console_t;
39 typedef struct intf_msg_s *             p_intf_msg_t;
40 typedef struct intf_channel_s *         p_intf_channel_t;
41
42 /* Input */
43 struct input_thread_s;
44 struct input_vlan_s;
45 struct input_cfg_s;
46
47 typedef struct input_thread_s *         p_input_thread_t;
48 typedef struct input_vlan_s *           p_input_vlan_t;
49 typedef struct input_cfg_s *            p_input_cfg_t;
50
51 /* Audio */
52 struct aout_thread_s;
53 struct aout_sys_s;
54
55 typedef struct aout_thread_s *          p_aout_thread_t;
56 typedef struct aout_sys_s *             p_aout_sys_t;
57
58 /* Video */
59 struct vout_thread_s;
60 struct vout_font_s;
61 struct vout_sys_s;
62 struct vdec_thread_s;
63 struct vpar_thread_s;
64 struct video_parser_s;
65
66 typedef struct vout_thread_s *          p_vout_thread_t;
67 typedef struct vout_font_s *            p_vout_font_t;
68 typedef struct vout_sys_s *             p_vout_sys_t;
69 typedef struct vdec_thread_s *          p_vdec_thread_t;
70 typedef struct vpar_thread_s *          p_vpar_thread_t;
71 typedef struct video_parser_s *         p_video_parser_t;
72
73 /*****************************************************************************
74  * Macros and inline functions
75  *****************************************************************************/
76
77 /* CEIL: division with round to nearest greater integer */
78 #define CEIL(n, d)  ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
79
80 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
81 #define PAD(n, d)   ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
82
83 /* MAX and MIN: self explanatory */
84 #define MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
85 #define MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
86
87 /* MSB (big endian)/LSB (little endian) convertions - network order is always
88  * MSB, and should be used for both network communications and files. Note that
89  * byte orders other than little and big endians are not supported, but only
90  * the VAX seems to have such exotic properties - note that these 'functions'
91  * needs <netinet/in.h> or the local equivalent. */
92 /* FIXME??: hton64 should be declared as an extern inline function to avoid border
93  * effects (see byteorder.h) */
94 #if __BYTE_ORDER == __LITTLE_ENDIAN
95 #define hton16      htons
96 #define hton32      htonl
97 #define hton64(i)   ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
98 #define ntoh16      ntohs
99 #define ntoh32      ntohl
100 #define ntoh64      hton64
101 #elif __BYTE_ORDER == __BIG_ENDIAN
102 #define hton16      htons
103 #define hton32      htonl
104 #define hton64(i)   ( i )
105 #define ntoh16      ntohs
106 #define ntoh32      ntohl
107 #define ntoh64(i)   ( i )
108 #else
109 /* XXX??: cause a compilation error */
110 #endif
111
112 /* Macros used by input to access the TS buffer */
113 #define U32_AT(p)   ( ntohl ( *( (u32 *)(p) ) ) )
114 #define U16_AT(p)   ( ntohs ( *( (u16 *)(p) ) ) )