mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
Update dr_flac.
This commit is contained in:
+60
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||
dr_flac - v0.12.28 - 2021-02-21
|
||||
dr_flac - v0.12.29 - 2021-04-02
|
||||
|
||||
David Reid - mackron@gmail.com
|
||||
|
||||
@@ -232,7 +232,7 @@ extern "C" {
|
||||
|
||||
#define DRFLAC_VERSION_MAJOR 0
|
||||
#define DRFLAC_VERSION_MINOR 12
|
||||
#define DRFLAC_VERSION_REVISION 28
|
||||
#define DRFLAC_VERSION_REVISION 29
|
||||
#define DRFLAC_VERSION_STRING DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
|
||||
|
||||
#include <stddef.h> /* For size_t. */
|
||||
@@ -1577,6 +1577,27 @@ static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
|
||||
#if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
||||
#define DRFLAC_HAS_BYTESWAP16_INTRINSIC
|
||||
#endif
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
#define DRFLAC_HAS_BYTESWAP16_INTRINSIC
|
||||
#define DRFLAC_HAS_BYTESWAP32_INTRINSIC
|
||||
#define DRFLAC_HAS_BYTESWAP64_INTRINSIC
|
||||
extern __inline drflac_uint16 _watcom_bswap16(drflac_uint16);
|
||||
extern __inline drflac_uint32 _watcom_bswap32(drflac_uint32);
|
||||
extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
|
||||
#pragma aux _watcom_bswap16 = \
|
||||
"xchg al, ah" \
|
||||
parm [ax] \
|
||||
modify [ax];
|
||||
#pragma aux _watcom_bswap32 = \
|
||||
"bswap eax" \
|
||||
parm [eax] \
|
||||
modify [eax];
|
||||
#pragma aux _watcom_bswap64 = \
|
||||
"bswap eax" \
|
||||
"bswap edx" \
|
||||
"xchg eax,edx" \
|
||||
parm [eax edx] \
|
||||
modify [eax edx];
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1800,6 +1821,8 @@ static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
|
||||
return _byteswap_ushort(n);
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_bswap16(n);
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
return _watcom_bswap16(n);
|
||||
#else
|
||||
#error "This compiler does not support the byte swap intrinsic."
|
||||
#endif
|
||||
@@ -1829,6 +1852,8 @@ static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
|
||||
#else
|
||||
return __builtin_bswap32(n);
|
||||
#endif
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
return _watcom_bswap32(n);
|
||||
#else
|
||||
#error "This compiler does not support the byte swap intrinsic."
|
||||
#endif
|
||||
@@ -1847,6 +1872,8 @@ static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
|
||||
return _byteswap_uint64(n);
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_bswap64(n);
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
return _watcom_bswap64(n);
|
||||
#else
|
||||
#error "This compiler does not support the byte swap intrinsic."
|
||||
#endif
|
||||
@@ -2654,6 +2681,9 @@ static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(__clang__)
|
||||
#define DRFLAC_IMPLEMENT_CLZ_MSVC
|
||||
#endif
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
#define DRFLAC_IMPLEMENT_CLZ_WATCOM
|
||||
#endif
|
||||
|
||||
static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
|
||||
{
|
||||
@@ -2801,6 +2831,16 @@ static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
|
||||
static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
|
||||
#pragma aux drflac__clz_watcom = \
|
||||
"bsr eax, eax" \
|
||||
"xor eax, 31" \
|
||||
parm [eax] nomemory \
|
||||
value [eax] \
|
||||
modify exact [eax] nomemory;
|
||||
#endif
|
||||
|
||||
static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
|
||||
{
|
||||
#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
|
||||
@@ -2811,6 +2851,8 @@ static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
|
||||
{
|
||||
#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
|
||||
return drflac__clz_msvc(x);
|
||||
#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
|
||||
return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
|
||||
#else
|
||||
return drflac__clz_software(x);
|
||||
#endif
|
||||
@@ -3194,7 +3236,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drfla
|
||||
drflac_uint32 i;
|
||||
|
||||
DRFLAC_ASSERT(bs != NULL);
|
||||
DRFLAC_ASSERT(count > 0);
|
||||
DRFLAC_ASSERT(pSamplesOut != NULL);
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
@@ -3576,7 +3617,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorde
|
||||
drflac_uint32 i;
|
||||
|
||||
DRFLAC_ASSERT(bs != NULL);
|
||||
DRFLAC_ASSERT(count > 0);
|
||||
DRFLAC_ASSERT(pSamplesOut != NULL);
|
||||
|
||||
(void)bitsPerSample;
|
||||
@@ -3622,7 +3662,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
|
||||
drflac_uint32 i;
|
||||
|
||||
DRFLAC_ASSERT(bs != NULL);
|
||||
DRFLAC_ASSERT(count > 0);
|
||||
DRFLAC_ASSERT(pSamplesOut != NULL);
|
||||
|
||||
if (order == 0) {
|
||||
@@ -4176,7 +4215,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac
|
||||
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)
|
||||
{
|
||||
DRFLAC_ASSERT(bs != NULL);
|
||||
DRFLAC_ASSERT(count > 0);
|
||||
DRFLAC_ASSERT(pSamplesOut != NULL);
|
||||
|
||||
/* In my testing the order is rarely > 12, so in this case I'm going to simplify the SSE implementation by only handling order <= 12. */
|
||||
@@ -4675,7 +4713,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
|
||||
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)
|
||||
{
|
||||
DRFLAC_ASSERT(bs != NULL);
|
||||
DRFLAC_ASSERT(count > 0);
|
||||
DRFLAC_ASSERT(pSamplesOut != NULL);
|
||||
|
||||
/* In my testing the order is rarely > 12, so in this case I'm going to simplify the NEON implementation by only handling order <= 12. */
|
||||
@@ -4718,7 +4755,6 @@ static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_
|
||||
drflac_uint32 i;
|
||||
|
||||
DRFLAC_ASSERT(bs != NULL);
|
||||
DRFLAC_ASSERT(count > 0);
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (!drflac__seek_rice_parts(bs, riceParam)) {
|
||||
@@ -4734,7 +4770,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs*
|
||||
drflac_uint32 i;
|
||||
|
||||
DRFLAC_ASSERT(bs != NULL);
|
||||
DRFLAC_ASSERT(count > 0);
|
||||
DRFLAC_ASSERT(unencodedBitsPerSample <= 31); /* <-- unencodedBitsPerSample is a 5 bit number, so cannot exceed 31. */
|
||||
DRFLAC_ASSERT(pSamplesOut != NULL);
|
||||
|
||||
@@ -4798,7 +4833,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
|
||||
}
|
||||
|
||||
/* Validation check. */
|
||||
if ((blockSize / (1 << partitionOrder)) <= order) {
|
||||
if ((blockSize / (1 << partitionOrder)) < order) {
|
||||
return DRFLAC_FALSE;
|
||||
}
|
||||
|
||||
@@ -11348,6 +11383,7 @@ DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 p
|
||||
return drflac__seek_to_first_frame(pFlac);
|
||||
} else {
|
||||
drflac_bool32 wasSuccessful = DRFLAC_FALSE;
|
||||
drflac_uint64 originalPCMFrame = pFlac->currentPCMFrame;
|
||||
|
||||
/* Clamp the sample to the end. */
|
||||
if (pcmFrameIndex > pFlac->totalPCMFrameCount) {
|
||||
@@ -11405,7 +11441,16 @@ DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 p
|
||||
}
|
||||
}
|
||||
|
||||
pFlac->currentPCMFrame = pcmFrameIndex;
|
||||
if (wasSuccessful) {
|
||||
pFlac->currentPCMFrame = pcmFrameIndex;
|
||||
} else {
|
||||
/* Seek failed. Try putting the decoder back to it's original state. */
|
||||
if (drflac_seek_to_pcm_frame(pFlac, originalPCMFrame) == DRFLAC_FALSE) {
|
||||
/* Failed to seek back to the original PCM frame. Fall back to 0. */
|
||||
drflac_seek_to_pcm_frame(pFlac, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return wasSuccessful;
|
||||
}
|
||||
}
|
||||
@@ -11806,6 +11851,10 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
|
||||
/*
|
||||
REVISION HISTORY
|
||||
================
|
||||
v0.12.29 - 2021-04-02
|
||||
- Fix a bug where the running PCM frame index is set to an invalid value when over-seeking.
|
||||
- Fix a decoding error due to an incorrect validation check.
|
||||
|
||||
v0.12.28 - 2021-02-21
|
||||
- Fix a warning due to referencing _MSC_VER when it is undefined.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user