VirtualBox

Changeset 87936 in vbox


Ignore:
Timestamp:
Mar 3, 2021 1:14:44 PM (4 years ago)
Author:
vboxsync
Message:

AudioMixBuffer: Combine the out-of-range checks in audioMixBufClipToXxxx. Mark it and it's counterpart as inline rather than callback. GCC 10 generates microscopically better code now. bugref:9890

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r82968 r87936  
    9090
    9191/** Logarithmic/exponential volume conversion table. */
    92 static uint32_t s_aVolumeConv[256] = {
     92static uint32_t const s_aVolumeConv[256] = {
    9393        1,     1,     1,     1,     1,     1,     1,     1, /*   7 */
    9494        1,     2,     2,     2,     2,     2,     2,     2, /*  15 */
     
    445445#define AUDMIXBUF_CONVERT(_aName, _aType, _aMin, _aMax, _aSigned, _aShift) \
    446446    /* Clips a specific output value to a single sample value. */ \
    447     DECLCALLBACK(int64_t) audioMixBufClipFrom##_aName(_aType aVal) \
     447    DECLINLINE(int64_t) audioMixBufClipFrom##_aName(_aType aVal) \
    448448    { \
    449449        /* left shifting of signed values is not defined, therefore the intermediate uint64_t cast */ \
     
    454454    \
    455455    /* Clips a single sample value to a specific output value. */ \
    456     DECLCALLBACK(_aType) audioMixBufClipTo##_aName(int64_t iVal) \
     456    DECLINLINE(_aType) audioMixBufClipTo##_aName(int64_t iVal) \
    457457    { \
    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; \
    466466    } \
    467467    \
     
    505505        PCPDMAUDIOFRAME pSrc = paSrc; \
    506506        _aType *pDst = (_aType *)pvDst; \
    507         _aType l, r; \
    508507        uint32_t cFrames = pOpts->cFrames; \
    509508        while (cFrames--) \
    510509        { \
    511510            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; \
    517515            pSrc++; \
    518516        } \
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette