Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
911bc61d
Commit
911bc61d
authored
Dec 02, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update external decoders.
parent
c78a11be
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
63 deletions
+128
-63
extras/dr_flac.h
extras/dr_flac.h
+69
-41
extras/dr_mp3.h
extras/dr_mp3.h
+18
-5
extras/dr_wav.h
extras/dr_wav.h
+41
-17
No files found.
extras/dr_flac.h
View file @
911bc61d
This diff is collapsed.
Click to expand it.
extras/dr_mp3.h
View file @
911bc61d
/*
MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
dr_mp3 - v0.5.
1 - 2019-10-08
dr_mp3 - v0.5.
4 - 2019-12-02
David Reid - mackron@gmail.com
...
...
@@ -41,11 +41,11 @@ To use the new system, you pass in a pointer to a drmp3_allocation_callbacks obj
allocationCallbacks.onMalloc = my_malloc;
allocationCallbacks.onRealloc = my_realloc;
allocationCallbacks.onFree = my_free;
drmp3_init_file(&mp3, "my_file.
wav
", NULL, &allocationCallbacks);
drmp3_init_file(&mp3, "my_file.
mp3
", NULL, &allocationCallbacks);
The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
Passing in null for the allocation callbacks object will cause dr_
wav
to use defaults which is the same as DRMP3_MALLOC,
Passing in null for the allocation callbacks object will cause dr_
mp3
to use defaults which is the same as DRMP3_MALLOC,
DRMP3_REALLOC and DRMP3_FREE and the equivalent of how it worked in previous versions.
Every API that opens a drmp3 object now takes this extra parameter. These include the following:
...
...
@@ -619,6 +619,7 @@ end:
}
#elif defined(__ARM_NEON) || defined(__aarch64__)
#include <arm_neon.h>
#define DRMP3_HAVE_SSE 0
#define DRMP3_HAVE_SIMD 1
#define DRMP3_VSTORE vst1q_f32
#define DRMP3_VLD vld1q_f32
...
...
@@ -636,6 +637,7 @@ static int drmp3_have_simd()
return
1
;
}
#else
#define DRMP3_HAVE_SSE 0
#define DRMP3_HAVE_SIMD 0
#ifdef DR_MP3_ONLY_SIMD
#error DR_MP3_ONLY_SIMD used, but SSE/NEON not enabled
...
...
@@ -2421,8 +2423,10 @@ static void* drmp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld,
return
NULL
;
}
DRMP3_COPY_MEMORY
(
p2
,
p
,
szOld
);
pAllocationCallbacks
->
onFree
(
p
,
pAllocationCallbacks
->
pUserData
);
if
(
p
!=
NULL
)
{
DRMP3_COPY_MEMORY
(
p2
,
p
,
szOld
);
pAllocationCallbacks
->
onFree
(
p
,
pAllocationCallbacks
->
pUserData
);
}
return
p2
;
}
...
...
@@ -4005,6 +4009,15 @@ DIFFERENCES BETWEEN minimp3 AND dr_mp3
/*
REVISION HISTORY
================
v0.5.4 - 2019-12-02
- Fix a possible null pointer dereference when using custom memory allocators for realloc().
v0.5.3 - 2019-11-14
- Fix typos in documentation.
v0.5.2 - 2019-11-02
- Bring up to date with minimp3.
v0.5.1 - 2019-10-08
- Fix a warning with GCC.
...
...
extras/dr_wav.h
View file @
911bc61d
/*
WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
dr_wav - v0.11.
1 - 2019-10-07
dr_wav - v0.11.
2 - 2019-12-02
David Reid - mackron@gmail.com
*/
...
...
@@ -1076,6 +1076,20 @@ void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
#endif
#endif
/*
These limits are used for basic validation when initializing the decoder. If you exceed these limits, first of all: what on Earth are
you doing?! (Let me know, I'd be curious!) Second, you can adjust these by #define-ing them before the dr_wav implementation.
*/
#ifndef DRWAV_MAX_SAMPLE_RATE
#define DRWAV_MAX_SAMPLE_RATE 384000
#endif
#ifndef DRWAV_MAX_CHANNELS
#define DRWAV_MAX_CHANNELS 256
#endif
#ifndef DRWAV_MAX_BITS_PER_SAMPLE
#define DRWAV_MAX_BITS_PER_SAMPLE 64
#endif
static
const
drwav_uint8
drwavGUID_W64_RIFF
[
16
]
=
{
0x72
,
0x69
,
0x66
,
0x66
,
0x2E
,
0x91
,
0xCF
,
0x11
,
0xA5
,
0xD6
,
0x28
,
0xDB
,
0x04
,
0xC1
,
0x00
,
0x00
};
/* 66666972-912E-11CF-A5D6-28DB04C10000 */
static
const
drwav_uint8
drwavGUID_W64_WAVE
[
16
]
=
{
0x77
,
0x61
,
0x76
,
0x65
,
0xF3
,
0xAC
,
0xD3
,
0x11
,
0x8C
,
0xD1
,
0x00
,
0xC0
,
0x4F
,
0x8E
,
0xDB
,
0x8A
};
/* 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
static
const
drwav_uint8
drwavGUID_W64_JUNK
[
16
]
=
{
0x6A
,
0x75
,
0x6E
,
0x6B
,
0xF3
,
0xAC
,
0xD3
,
0x11
,
0x8C
,
0xD1
,
0x00
,
0xC0
,
0x4F
,
0x8E
,
0xDB
,
0x8A
};
/* 6B6E756A-ACF3-11D3-8CD1-00C04F8EDB8A */
...
...
@@ -1446,8 +1460,10 @@ static void* drwav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld,
return
NULL
;
}
DRWAV_COPY_MEMORY
(
p2
,
p
,
szOld
);
pAllocationCallbacks
->
onFree
(
p
,
pAllocationCallbacks
->
pUserData
);
if
(
p
!=
NULL
)
{
DRWAV_COPY_MEMORY
(
p2
,
p
,
szOld
);
pAllocationCallbacks
->
onFree
(
p
,
pAllocationCallbacks
->
pUserData
);
}
return
p2
;
}
...
...
@@ -1862,8 +1878,11 @@ drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc onChunk, void* p
}
/* Basic validation. */
if
(
fmt
.
sampleRate
==
0
||
fmt
.
channels
==
0
||
fmt
.
bitsPerSample
==
0
||
fmt
.
blockAlign
==
0
)
{
return
DRWAV_FALSE
;
/* Invalid channel count. Probably an invalid WAV file. */
if
((
fmt
.
sampleRate
==
0
||
fmt
.
sampleRate
>
DRWAV_MAX_SAMPLE_RATE
)
||
(
fmt
.
channels
==
0
||
fmt
.
channels
>
DRWAV_MAX_CHANNELS
)
||
(
fmt
.
bitsPerSample
==
0
||
fmt
.
bitsPerSample
>
DRWAV_MAX_BITS_PER_SAMPLE
)
||
fmt
.
blockAlign
==
0
)
{
return
DRWAV_FALSE
;
/* Probably an invalid WAV file. */
}
...
...
@@ -2926,11 +2945,12 @@ drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex)
{
/* Seeking should be compatible with wave files > 2GB. */
if
(
pWav
->
onWrite
!
=
NULL
)
{
return
DRWAV_FALSE
;
/* No seeking in write mode. */
if
(
pWav
==
NULL
||
pWav
->
onSeek
=
=
NULL
)
{
return
DRWAV_FALSE
;
}
if
(
pWav
==
NULL
||
pWav
->
onSeek
==
NULL
)
{
/* No seeking in write mode. */
if
(
pWav
->
onWrite
!=
NULL
)
{
return
DRWAV_FALSE
;
}
...
...
@@ -3060,10 +3080,10 @@ drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite,
while
(
bytesToWrite
>
0
)
{
size_t
bytesJustWritten
;
drwav_uint64
bytesToWriteThisIteration
=
bytesToWrite
;
if
(
bytesToWriteThisIteration
>
DRWAV_SIZE_MAX
)
{
bytesToWriteThisIteration
=
DRWAV_SIZE_MAX
;
}
drwav_uint64
bytesToWriteThisIteration
;
bytesToWriteThisIteration
=
bytesToWrite
;
DRWAV_ASSERT
(
bytesToWriteThisIteration
<=
DRWAV_SIZE_MAX
);
/* <-- This is checked above. */
bytesJustWritten
=
drwav_write_raw
(
pWav
,
(
size_t
)
bytesToWriteThisIteration
,
pRunningData
);
if
(
bytesJustWritten
==
0
)
{
...
...
@@ -3106,9 +3126,7 @@ drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite,
drwav_uint64
bytesToWriteThisIteration
;
bytesToWriteThisIteration
=
bytesToWrite
;
if
(
bytesToWriteThisIteration
>
DRWAV_SIZE_MAX
)
{
bytesToWriteThisIteration
=
DRWAV_SIZE_MAX
;
}
DRWAV_ASSERT
(
bytesToWriteThisIteration
<=
DRWAV_SIZE_MAX
);
/* <-- This is checked above. */
/*
WAV files are always little-endian. We need to byte swap on big-endian architectures. Since our input buffer is read-only we need
...
...
@@ -3116,8 +3134,8 @@ drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite,
*/
sampleCount
=
sizeof
(
temp
)
/
bytesPerSample
;
if
(
bytesToWriteThisIteration
>
sampleCount
*
bytesPerSample
)
{
bytesToWriteThisIteration
=
sampleCount
*
bytesPerSample
;
if
(
bytesToWriteThisIteration
>
((
drwav_uint64
)
sampleCount
)
*
bytesPerSample
)
{
bytesToWriteThisIteration
=
((
drwav_uint64
)
sampleCount
)
*
bytesPerSample
;
}
DRWAV_COPY_MEMORY
(
temp
,
pRunningData
,
(
size_t
)
bytesToWriteThisIteration
);
...
...
@@ -5033,6 +5051,12 @@ void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
/*
REVISION HISTORY
================
v0.11.2 - 2019-12-02
- Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
- Fix an integer overflow bug.
- Fix a null pointer dereference bug.
- Add limits to sample rate, channels and bits per sample to tighten up some validation.
v0.11.1 - 2019-10-07
- Internal code clean up.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment