]> git.sesse.net Git - vlc/blob - include/common.h
Bon, puisque �a semble commiter sous BeOS, je commite.
[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 /* Plugins */
51 struct plugin_bank_s;
52 struct plugin_info_s;
53
54 typedef struct plugin_bank_s *          p_plugin_bank_t;
55 typedef struct plugin_info_s *          p_plugin_info_t;
56
57 /* Playlist */
58 struct playlist_s;
59
60 typedef struct playlist_s *             p_playlist_t;
61
62 /* Interface */
63 struct intf_thread_s;
64 struct intf_sys_s;
65 struct intf_console_s;
66 struct intf_msg_s;
67 struct intf_channel_s;
68
69 typedef struct intf_thread_s *          p_intf_thread_t;
70 typedef struct intf_sys_s *             p_intf_sys_t;
71 typedef struct intf_console_s *         p_intf_console_t;
72 typedef struct intf_msg_s *             p_intf_msg_t;
73 typedef struct intf_channel_s *         p_intf_channel_t;
74
75 /* Input */
76 struct input_thread_s;
77 struct input_vlan_s;
78 struct input_cfg_s;
79
80 typedef struct input_thread_s *         p_input_thread_t;
81 typedef struct input_vlan_s *           p_input_vlan_t;
82 typedef struct input_cfg_s *            p_input_cfg_t;
83
84 /* Audio */
85 struct aout_thread_s;
86 struct aout_sys_s;
87
88 typedef struct aout_thread_s *          p_aout_thread_t;
89 typedef struct aout_sys_s *             p_aout_sys_t;
90
91 /* Video */
92 struct vout_thread_s;
93 struct vout_font_s;
94 struct vout_sys_s;
95 struct vdec_thread_s;
96 struct vpar_thread_s;
97 struct video_parser_s;
98
99 typedef struct vout_thread_s *          p_vout_thread_t;
100 typedef struct vout_font_s *            p_vout_font_t;
101 typedef struct vout_sys_s *             p_vout_sys_t;
102 typedef struct vdec_thread_s *          p_vdec_thread_t;
103 typedef struct vpar_thread_s *          p_vpar_thread_t;
104 typedef struct video_parser_s *         p_video_parser_t;
105
106 /*****************************************************************************
107  * Macros and inline functions
108  *****************************************************************************/
109
110 /* CEIL: division with round to nearest greater integer */
111 #define CEIL(n, d)  ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
112
113 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
114 #define PAD(n, d)   ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
115
116 /* MAX and MIN: self explanatory */
117 #ifndef MAX
118 #define MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
119 #endif
120 #ifndef MIN
121 #define MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
122 #endif
123
124 /* MSB (big endian)/LSB (little endian) convertions - network order is always
125  * MSB, and should be used for both network communications and files. Note that
126  * byte orders other than little and big endians are not supported, but only
127  * the VAX seems to have such exotic properties - note that these 'functions'
128  * needs <netinet/in.h> or the local equivalent. */
129 /* FIXME??: hton64 should be declared as an extern inline function to avoid border
130  * effects (see byteorder.h) */
131 #if __BYTE_ORDER == __LITTLE_ENDIAN
132 #define hton16      htons
133 #define hton32      htonl
134 #define hton64(i)   ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
135 #define ntoh16      ntohs
136 #define ntoh32      ntohl
137 #define ntoh64      hton64
138 #elif __BYTE_ORDER == __BIG_ENDIAN
139 #define hton16      htons
140 #define hton32      htonl
141 #define hton64(i)   ( i )
142 #define ntoh16      ntohs
143 #define ntoh32      ntohl
144 #define ntoh64(i)   ( i )
145 #else
146 /* XXX??: cause a compilation error */
147 #endif
148
149 /* Macros used by input to access the TS buffer */
150 #define U32_AT(p)   ( ntohl ( *( (u32 *)(p) ) ) )
151 #define U16_AT(p)   ( ntohs ( *( (u16 *)(p) ) ) )