]> git.sesse.net Git - vlc/blob - include/common.h
Encore un commit venu tout droit des abysses de l'enfer, d�sol� pour
[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 GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public
20  * License along with this program; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, 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 /* Interface */
52 struct intf_thread_s;
53 struct intf_sys_s;
54 struct intf_console_s;
55 struct intf_msg_s;
56 struct intf_channel_s;
57
58 typedef struct intf_thread_s *          p_intf_thread_t;
59 typedef struct intf_sys_s *             p_intf_sys_t;
60 typedef struct intf_console_s *         p_intf_console_t;
61 typedef struct intf_msg_s *             p_intf_msg_t;
62 typedef struct intf_channel_s *         p_intf_channel_t;
63
64 /* Input */
65 struct input_thread_s;
66 struct input_vlan_s;
67 struct input_cfg_s;
68
69 typedef struct input_thread_s *         p_input_thread_t;
70 typedef struct input_vlan_s *           p_input_vlan_t;
71 typedef struct input_cfg_s *            p_input_cfg_t;
72
73 /* Audio */
74 struct aout_thread_s;
75 struct aout_sys_s;
76
77 typedef struct aout_thread_s *          p_aout_thread_t;
78 typedef struct aout_sys_s *             p_aout_sys_t;
79
80 /* Video */
81 struct vout_thread_s;
82 struct vout_font_s;
83 struct vout_sys_s;
84 struct vdec_thread_s;
85 struct vpar_thread_s;
86 struct video_parser_s;
87
88 typedef struct vout_thread_s *          p_vout_thread_t;
89 typedef struct vout_font_s *            p_vout_font_t;
90 typedef struct vout_sys_s *             p_vout_sys_t;
91 typedef struct vdec_thread_s *          p_vdec_thread_t;
92 typedef struct vpar_thread_s *          p_vpar_thread_t;
93 typedef struct video_parser_s *         p_video_parser_t;
94
95 /*****************************************************************************
96  * Macros and inline functions
97  *****************************************************************************/
98
99 /* CEIL: division with round to nearest greater integer */
100 #define CEIL(n, d)  ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
101
102 /* PAD: PAD(n, d) = CEIL(n ,d) * d */
103 #define PAD(n, d)   ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
104
105 /* MAX and MIN: self explanatory */
106 #define MAX(a, b)   ( ((a) > (b)) ? (a) : (b) )
107 #define MIN(a, b)   ( ((a) < (b)) ? (a) : (b) )
108
109 /* MSB (big endian)/LSB (little endian) convertions - network order is always
110  * MSB, and should be used for both network communications and files. Note that
111  * byte orders other than little and big endians are not supported, but only
112  * the VAX seems to have such exotic properties - note that these 'functions'
113  * needs <netinet/in.h> or the local equivalent. */
114 /* FIXME??: hton64 should be declared as an extern inline function to avoid border
115  * effects (see byteorder.h) */
116 #if __BYTE_ORDER == __LITTLE_ENDIAN
117 #define hton16      htons
118 #define hton32      htonl
119 #define hton64(i)   ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
120 #define ntoh16      ntohs
121 #define ntoh32      ntohl
122 #define ntoh64      hton64
123 #elif __BYTE_ORDER == __BIG_ENDIAN
124 #define hton16      htons
125 #define hton32      htonl
126 #define hton64(i)   ( i )
127 #define ntoh16      ntohs
128 #define ntoh32      ntohl
129 #define ntoh64(i)   ( i )
130 #else
131 /* XXX??: cause a compilation error */
132 #endif
133
134 /* Macros used by input to access the TS buffer */
135 #define U32_AT(p)   ( ntohl ( *( (u32 *)(p) ) ) )
136 #define U16_AT(p)   ( ntohs ( *( (u16 *)(p) ) ) )