changeset 3908:0cc94b1eec0f

runtime cpudetect in liba52 way
author michael
date Sun, 30 Dec 2001 21:38:53 +0000
parents 6312aa265429
children ef32c8bdee81
files liba52/imdct.c liba52/resample.c liba52/resample_c.c liba52/resample_mmx.c liba52/test.c
diffstat 5 files changed, 28 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/liba52/imdct.c	Sun Dec 30 20:42:49 2001 +0000
+++ b/liba52/imdct.c	Sun Dec 30 21:38:53 2001 +0000
@@ -26,7 +26,6 @@
  */
 
 #include "config.h"
-#include "../cpudetect.h"
 
 #include <math.h>
 #include <stdio.h>
@@ -1107,9 +1106,9 @@
     {
 	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 @@
 
 	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;
     }
--- a/liba52/resample.c	Sun Dec 30 20:42:49 2001 +0000
+++ b/liba52/resample.c	Sun Dec 30 21:38:53 2001 +0000
@@ -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 @@
 
     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
--- a/liba52/resample_c.c	Sun Dec 30 20:42:49 2001 +0000
+++ b/liba52/resample_c.c	Sun Dec 30 21:38:53 2001 +0000
@@ -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 @@
 
     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
--- a/liba52/resample_mmx.c	Sun Dec 30 20:42:49 2001 +0000
+++ b/liba52/resample_mmx.c	Sun Dec 30 21:38:53 2001 +0000
@@ -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 @@
 
     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
--- a/liba52/test.c	Sun Dec 30 20:42:49 2001 +0000
+++ b/liba52/test.c	Sun Dec 30 21:38:53 2001 +0000
@@ -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 @@
     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 @@
     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 @@
     // 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 @@
 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);
 
 }