@ingroup common_src
@brief Conversion function implementations.
-
- If the C9x function lrintf() is available, define PA_USE_C99_LRINTF to use it
@todo Consider whether functions which dither but don't clip should exist,
V18 automatically enabled clipping whenever dithering was selected. Perhaps
while( count-- )
{
/* REVIEW */
-#ifdef PA_USE_C99_LRINTF
- float scaled = *src * 0x7FFFFFFF;
- *dest = lrintf(scaled-0.5f);
-#else
double scaled = *src * 0x7FFFFFFF;
*dest = (PaInt32) scaled;
-#endif
src += sourceStride;
dest += destinationStride;
while( count-- )
{
/* REVIEW */
-#ifdef PA_USE_C99_LRINTF
- float dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
- /* use smaller scaler to prevent overflow when we add the dither */
- float dithered = ((float)*src * (2147483646.0f)) + dither;
- *dest = lrintf(dithered - 0.5f);
-#else
double dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
/* use smaller scaler to prevent overflow when we add the dither */
double dithered = ((double)*src * (2147483646.0)) + dither;
*dest = (PaInt32) dithered;
-#endif
+
src += sourceStride;
dest += destinationStride;
}
while( count-- )
{
/* REVIEW */
-#ifdef PA_USE_C99_LRINTF
- float scaled = *src * 0x7FFFFFFF;
- PA_CLIP_( scaled, -2147483648.f, 2147483647.f );
- *dest = lrintf(scaled-0.5f);
-#else
double scaled = *src * 0x7FFFFFFF;
PA_CLIP_( scaled, -2147483648., 2147483647. );
*dest = (PaInt32) scaled;
-#endif
src += sourceStride;
dest += destinationStride;
while( count-- )
{
/* REVIEW */
-#ifdef PA_USE_C99_LRINTF
- float dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
- /* use smaller scaler to prevent overflow when we add the dither */
- float dithered = ((float)*src * (2147483646.0f)) + dither;
- PA_CLIP_( dithered, -2147483648.f, 2147483647.f );
- *dest = lrintf(dithered-0.5f);
-#else
double dither = PaUtil_GenerateFloatTriangularDither( ditherGenerator );
/* use smaller scaler to prevent overflow when we add the dither */
double dithered = ((double)*src * (2147483646.0)) + dither;
PA_CLIP_( dithered, -2147483648., 2147483647. );
*dest = (PaInt32) dithered;
-#endif
src += sourceStride;
dest += destinationStride;
while( count-- )
{
-#ifdef PA_USE_C99_LRINTF
- float tempf = (*src * (32767.0f)) ;
- *dest = lrintf(tempf-0.5f);
-#else
short samp = (short) (*src * (32767.0f));
*dest = samp;
-#endif
src += sourceStride;
dest += destinationStride;
/* use smaller scaler to prevent overflow when we add the dither */
float dithered = (*src * (32766.0f)) + dither;
-#ifdef PA_USE_C99_LRINTF
- *dest = lrintf(dithered-0.5f);
-#else
*dest = (PaInt16) dithered;
-#endif
src += sourceStride;
dest += destinationStride;
while( count-- )
{
-#ifdef PA_USE_C99_LRINTF
- long samp = lrintf((*src * (32767.0f)) -0.5f);
-#else
long samp = (PaInt32) (*src * (32767.0f));
-#endif
+
PA_CLIP_( samp, -0x8000, 0x7FFF );
*dest = (PaInt16) samp;
float dithered = (*src * (32766.0f)) + dither;
PaInt32 samp = (PaInt32) dithered;
PA_CLIP_( samp, -0x8000, 0x7FFF );
-#ifdef PA_USE_C99_LRINTF
- *dest = lrintf(samp-0.5f);
-#else
*dest = (PaInt16) samp;
-#endif
src += sourceStride;
dest += destinationStride;