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
6e72abd4
Commit
6e72abd4
authored
Nov 25, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict resampling ratio to reasonable limits.
parent
34d88af6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
research/mal_resampler.h
research/mal_resampler.h
+18
-3
No files found.
research/mal_resampler.h
View file @
6e72abd4
...
@@ -38,6 +38,8 @@ Other Notes:
...
@@ -38,6 +38,8 @@ Other Notes:
Random Notes:
Random Notes:
- You cannot change the algorithm after initialization.
- You cannot change the algorithm after initialization.
- It is recommended to keep the mal_resampler object aligned to MAL_SIMD_ALIGNMENT, though it is not necessary.
- It is recommended to keep the mal_resampler object aligned to MAL_SIMD_ALIGNMENT, though it is not necessary.
- Ratios need to be in the range of MAL_RESAMPLER_MIN_RATIO and MAL_RESAMPLER_MAX_RATIO. If you need extreme ratios
then you will need to chain resamplers together.
*/
*/
#ifndef mal_resampler_h
#ifndef mal_resampler_h
#define mal_resampler_h
#define mal_resampler_h
...
@@ -198,6 +200,14 @@ mal_uint64 mal_resampler_get_expected_output_frame_count(mal_resampler* pResampl
...
@@ -198,6 +200,14 @@ mal_uint64 mal_resampler_get_expected_output_frame_count(mal_resampler* pResampl
#endif
#endif
#ifdef MINI_AL_IMPLEMENTATION
#ifdef MINI_AL_IMPLEMENTATION
#ifndef MAL_RESAMPLER_MIN_RATIO
#define MAL_RESAMPLER_MIN_RATIO 0.001
#endif
#ifndef MAL_RESAMPLER_MAX_RATIO
#define MAL_RESAMPLER_MAX_RATIO 100.0
#endif
mal_uint64
mal_resampler_read__linear
(
mal_resampler
*
pResampler
,
mal_uint64
frameCount
,
void
**
ppFrames
);
mal_uint64
mal_resampler_read__linear
(
mal_resampler
*
pResampler
,
mal_uint64
frameCount
,
void
**
ppFrames
);
mal_uint64
mal_resampler_seek__linear
(
mal_resampler
*
pResampler
,
mal_uint64
frameCount
,
mal_uint32
options
);
mal_uint64
mal_resampler_seek__linear
(
mal_resampler
*
pResampler
,
mal_uint64
frameCount
,
mal_uint32
options
);
...
@@ -298,9 +308,14 @@ mal_result mal_resampler_set_rate(mal_resampler* pResampler, mal_uint32 sampleRa
...
@@ -298,9 +308,14 @@ mal_result mal_resampler_set_rate(mal_resampler* pResampler, mal_uint32 sampleRa
return
MAL_INVALID_ARGS
;
return
MAL_INVALID_ARGS
;
}
}
double
ratio
=
(
double
)
pResampler
->
config
.
sampleRateIn
/
(
double
)
pResampler
->
config
.
sampleRateOut
;
if
(
ratio
<
MAL_RESAMPLER_MIN_RATIO
||
ratio
>
MAL_RESAMPLER_MAX_RATIO
)
{
return
MAL_INVALID_ARGS
;
/* Ratio is too extreme. */
}
pResampler
->
config
.
sampleRateIn
=
sampleRateIn
;
pResampler
->
config
.
sampleRateIn
=
sampleRateIn
;
pResampler
->
config
.
sampleRateOut
=
sampleRateOut
;
pResampler
->
config
.
sampleRateOut
=
sampleRateOut
;
pResampler
->
config
.
ratio
=
(
double
)
pResampler
->
config
.
sampleRateIn
/
(
double
)
pResampler
->
config
.
sampleRateOut
;
pResampler
->
config
.
ratio
=
ratio
;
return
MAL_SUCCESS
;
return
MAL_SUCCESS
;
}
}
...
@@ -311,8 +326,8 @@ mal_result mal_resampler_set_rate_ratio(mal_resampler* pResampler, double ratio)
...
@@ -311,8 +326,8 @@ mal_result mal_resampler_set_rate_ratio(mal_resampler* pResampler, double ratio)
return
MAL_INVALID_ARGS
;
return
MAL_INVALID_ARGS
;
}
}
if
(
ratio
==
0
)
{
if
(
ratio
<
MAL_RESAMPLER_MIN_RATIO
||
ratio
>
MAL_RESAMPLER_MAX_RATIO
)
{
return
MAL_INVALID_ARGS
;
return
MAL_INVALID_ARGS
;
/* Ratio is too extreme. */
}
}
pResampler
->
config
.
ratio
=
ratio
;
pResampler
->
config
.
ratio
=
ratio
;
...
...
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