- Timestamp:
- May 31, 2021 12:35:46 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer-Convert.cpp.h
r89396 r89397 1 1 /* $Id$ */ 2 2 /** @file 3 * Audio mixing buffer for convertingtemplate.3 * Audio mixing buffer - Format conversion template. 4 4 */ 5 5 … … 17 17 18 18 19 /** 20 * Macro for generating the conversion routines from/to different formats. 21 * Be careful what to pass in/out, as most of the macros are optimized for speed and 22 * thus don't do any bounds checking! 23 * 24 * @note Currently does not handle any endianness conversion yet! 25 */ 26 #define AUDMIXBUF_CONVERT(a_Name, a_Type, _aMin, _aMax, _aSigned, _aShift) \ 19 #define AUDMIXBUF_CONVERT(a_Name, a_Type, a_Min, a_Max, a_fSigned, a_cShift) \ 27 20 /* Clips a specific output value to a single sample value. */ \ 28 21 DECLINLINE(int32_t) audioMixBufSampleFrom##a_Name(a_Type aVal) \ 29 22 { \ 30 23 /* left shifting of signed values is not defined, therefore the intermediate uint64_t cast */ \ 31 if ( _aSigned) \32 return (int32_t) (((uint32_t) ((int32_t) aVal )) << (32 - _aShift)); \33 return (int32_t) (((uint32_t) ((int32_t) aVal - (( _aMax >> 1) + 1))) << (32 - _aShift)); \24 if (a_fSigned) \ 25 return (int32_t) (((uint32_t) ((int32_t) aVal )) << (32 - a_cShift)); \ 26 return (int32_t) (((uint32_t) ((int32_t) aVal - ((a_Max >> 1) + 1))) << (32 - a_cShift)); \ 34 27 } \ 35 28 \ … … 37 30 DECLINLINE(a_Type) audioMixBufSampleTo##a_Name(int32_t iVal) \ 38 31 { \ 39 if ( _aSigned) \40 return (a_Type) (iVal >> (32 - _aShift)); \41 return (a_Type) ((iVal >> (32 - _aShift)) + ((_aMax >> 1) + 1)); \32 if (a_fSigned) \ 33 return (a_Type) (iVal >> (32 - a_cShift)); \ 34 return (a_Type) ((iVal >> (32 - a_cShift)) + ((a_Max >> 1) + 1)); \ 42 35 } \ 43 36 \ … … 61 54 pDst[idxDst] = audioMixBufSampleTo##a_Name(pi32Src[idxSrc]); \ 62 55 else if (idxSrc != -2) \ 63 pDst[idxDst] = ( _aSigned) ? 0 : (_aMax >> 1); \56 pDst[idxDst] = (a_fSigned) ? 0 : (a_Max >> 1); \ 64 57 else \ 65 58 pDst[idxDst] = 0; \ … … 147 140 pi32Dst[idxDst] = audioMixBufSampleTo##a_Name(pSrc[idxSrc]); \ 148 141 else if (idxSrc != -2) \ 149 pi32Dst[idxDst] = ( _aSigned) ? 0 : (_aMax >> 1); \142 pi32Dst[idxDst] = (a_fSigned) ? 0 : (a_Max >> 1); \ 150 143 else \ 151 144 pi32Dst[idxDst] = 0; \
Note:
See TracChangeset
for help on using the changeset viewer.