+#define U64_AT(p) ( ntoh64 ( *( (u64 *)(p) ) ) )
+#define U32_AT(p) ( ntoh32 ( *( (u32 *)(p) ) ) )
+#define U16_AT(p) ( ntoh16 ( *( (u16 *)(p) ) ) )
+
+/* Alignment of critical static data structures */
+#ifdef ATTRIBUTE_ALIGNED_MAX
+# define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
+#else
+# define ATTR_ALIGN(align)
+#endif
+
+/* Alignment of critical dynamic data structure */
+#ifdef HAVE_MEMALIGN
+ /* Some systems have memalign() but no declaration for it */
+ void * memalign( size_t align, size_t size );
+#else
+# ifdef HAVE_VALLOC
+ /* That's like using a hammer to kill a fly, but eh... */
+# include <unistd.h>
+# define memalign(align,size) valloc(size)
+# else
+ /* Assume malloc alignment is sufficient */
+# define memalign(align,size) malloc(size)
+# endif
+#endif
+
+#define I64C(x) x##LL
+
+
+#if defined( WIN32 )
+/* The ntoh* and hton* bytes swapping functions are provided by winsock
+ * but for conveniency and speed reasons it is better to implement them
+ * ourselves. ( several plugins use them and it is too much hassle to link
+ * winsock with each of them ;-)
+ */
+# ifdef WORDS_BIGENDIAN
+# define ntoh32(x) (x)
+# define ntoh16(x) (x)
+# define ntoh64(x) (x)
+# define hton32(x) (x)
+# define hton16(x) (x)
+# define hton64(x) (x)
+# else
+# define ntoh32(x) __bswap_32 (x)
+# define ntoh16(x) __bswap_16 (x)
+# define ntoh64(x) __bswap_32 (x)
+# define hton32(x) __bswap_32 (x)
+# define hton16(x) __bswap_16 (x)
+# define hton64(x) __bswap_64 (x)
+# endif
+
+/* win32, cl and icl support */
+# if defined( _MSC_VER ) || !defined( __MINGW32__ )
+# define __attribute__(x)
+# define __inline__ __inline
+# define strncasecmp strnicmp
+# define strcasecmp stricmp
+# define S_ISBLK(m) (0)
+# define S_ISCHR(m) (0)
+# define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO)
+# define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
+# undef I64C(x)
+# define I64C(x) x##i64
+# endif
+
+/* several type definitions */
+# if defined( __MINGW32__ )
+# if !defined( _OFF_T_ )
+typedef long long _off_t;
+typedef _off_t off_t;
+# define _OFF_T_
+# else
+# define off_t long long
+# endif
+# endif
+
+# if defined( _MSC_VER )
+# if !defined( _OFF_T_DEFINED )
+typedef __int64 off_t;
+# define _OFF_T_DEFINED
+# else
+# define off_t __int64
+# endif
+# define stat _stati64
+# endif
+
+# if defined( __BORLANDC__ )
+# undef off_t
+# define off_t unsigned __int64
+# endif
+
+# ifndef O_NONBLOCK
+# define O_NONBLOCK 0
+# endif
+
+# ifndef snprintf
+# define snprintf _snprintf /* snprintf not defined in mingw32 (bug?) */
+# endif
+
+#endif
+
+/*****************************************************************************
+ * CPU capabilities
+ *****************************************************************************/
+#define CPU_CAPABILITY_NONE 0
+#define CPU_CAPABILITY_486 (1<<0)
+#define CPU_CAPABILITY_586 (1<<1)
+#define CPU_CAPABILITY_PPRO (1<<2)
+#define CPU_CAPABILITY_MMX (1<<3)
+#define CPU_CAPABILITY_3DNOW (1<<4)
+#define CPU_CAPABILITY_MMXEXT (1<<5)
+#define CPU_CAPABILITY_SSE (1<<6)
+#define CPU_CAPABILITY_ALTIVEC (1<<16)
+#define CPU_CAPABILITY_FPU (1<<31)
+
+/*****************************************************************************
+ * I18n stuff
+ *****************************************************************************/
+#if defined( ENABLE_NLS ) && defined ( HAVE_GETTEXT )
+# include <libintl.h>
+#else
+# define _(String) (String)
+# define N_(String) (String)
+#endif
+
+/*****************************************************************************
+ * Plug-in stuff
+ *****************************************************************************/
+typedef struct module_symbols_s
+{
+ struct main_s* p_main;
+ struct module_bank_s* p_module_bank;
+ struct input_bank_s* p_input_bank;
+ struct aout_bank_s* p_aout_bank;
+ struct vout_bank_s* p_vout_bank;
+
+ int ( * config_GetIntVariable ) ( const char * );
+ char * ( * config_GetPszVariable ) ( const char * );
+ void ( * config_PutIntVariable ) ( const char *, int );
+ void ( * config_PutPszVariable ) ( const char *, char * );
+ int ( * config_LoadConfigFile ) ( const char * );
+ int ( * config_SaveConfigFile ) ( const char * );
+ struct module_config_s * ( * config_FindConfig ) ( const char * );
+ struct module_config_s * ( * config_Duplicate ) ( struct module_s * );
+
+ struct intf_subscription_s * ( * intf_MsgSub ) ( void );
+ void ( * intf_MsgUnsub ) ( struct intf_subscription_s * );
+
+ void ( * intf_Msg ) ( char *, ... );
+ void ( * intf_ErrMsg ) ( char *, ... );
+ void ( * intf_StatMsg ) ( char *, ... );
+ void ( * intf_WarnMsg ) ( int, char *, ... );
+
+ int ( * intf_PlaylistAdd ) ( struct playlist_s *, int, const char* );
+ int ( * intf_PlaylistDelete ) ( struct playlist_s *, int );
+ void ( * intf_PlaylistNext ) ( struct playlist_s * );
+ void ( * intf_PlaylistPrev ) ( struct playlist_s * );
+ void ( * intf_PlaylistDestroy ) ( struct playlist_s * );
+ void ( * intf_PlaylistJumpto ) ( struct playlist_s *, int );
+ void ( * intf_UrlDecode ) ( char * );
+ int ( * intf_Eject ) ( const char * );
+
+ void ( * msleep ) ( mtime_t );
+ mtime_t ( * mdate ) ( void );
+ char * ( * mstrtime ) ( char *, mtime_t );
+
+ int ( * network_ChannelCreate )( void );
+ int ( * network_ChannelJoin ) ( int );
+
+ int ( * input_SetProgram ) ( struct input_thread_s *,
+ struct pgrm_descriptor_s * );
+ void ( * input_SetStatus ) ( struct input_thread_s *, int );
+ void ( * input_Seek ) ( struct input_thread_s *, off_t );
+ void ( * input_DumpStream ) ( struct input_thread_s * );
+ char * ( * input_OffsetToTime ) ( struct input_thread_s *, char *, off_t );
+ int ( * input_ChangeES ) ( struct input_thread_s *,
+ struct es_descriptor_s *, u8 );
+ int ( * input_ToggleES ) ( struct input_thread_s *,
+ struct es_descriptor_s *, boolean_t );
+ int ( * input_ChangeArea ) ( struct input_thread_s *,
+ struct input_area_s * );
+ int ( * input_ChangeProgram ) ( struct input_thread_s *, u16 );
+ struct es_descriptor_s * ( * input_FindES ) ( struct input_thread_s *,
+ u16 );
+ struct es_descriptor_s * ( * input_AddES ) ( struct input_thread_s *,
+ struct pgrm_descriptor_s *, u16, size_t );
+ void ( * input_DelES ) ( struct input_thread_s *,
+ struct es_descriptor_s * );
+ int ( * input_SelectES ) ( struct input_thread_s *,
+ struct es_descriptor_s * );
+ int ( * input_UnselectES ) ( struct input_thread_s *,
+ struct es_descriptor_s * );
+ struct pgrm_descriptor_s* ( * input_AddProgram ) ( struct input_thread_s *,
+ u16, size_t );
+ void ( * input_DelProgram ) ( struct input_thread_s *,
+ struct pgrm_descriptor_s * );
+ struct input_area_s * ( * input_AddArea ) ( struct input_thread_s * );
+ void ( * input_DelArea ) ( struct input_thread_s *,
+ struct input_area_s * );
+
+ void ( * InitBitstream ) ( struct bit_stream_s *,
+ struct decoder_fifo_s *,
+ void ( * ) ( struct bit_stream_s *,
+ boolean_t ),
+ void * );
+ void ( * BitstreamNextDataPacket )( struct bit_stream_s * );
+ boolean_t ( * NextDataPacket ) ( struct decoder_fifo_s *,
+ struct data_packet_s ** );
+ void ( * DecoderError ) ( struct decoder_fifo_s * p_fifo );
+ int ( * input_InitStream ) ( struct input_thread_s *, size_t );
+ void ( * input_EndStream ) ( struct input_thread_s * );
+
+ void ( * input_ParsePES ) ( struct input_thread_s *,
+ struct es_descriptor_s * );
+ void ( * input_GatherPES ) ( struct input_thread_s *,
+ struct data_packet_s *,
+ struct es_descriptor_s *,
+ boolean_t, boolean_t );
+ void ( * input_DecodePES ) ( struct decoder_fifo_s *,
+ struct pes_packet_s * );
+ struct es_descriptor_s * ( * input_ParsePS ) ( struct input_thread_s *,
+ struct data_packet_s * );
+ ssize_t ( * input_ReadPS ) ( struct input_thread_s *,
+ struct data_packet_s ** );
+ void ( * input_DemuxPS ) ( struct input_thread_s *,
+ struct data_packet_s * );
+ ssize_t ( * input_ReadTS ) ( struct input_thread_s *,
+ struct data_packet_s ** );
+ void ( * input_DemuxTS ) ( struct input_thread_s *,
+ struct data_packet_s * );
+ void ( * input_DemuxPSI ) ( struct input_thread_s *,
+ struct data_packet_s *,
+ struct es_descriptor_s *,
+ boolean_t, boolean_t );
+ int ( * input_ClockManageControl ) ( struct input_thread_s *,
+ struct pgrm_descriptor_s *,
+ mtime_t );
+ void ( * input_FDSeek ) ( struct input_thread_s *, off_t );
+ void ( * input_FDClose ) ( struct input_thread_s * );
+ ssize_t ( * input_FDRead ) ( struct input_thread_s *, byte_t *,
+ size_t );
+ ssize_t ( * input_FDNetworkRead ) ( struct input_thread_s *, byte_t *,
+ size_t );
+
+ void * ( * input_BuffersInit )( void );
+ void ( * input_BuffersEnd )( struct input_buffers_s * );
+ struct data_buffer_s * ( * input_NewBuffer )( struct input_buffers_s *, size_t );
+ void ( * input_ReleaseBuffer )( struct input_buffers_s *, struct data_buffer_s * );
+ struct data_packet_s * ( * input_ShareBuffer )( struct input_buffers_s *,
+ struct data_buffer_s * );
+ struct data_packet_s * ( * input_NewPacket )( struct input_buffers_s *, size_t );
+ void ( * input_DeletePacket )( struct input_buffers_s *, struct data_packet_s * );
+ struct pes_packet_s * ( * input_NewPES )( struct input_buffers_s * );
+ void ( * input_DeletePES )( struct input_buffers_s *, struct pes_packet_s * );
+ ssize_t ( * input_FillBuffer )( struct input_thread_s * );
+ ssize_t ( * input_Peek )( struct input_thread_s *, byte_t **, size_t );
+ ssize_t ( * input_SplitBuffer )( struct input_thread_s *, struct data_packet_s **, size_t );
+ int ( * input_AccessInit )( struct input_thread_s * );
+ void ( * input_AccessReinit )( struct input_thread_s * );
+ void ( * input_AccessEnd )( struct input_thread_s * );
+
+ struct aout_fifo_s * ( * aout_CreateFifo ) ( int, int, int, int, void * );
+ void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
+
+ struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, u32, int );
+ void ( * vout_DestroyThread ) ( struct vout_thread_s *, int * );
+
+ struct picture_s * ( * vout_CreatePicture )
+ ( struct vout_thread_s *,
+ boolean_t, boolean_t, boolean_t );
+ void ( * vout_AllocatePicture )( struct picture_s *, int, int, u32 );
+ void ( * vout_DisplayPicture ) ( struct vout_thread_s *,
+ struct picture_s * );
+ void ( * vout_DestroyPicture ) ( struct vout_thread_s *,
+ struct picture_s * );
+ void ( * vout_LinkPicture ) ( struct vout_thread_s *,
+ struct picture_s * );
+ void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
+ struct picture_s * );
+ void ( * vout_DatePicture ) ( struct vout_thread_s *,
+ struct picture_s *, mtime_t );
+ void ( * vout_PlacePicture ) ( struct vout_thread_s *, int, int,
+ int *, int *, int *, int * );
+
+ struct subpicture_s * (* vout_CreateSubPicture)
+ ( struct vout_thread_s *, int, int );
+ void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
+ struct subpicture_s * );
+ void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
+ struct subpicture_s * );
+
+ u32 ( * UnalignedShowBits ) ( struct bit_stream_s *, unsigned int );
+ void ( * UnalignedRemoveBits ) ( struct bit_stream_s * );
+ u32 ( * UnalignedGetBits ) ( struct bit_stream_s *, unsigned int );
+ void ( * CurrentPTS ) ( struct bit_stream_s *, mtime_t *,
+ mtime_t * );
+
+ char * ( * DecodeLanguage ) ( u16 );
+
+ struct module_s * ( * module_Need ) ( int, char *, void * );
+ void ( * module_Unneed ) ( struct module_s * );
+
+} module_symbols_t;
+
+#ifdef PLUGIN
+extern module_symbols_t* p_symbols;
+#endif
+