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
3d867739
Commit
3d867739
authored
Apr 05, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dr_flac and dr_mp3.
parent
42653967
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
23 deletions
+41
-23
extras/dr_flac.h
extras/dr_flac.h
+17
-16
extras/dr_mp3.h
extras/dr_mp3.h
+24
-7
No files found.
extras/dr_flac.h
View file @
3d867739
/*
/*
FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
dr_flac - v0.12.
8 - 2020-04-04
dr_flac - v0.12.
9 - 2020-04-05
David Reid - mackron@gmail.com
David Reid - mackron@gmail.com
...
@@ -1678,10 +1678,9 @@ DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps()
...
@@ -1678,10 +1678,9 @@ DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps()
static
drflac_bool32
isCPUCapsInitialized
=
DRFLAC_FALSE
;
static
drflac_bool32
isCPUCapsInitialized
=
DRFLAC_FALSE
;
if
(
!
isCPUCapsInitialized
)
{
if
(
!
isCPUCapsInitialized
)
{
int
info
[
4
]
=
{
0
};
/* LZCNT */
/* LZCNT */
#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
int
info
[
4
]
=
{
0
};
drflac__cpuid
(
info
,
0x80000001
);
drflac__cpuid
(
info
,
0x80000001
);
drflac__gIsLZCNTSupported
=
(
info
[
2
]
&
(
1
<<
5
))
!=
0
;
drflac__gIsLZCNTSupported
=
(
info
[
2
]
&
(
1
<<
5
))
!=
0
;
#endif
#endif
...
@@ -1962,7 +1961,7 @@ static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 da
...
@@ -1962,7 +1961,7 @@ static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 da
case
3
:
crc
=
drflac_crc8_byte
(
crc
,
(
drflac_uint8
)((
data
&
(
0x00FF0000UL
<<
leftoverBits
))
>>
(
16
+
leftoverBits
)));
case
3
:
crc
=
drflac_crc8_byte
(
crc
,
(
drflac_uint8
)((
data
&
(
0x00FF0000UL
<<
leftoverBits
))
>>
(
16
+
leftoverBits
)));
case
2
:
crc
=
drflac_crc8_byte
(
crc
,
(
drflac_uint8
)((
data
&
(
0x0000FF00UL
<<
leftoverBits
))
>>
(
8
+
leftoverBits
)));
case
2
:
crc
=
drflac_crc8_byte
(
crc
,
(
drflac_uint8
)((
data
&
(
0x0000FF00UL
<<
leftoverBits
))
>>
(
8
+
leftoverBits
)));
case
1
:
crc
=
drflac_crc8_byte
(
crc
,
(
drflac_uint8
)((
data
&
(
0x000000FFUL
<<
leftoverBits
))
>>
(
0
+
leftoverBits
)));
case
1
:
crc
=
drflac_crc8_byte
(
crc
,
(
drflac_uint8
)((
data
&
(
0x000000FFUL
<<
leftoverBits
))
>>
(
0
+
leftoverBits
)));
case
0
:
if
(
leftoverBits
>
0
)
crc
=
(
crc
<<
leftoverBits
)
^
drflac__crc8_table
[(
crc
>>
(
8
-
leftoverBits
))
^
(
data
&
leftoverDataMask
)]
;
case
0
:
if
(
leftoverBits
>
0
)
crc
=
(
drflac_uint8
)((
crc
<<
leftoverBits
)
^
drflac__crc8_table
[(
crc
>>
(
8
-
leftoverBits
))
^
(
data
&
leftoverDataMask
)])
;
}
}
return
crc
;
return
crc
;
#endif
#endif
...
@@ -5159,10 +5158,10 @@ static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe
...
@@ -5159,10 +5158,10 @@ static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe
}
else
{
}
else
{
if
((
type
&
0x20
)
!=
0
)
{
if
((
type
&
0x20
)
!=
0
)
{
pSubframe
->
subframeType
=
DRFLAC_SUBFRAME_LPC
;
pSubframe
->
subframeType
=
DRFLAC_SUBFRAME_LPC
;
pSubframe
->
lpcOrder
=
(
type
&
0x1F
)
+
1
;
pSubframe
->
lpcOrder
=
(
drflac_uint8
)(
type
&
0x1F
)
+
1
;
}
else
if
((
type
&
0x08
)
!=
0
)
{
}
else
if
((
type
&
0x08
)
!=
0
)
{
pSubframe
->
subframeType
=
DRFLAC_SUBFRAME_FIXED
;
pSubframe
->
subframeType
=
DRFLAC_SUBFRAME_FIXED
;
pSubframe
->
lpcOrder
=
(
type
&
0x07
);
pSubframe
->
lpcOrder
=
(
drflac_uint8
)(
type
&
0x07
);
if
(
pSubframe
->
lpcOrder
>
4
)
{
if
(
pSubframe
->
lpcOrder
>
4
)
{
pSubframe
->
subframeType
=
DRFLAC_SUBFRAME_RESERVED
;
pSubframe
->
subframeType
=
DRFLAC_SUBFRAME_RESERVED
;
pSubframe
->
lpcOrder
=
0
;
pSubframe
->
lpcOrder
=
0
;
...
@@ -5377,7 +5376,7 @@ static drflac_result drflac__decode_flac_frame(drflac* pFlac)
...
@@ -5377,7 +5376,7 @@ static drflac_result drflac__decode_flac_frame(drflac* pFlac)
}
}
}
}
paddingSizeInBits
=
DRFLAC_CACHE_L1_BITS_REMAINING
(
&
pFlac
->
bs
)
&
7
;
paddingSizeInBits
=
(
drflac_uint8
)(
DRFLAC_CACHE_L1_BITS_REMAINING
(
&
pFlac
->
bs
)
&
7
)
;
if
(
paddingSizeInBits
>
0
)
{
if
(
paddingSizeInBits
>
0
)
{
drflac_uint8
padding
=
0
;
drflac_uint8
padding
=
0
;
if
(
!
drflac__read_uint8
(
&
pFlac
->
bs
,
paddingSizeInBits
,
&
padding
))
{
if
(
!
drflac__read_uint8
(
&
pFlac
->
bs
,
paddingSizeInBits
,
&
padding
))
{
...
@@ -6055,9 +6054,9 @@ typedef struct
...
@@ -6055,9 +6054,9 @@ typedef struct
static
DRFLAC_INLINE
void
drflac__decode_block_header
(
drflac_uint32
blockHeader
,
drflac_uint8
*
isLastBlock
,
drflac_uint8
*
blockType
,
drflac_uint32
*
blockSize
)
static
DRFLAC_INLINE
void
drflac__decode_block_header
(
drflac_uint32
blockHeader
,
drflac_uint8
*
isLastBlock
,
drflac_uint8
*
blockType
,
drflac_uint32
*
blockSize
)
{
{
blockHeader
=
drflac__be2host_32
(
blockHeader
);
blockHeader
=
drflac__be2host_32
(
blockHeader
);
*
isLastBlock
=
(
blockHeader
&
0x80000000UL
)
>>
31
;
*
isLastBlock
=
(
drflac_uint8
)((
blockHeader
&
0x80000000UL
)
>>
31
)
;
*
blockType
=
(
blockHeader
&
0x7F000000UL
)
>>
24
;
*
blockType
=
(
drflac_uint8
)((
blockHeader
&
0x7F000000UL
)
>>
24
)
;
*
blockSize
=
(
blockHeader
&
0x00FFFFFFUL
);
*
blockSize
=
(
blockHeader
&
0x00FFFFFFUL
);
}
}
static
DRFLAC_INLINE
drflac_bool32
drflac__read_and_decode_block_header
(
drflac_read_proc
onRead
,
void
*
pUserData
,
drflac_uint8
*
isLastBlock
,
drflac_uint8
*
blockType
,
drflac_uint32
*
blockSize
)
static
DRFLAC_INLINE
drflac_bool32
drflac__read_and_decode_block_header
(
drflac_read_proc
onRead
,
void
*
pUserData
,
drflac_uint8
*
isLastBlock
,
drflac_uint8
*
blockType
,
drflac_uint32
*
blockSize
)
...
@@ -6104,8 +6103,8 @@ static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUse
...
@@ -6104,8 +6103,8 @@ static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUse
frameSizes
=
drflac__be2host_64
(
frameSizes
);
frameSizes
=
drflac__be2host_64
(
frameSizes
);
importantProps
=
drflac__be2host_64
(
importantProps
);
importantProps
=
drflac__be2host_64
(
importantProps
);
pStreamInfo
->
minBlockSizeInPCMFrames
=
(
blockSizes
&
0xFFFF0000
)
>>
16
;
pStreamInfo
->
minBlockSizeInPCMFrames
=
(
drflac_uint16
)((
blockSizes
&
0xFFFF0000
)
>>
16
)
;
pStreamInfo
->
maxBlockSizeInPCMFrames
=
(
blockSizes
&
0x0000FFFF
);
pStreamInfo
->
maxBlockSizeInPCMFrames
=
(
drflac_uint16
)
(
blockSizes
&
0x0000FFFF
);
pStreamInfo
->
minFrameSizeInPCMFrames
=
(
drflac_uint32
)((
frameSizes
&
(((
drflac_uint64
)
0x00FFFFFF
<<
16
)
<<
24
))
>>
40
);
pStreamInfo
->
minFrameSizeInPCMFrames
=
(
drflac_uint32
)((
frameSizes
&
(((
drflac_uint64
)
0x00FFFFFF
<<
16
)
<<
24
))
>>
40
);
pStreamInfo
->
maxFrameSizeInPCMFrames
=
(
drflac_uint32
)((
frameSizes
&
(((
drflac_uint64
)
0x00FFFFFF
<<
16
)
<<
0
))
>>
16
);
pStreamInfo
->
maxFrameSizeInPCMFrames
=
(
drflac_uint32
)((
frameSizes
&
(((
drflac_uint64
)
0x00FFFFFF
<<
16
)
<<
0
))
>>
16
);
pStreamInfo
->
sampleRate
=
(
drflac_uint32
)((
importantProps
&
(((
drflac_uint64
)
0x000FFFFF
<<
16
)
<<
28
))
>>
44
);
pStreamInfo
->
sampleRate
=
(
drflac_uint32
)((
importantProps
&
(((
drflac_uint64
)
0x000FFFFF
<<
16
)
<<
28
))
>>
44
);
...
@@ -7763,8 +7762,7 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
...
@@ -7763,8 +7762,7 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
*/
*/
if
(
!
init
.
hasStreamInfoBlock
)
{
if
(
!
init
.
hasStreamInfoBlock
)
{
pFlac
->
currentFLACFrame
.
header
=
init
.
firstFrameHeader
;
pFlac
->
currentFLACFrame
.
header
=
init
.
firstFrameHeader
;
do
for
(;;)
{
{
drflac_result
result
=
drflac__decode_flac_frame
(
pFlac
);
drflac_result
result
=
drflac__decode_flac_frame
(
pFlac
);
if
(
result
==
DRFLAC_SUCCESS
)
{
if
(
result
==
DRFLAC_SUCCESS
)
{
break
;
break
;
...
@@ -7780,7 +7778,7 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
...
@@ -7780,7 +7778,7 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
return
NULL
;
return
NULL
;
}
}
}
}
}
while
(
1
);
}
}
}
return
pFlac
;
return
pFlac
;
...
@@ -11694,8 +11692,11 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
...
@@ -11694,8 +11692,11 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
/*
/*
REVISION HISTORY
REVISION HISTORY
================
================
v0.12.9 - 2020-04-05
- Fix warnings.
v0.12.8 - 2020-04-04
v0.12.8 - 2020-04-04
- Add drflac_open_file_w() drflac_open_file_with_metadata_w().
- Add drflac_open_file_w()
and
drflac_open_file_with_metadata_w().
- Fix some static analysis warnings.
- Fix some static analysis warnings.
- Minor documentation updates.
- Minor documentation updates.
...
...
extras/dr_mp3.h
View file @
3d867739
/*
/*
MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
dr_mp3 - v0.6.
0 - 2020-04-04
dr_mp3 - v0.6.
1 - 2020-04-05
David Reid - mackron@gmail.com
David Reid - mackron@gmail.com
...
@@ -485,6 +485,11 @@ DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, d
...
@@ -485,6 +485,11 @@ DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, d
DRMP3_API
drmp3_int16
*
drmp3_open_file_and_read_pcm_frames_s16
(
const
char
*
filePath
,
drmp3_config
*
pConfig
,
drmp3_uint64
*
pTotalFrameCount
,
const
drmp3_allocation_callbacks
*
pAllocationCallbacks
);
DRMP3_API
drmp3_int16
*
drmp3_open_file_and_read_pcm_frames_s16
(
const
char
*
filePath
,
drmp3_config
*
pConfig
,
drmp3_uint64
*
pTotalFrameCount
,
const
drmp3_allocation_callbacks
*
pAllocationCallbacks
);
#endif
#endif
/*
Allocates a block of memory on the heap.
*/
DRMP3_API
void
*
drmp3_malloc
(
size_t
sz
,
const
drmp3_allocation_callbacks
*
pAllocationCallbacks
);
/*
/*
Frees any memory that was allocated by a public drmp3 API.
Frees any memory that was allocated by a public drmp3 API.
*/
*/
...
@@ -1153,16 +1158,16 @@ static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *is
...
@@ -1153,16 +1158,16 @@ static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *is
int
sh
=
3
-
scf_shift
;
int
sh
=
3
-
scf_shift
;
for
(
i
=
0
;
i
<
gr
->
n_short_sfb
;
i
+=
3
)
for
(
i
=
0
;
i
<
gr
->
n_short_sfb
;
i
+=
3
)
{
{
iscf
[
gr
->
n_long_sfb
+
i
+
0
]
+=
gr
->
subblock_gain
[
0
]
<<
sh
;
iscf
[
gr
->
n_long_sfb
+
i
+
0
]
=
(
drmp3_uint8
)(
iscf
[
gr
->
n_long_sfb
+
i
+
0
]
+
(
gr
->
subblock_gain
[
0
]
<<
sh
))
;
iscf
[
gr
->
n_long_sfb
+
i
+
1
]
+=
gr
->
subblock_gain
[
1
]
<<
sh
;
iscf
[
gr
->
n_long_sfb
+
i
+
1
]
=
(
drmp3_uint8
)(
iscf
[
gr
->
n_long_sfb
+
i
+
1
]
+
(
gr
->
subblock_gain
[
1
]
<<
sh
))
;
iscf
[
gr
->
n_long_sfb
+
i
+
2
]
+=
gr
->
subblock_gain
[
2
]
<<
sh
;
iscf
[
gr
->
n_long_sfb
+
i
+
2
]
=
(
drmp3_uint8
)(
iscf
[
gr
->
n_long_sfb
+
i
+
2
]
+
(
gr
->
subblock_gain
[
2
]
<<
sh
))
;
}
}
}
else
if
(
gr
->
preflag
)
}
else
if
(
gr
->
preflag
)
{
{
static
const
drmp3_uint8
g_preamp
[
10
]
=
{
1
,
1
,
1
,
1
,
2
,
2
,
3
,
3
,
3
,
2
};
static
const
drmp3_uint8
g_preamp
[
10
]
=
{
1
,
1
,
1
,
1
,
2
,
2
,
3
,
3
,
3
,
2
};
for
(
i
=
0
;
i
<
10
;
i
++
)
for
(
i
=
0
;
i
<
10
;
i
++
)
{
{
iscf
[
11
+
i
]
+=
g_preamp
[
i
]
;
iscf
[
11
+
i
]
=
(
drmp3_uint8
)(
iscf
[
11
+
i
]
+
g_preamp
[
i
])
;
}
}
}
}
...
@@ -2584,7 +2589,7 @@ static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPC
...
@@ -2584,7 +2589,7 @@ static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPC
return
0
;
return
0
;
}
}
do
{
for
(;;)
{
drmp3dec_frame_info
info
;
drmp3dec_frame_info
info
;
size_t
leftoverDataSize
;
size_t
leftoverDataSize
;
...
@@ -2672,7 +2677,7 @@ static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPC
...
@@ -2672,7 +2677,7 @@ static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPC
pMP3
->
dataSize
+=
bytesRead
;
pMP3
->
dataSize
+=
bytesRead
;
}
}
}
while
(
DRMP3_TRUE
)
;
};
return
pcmFramesRead
;
return
pcmFramesRead
;
}
}
...
@@ -4241,6 +4246,15 @@ DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* fileP
...
@@ -4241,6 +4246,15 @@ DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* fileP
}
}
#endif
#endif
DRMP3_API
void
*
drmp3_malloc
(
size_t
sz
,
const
drmp3_allocation_callbacks
*
pAllocationCallbacks
)
{
if
(
pAllocationCallbacks
!=
NULL
)
{
return
drmp3__malloc_from_callbacks
(
sz
,
pAllocationCallbacks
);
}
else
{
return
drmp3__malloc_default
(
sz
,
NULL
);
}
}
DRMP3_API
void
drmp3_free
(
void
*
p
,
const
drmp3_allocation_callbacks
*
pAllocationCallbacks
)
DRMP3_API
void
drmp3_free
(
void
*
p
,
const
drmp3_allocation_callbacks
*
pAllocationCallbacks
)
{
{
if
(
pAllocationCallbacks
!=
NULL
)
{
if
(
pAllocationCallbacks
!=
NULL
)
{
...
@@ -4335,6 +4349,9 @@ counts rather than sample counts.
...
@@ -4335,6 +4349,9 @@ counts rather than sample counts.
/*
/*
REVISION HISTORY
REVISION HISTORY
================
================
v0.6.1 - 2020-04-05
- Fix warnings.
v0.6.0 - 2020-04-04
v0.6.0 - 2020-04-04
- API CHANGE: Remove the pConfig parameter from the following APIs:
- API CHANGE: Remove the pConfig parameter from the following APIs:
- drmp3_init()
- drmp3_init()
...
...
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