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