mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Update external libraries
This commit is contained in:
124
src/external/dr_flac.h
vendored
124
src/external/dr_flac.h
vendored
@ -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.22 - 2020-11-01
|
||||
dr_flac - v0.12.29 - 2021-04-02
|
||||
|
||||
David Reid - mackron@gmail.com
|
||||
|
||||
@ -166,7 +166,7 @@ If you just want to quickly decode an entire FLAC file in one go you can do some
|
||||
|
||||
...
|
||||
|
||||
drflac_free(pSampleData);
|
||||
drflac_free(pSampleData, NULL);
|
||||
```
|
||||
|
||||
You can read samples as signed 16-bit integer and 32-bit floating-point PCM with the *_s16() and *_f32() family of APIs respectively, but note that these
|
||||
@ -232,7 +232,7 @@ extern "C" {
|
||||
|
||||
#define DRFLAC_VERSION_MAJOR 0
|
||||
#define DRFLAC_VERSION_MINOR 12
|
||||
#define DRFLAC_VERSION_REVISION 22
|
||||
#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. */
|
||||
@ -408,7 +408,10 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* The metadata type. Use this to know how to interpret the data below. */
|
||||
/*
|
||||
The metadata type. Use this to know how to interpret the data below. Will be set to one of the
|
||||
DRFLAC_METADATA_BLOCK_TYPE_* tokens.
|
||||
*/
|
||||
drflac_uint32 type;
|
||||
|
||||
/*
|
||||
@ -552,7 +555,8 @@ pMetadata (in)
|
||||
|
||||
Remarks
|
||||
-------
|
||||
Use pMetadata->type to determine which metadata block is being handled and how to read the data.
|
||||
Use pMetadata->type to determine which metadata block is being handled and how to read the data. This
|
||||
will be set to one of the DRFLAC_METADATA_BLOCK_TYPE_* tokens.
|
||||
*/
|
||||
typedef void (* drflac_meta_proc)(void* pUserData, drflac_metadata* pMetadata);
|
||||
|
||||
@ -797,6 +801,8 @@ from a block of memory respectively.
|
||||
|
||||
The STREAMINFO block must be present for this to succeed. Use `drflac_open_relaxed()` to open a FLAC stream where the header may not be present.
|
||||
|
||||
Use `drflac_open_with_metadata()` if you need access to metadata.
|
||||
|
||||
|
||||
Seek Also
|
||||
---------
|
||||
@ -843,6 +849,8 @@ as that is for internal use only.
|
||||
|
||||
Opening in relaxed mode will continue reading data from onRead until it finds a valid frame. If a frame is never found it will continue forever. To abort,
|
||||
force your `onRead` callback to return 0, which dr_flac will use as an indicator that the end of the stream was found.
|
||||
|
||||
Use `drflac_open_with_metadata_relaxed()` if you need access to metadata.
|
||||
*/
|
||||
DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
|
||||
|
||||
@ -882,7 +890,9 @@ Close the decoder with `drflac_close()`.
|
||||
This is slower than `drflac_open()`, so avoid this one if you don't need metadata. Internally, this will allocate and free memory on the heap for every
|
||||
metadata block except for STREAMINFO and PADDING blocks.
|
||||
|
||||
The caller is notified of the metadata via the `onMeta` callback. All metadata blocks will be handled before the function returns.
|
||||
The caller is notified of the metadata via the `onMeta` callback. All metadata blocks will be handled before the function returns. This callback takes a
|
||||
pointer to a `drflac_metadata` object which is a union containing the data of all relevant metadata blocks. Use the `type` member to discriminate against
|
||||
the different metadata types.
|
||||
|
||||
The STREAMINFO block must be present for this to succeed. Use `drflac_open_with_metadata_relaxed()` to open a FLAC stream where the header may not be present.
|
||||
|
||||
@ -1330,6 +1340,9 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
|
||||
#ifndef _BSD_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#endif
|
||||
#ifndef _DEFAULT_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#endif
|
||||
#ifndef __USE_BSD
|
||||
#define __USE_BSD
|
||||
#endif
|
||||
@ -1354,6 +1367,8 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
|
||||
#else
|
||||
#define DRFLAC_INLINE inline __attribute__((always_inline))
|
||||
#endif
|
||||
#elif defined(__WATCOMC__)
|
||||
#define DRFLAC_INLINE __inline
|
||||
#else
|
||||
#define DRFLAC_INLINE
|
||||
#endif
|
||||
@ -1363,7 +1378,7 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
|
||||
#define DRFLAC_X64
|
||||
#elif defined(__i386) || defined(_M_IX86)
|
||||
#define DRFLAC_X86
|
||||
#elif defined(__arm__) || defined(_M_ARM)
|
||||
#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
|
||||
#define DRFLAC_ARM
|
||||
#endif
|
||||
|
||||
@ -1562,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
|
||||
|
||||
|
||||
@ -1785,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
|
||||
@ -1814,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
|
||||
@ -1832,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
|
||||
@ -2639,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)
|
||||
{
|
||||
@ -2786,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
|
||||
@ -2796,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
|
||||
@ -3179,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) {
|
||||
@ -3561,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;
|
||||
@ -3607,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) {
|
||||
@ -4161,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. */
|
||||
@ -4660,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. */
|
||||
@ -4703,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)) {
|
||||
@ -4719,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);
|
||||
|
||||
@ -4783,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;
|
||||
}
|
||||
|
||||
@ -5155,7 +5205,8 @@ static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_u
|
||||
DRFLAC_ASSERT(blockSize > 0);
|
||||
if (blockSize == 1) {
|
||||
header->blockSizeInPCMFrames = 192;
|
||||
} else if (blockSize >= 2 && blockSize <= 5) {
|
||||
} else if (blockSize <= 5) {
|
||||
DRFLAC_ASSERT(blockSize >= 2);
|
||||
header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2));
|
||||
} else if (blockSize == 6) {
|
||||
if (!drflac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) {
|
||||
@ -8309,7 +8360,7 @@ static drflac_result drflac_result_from_errno(int e)
|
||||
|
||||
static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
|
||||
{
|
||||
#if _MSC_VER && _MSC_VER >= 1400
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
errno_t err;
|
||||
#endif
|
||||
|
||||
@ -8321,7 +8372,7 @@ static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const ch
|
||||
return DRFLAC_INVALID_ARGS;
|
||||
}
|
||||
|
||||
#if _MSC_VER && _MSC_VER >= 1400
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
err = fopen_s(ppFile, pFilePath, pOpenMode);
|
||||
if (err != 0) {
|
||||
return drflac_result_from_errno(err);
|
||||
@ -8356,12 +8407,13 @@ _wfopen() isn't always available in all compilation environments.
|
||||
* MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
|
||||
* MinGW-64 (both 32- and 64-bit) seems to support it.
|
||||
* MinGW wraps it in !defined(__STRICT_ANSI__).
|
||||
* OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
|
||||
|
||||
This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
|
||||
fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
#if defined(_MSC_VER) || defined(__MINGW64__) || !defined(__STRICT_ANSI__)
|
||||
#if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
|
||||
#define DRFLAC_HAS_WFOPEN
|
||||
#endif
|
||||
#endif
|
||||
@ -11331,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) {
|
||||
@ -11388,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;
|
||||
}
|
||||
}
|
||||
@ -11789,6 +11851,28 @@ 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.
|
||||
|
||||
v0.12.27 - 2021-01-31
|
||||
- Fix a static analysis warning.
|
||||
|
||||
v0.12.26 - 2021-01-17
|
||||
- Fix a compilation warning due to _BSD_SOURCE being deprecated.
|
||||
|
||||
v0.12.25 - 2020-12-26
|
||||
- Update documentation.
|
||||
|
||||
v0.12.24 - 2020-11-29
|
||||
- Fix ARM64/NEON detection when compiling with MSVC.
|
||||
|
||||
v0.12.23 - 2020-11-21
|
||||
- Fix compilation with OpenWatcom.
|
||||
|
||||
v0.12.22 - 2020-11-01
|
||||
- Fix an error with the previous release.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user