]> Repos - portaudio/commitdiff
disable dither conversion when host input format is 32 bit and user format is 24...
authorrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Sun, 26 Dec 2010 06:43:58 +0000 (06:43 +0000)
committerrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Sun, 26 Dec 2010 06:43:58 +0000 (06:43 +0000)
src/common/pa_process.c

index 38305320bfbf3ac8abf422cffabe5ef5afd8d819..86995a7a6d063bb53e223a7847ed218814b96200 100644 (file)
@@ -137,6 +137,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
     PaError result = paNoError;
     PaError bytesPerSample;
     unsigned long tempInputBufferSize, tempOutputBufferSize;
+    PaStreamFlags tempInputStreamFlags;
 
     if( streamFlags & paNeverDropInput )
     {
@@ -257,8 +258,20 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp,
             goto error;
         }
 
+        /* Under the assumption that no ADC in existence delivers better than 24bits resoultion,
+            we disable dithering when host input format is paInt32 and user format is paInt24, 
+            since the host samples will just be padded with zeros anyway. */
+
+        tempInputStreamFlags = streamFlags;
+        if( !(tempInputStreamFlags & paDitherOff) /* dither is on */
+                && (hostInputSampleFormat & paInt32) /* host input format is int32 */
+                && (userInputSampleFormat & paInt24) /* user requested format is int24 */ ){
+
+            tempInputStreamFlags = tempInputStreamFlags | paDitherOff;
+        }
+
         bp->inputConverter =
-            PaUtil_SelectConverter( hostInputSampleFormat, userInputSampleFormat, streamFlags );
+            PaUtil_SelectConverter( hostInputSampleFormat, userInputSampleFormat, tempInputStreamFlags );
 
         bp->inputZeroer = PaUtil_SelectZeroer( hostInputSampleFormat );