* ac3_imdct.h : AC3 IMDCT types
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: ac3_imdct.h,v 1.3 2001/05/15 16:19:42 sam Exp $
+ * $Id: ac3_imdct.h,v 1.4 2001/06/12 00:30:41 reno Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Renaud Dartus <reno@videolan.org>
typedef struct imdct_s
{
- complex_t buf[N/4];
+ complex_t buf[N/4] __attribute__ ((aligned(16)));
/* Delay buffer for time domain interleaving */
- float delay[6][256];
- float delay1[6][256];
+ float delay[6][256] __attribute__ ((aligned(16)));
+ float delay1[6][256] __attribute__ ((aligned(16)));
/* Twiddle factors for IMDCT */
- float xcos1[N/4];
- float xsin1[N/4];
- float xcos2[N/8];
- float xsin2[N/8];
+ float xcos1[N/4] __attribute__ ((aligned(16)));
+ float xsin1[N/4] __attribute__ ((aligned(16)));
+ float xcos2[N/8] __attribute__ ((aligned(16)));
+ float xsin2[N/8] __attribute__ ((aligned(16)));
/* Twiddle factor LUT */
- complex_t *w[7];
- complex_t w_1[1];
- complex_t w_2[2];
- complex_t w_4[4];
- complex_t w_8[8];
- complex_t w_16[16];
- complex_t w_32[32];
- complex_t w_64[64];
+ complex_t *w[7] __attribute__ ((aligned(16)));
+ complex_t w_1[1] __attribute__ ((aligned(16)));
+ complex_t w_2[2] __attribute__ ((aligned(16)));
+ complex_t w_4[4] __attribute__ ((aligned(16)));
+ complex_t w_8[8] __attribute__ ((aligned(16)));
+ complex_t w_16[16] __attribute__ ((aligned(16)));
+ complex_t w_32[32] __attribute__ ((aligned(16)));
+ complex_t w_64[64] __attribute__ ((aligned(16)));
- float xcos_sin_sse[128 * 4] __attribute__((aligned(16)));
+ float xcos_sin_sse[128 * 4] __attribute__ ((aligned(16)));
/* Module used and shortcuts */
struct module_s * p_module;
* and spawn threads.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: main.c,v 1.99 2001/05/31 01:37:08 sam Exp $
+ * $Id: main.c,v 1.100 2001/06/12 00:30:41 reno Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include <signal.h> /* SIGHUP, SIGINT, SIGKILL */
#include <stdio.h> /* sprintf() */
+#include <setjmp.h> /* longjmp, setjmp */
#ifdef HAVE_GETOPT_LONG
# ifdef HAVE_GETOPT_H
static void InitSignalHandler ( void );
static void SimpleSignalHandler ( int i_signal );
static void FatalSignalHandler ( int i_signal );
-
+static void InstructionSignalHandler( int i_signal );
static int CPUCapabilities ( void );
+static jmp_buf env;
+static int i_illegal;
/*****************************************************************************
* main: parse command line, start interface and spawn threads
p_main->p_intf->b_die = 1;
}
+/*****************************************************************************
+ * InstructionSignalHandler: system signal handler
+ *****************************************************************************
+ * This function is called when a illegal instruction signal is received by
+ * the program.
+ * We use this function to test OS and CPU_Capabilities
+ *****************************************************************************/
+static void InstructionSignalHandler( int i_signal )
+{
+ /* Once a signal has been trapped, the termination sequence will be
+ * armed and following signals will be ignored to avoid sending messages
+ * to an interface having been destroyed */
+
+ /* Acknowledge the signal received */
+ fprintf(stderr,"illegal instruction : optimization disable\n");
+
+ i_illegal = 1;
+
+ sigrelse( i_signal );
+ longjmp( env, 1 );
+}
+
+
+
+
/*****************************************************************************
* CPUCapabilities: list the processors MMX support and other capabilities
*****************************************************************************
unsigned int i_eax, i_ebx, i_ecx, i_edx;
boolean_t b_amd;
+ signal( SIGILL, InstructionSignalHandler );
+
# define cpuid( a ) \
asm volatile ( "cpuid" \
: "=a" ( i_eax ), \
if( i_eax == i_ebx )
{
+ signal( SIGILL, NULL );
return( i_capabilities );
}
if( !i_eax )
{
+ signal( SIGILL, NULL );
return( i_capabilities );
}
if( ! (i_edx & 0x00800000) )
{
+ signal( SIGILL, NULL );
return( i_capabilities );
}
if( i_edx & 0x02000000 )
{
+
i_capabilities |= CPU_CAPABILITY_MMXEXT;
- i_capabilities |= CPU_CAPABILITY_SSE;
+
+ /* We test if OS support the SSE instructions */
+ i_illegal = 0;
+ if(setjmp(env)==0) { /* Test a SSE instruction */
+ __asm__ __volatile__ (
+ "xorps %%xmm0,%%xmm0\n"
+ ::);
+ }
+
+ if( i_illegal != 1 )
+ i_capabilities |= CPU_CAPABILITY_SSE;
}
/* test for additional capabilities */
if( i_eax < 0x80000001 )
{
+ signal( SIGILL, NULL );
return( i_capabilities );
}
if( i_edx & 0x80000000 )
{
- i_capabilities |= CPU_CAPABILITY_3DNOW;
+ i_illegal = 0;
+ if(setjmp(env)==0) { /* Test a 3D Now! instruction */
+ __asm__ __volatile__ (
+ "pfadd %%mm0,%%mm0\n"
+ "femms\n"
+ ::);
+ }
+
+ if( i_illegal != 1 )
+ i_capabilities |= CPU_CAPABILITY_3DNOW;
}
if( b_amd && ( i_edx & 0x00400000 ) )
/* default behaviour */
#endif
+ signal( SIGILL, NULL );
return( i_capabilities );
}