Commit 2788bc6a authored by Renaud Dartus's avatar Renaud Dartus

* Check that OS support SSE optimization for PIII (to avoid illegal hardware...

* Check that OS support SSE optimization for PIII (to avoid illegal hardware instruction on Linux 2.2.x)
parent 7b5259e0
......@@ -2,7 +2,7 @@
* 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>
......@@ -31,29 +31,29 @@ typedef struct complex_s {
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;
......
......@@ -2,7 +2,7 @@
* imdct3dn.c : accelerated 3D Now! IMDCT module
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: imdct3dn.c,v 1.4 2001/06/03 12:47:21 sam Exp $
* $Id: imdct3dn.c,v 1.5 2001/06/12 00:30:41 reno Exp $
*
* Authors: Gal Hendryckx <jimmy@via.ecp.fr>
*
......@@ -98,7 +98,7 @@ static int imdct_Probe( probedata_t *p_data )
return( 0 );
}
if( TestMethod( DOWNMIX_METHOD_VAR, "imdct3dn" ) )
if( TestMethod( IMDCT_METHOD_VAR, "imdct3dn" ) )
{
return( 999 );
}
......
......@@ -2,7 +2,7 @@
* imdctsse.c : accelerated SSE IMDCT module
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: imdctsse.c,v 1.4 2001/06/03 12:47:21 sam Exp $
* $Id: imdctsse.c,v 1.5 2001/06/12 00:30:41 reno Exp $
*
* Authors: Gal Hendryckx <jimmy@via.ecp.fr>
*
......@@ -98,7 +98,7 @@ static int imdct_Probe( probedata_t *p_data )
return( 0 );
}
if( TestMethod( IDCT_METHOD_VAR, "imdctsse" ) )
if( TestMethod( IMDCT_METHOD_VAR, "imdctsse" ) )
{
return( 999 );
}
......
......@@ -2,7 +2,7 @@
* ac3_decoder.h : ac3 decoder interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder.h,v 1.9 2001/05/15 16:19:42 sam Exp $
* $Id: ac3_decoder.h,v 1.10 2001/06/12 00:30:41 reno Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Renaud Dartus <reno@videolan.org>
......@@ -370,7 +370,7 @@ struct ac3dec_s
bsi_t bsi;
audblk_t audblk;
float samples[6][256];
float samples[6][256] __attribute__ ((aligned(16)));
dm_par_t dm_par;
bit_allocate_t bit_allocate;
......
......@@ -4,7 +4,7 @@
* 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>
......@@ -31,6 +31,7 @@
#include <signal.h> /* SIGHUP, SIGINT, SIGKILL */
#include <stdio.h> /* sprintf() */
#include <setjmp.h> /* longjmp, setjmp */
#ifdef HAVE_GETOPT_LONG
# ifdef HAVE_GETOPT_H
......@@ -213,8 +214,10 @@ static void Version ( void );
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
......@@ -895,6 +898,31 @@ static void FatalSignalHandler( int i_signal )
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
*****************************************************************************
......@@ -942,6 +970,8 @@ static int CPUCapabilities( void )
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 ), \
......@@ -967,6 +997,7 @@ static int CPUCapabilities( void )
if( i_eax == i_ebx )
{
signal( SIGILL, NULL );
return( i_capabilities );
}
......@@ -977,6 +1008,7 @@ static int CPUCapabilities( void )
if( !i_eax )
{
signal( SIGILL, NULL );
return( i_capabilities );
}
......@@ -992,6 +1024,7 @@ static int CPUCapabilities( void )
if( ! (i_edx & 0x00800000) )
{
signal( SIGILL, NULL );
return( i_capabilities );
}
......@@ -999,8 +1032,19 @@ static int CPUCapabilities( void )
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 */
......@@ -1008,6 +1052,7 @@ static int CPUCapabilities( void )
if( i_eax < 0x80000001 )
{
signal( SIGILL, NULL );
return( i_capabilities );
}
......@@ -1016,7 +1061,16 @@ static int CPUCapabilities( void )
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 ) )
......@@ -1027,6 +1081,7 @@ static int CPUCapabilities( void )
/* default behaviour */
#endif
signal( SIGILL, NULL );
return( i_capabilities );
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment