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
4cbeff8f
Commit
4cbeff8f
authored
Sep 09, 2017
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small optimizations to some format conversion routines.
parent
d68ed4f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
19 deletions
+18
-19
mini_al.h
mini_al.h
+5
-9
resources/format_conversions.txt
resources/format_conversions.txt
+12
-9
tools/malgen/source/malgen.cpp
tools/malgen/source/malgen.cpp
+1
-1
No files found.
mini_al.h
View file @
4cbeff8f
...
...
@@ -2443,7 +2443,6 @@ static void mal_channel_mask_to_channel_map__win32(DWORD dwChannelMask, mal_uint
#include <audioclient.h>
#include <audiopolicy.h>
#include <mmdeviceapi.h>
//#include <functiondiscoverykeys_devpkey.h>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
...
...
@@ -8727,8 +8726,7 @@ void mal_pcm_u8_to_f32(float* pOut, const unsigned char* pIn, unsigned int count
float
r
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
++
i
)
{
int
x
=
pIn
[
i
];
r
=
x
/
255
.
0
f
;
r
=
r
*
2
;
r
=
x
*
0
.
007
84313725490196078
f
;
r
=
r
-
1
;
pOut
[
i
]
=
(
float
)
r
;
}
...
...
@@ -8770,9 +8768,8 @@ void mal_pcm_s16_to_f32(float* pOut, const short* pIn, unsigned int count)
float
r
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
++
i
)
{
int
x
=
pIn
[
i
];
r
=
x
+
32768
.
0
f
;
r
=
r
/
65536
.
0
f
;
r
=
r
*
2
;
r
=
(
float
)(
x
+
32768
);
r
=
r
*
0
.
00003051
804379339284
f
;
r
=
r
-
1
;
pOut
[
i
]
=
(
float
)
r
;
}
...
...
@@ -8814,9 +8811,8 @@ void mal_pcm_s24_to_f32(float* pOut, const void* pIn, unsigned int count)
float
r
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
++
i
)
{
int
x
=
((
int
)(((
unsigned
int
)(((
unsigned
char
*
)
pIn
)[
i
*
3
+
0
])
<<
8
)
|
((
unsigned
int
)(((
unsigned
char
*
)
pIn
)[
i
*
3
+
1
])
<<
16
)
|
((
unsigned
int
)(((
unsigned
char
*
)
pIn
)[
i
*
3
+
2
]))
<<
24
))
>>
8
;
r
=
x
+
8388608
.
0
f
;
r
=
r
/
16777215
.
0
f
;
r
=
r
*
2
;
r
=
(
float
)(
x
+
8388608
);
r
=
r
*
0
.
00000011
920929665621
f
;
r
=
r
-
1
;
pOut
[
i
]
=
(
float
)
r
;
}
...
...
resources/format_conversions.txt
View file @
4cbeff8f
...
...
@@ -36,9 +36,10 @@ u8->s32 {
}
# r = (x / 255) * 2 - 1
# = (x / 127.5) - 1
# = (x * 0.00784313725490196078) - 1
u8->f32 {
div r x 255.0f;
mul r r 2;
mul r x 0.00784313725490196078f;
sub r r 1;
}
...
...
@@ -60,11 +61,12 @@ s16->s32 {
shl r x 16;
}
# r = ((x + 32768) / 65536) * 2 - 1
# r = ((x + 32768) / 65535) * 2 - 1
# = (x + 32768) / 32767.5) - 1
# = (x + 32768) * 0.00003051804379339284) - 1
s16->f32 {
add r x 32768.0f;
div r r 65536.0f;
mul r r 2;
add (flt)r x 32768;
mul r r 0.00003051804379339284f;
sub r r 1;
}
...
...
@@ -87,10 +89,11 @@ s24->s32 {
}
# r = ((x + 8388608) / 16777215) * 2 - 1
# = (x + 8388608) / 8388607.5) - 1
# = (x + 8388608) * 0.00000011920929665621) - 1
s24->f32 {
add r x 8388608.0f;
div r r 16777215.0f;
mul r r 2;
add (flt)r x 8388608;
mul r r 0.00000011920929665621f;
sub r r 1;
}
...
...
tools/malgen/source/malgen.cpp
View file @
4cbeff8f
...
...
@@ -441,7 +441,7 @@ std::string malgen_generate_code__conversion_func_inst_binary_op(const char* res
char
typeStr
[
64
];
strncpy_s
(
typeStr
,
result
,
resultVar
-
result
);
code
+=
typeStr
;
code
+=
"("
;
code
+=
assignmentStr
;
code
+=
")"
;
code
+=
malgen_format_op_param
(
typeStr
)
;
code
+=
"("
;
code
+=
assignmentStr
;
code
+=
")"
;
return
code
;
}
else
{
code
+=
assignmentStr
;
...
...
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