1
mirror of https://github.com/mpv-player/mpv synced 2024-10-18 10:25:02 +02:00

runtime cpudetect in liba52 way

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3909 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
michael 2001-12-30 21:38:53 +00:00
parent 2addc399ab
commit 8a95255ef2
5 changed files with 28 additions and 21 deletions

View File

@ -26,7 +26,6 @@
*/
#include "config.h"
#include "../cpudetect.h"
#include <math.h>
#include <stdio.h>
@ -1107,9 +1106,9 @@ void imdct_init (uint32_t mm_accel)
{
int i, j, k;
if(gCpuCaps.hasSSE) fprintf (stderr, "Using SSE optimized IMDCT transform\n");
else if(gCpuCaps.has3DNow) fprintf (stderr, "Using experimental 3DNow optimized IMDCT transform\n");
else fprintf (stderr, "No accelerated IMDCT transform found\n");
if(mm_accel & MM_ACCEL_X86_SSE) fprintf (stderr, "Using SSE optimized IMDCT transform\n");
else if(mm_accel & MM_ACCEL_X86_3DNOW) fprintf (stderr, "Using 3DNow optimized IMDCT transform\n");
else fprintf (stderr, "No accelerated IMDCT transform found\n");
/* Twiddle factors to turn IFFT into IMDCT */
for (i = 0; i < 128; i++) {
@ -1185,8 +1184,8 @@ void imdct_init (uint32_t mm_accel)
imdct_512 = imdct_do_512;
#ifdef ARCH_X86
if(gCpuCaps.hasSSE) imdct_512 = imdct_do_512_sse;
else if(gCpuCaps.has3DNow) imdct_512 = imdct_do_512_3dnow;
if(mm_accel & MM_ACCEL_X86_SSE) imdct_512 = imdct_do_512_sse;
else if(mm_accel & MM_ACCEL_X86_3DNOW) imdct_512 = imdct_do_512_3dnow;
#endif // arch_x86
imdct_256 = imdct_do_256;
}

View File

@ -18,8 +18,8 @@
#include <inttypes.h>
#include <stdio.h>
#include "a52.h"
#include "mm_accel.h"
#include "../config.h"
#include "../cpudetect.h"
int (* a52_resample) (float * _f, int16_t * s16)=NULL;
@ -592,12 +592,12 @@ void a52_resample_init(uint32_t mm_accel,int _flags,int _chans){
if(a52_resample==NULL) // only once please ;)
{
if(gCpuCaps.hasMMX) fprintf(stderr, "Using MMX optimized resampler\n");
else fprintf(stderr, "No accelerated resampler found\n");
if(mm_accel & MM_ACCEL_X86_MMX) fprintf(stderr, "Using MMX optimized resampler\n");
else fprintf(stderr, "No accelerated resampler found\n");
}
#ifdef ARCH_X86
if(gCpuCaps.hasMMX) a52_resample= a52_resample_MMX;
if(mm_accel & MM_ACCEL_X86_MMX) a52_resample= a52_resample_MMX;
#else
if(0);
#endif

View File

@ -18,8 +18,8 @@
#include <inttypes.h>
#include <stdio.h>
#include "a52.h"
#include "mm_accel.h"
#include "../config.h"
#include "../cpudetect.h"
int (* a52_resample) (float * _f, int16_t * s16)=NULL;
@ -592,12 +592,12 @@ void a52_resample_init(uint32_t mm_accel,int _flags,int _chans){
if(a52_resample==NULL) // only once please ;)
{
if(gCpuCaps.hasMMX) fprintf(stderr, "Using MMX optimized resampler\n");
else fprintf(stderr, "No accelerated resampler found\n");
if(mm_accel & MM_ACCEL_X86_MMX) fprintf(stderr, "Using MMX optimized resampler\n");
else fprintf(stderr, "No accelerated resampler found\n");
}
#ifdef ARCH_X86
if(gCpuCaps.hasMMX) a52_resample= a52_resample_MMX;
if(mm_accel & MM_ACCEL_X86_MMX) a52_resample= a52_resample_MMX;
#else
if(0);
#endif

View File

@ -18,8 +18,8 @@
#include <inttypes.h>
#include <stdio.h>
#include "a52.h"
#include "mm_accel.h"
#include "../config.h"
#include "../cpudetect.h"
int (* a52_resample) (float * _f, int16_t * s16)=NULL;
@ -592,12 +592,12 @@ void a52_resample_init(uint32_t mm_accel,int _flags,int _chans){
if(a52_resample==NULL) // only once please ;)
{
if(gCpuCaps.hasMMX) fprintf(stderr, "Using MMX optimized resampler\n");
else fprintf(stderr, "No accelerated resampler found\n");
if(mm_accel & MM_ACCEL_X86_MMX) fprintf(stderr, "Using MMX optimized resampler\n");
else fprintf(stderr, "No accelerated resampler found\n");
}
#ifdef ARCH_X86
if(gCpuCaps.hasMMX) a52_resample= a52_resample_MMX;
if(mm_accel & MM_ACCEL_X86_MMX) a52_resample= a52_resample_MMX;
#else
if(0);
#endif

View File

@ -11,6 +11,7 @@
#include <inttypes.h>
#include "a52.h"
#include "mm_accel.h"
#include "../cpudetect.h"
static sample_t * samples;
@ -51,6 +52,13 @@ long long t, sum=0, min=256*256*256*64;
stdout= stderr; //EVIL HACK FIXME
GetCpuCaps(&gCpuCaps);
stdout= temp;
// gCpuCaps.hasMMX=0;
// gCpuCaps.hasSSE=0;
if(gCpuCaps.hasMMX) accel |= MM_ACCEL_X86_MMX;
if(gCpuCaps.hasMMX2) accel |= MM_ACCEL_X86_MMXEXT;
if(gCpuCaps.hasSSE) accel |= MM_ACCEL_X86_SSE;
if(gCpuCaps.has3DNow) accel |= MM_ACCEL_X86_3DNOW;
// if(gCpuCaps.has3DNowExt) accel |= MM_ACCEL_X86_3DNOWEXT;
samples = a52_init (accel);
if (samples == NULL) {
@ -87,7 +95,7 @@ ENDTIMING
buf_size=0;
// decode:
flags=A52_STEREO; //A52_STEREO; // A52_DOLBY // A52_2F2R // A52_3F2R | A52_LFE
flags=A52_STEREO; //A52_STEREO; //A52_DOLBY; //A52_STEREO; // A52_DOLBY // A52_2F2R // A52_3F2R | A52_LFE
channels=2;
flags |= A52_ADJUST_LEVEL;
@ -99,7 +107,7 @@ ENDTIMING
// a52_dynrng (&state, NULL, NULL); // disable dynamic range compensation
STARTTIMING
a52_resample_init(flags,channels);
a52_resample_init(accel,flags,channels);
s16 = out_buf;
for (i = 0; i < 6; i++) {
if (a52_block (&state, samples))
@ -112,7 +120,7 @@ ENDTIMING
if(sum<min) min=sum;
sum=0;
#endif
fwrite(out_buf,6*256*2*2,1,stdout);
fwrite(out_buf,6*256*2*channels,1,stdout);
}