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