* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: common.h,v 1.54 2001/12/09 17:01:35 sam Exp $
+ * $Id: common.h,v 1.67 2002/01/09 02:01:14 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
+ * Gildas Bazin <gbazin@netcourrier.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*****************************************************************************/
/*****************************************************************************
- * Required headers
+ * Required system headers
*****************************************************************************/
-
-#include "config.h"
-#include "int_types.h"
+#include <string.h> /* strerror() */
/*****************************************************************************
* Basic types definitions
*****************************************************************************
* Store an high precision date or time interval. The maximum precision is the
* micro-second, and a 64 bits integer is used to avoid any overflow (maximum
- * time interval is then 292271 years, which should be length enough for any
+ * time interval is then 292271 years, which should be long enough for any
* video). Date are stored as a time interval since a common date.
- * Note that date and time intervals can be manipulated using regular arithmetic
- * operators, and that no special functions are required.
+ * Note that date and time intervals can be manipulated using regular
+ * arithmetic operators, and that no special functions are required.
*****************************************************************************/
typedef s64 mtime_t;
struct vout_thread_s;
struct vout_font_s;
struct vout_sys_s;
+struct chroma_sys_s;
struct vdec_thread_s;
struct vpar_thread_s;
struct video_parser_s;
typedef struct vpar_thread_s * p_vpar_thread_t;
typedef struct video_parser_s * p_video_parser_t;
+/* Decoders */
+struct decoder_config_s;
+struct decoder_fifo_s;
+
/* Misc */
struct macroblock_s;
struct data_packet_s;
struct dm_par_s;
struct picture_s;
struct picture_sys_s;
+struct picture_heap_s;
struct es_descriptor_s;
struct pgrm_descriptor_s;
struct pes_packet_s;
struct input_area_s;
struct bit_stream_s;
-
-/* Decoders */
-struct decoder_config_s;
-struct decoder_fifo_s;
+struct probedata_s;
/*****************************************************************************
* Macros and inline functions
*****************************************************************************/
#ifdef NTOHL_IN_SYS_PARAM_H
# include <sys/param.h>
+
#elif defined(WIN32)
-# include "bytes_swap.h"
-#else
+/* Swap bytes in 16 bit value. */
+# define __bswap_constant_16(x) \
+ ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+
+# if defined __GNUC__ && __GNUC__ >= 2
+# define __bswap_16(x) \
+ (__extension__ \
+ ({ register unsigned short int __v; \
+ if (__builtin_constant_p (x)) \
+ __v = __bswap_constant_16 (x); \
+ else \
+ __asm__ __volatile__ ("rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" ((unsigned short int) (x)) \
+ : "cc"); \
+ __v; }))
+# else
+/* This is better than nothing. */
+# define __bswap_16(x) __bswap_constant_16 (x)
+# endif
+
+/* Swap bytes in 32 bit value. */
+# define __bswap_constant_32(x) \
+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
+# if defined __GNUC__ && __GNUC__ >= 2
+/* To swap the bytes in a word the i486 processors and up provide the
+ `bswap' opcode. On i386 we have to use three instructions. */
+# if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ register unsigned int __v; \
+ if (__builtin_constant_p (x)) \
+ __v = __bswap_constant_32 (x); \
+ else \
+ __asm__ __volatile__ ("rorw $8, %w0;" \
+ "rorl $16, %0;" \
+ "rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" ((unsigned int) (x)) \
+ : "cc"); \
+ __v; }))
+# else
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ register unsigned int __v; \
+ if (__builtin_constant_p (x)) \
+ __v = __bswap_constant_32 (x); \
+ else \
+ __asm__ __volatile__ ("bswap %0" \
+ : "=r" (__v) \
+ : "0" ((unsigned int) (x))); \
+ __v; }))
+# endif
+# else
+# define __bswap_32(x) __bswap_constant_32 (x)
+# endif
+
+# if defined __GNUC__ && __GNUC__ >= 2
+/* Swap bytes in 64 bit value. */
+# define __bswap_constant_64(x) \
+ ((((x) & 0xff00000000000000ull) >> 56) \
+ | (((x) & 0x00ff000000000000ull) >> 40) \
+ | (((x) & 0x0000ff0000000000ull) >> 24) \
+ | (((x) & 0x000000ff00000000ull) >> 8) \
+ | (((x) & 0x00000000ff000000ull) << 8) \
+ | (((x) & 0x0000000000ff0000ull) << 24) \
+ | (((x) & 0x000000000000ff00ull) << 40) \
+ | (((x) & 0x00000000000000ffull) << 56))
+
+# define __bswap_64(x) \
+ (__extension__ \
+ ({ union { __extension__ unsigned long long int __ll; \
+ unsigned long int __l[2]; } __w, __r; \
+ if (__builtin_constant_p (x)) \
+ __r.__ll = __bswap_constant_64 (x); \
+ else \
+ { \
+ __w.__ll = (x); \
+ __r.__l[0] = __bswap_32 (__w.__l[1]); \
+ __r.__l[1] = __bswap_32 (__w.__l[0]); \
+ } \
+ __r.__ll; }))
+# endif
+
+#else /* NTOHL_IN_SYS_PARAM_H || WIN32 */
# include <netinet/in.h>
-#endif
+
+#endif /* NTOHL_IN_SYS_PARAM_H || WIN32 */
/* CEIL: division with round to nearest greater integer */
#define CEIL(n, d) ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
* byte orders other than little and big endians are not supported, but only
* the VAX seems to have such exotic properties - note that these 'functions'
* needs <netinet/in.h> or the local equivalent. */
-/* FIXME: hton64 should be declared as an extern inline function to avoid
- * border effects (see byteorder.h) */
#if WORDS_BIGENDIAN
# define hton16 htons
# define hton32 htonl
#else
# define hton16 htons
# define hton32 htonl
-# define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
+ static __inline__ u64 __hton64( u64 i )
+ {
+ return ((u64)(htonl((i) & 0xffffffff)) << 32)
+ | htonl(((i) >> 32) & 0xffffffff );
+ }
+# define hton64(i) __hton64( i )
# define ntoh16 ntohs
# define ntoh32 ntohl
# define ntoh64 hton64
# endif
#endif
-
#define I64C(x) x##LL
-/* The win32 specific stuff was getting really big so it has been moved */
+
#if defined( WIN32 )
-# include "common_win32.h"
+/* 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 ;-)
+ */
+# undef ntoh32(x)
+# undef ntoh16(x)
+# undef ntoh64(x)
+# undef hton32(x)
+# undef hton16(x)
+# undef hton64(x)
+
+# 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_32 (x)
+# endif
+
+/* win32, cl and icl support */
+# if defined( _MSC_VER )
+# 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
+
+# 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)
+# define textdomain(Domain)
+# define bindtextdomain(Package, Directory) 1
#endif
/*****************************************************************************
typedef struct module_symbols_s
{
struct main_s* p_main;
- struct aout_bank_s* p_aout_bank;
- struct vout_bank_s* p_vout_bank;
+ struct input_bank_s* p_input_bank;
+ struct aout_bank_s* p_aout_bank;
+ struct vout_bank_s* p_vout_bank;
int ( * main_GetIntVariable ) ( char *, int );
char * ( * main_GetPszVariable ) ( char *, char * );
void ( * main_PutIntVariable ) ( char *, int );
void ( * main_PutPszVariable ) ( char *, char * );
- int ( * TestProgram ) ( char * );
- int ( * TestMethod ) ( char *, char * );
- int ( * TestCPU ) ( int );
-
int ( * intf_ProcessKey ) ( struct intf_thread_s *, int );
void ( * intf_AssignKey ) ( struct intf_thread_s *, int, int, int );
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 );
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 * );
void ( * ) ( struct bit_stream_s *,
boolean_t ),
void * );
+ void ( * DecoderError ) ( struct decoder_fifo_s * p_fifo );
int ( * input_InitStream ) ( struct input_thread_s *, size_t );
void ( * input_EndStream ) ( struct input_thread_s * );
struct pgrm_descriptor_s *,
mtime_t );
- int ( * input_NetlistInit ) ( struct input_thread_s *,
- int, int, int, size_t, int );
- struct iovec * ( * input_NetlistGetiovec ) ( void * p_method_data );
- void ( * input_NetlistMviovec ) ( void * , int,
- struct data_packet_s **);
- struct data_packet_s * ( * input_NetlistNewPacket ) ( void *, size_t );
- struct data_packet_s * ( * input_NetlistNewPtr ) ( void * );
- struct pes_packet_s * ( * input_NetlistNewPES ) ( void * );
- void ( * input_NetlistDeletePacket ) ( void *, struct data_packet_s * );
- void ( * input_NetlistDeletePES ) ( void *, struct pes_packet_s * );
- void ( * input_NetlistEnd ) ( struct input_thread_s * );
-
struct aout_fifo_s * ( * aout_CreateFifo )
( int, int, long, long, long, void * );
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
- struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, int, int );
- struct subpicture_s * (* vout_CreateSubPicture) ( struct vout_thread_s *,
- int, int );
- struct picture_s * ( * vout_CreatePicture ) ( struct vout_thread_s *,
- int, int, int, int );
+ struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, u32, int );
+ void ( * vout_DestroyThread ) ( struct vout_thread_s *, int * );
- void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
- struct subpicture_s * );
- void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
- struct subpicture_s * );
+ 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 *,
+ void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
- void ( * vout_DatePicture ) ( struct vout_thread_s *p_vout,
- struct picture_s *p_pic, mtime_t );
+ 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 * );
char * ( * DecodeLanguage ) ( u16 );
- struct module_s * ( * module_Need ) ( int, void * );
- void ( * module_Unneed ) ( struct module_s * );
+ struct module_s * ( * module_Need ) ( int, char *, struct probedata_s * );
+ void ( * module_Unneed ) ( struct module_s * );
+
} module_symbols_t;
#ifdef PLUGIN
extern module_symbols_t* p_symbols;
#endif
-/*****************************************************************************
- * Global headers
- *****************************************************************************/
-
-#include "main.h"
-