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