📄 pa_converters.c
字号:
#elif defined(PA_BIG_ENDIAN) dest[0] = (*src); dest[1] = 0; dest[2] = 0;#endif src += sourceStride; dest += destinationStride * 3; }}/* -------------------------------------------------------------------------- */static void Int8_To_Int16( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ signed char *src = (signed char*)sourceBuffer; signed short *dest = (signed short*)destinationBuffer; (void)ditherGenerator; /* unused parameter */ while( count-- ) { (*dest) = (signed short)((*src) << 8); src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void Int8_To_UInt8( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ signed char *src = (signed char*)sourceBuffer; unsigned char *dest = (unsigned char*)destinationBuffer; (void)ditherGenerator; /* unused parameter */ while( count-- ) { (*dest) = (unsigned char)(*src + 128); src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void UInt8_To_Float32( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned char *src = (unsigned char*)sourceBuffer; float *dest = (float*)destinationBuffer; (void)ditherGenerator; /* unused parameter */ while( count-- ) { float samp = (*src - 128) * const_1_div_128_; *dest = samp; src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void UInt8_To_Int32( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned char *src = (unsigned char*)sourceBuffer; signed long *dest = (signed long*)destinationBuffer; (void)ditherGenerator; /* unused parameter */ while( count-- ) { (*dest) = (*src - 128) << 24; src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void UInt8_To_Int24( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned char *src = (unsigned char*)sourceBuffer; unsigned char *dest = (unsigned char*)destinationBuffer; (void) ditherGenerator; /* unused parameters */ while( count-- ) {#if defined(PA_LITTLE_ENDIAN) dest[0] = 0; dest[1] = 0; dest[2] = (unsigned char)(*src - 128);#elif defined(PA_BIG_ENDIAN) dest[0] = (unsigned char)(*src - 128); dest[1] = 0; dest[2] = 0;#endif src += sourceStride; dest += destinationStride * 3; }}/* -------------------------------------------------------------------------- */static void UInt8_To_Int16( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned char *src = (unsigned char*)sourceBuffer; signed short *dest = (signed short*)destinationBuffer; (void)ditherGenerator; /* unused parameter */ while( count-- ) { (*dest) = (signed short)((*src - 128) << 8); src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void UInt8_To_Int8( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned char *src = (unsigned char*)sourceBuffer; signed char *dest = (signed char*)destinationBuffer; (void)ditherGenerator; /* unused parameter */ while( count-- ) { (*dest) = (signed char)(*src - 128); src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void Copy_8_To_8( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned char *src = (unsigned char*)sourceBuffer; unsigned char *dest = (unsigned char*)destinationBuffer; (void) ditherGenerator; /* unused parameter */ while( count-- ) { *dest = *src; src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void Copy_16_To_16( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned short *src = (unsigned short*)sourceBuffer; unsigned short *dest = (unsigned short*)destinationBuffer; (void) ditherGenerator; /* unused parameter */ while( count-- ) { *dest = *src; src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */static void Copy_24_To_24( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned char *src = (unsigned char*)sourceBuffer; unsigned char *dest = (unsigned char*)destinationBuffer; (void) ditherGenerator; /* unused parameter */ while( count-- ) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; src += sourceStride * 3; dest += destinationStride * 3; }}/* -------------------------------------------------------------------------- */static void Copy_32_To_32( void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ){ unsigned long *dest = (unsigned long*)destinationBuffer; unsigned long *src = (unsigned long*)sourceBuffer; (void) ditherGenerator; /* unused parameter */ while( count-- ) { *dest = *src; src += sourceStride; dest += destinationStride; }}/* -------------------------------------------------------------------------- */PaUtilConverterTable paConverters = { Float32_To_Int32, /* PaUtilConverter *Float32_To_Int32; */ Float32_To_Int32_Dither, /* PaUtilConverter *Float32_To_Int32_Dither; */ Float32_To_Int32_Clip, /* PaUtilConverter *Float32_To_Int32_Clip; */ Float32_To_Int32_DitherClip, /* PaUtilConverter *Float32_To_Int32_DitherClip; */ Float32_To_Int24, /* PaUtilConverter *Float32_To_Int24; */ Float32_To_Int24_Dither, /* PaUtilConverter *Float32_To_Int24_Dither; */ Float32_To_Int24_Clip, /* PaUtilConverter *Float32_To_Int24_Clip; */ Float32_To_Int24_DitherClip, /* PaUtilConverter *Float32_To_Int24_DitherClip; */ Float32_To_Int16, /* PaUtilConverter *Float32_To_Int16; */ Float32_To_Int16_Dither, /* PaUtilConverter *Float32_To_Int16_Dither; */ Float32_To_Int16_Clip, /* PaUtilConverter *Float32_To_Int16_Clip; */ Float32_To_Int16_DitherClip, /* PaUtilConverter *Float32_To_Int16_DitherClip; */ Float32_To_Int8, /* PaUtilConverter *Float32_To_Int8; */ Float32_To_Int8_Dither, /* PaUtilConverter *Float32_To_Int8_Dither; */ Float32_To_Int8_Clip, /* PaUtilConverter *Float32_To_Int8_Clip; */ Float32_To_Int8_DitherClip, /* PaUtilConverter *Float32_To_Int8_DitherClip; */ Float32_To_UInt8, /* PaUtilConverter *Float32_To_UInt8; */ Float32_To_UInt8_Dither, /* PaUtilConverter *Float32_To_UInt8_Dither; */ Float32_To_UInt8_Clip, /* PaUtilConverter *Float32_To_UInt8_Clip; */ Float32_To_UInt8_DitherClip, /* PaUtilConverter *Float32_To_UInt8_DitherClip; */ Int32_To_Float32, /* PaUtilConverter *Int32_To_Float32; */ Int32_To_Int24, /* PaUtilConverter *Int32_To_Int24; */ Int32_To_Int24_Dither, /* PaUtilConverter *Int32_To_Int24_Dither; */ Int32_To_Int16, /* PaUtilConverter *Int32_To_Int16; */ Int32_To_Int16_Dither, /* PaUtilConverter *Int32_To_Int16_Dither; */ Int32_To_Int8, /* PaUtilConverter *Int32_To_Int8; */ Int32_To_Int8_Dither, /* PaUtilConverter *Int32_To_Int8_Dither; */ Int32_To_UInt8, /* PaUtilConverter *Int32_To_UInt8; */ Int32_To_UInt8_Dither, /* PaUtilConverter *Int32_To_UInt8_Dither; */ Int24_To_Float32, /* PaUtilConverter *Int24_To_Float32; */ Int24_To_Int32, /* PaUtilConverter *Int24_To_Int32; */ Int24_To_Int16, /* PaUtilConverter *Int24_To_Int16; */ Int24_To_Int16_Dither, /* PaUtilConverter *Int24_To_Int16_Dither; */ Int24_To_Int8, /* PaUtilConverter *Int24_To_Int8; */ Int24_To_Int8_Dither, /* PaUtilConverter *Int24_To_Int8_Dither; */ Int24_To_UInt8, /* PaUtilConverter *Int24_To_UInt8; */ Int24_To_UInt8_Dither, /* PaUtilConverter *Int24_To_UInt8_Dither; */ Int16_To_Float32, /* PaUtilConverter *Int16_To_Float32; */ Int16_To_Int32, /* PaUtilConverter *Int16_To_Int32; */ Int16_To_Int24, /* PaUtilConverter *Int16_To_Int24; */ Int16_To_Int8, /* PaUtilConverter *Int16_To_Int8; */ Int16_To_Int8_Dither, /* PaUtilConverter *Int16_To_Int8_Dither; */ Int16_To_UInt8, /* PaUtilConverter *Int16_To_UInt8; */ Int16_To_UInt8_Dither, /* PaUtilConverter *Int16_To_UInt8_Dither; */ Int8_To_Float32, /* PaUtilConverter *Int8_To_Float32; */ Int8_To_Int32, /* PaUtilConverter *Int8_To_Int32; */ Int8_To_Int24, /* PaUtilConverter *Int8_To_Int24 */ Int8_To_Int16, /* PaUtilConverter *Int8_To_Int16; */ Int8_To_UInt8, /* PaUtilConverter *Int8_To_UInt8; */ UInt8_To_Float32, /* PaUtilConverter *UInt8_To_Float32; */ UInt8_To_Int32, /* PaUtilConverter *UInt8_To_Int32; */ UInt8_To_Int24, /* PaUtilConverter *UInt8_To_Int24; */ UInt8_To_Int16, /* PaUtilConverter *UInt8_To_Int16; */ UInt8_To_Int8, /* PaUtilConverter *UInt8_To_Int8; */ Copy_8_To_8, /* PaUtilConverter *Copy_8_To_8; */ Copy_16_To_16, /* PaUtilConverter *Copy_16_To_16; */ Copy_24_To_24, /* PaUtilConverter *Copy_24_To_24; */ Copy_32_To_32 /* PaUtilConverter *Copy_32_To_32; */};/* -------------------------------------------------------------------------- */#endif /* PA_NO_STANDARD_CONVERTERS *//* -------------------------------------------------------------------------- */PaUtilZeroer* PaUtil_SelectZeroer( PaSampleFormat destinationFormat ){ switch( destinationFormat & ~paNonInterleaved ){ case paFloat32: return paZeroers.Zero32; case paInt32: return paZeroers.Zero32; case paInt24: return paZeroers.Zero24; case paInt16: return paZeroers.Zero16; case paInt8: return paZeroers.Zero8; case paUInt8: return paZeroers.ZeroU8; default: return 0; }}/* -------------------------------------------------------------------------- */#ifdef PA_NO_STANDARD_ZEROERS/* -------------------------------------------------------------------------- */PaUtilZeroerTable paZeroers = { 0, /* PaUtilZeroer *ZeroU8; */ 0, /* PaUtilZeroer *Zero8; */ 0, /* PaUtilZeroer *Zero16; */ 0, /* PaUtilZeroer *Zero24; */ 0, /* PaUtilZeroer *Zero32; */};/* -------------------------------------------------------------------------- */#else /* PA_NO_STANDARD_ZEROERS is not defined *//*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -