Overview:

This is a small effort to improve the efficiency of sampler converter. A
direct memcpy bypass is added for 16bit to 16bit converting case,
similar to what we already have for 32bit to 32bit conversion. Also
memcpy bypass is turned on by conditional pre-compiling macro now,
instead of 'if' statement. This enables memcpy bypass on compilers that
don't do aggressive constant expression optimization and debug build.

Head and Atlas310

fxd
Index: pub/mixengine.h
===================================================================
RCS file: /cvsroot/client/audiosvc/pub/mixengine.h,v
retrieving revision 1.17
diff -u -w -r1.17 mixengine.h
--- pub/mixengine.h	6 Jul 2007 21:57:40 -0000	1.17
+++ pub/mixengine.h	28 Apr 2009 15:31:00 -0000
@@ -59,6 +59,7 @@
 // on memory- and resource-constrained devices, use 16-bit processing
 #ifdef HELIX_FEATURE_16BIT_MIXENGINE
 typedef INT16 tAudioSample ;
+#define NBITS_PER_AUDIOSAMPLE 16
 
 #if defined(HELIX_FEATURE_GAINTOOL) || defined(HELIX_FEATURE_CROSSFADE)\
  || defined(HELIX_FEATURE_LIMITER)
@@ -67,9 +68,9 @@
 
 #else // all other platforms use 32-bit processing
 typedef INT32 tAudioSample ;
+#define NBITS_PER_AUDIOSAMPLE 32
 #endif
 
-#define NBITS_PER_AUDIOSAMPLE (sizeof(tAudioSample)<<3)
 
 // derive your class from this. This will be used as a callback to convert samples from
 // the renderer input queues into the HXAudioSvcMixEngine source buffer
@@ -93,14 +94,19 @@
     }
     static void cvt16(const void *in, tAudioSample* out, int nSamples)
     {
+#if NBITS_PER_AUDIOSAMPLE == 16
+        memcpy(out, in, nSamples * sizeof(tAudioSample));
+#else
         for (int i=0; i < nSamples; i++) out[i] = ((const INT16*)in)[i] << (NBITS_PER_AUDIOSAMPLE-16) ;
+#endif
     }
     static void cvt32(const void *in, tAudioSample* out, int nSamples)
     {
-        if (NBITS_PER_AUDIOSAMPLE == 32)
-            memcpy(out, in, nSamples * sizeof(*out));
-        else
+#if NBITS_PER_AUDIOSAMPLE == 32
+        memcpy(out, in, nSamples * sizeof(tAudioSample));
+#else
             for (int i=0; i < nSamples; i++) out[i] = (INT16)(((const INT32*)in)[i] >> (NBITS_PER_AUDIOSAMPLE-16)) ;
+#endif
     }
     static void silence(tAudioSample* out, int nSamples)
     {
_______________________________________________
Audio-dev mailing list
Audio-dev@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/audio-dev

Reply via email to