Changeset 87936 in vbox
- Timestamp:
- Mar 3, 2021 1:14:44 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r82968 r87936 90 90 91 91 /** Logarithmic/exponential volume conversion table. */ 92 static uint32_t s_aVolumeConv[256] = {92 static uint32_t const s_aVolumeConv[256] = { 93 93 1, 1, 1, 1, 1, 1, 1, 1, /* 7 */ 94 94 1, 2, 2, 2, 2, 2, 2, 2, /* 15 */ … … 445 445 #define AUDMIXBUF_CONVERT(_aName, _aType, _aMin, _aMax, _aSigned, _aShift) \ 446 446 /* Clips a specific output value to a single sample value. */ \ 447 DECL CALLBACK(int64_t) audioMixBufClipFrom##_aName(_aType aVal) \447 DECLINLINE(int64_t) audioMixBufClipFrom##_aName(_aType aVal) \ 448 448 { \ 449 449 /* left shifting of signed values is not defined, therefore the intermediate uint64_t cast */ \ … … 454 454 \ 455 455 /* Clips a single sample value to a specific output value. */ \ 456 DECL CALLBACK(_aType) audioMixBufClipTo##_aName(int64_t iVal) \456 DECLINLINE(_aType) audioMixBufClipTo##_aName(int64_t iVal) \ 457 457 { \ 458 if (iVal >= 0x7fffffff)\459 return _aMax;\460 if (iVal < -INT64_C(0x80000000))\461 return _aMin;\462 \463 if (_aSigned)\464 return (_aType) (iVal >> (32 - _aShift));\465 return ((_aType) ((iVal >> (32 - _aShift)) + ((_aMax >> 1) + 1))); \458 /*if (iVal >= 0x7fffffff) return _aMax; if (iVal < -INT64_C(0x80000000)) return _aMin;*/ \ 459 if (!(((uint64_t)iVal + UINT64_C(0x80000000)) & UINT64_C(0xffffffff00000000))) \ 460 { \ 461 if (_aSigned) \ 462 return (_aType) (iVal >> (32 - _aShift)); \ 463 return (_aType) ((iVal >> (32 - _aShift)) + ((_aMax >> 1) + 1)); \ 464 } \ 465 return iVal >= 0 ? _aMax : _aMin; \ 466 466 } \ 467 467 \ … … 505 505 PCPDMAUDIOFRAME pSrc = paSrc; \ 506 506 _aType *pDst = (_aType *)pvDst; \ 507 _aType l, r; \508 507 uint32_t cFrames = pOpts->cFrames; \ 509 508 while (cFrames--) \ 510 509 { \ 511 510 AUDMIXBUF_MACRO_LOG(("%p: l=%RI64, r=%RI64\n", pSrc, pSrc->i64LSample, pSrc->i64RSample)); \ 512 l = audioMixBufClipTo##_aName(pSrc->i64LSample); \ 513 r = audioMixBufClipTo##_aName(pSrc->i64RSample); \ 514 AUDMIXBUF_MACRO_LOG(("\t-> l=%RI16, r=%RI16\n", l, r)); \ 515 *pDst++ = l; \ 516 *pDst++ = r; \ 511 pDst[0] = audioMixBufClipTo##_aName(pSrc->i64LSample); \ 512 pDst[1] = audioMixBufClipTo##_aName(pSrc->i64RSample); \ 513 AUDMIXBUF_MACRO_LOG(("\t-> l=%RI16, r=%RI16\n", pDst[0], pDst[1])); \ 514 pDst += 2; \ 517 515 pSrc++; \ 518 516 } \
Note:
See TracChangeset
for help on using the changeset viewer.