Commit 073b7bbb authored by David Reid's avatar David Reid

Version 0.11.7

parent 353eaba3
v0.11.7 - TBD v0.11.7 - 2022-02-06
==================== ====================
* Fix an error when seeking to the end of a WAV file. * Fix an error when seeking to the end of a WAV file.
* Fix a memory leak with low-pass, high-pass and band-pass filters. * Fix a memory leak with low-pass, high-pass and band-pass filters.
......
/* /*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.6 - 2022-01-22 miniaudio - v0.11.7 - 2022-02-06
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
...@@ -33457,6 +33457,10 @@ MA_API void ma_lpf_uninit(ma_lpf* pLPF, const ma_allocation_callbacks* pAllocati ...@@ -33457,6 +33457,10 @@ MA_API void ma_lpf_uninit(ma_lpf* pLPF, const ma_allocation_callbacks* pAllocati
for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) { for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) {
ma_lpf2_uninit(&pLPF->pLPF2[ilpf2], pAllocationCallbacks); ma_lpf2_uninit(&pLPF->pLPF2[ilpf2], pAllocationCallbacks);
} }
if (pLPF->_ownsHeap) {
ma_free(pLPF->_pHeap, pAllocationCallbacks);
}
} }
MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF) MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF)
...@@ -34295,6 +34299,10 @@ MA_API void ma_hpf_uninit(ma_hpf* pHPF, const ma_allocation_callbacks* pAllocati ...@@ -34295,6 +34299,10 @@ MA_API void ma_hpf_uninit(ma_hpf* pHPF, const ma_allocation_callbacks* pAllocati
for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) { for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) {
ma_hpf2_uninit(&pHPF->pHPF2[ihpf2], pAllocationCallbacks); ma_hpf2_uninit(&pHPF->pHPF2[ihpf2], pAllocationCallbacks);
} }
if (pHPF->_ownsHeap) {
ma_free(pHPF->_pHeap, pAllocationCallbacks);
}
} }
MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF) MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF)
...@@ -34793,6 +34801,10 @@ MA_API void ma_bpf_uninit(ma_bpf* pBPF, const ma_allocation_callbacks* pAllocati ...@@ -34793,6 +34801,10 @@ MA_API void ma_bpf_uninit(ma_bpf* pBPF, const ma_allocation_callbacks* pAllocati
for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) { for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) {
ma_bpf2_uninit(&pBPF->pBPF2[ibpf2], pAllocationCallbacks); ma_bpf2_uninit(&pBPF->pBPF2[ibpf2], pAllocationCallbacks);
} }
if (pBPF->_ownsHeap) {
ma_free(pBPF->_pHeap, pAllocationCallbacks);
}
} }
MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF) MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF)
...@@ -45959,7 +45971,7 @@ extern "C" { ...@@ -45959,7 +45971,7 @@ extern "C" {
#define DRWAV_XSTRINGIFY(x) DRWAV_STRINGIFY(x) #define DRWAV_XSTRINGIFY(x) DRWAV_STRINGIFY(x)
#define DRWAV_VERSION_MAJOR 0 #define DRWAV_VERSION_MAJOR 0
#define DRWAV_VERSION_MINOR 13 #define DRWAV_VERSION_MINOR 13
#define DRWAV_VERSION_REVISION 4 #define DRWAV_VERSION_REVISION 5
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION) #define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
#include <stddef.h> #include <stddef.h>
typedef signed char drwav_int8; typedef signed char drwav_int8;
...@@ -46494,7 +46506,7 @@ extern "C" { ...@@ -46494,7 +46506,7 @@ extern "C" {
#define DRFLAC_XSTRINGIFY(x) DRFLAC_STRINGIFY(x) #define DRFLAC_XSTRINGIFY(x) DRFLAC_STRINGIFY(x)
#define DRFLAC_VERSION_MAJOR 0 #define DRFLAC_VERSION_MAJOR 0
#define DRFLAC_VERSION_MINOR 12 #define DRFLAC_VERSION_MINOR 12
#define DRFLAC_VERSION_REVISION 34 #define DRFLAC_VERSION_REVISION 35
#define DRFLAC_VERSION_STRING DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION) #define DRFLAC_VERSION_STRING DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
#include <stddef.h> #include <stddef.h>
typedef signed char drflac_int8; typedef signed char drflac_int8;
...@@ -65749,8 +65761,8 @@ DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetF ...@@ -65749,8 +65761,8 @@ DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetF
if (pWav->totalPCMFrameCount == 0) { if (pWav->totalPCMFrameCount == 0) {
return DRWAV_TRUE; return DRWAV_TRUE;
} }
if (targetFrameIndex >= pWav->totalPCMFrameCount) { if (targetFrameIndex > pWav->totalPCMFrameCount) {
targetFrameIndex = pWav->totalPCMFrameCount - 1; targetFrameIndex = pWav->totalPCMFrameCount;
} }
if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) { if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
if (targetFrameIndex < pWav->readCursorInPCMFrames) { if (targetFrameIndex < pWav->readCursorInPCMFrames) {
...@@ -68490,6 +68502,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned i ...@@ -68490,6 +68502,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned i
if (!drflac__reload_cache(bs)) { if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
if (bitCountLo > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
return DRFLAC_FALSE;
}
*pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo); *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
bs->consumedBits += bitCountLo; bs->consumedBits += bitCountLo;
bs->cache <<= bitCountLo; bs->cache <<= bitCountLo;
...@@ -68831,8 +68846,18 @@ static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, ...@@ -68831,8 +68846,18 @@ static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs,
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
} }
if (bs->cache == 1) {
*pOffsetOut = zeroCounter + (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs) - 1;
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
return DRFLAC_TRUE;
}
setBitOffsetPlus1 = drflac__clz(bs->cache); setBitOffsetPlus1 = drflac__clz(bs->cache);
setBitOffsetPlus1 += 1; setBitOffsetPlus1 += 1;
if (setBitOffsetPlus1 > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
return DRFLAC_FALSE;
}
bs->consumedBits += setBitOffsetPlus1; bs->consumedBits += setBitOffsetPlus1;
bs->cache <<= setBitOffsetPlus1; bs->cache <<= setBitOffsetPlus1;
*pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1; *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1;
...@@ -68918,6 +68943,24 @@ static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64 ...@@ -68918,6 +68943,24 @@ static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64
*pCRCOut = crc; *pCRCOut = crc;
return DRFLAC_SUCCESS; return DRFLAC_SUCCESS;
} }
static DRFLAC_INLINE drflac_uint32 drflac__ilog2_u32(drflac_uint32 x)
{
#if 1
drflac_uint32 result = 0;
while (x > 0) {
result += 1;
x >>= 1;
}
return result;
#endif
}
static DRFLAC_INLINE drflac_bool32 drflac__use_64_bit_prediction(drflac_uint32 bitsPerSample, drflac_uint32 order, drflac_uint32 precision)
{
return bitsPerSample + precision + drflac__ilog2_u32(order) > 32;
}
#if defined(__clang__)
__attribute__((no_sanitize("signed-integer-overflow")))
#endif
static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples) static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
{ {
drflac_int32 prediction = 0; drflac_int32 prediction = 0;
...@@ -69128,7 +69171,7 @@ static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 ...@@ -69128,7 +69171,7 @@ static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32
return (drflac_int32)(prediction >> shift); return (drflac_int32)(prediction >> shift);
} }
#if 0 #if 0
static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut) static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{ {
drflac_uint32 i; drflac_uint32 i;
DRFLAC_ASSERT(bs != NULL); DRFLAC_ASSERT(bs != NULL);
...@@ -69160,10 +69203,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drfla ...@@ -69160,10 +69203,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drfla
} else { } else {
decodedRice = (decodedRice >> 1); decodedRice = (decodedRice >> 1);
} }
if (bitsPerSample+shift >= 32) { if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i); pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
} else { } else {
pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i); pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
} }
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
...@@ -69242,6 +69285,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac ...@@ -69242,6 +69285,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac
if (!drflac__reload_cache(bs)) { if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
if (bitCountLo > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
return DRFLAC_FALSE;
}
} }
riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo)); riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
bs->consumedBits += bitCountLo; bs->consumedBits += bitCountLo;
...@@ -69289,6 +69335,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drf ...@@ -69289,6 +69335,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drf
if (!drflac__reload_cache(bs)) { if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
if (riceParamPartLoBitCount > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
return DRFLAC_FALSE;
}
bs_cache = bs->cache; bs_cache = bs->cache;
bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount; bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
} }
...@@ -69358,6 +69407,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac ...@@ -69358,6 +69407,9 @@ static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac
if (!drflac__reload_cache(bs)) { if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
if (riceParamPartLoBitCount > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
return DRFLAC_FALSE;
}
bs_cache = bs->cache; bs_cache = bs->cache;
bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount; bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
} }
...@@ -69419,7 +69471,7 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorde ...@@ -69419,7 +69471,7 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorde
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
} }
static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut) static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{ {
drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF}; drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
drflac_uint32 zeroCountPart0 = 0; drflac_uint32 zeroCountPart0 = 0;
...@@ -69435,12 +69487,12 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b ...@@ -69435,12 +69487,12 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
drflac_uint32 i; drflac_uint32 i;
DRFLAC_ASSERT(bs != NULL); DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(pSamplesOut != NULL); DRFLAC_ASSERT(pSamplesOut != NULL);
if (order == 0) { if (lpcOrder == 0) {
return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
} }
riceParamMask = (drflac_uint32)~((~0UL) << riceParam); riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
pSamplesOutEnd = pSamplesOut + (count & ~3); pSamplesOutEnd = pSamplesOut + (count & ~3);
if (bitsPerSample+shift > 32) { if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
while (pSamplesOut < pSamplesOutEnd) { while (pSamplesOut < pSamplesOutEnd) {
if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) || if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) || !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
...@@ -69460,10 +69512,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b ...@@ -69460,10 +69512,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01]; riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01]; riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01]; riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0); pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 1); pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 1);
pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 2); pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 2);
pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 3); pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 3);
pSamplesOut += 4; pSamplesOut += 4;
} }
} else { } else {
...@@ -69486,10 +69538,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b ...@@ -69486,10 +69538,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01]; riceParamPart1 = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01]; riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01]; riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0); pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 1); pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 1);
pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 2); pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 2);
pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 3); pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 3);
pSamplesOut += 4; pSamplesOut += 4;
} }
} }
...@@ -69501,10 +69553,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b ...@@ -69501,10 +69553,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
riceParamPart0 &= riceParamMask; riceParamPart0 &= riceParamMask;
riceParamPart0 |= (zeroCountPart0 << riceParam); riceParamPart0 |= (zeroCountPart0 << riceParam);
riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01]; riceParamPart0 = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
if (bitsPerSample+shift > 32) { if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0); pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
} else { } else {
pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0); pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
} }
i += 1; i += 1;
pSamplesOut += 1; pSamplesOut += 1;
...@@ -69849,18 +69901,18 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac ...@@ -69849,18 +69901,18 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
} }
static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut) static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{ {
DRFLAC_ASSERT(bs != NULL); DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(pSamplesOut != NULL); DRFLAC_ASSERT(pSamplesOut != NULL);
if (order > 0 && order <= 12) { if (lpcOrder > 0 && lpcOrder <= 12) {
if (bitsPerSample+shift > 32) { if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
} else { } else {
return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
} }
} else { } else {
return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
} }
} }
#endif #endif
...@@ -70199,37 +70251,37 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_ ...@@ -70199,37 +70251,37 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
} }
static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut) static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{ {
DRFLAC_ASSERT(bs != NULL); DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(pSamplesOut != NULL); DRFLAC_ASSERT(pSamplesOut != NULL);
if (order > 0 && order <= 12) { if (order > 0 && order <= 12) {
if (bitsPerSample+shift > 32) { if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
} else { } else {
return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
} }
} else { } else {
return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
} }
} }
#endif #endif
static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut) static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{ {
#if defined(DRFLAC_SUPPORT_SSE41) #if defined(DRFLAC_SUPPORT_SSE41)
if (drflac__gIsSSE41Supported) { if (drflac__gIsSSE41Supported) {
return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
} else } else
#elif defined(DRFLAC_SUPPORT_NEON) #elif defined(DRFLAC_SUPPORT_NEON)
if (drflac__gIsNEONSupported) { if (drflac__gIsNEONSupported) {
return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
} else } else
#endif #endif
{ {
#if 0 #if 0
return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
#else #else
return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut); return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
#endif #endif
} }
} }
...@@ -70244,7 +70296,10 @@ static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_ ...@@ -70244,7 +70296,10 @@ static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
} }
static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut) #if defined(__clang__)
__attribute__((no_sanitize("signed-integer-overflow")))
#endif
static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{ {
drflac_uint32 i; drflac_uint32 i;
DRFLAC_ASSERT(bs != NULL); DRFLAC_ASSERT(bs != NULL);
...@@ -70258,15 +70313,15 @@ static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* ...@@ -70258,15 +70313,15 @@ static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs*
} else { } else {
pSamplesOut[i] = 0; pSamplesOut[i] = 0;
} }
if (bitsPerSample >= 24) { if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
pSamplesOut[i] += drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i); pSamplesOut[i] += drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
} else { } else {
pSamplesOut[i] += drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i); pSamplesOut[i] += drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
} }
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
} }
static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples) static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
{ {
drflac_uint8 residualMethod; drflac_uint8 residualMethod;
drflac_uint8 partitionOrder; drflac_uint8 partitionOrder;
...@@ -70281,17 +70336,17 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_ ...@@ -70281,17 +70336,17 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) { if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
pDecodedSamples += order; pDecodedSamples += lpcOrder;
if (!drflac__read_uint8(bs, 4, &partitionOrder)) { if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
if (partitionOrder > 8) { if (partitionOrder > 8) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
if ((blockSize / (1 << partitionOrder)) < order) { if ((blockSize / (1 << partitionOrder)) < lpcOrder) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
samplesInPartition = (blockSize / (1 << partitionOrder)) - order; samplesInPartition = (blockSize / (1 << partitionOrder)) - lpcOrder;
partitionsRemaining = (1 << partitionOrder); partitionsRemaining = (1 << partitionOrder);
for (;;) { for (;;) {
drflac_uint8 riceParam = 0; drflac_uint8 riceParam = 0;
...@@ -70311,7 +70366,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_ ...@@ -70311,7 +70366,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
} }
} }
if (riceParam != 0xFF) { if (riceParam != 0xFF) {
if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, order, shift, coefficients, pDecodedSamples)) { if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
} else { } else {
...@@ -70319,7 +70374,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_ ...@@ -70319,7 +70374,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) { if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, order, shift, coefficients, pDecodedSamples)) { if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
} }
...@@ -70439,7 +70494,7 @@ static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32 ...@@ -70439,7 +70494,7 @@ static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32
} }
pDecodedSamples[i] = sample; pDecodedSamples[i] = sample;
} }
if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) { if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, 4, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
...@@ -70476,7 +70531,7 @@ static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 bl ...@@ -70476,7 +70531,7 @@ static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 bl
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
} }
if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, coefficients, pDecodedSamples)) { if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
return DRFLAC_TRUE; return DRFLAC_TRUE;
...@@ -70585,6 +70640,9 @@ static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_u ...@@ -70585,6 +70640,9 @@ static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_u
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16); crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
if (header->blockSizeInPCMFrames == 0xFFFF) {
return DRFLAC_FALSE;
}
header->blockSizeInPCMFrames += 1; header->blockSizeInPCMFrames += 1;
} else { } else {
DRFLAC_ASSERT(blockSize >= 8); DRFLAC_ASSERT(blockSize >= 8);
...@@ -70617,6 +70675,9 @@ static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_u ...@@ -70617,6 +70675,9 @@ static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_u
if (header->bitsPerSample == 0) { if (header->bitsPerSample == 0) {
header->bitsPerSample = streaminfoBitsPerSample; header->bitsPerSample = streaminfoBitsPerSample;
} }
if (header->bitsPerSample != streaminfoBitsPerSample) {
return DRFLAC_FALSE;
}
if (!drflac__read_uint8(bs, 8, &header->crc8)) { if (!drflac__read_uint8(bs, 8, &header->crc8)) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
...@@ -70687,6 +70748,9 @@ static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame, ...@@ -70687,6 +70748,9 @@ static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame,
} else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) { } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
subframeBitsPerSample += 1; subframeBitsPerSample += 1;
} }
if (subframeBitsPerSample > 32) {
return DRFLAC_FALSE;
}
if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) { if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
return DRFLAC_FALSE; return DRFLAC_FALSE;
} }
/* /*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.6 - 2022-01-22 miniaudio - v0.11.7 - 2022-02-06
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
...@@ -20,7 +20,7 @@ extern "C" { ...@@ -20,7 +20,7 @@ extern "C" {
#define MA_VERSION_MAJOR 0 #define MA_VERSION_MAJOR 0
#define MA_VERSION_MINOR 11 #define MA_VERSION_MINOR 11
#define MA_VERSION_REVISION 6 #define MA_VERSION_REVISION 7
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION) #define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
#if defined(_MSC_VER) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__)
...@@ -117,9 +117,9 @@ typedef ma_uint16 wchar_t; ...@@ -117,9 +117,9 @@ typedef ma_uint16 wchar_t;
/* Platform/backend detection. */ /* Platform/backend detection. */
#ifdef _WIN32 #ifdef _WIN32
#define MA_WIN32 #define MA_WIN32
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) #if defined(WINAPI_FAMILY) && ((defined(WINAPI_FAMILY_PC_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) || (defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP))
#define MA_WIN32_UWP #define MA_WIN32_UWP
#elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES) #elif defined(WINAPI_FAMILY) && (defined(WINAPI_FAMILY_GAMES) && WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
#define MA_WIN32_GDK #define MA_WIN32_GDK
#else #else
#define MA_WIN32_DESKTOP #define MA_WIN32_DESKTOP
......
/* /*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.7 - TBD miniaudio - v0.11.7 - 2022-02-06
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment