Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
f1f5b398
Commit
f1f5b398
authored
Apr 26, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swr-test: support fabrices audiogen like avr
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
73be22f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
swresample_test.c
libswresample/swresample_test.c
+83
-0
No files found.
libswresample/swresample_test.c
View file @
f1f5b398
/*
* Copyright (C) 2011 Michael Niedermayer (michaelni@gmx.at)
* Copyright (c) 2002 Fabrice Bellard
*
* This file is part of libswresample
*
...
...
@@ -136,6 +137,84 @@ static int cmp(const int *a, const int *b){
return
*
a
-
*
b
;
}
static
void
audiogen
(
void
*
data
,
enum
AVSampleFormat
sample_fmt
,
int
channels
,
int
sample_rate
,
int
nb_samples
)
{
int
i
,
ch
,
k
;
double
v
,
f
,
a
,
ampa
;
double
tabf1
[
SWR_CH_MAX
];
double
tabf2
[
SWR_CH_MAX
];
double
taba
[
SWR_CH_MAX
];
unsigned
static
seed
;
#define PUT_SAMPLE set(data, ch, k, channels, sample_fmt, v);
#define dbl_rand(x) ((seed = seed * 1664525 + 1013904223)*2.0 / (double)UINT_MAX - 1)
k
=
0
;
/* 1 second of single freq sinus at 1000 Hz */
a
=
0
;
for
(
i
=
0
;
i
<
1
*
sample_rate
&&
k
<
nb_samples
;
i
++
,
k
++
)
{
v
=
sin
(
a
)
*
0
.
30
;
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
PUT_SAMPLE
a
+=
M_PI
*
1000
.
0
*
2
.
0
/
sample_rate
;
}
/* 1 second of varing frequency between 100 and 10000 Hz */
a
=
0
;
for
(
i
=
0
;
i
<
1
*
sample_rate
&&
k
<
nb_samples
;
i
++
,
k
++
)
{
v
=
sin
(
a
)
*
0
.
30
;
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
PUT_SAMPLE
f
=
100
.
0
+
(((
10000
.
0
-
100
.
0
)
*
i
)
/
sample_rate
);
a
+=
M_PI
*
f
*
2
.
0
/
sample_rate
;
}
/* 0.5 second of low amplitude white noise */
for
(
i
=
0
;
i
<
sample_rate
/
2
&&
k
<
nb_samples
;
i
++
,
k
++
)
{
v
=
dbl_rand
(
rnd
)
*
0
.
30
;
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
PUT_SAMPLE
}
/* 0.5 second of high amplitude white noise */
for
(
i
=
0
;
i
<
sample_rate
/
2
&&
k
<
nb_samples
;
i
++
,
k
++
)
{
v
=
dbl_rand
(
rnd
);
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
PUT_SAMPLE
}
/* 1 second of unrelated ramps for each channel */
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
{
taba
[
ch
]
=
0
;
tabf1
[
ch
]
=
100
+
(
seed
=
seed
*
1664525
+
1013904223
)
%
5000
;
tabf2
[
ch
]
=
100
+
(
seed
=
seed
*
1664525
+
1013904223
)
%
5000
;
}
for
(
i
=
0
;
i
<
1
*
sample_rate
&&
k
<
nb_samples
;
i
++
,
k
++
)
{
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
{
v
=
sin
(
taba
[
ch
])
*
0
.
30
;
PUT_SAMPLE
f
=
tabf1
[
ch
]
+
(((
tabf2
[
ch
]
-
tabf1
[
ch
])
*
i
)
/
sample_rate
);
taba
[
ch
]
+=
M_PI
*
f
*
2
.
0
/
sample_rate
;
}
}
/* 2 seconds of 500 Hz with varying volume */
a
=
0
;
ampa
=
0
;
for
(
i
=
0
;
i
<
2
*
sample_rate
&&
k
<
nb_samples
;
i
++
,
k
++
)
{
for
(
ch
=
0
;
ch
<
channels
;
ch
++
)
{
double
amp
=
(
1
.
0
+
sin
(
ampa
))
*
0
.
15
;
if
(
ch
&
1
)
amp
=
0
.
30
-
amp
;
v
=
sin
(
a
)
*
amp
;
PUT_SAMPLE
a
+=
M_PI
*
500
.
0
*
2
.
0
/
sample_rate
;
ampa
+=
M_PI
*
2
.
0
/
sample_rate
;
}
}
}
int
main
(
int
argc
,
char
**
argv
){
int
in_sample_rate
,
out_sample_rate
,
ch
,
i
,
in_ch_layout_index
,
out_ch_layout_index
,
osr
,
flush_count
;
int
in_sample_fmt_index
,
out_sample_fmt_index
;
...
...
@@ -220,10 +299,14 @@ int main(int argc, char **argv){
setup_array
(
ain
,
array_in
,
in_sample_fmt
,
SAMPLES
);
setup_array
(
amid
,
array_mid
,
out_sample_fmt
,
3
*
SAMPLES
);
setup_array
(
aout
,
array_out
,
in_sample_fmt
,
SAMPLES
);
#if 0
for(ch=0; ch<in_ch_count; ch++){
for(i=0; i<SAMPLES; i++)
set(ain, ch, i, in_ch_count, in_sample_fmt, sin(i*i*3/SAMPLES));
}
#else
audiogen
(
ain
,
in_sample_fmt
,
in_ch_count
,
SAMPLES
/
6
+
1
,
SAMPLES
);
#endif
mode
++
;
mode
%=
3
;
if
(
mode
==
0
/*|| out_sample_rate == in_sample_rate*/
)
{
...
...
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