]> git.sesse.net Git - vlc/blob - include/common.h
. encore un peu plus loin dans le passage � autoconf
[vlc] / include / common.h
1 /*****************************************************************************
2  * common.h: common definitions
3  * Collection of useful common types and macros definitions
4  *****************************************************************************
5  * Copyright (C) 1998, 1999, 2000 VideoLAN
6  *
7  * Authors:
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * required headers:
26  *  config.h
27  *****************************************************************************/
28
29 /*****************************************************************************
30  * Basic types definitions
31  *****************************************************************************/
32
33 #include "int_types.h"
34
35 typedef u8                  byte_t;
36
37 /* Boolean type */
38 typedef int                 boolean_t;
39 #ifdef SYS_GNU
40 #define _MACH_I386_BOOLEAN_H_
41 #endif
42
43 /* Counter for statistics and profiling */
44 typedef unsigned long       count_t;
45
46 /*****************************************************************************
47  * Classes declaration
48  *****************************************************************************/
49
50 /* Interface */
51 struct intf_thread_s;
52 struct intf_sys_s;
53 struct intf_console_s;
54 struct intf_msg_s;
55 struct intf_channel_s;
56
57 typedef struct intf_thread_s *          p_intf_thread_t;
58 typedef struct intf_sys_s *             p_intf_sys_t;
59 typedef struct intf_console_s *         p_intf_console_t;
60 typedef struct intf_msg_s *             p_intf_msg_t;
61 typedef struct intf_channel_s *         p_intf_channel_t;
62
63 /* Input */
64 struct input_thread_s;
65 struct input_vlan_s;
66 struct input_cfg_s;
67
68 typedef struct input_thread_s *         p_input_thread_t;
69 typedef struct input_vlan_s *           p_input_vlan_t;
70 typedef struct input_cfg_s *            p_input_cfg_t;
71
72 /* Audio */
73 struct aout_thread_s;
74 struct aout_sys_s;
75
76 typedef struct aout_thread_s *          p_aout_thread_t;
77 typedef struct aout_sys_s *             p_aout_sys_t;
78
79 /* Video */
80 struct vout_thread_s;
81 struct vout_font_s;
82 struct vout_sys_s;
83 struct vdec_thread_s;
84 struct vpar_thread_s;
85 struct video_parser_s;
86
87 typedef struct vout_thread_s *          p_vout_thread_t;
88 typedef struct vout_font_s *            p_vout_font_t;
89 typedef struct vout_sys_s *             p_vout_sys_t;
90 typedef struct vdec_thread_s *          p_vdec_thread_t;
91 typedef struct vpar_thread_s *          p_vpar_thread_t;
92 typedef struct video_parser_s *         p_video_parser_t;
93
94 /*****************************************************************************
95  * Macros and inline functions
96  *****************************************************************************/
97
98 /* CEIL: division with round to nearest greater integer */
99 #define CEIL(n, d)  ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
100
101 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
102 #define PAD(n, d)   ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
103
104 /* MAX and MIN: self explanatory */
105 #ifndef MAX
106 #define MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
107 #endif
108 #ifndef MIN
109 #define MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
110 #endif
111
112 /* MSB (big endian)/LSB (little endian) convertions - network order is always
113  * MSB, and should be used for both network communications and files. Note that
114  * byte orders other than little and big endians are not supported, but only
115  * the VAX seems to have such exotic properties - note that these 'functions'
116  * needs <netinet/in.h> or the local equivalent. */
117 /* FIXME??: hton64 should be declared as an extern inline function to avoid border
118  * effects (see byteorder.h) */
119 #if __BYTE_ORDER == __LITTLE_ENDIAN
120 #define hton16      htons
121 #define hton32      htonl
122 #define hton64(i)   ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
123 #define ntoh16      ntohs
124 #define ntoh32      ntohl
125 #define ntoh64      hton64
126 #elif __BYTE_ORDER == __BIG_ENDIAN
127 #define hton16      htons
128 #define hton32      htonl
129 #define hton64(i)   ( i )
130 #define ntoh16      ntohs
131 #define ntoh32      ntohl
132 #define ntoh64(i)   ( i )
133 #else
134 /* XXX??: cause a compilation error */
135 #endif
136
137 /* Macros used by input to access the TS buffer */
138 #define U32_AT(p)   ( ntohl ( *( (u32 *)(p) ) ) )
139 #define U16_AT(p)   ( ntohs ( *( (u16 *)(p) ) ) )