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
273886fa
Commit
273886fa
authored
Jan 13, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/asrc_anoisesrc: add velvet noise
parent
fdddc0d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
filters.texi
doc/filters.texi
+1
-1
asrc_anoisesrc.c
libavfilter/asrc_anoisesrc.c
+15
-7
No files found.
doc/filters.texi
View file @
273886fa
...
...
@@ -5985,7 +5985,7 @@ results in noise with an infinite length.
@
item
color
,
colour
,
c
Specify
the
color
of
noise
.
Available
noise
colors
are
white
,
pink
,
brown
,
blue
and
viol
et
.
Default
color
is
white
.
blue
,
violet
and
velv
et
.
Default
color
is
white
.
@
item
seed
,
s
Specify
a
value
used
to
seed
the
PRNG
.
...
...
libavfilter/asrc_anoisesrc.c
View file @
273886fa
...
...
@@ -36,7 +36,7 @@ typedef struct ANoiseSrcContext {
int64_t
pts
;
int
infinite
;
double
(
*
filter
)(
double
white
,
double
*
buf
);
double
(
*
filter
)(
double
white
,
double
*
buf
,
double
half_amplitude
);
double
buf
[
7
];
AVLFG
c
;
}
ANoiseSrcContext
;
...
...
@@ -47,6 +47,7 @@ enum NoiseMode {
NM_BROWN
,
NM_BLUE
,
NM_VIOLET
,
NM_VELVET
,
NM_NB
};
...
...
@@ -68,6 +69,7 @@ static const AVOption anoisesrc_options[] = {
{
"brown"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NM_BROWN
},
0
,
0
,
FLAGS
,
"color"
},
{
"blue"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NM_BLUE
},
0
,
0
,
FLAGS
,
"color"
},
{
"violet"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NM_VIOLET
},
0
,
0
,
FLAGS
,
"color"
},
{
"velvet"
,
0
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NM_VELVET
},
0
,
0
,
FLAGS
,
"color"
},
{
"seed"
,
"set random seed"
,
OFFSET
(
seed
),
AV_OPT_TYPE_INT64
,
{.
i64
=
-
1
},
-
1
,
UINT_MAX
,
FLAGS
},
{
"s"
,
"set random seed"
,
OFFSET
(
seed
),
AV_OPT_TYPE_INT64
,
{.
i64
=
-
1
},
-
1
,
UINT_MAX
,
FLAGS
},
{
"nb_samples"
,
"set the number of samples per requested frame"
,
OFFSET
(
nb_samples
),
AV_OPT_TYPE_INT
,
{.
i64
=
1024
},
1
,
INT_MAX
,
FLAGS
},
...
...
@@ -111,12 +113,12 @@ static av_cold int query_formats(AVFilterContext *ctx)
return
ff_set_common_samplerates
(
ctx
,
formats
);
}
static
double
white_filter
(
double
white
,
double
*
buf
)
static
double
white_filter
(
double
white
,
double
*
buf
,
double
ha
)
{
return
white
;
}
static
double
pink_filter
(
double
white
,
double
*
buf
)
static
double
pink_filter
(
double
white
,
double
*
buf
,
double
ha
)
{
double
pink
;
...
...
@@ -132,7 +134,7 @@ static double pink_filter(double white, double *buf)
return
pink
*
0
.
11
;
}
static
double
blue_filter
(
double
white
,
double
*
buf
)
static
double
blue_filter
(
double
white
,
double
*
buf
,
double
ha
)
{
double
blue
;
...
...
@@ -148,7 +150,7 @@ static double blue_filter(double white, double *buf)
return
blue
*
0
.
11
;
}
static
double
brown_filter
(
double
white
,
double
*
buf
)
static
double
brown_filter
(
double
white
,
double
*
buf
,
double
ha
)
{
double
brown
;
...
...
@@ -157,7 +159,7 @@ static double brown_filter(double white, double *buf)
return
brown
*
3
.
5
;
}
static
double
violet_filter
(
double
white
,
double
*
buf
)
static
double
violet_filter
(
double
white
,
double
*
buf
,
double
ha
)
{
double
violet
;
...
...
@@ -166,6 +168,11 @@ static double violet_filter(double white, double *buf)
return
violet
*
3
.
5
;
}
static
double
velvet_filter
(
double
white
,
double
*
buf
,
double
ha
)
{
return
2
.
*
ha
*
((
white
>
ha
)
-
(
white
<
-
ha
));
}
static
av_cold
int
config_props
(
AVFilterLink
*
outlink
)
{
AVFilterContext
*
ctx
=
outlink
->
src
;
...
...
@@ -185,6 +192,7 @@ static av_cold int config_props(AVFilterLink *outlink)
case
NM_BROWN
:
s
->
filter
=
brown_filter
;
break
;
case
NM_BLUE
:
s
->
filter
=
blue_filter
;
break
;
case
NM_VIOLET
:
s
->
filter
=
violet_filter
;
break
;
case
NM_VELVET
:
s
->
filter
=
velvet_filter
;
break
;
}
return
0
;
...
...
@@ -213,7 +221,7 @@ static int request_frame(AVFilterLink *outlink)
for
(
i
=
0
;
i
<
nb_samples
;
i
++
)
{
double
white
;
white
=
s
->
amplitude
*
((
2
*
((
double
)
av_lfg_get
(
&
s
->
c
)
/
0xffffffff
))
-
1
);
dst
[
i
]
=
s
->
filter
(
white
,
s
->
buf
);
dst
[
i
]
=
s
->
filter
(
white
,
s
->
buf
,
s
->
amplitude
*
0
.
5
);
}
if
(
!
s
->
infinite
)
...
...
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