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
eb85060b
Commit
eb85060b
authored
Jun 14, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_afade: add couple of more curves
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
12e36a3d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
6 deletions
+42
-6
filters.texi
doc/filters.texi
+13
-1
af_afade.c
libavfilter/af_afade.c
+29
-5
No files found.
doc/filters.texi
View file @
eb85060b
...
@@ -522,7 +522,7 @@ select half of sine wave
...
@@ -522,7 +522,7 @@ select half of sine wave
select exponential sine wave
select exponential sine wave
@item log
@item log
select logarithmic
select logarithmic
@item par
@item
i
par
select inverted parabola
select inverted parabola
@item qua
@item qua
select quadratic
select quadratic
...
@@ -532,6 +532,18 @@ select cubic
...
@@ -532,6 +532,18 @@ select cubic
select square root
select square root
@item cbr
@item cbr
select cubic root
select cubic root
@item par
select parabola
@item exp
select exponential
@item iqsin
select inverted quarter of sine wave
@item ihsin
select inverted half of sine wave
@item dese
select double-exponential seat
@item desi
select double-exponential sigmoid
@end table
@end table
@end table
@end table
...
...
libavfilter/af_afade.c
View file @
eb85060b
...
@@ -42,7 +42,7 @@ typedef struct {
...
@@ -42,7 +42,7 @@ typedef struct {
int64_t
start
,
int
range
,
int
curve
);
int64_t
start
,
int
range
,
int
curve
);
}
AudioFadeContext
;
}
AudioFadeContext
;
enum
CurveType
{
TRI
,
QSIN
,
ESIN
,
HSIN
,
LOG
,
PAR
,
QUA
,
CUB
,
SQU
,
CBR
};
enum
CurveType
{
TRI
,
QSIN
,
ESIN
,
HSIN
,
LOG
,
IPAR
,
QUA
,
CUB
,
SQU
,
CBR
,
PAR
,
EXP
,
IQSIN
,
IHSIN
,
DESE
,
DESI
,
NB_CURVES
};
#define OFFSET(x) offsetof(AudioFadeContext, x)
#define OFFSET(x) offsetof(AudioFadeContext, x)
#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
...
@@ -60,18 +60,24 @@ static const AVOption afade_options[] = {
...
@@ -60,18 +60,24 @@ static const AVOption afade_options[] = {
{
"st"
,
"set time to start fading"
,
OFFSET
(
start_time
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
.
},
0
,
INT32_MAX
,
FLAGS
},
{
"st"
,
"set time to start fading"
,
OFFSET
(
start_time
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
.
},
0
,
INT32_MAX
,
FLAGS
},
{
"duration"
,
"set fade duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
.
},
0
,
INT32_MAX
,
FLAGS
},
{
"duration"
,
"set fade duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
.
},
0
,
INT32_MAX
,
FLAGS
},
{
"d"
,
"set fade duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
.
},
0
,
INT32_MAX
,
FLAGS
},
{
"d"
,
"set fade duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
.
},
0
,
INT32_MAX
,
FLAGS
},
{
"curve"
,
"set fade curve type"
,
OFFSET
(
curve
),
AV_OPT_TYPE_INT
,
{.
i64
=
TRI
},
TRI
,
CBR
,
FLAGS
,
"curve"
},
{
"curve"
,
"set fade curve type"
,
OFFSET
(
curve
),
AV_OPT_TYPE_INT
,
{.
i64
=
TRI
},
0
,
NB_CURVES
-
1
,
FLAGS
,
"curve"
},
{
"c"
,
"set fade curve type"
,
OFFSET
(
curve
),
AV_OPT_TYPE_INT
,
{.
i64
=
TRI
},
TRI
,
CBR
,
FLAGS
,
"curve"
},
{
"c"
,
"set fade curve type"
,
OFFSET
(
curve
),
AV_OPT_TYPE_INT
,
{.
i64
=
TRI
},
0
,
NB_CURVES
-
1
,
FLAGS
,
"curve"
},
{
"tri"
,
"linear slope"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
TRI
},
0
,
0
,
FLAGS
,
"curve"
},
{
"tri"
,
"linear slope"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
TRI
},
0
,
0
,
FLAGS
,
"curve"
},
{
"qsin"
,
"quarter of sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
QSIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"qsin"
,
"quarter of sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
QSIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"esin"
,
"exponential sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
ESIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"esin"
,
"exponential sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
ESIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"hsin"
,
"half of sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HSIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"hsin"
,
"half of sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HSIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"log"
,
"logarithmic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LOG
},
0
,
0
,
FLAGS
,
"curve"
},
{
"log"
,
"logarithmic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LOG
},
0
,
0
,
FLAGS
,
"curve"
},
{
"
par"
,
"inverted parabola"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
PAR
},
0
,
0
,
FLAGS
,
"curve"
},
{
"
ipar"
,
"inverted parabola"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
IPAR
},
0
,
0
,
FLAGS
,
"curve"
},
{
"qua"
,
"quadratic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
QUA
},
0
,
0
,
FLAGS
,
"curve"
},
{
"qua"
,
"quadratic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
QUA
},
0
,
0
,
FLAGS
,
"curve"
},
{
"cub"
,
"cubic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CUB
},
0
,
0
,
FLAGS
,
"curve"
},
{
"cub"
,
"cubic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CUB
},
0
,
0
,
FLAGS
,
"curve"
},
{
"squ"
,
"square root"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SQU
},
0
,
0
,
FLAGS
,
"curve"
},
{
"squ"
,
"square root"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SQU
},
0
,
0
,
FLAGS
,
"curve"
},
{
"cbr"
,
"cubic root"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CBR
},
0
,
0
,
FLAGS
,
"curve"
},
{
"cbr"
,
"cubic root"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CBR
},
0
,
0
,
FLAGS
,
"curve"
},
{
"par"
,
"parabola"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
PAR
},
0
,
0
,
FLAGS
,
"curve"
},
{
"exp"
,
"exponential"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EXP
},
0
,
0
,
FLAGS
,
"curve"
},
{
"iqsin"
,
"inverted quarter of sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
IQSIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"ihsin"
,
"inverted half of sine wave"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
IHSIN
},
0
,
0
,
FLAGS
,
"curve"
},
{
"dese"
,
"double-exponential seat"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
DESE
},
0
,
0
,
FLAGS
,
"curve"
},
{
"desi"
,
"double-exponential sigmoid"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
DESI
},
0
,
0
,
FLAGS
,
"curve"
},
{
NULL
}
{
NULL
}
};
};
...
@@ -130,16 +136,28 @@ static double fade_gain(int curve, int64_t index, int range)
...
@@ -130,16 +136,28 @@ static double fade_gain(int curve, int64_t index, int range)
case
QSIN
:
case
QSIN
:
gain
=
sin
(
gain
*
M_PI
/
2
.
0
);
gain
=
sin
(
gain
*
M_PI
/
2
.
0
);
break
;
break
;
case
IQSIN
:
gain
=
0
.
636943
*
asin
(
gain
);
break
;
case
ESIN
:
case
ESIN
:
gain
=
1
.
0
-
cos
(
M_PI
/
4
.
0
*
(
pow
(
2
.
0
*
gain
-
1
,
3
)
+
1
));
gain
=
1
.
0
-
cos
(
M_PI
/
4
.
0
*
(
pow
(
2
.
0
*
gain
-
1
,
3
)
+
1
));
break
;
break
;
case
HSIN
:
case
HSIN
:
gain
=
(
1
.
0
-
cos
(
gain
*
M_PI
))
/
2
.
0
;
gain
=
(
1
.
0
-
cos
(
gain
*
M_PI
))
/
2
.
0
;
break
;
break
;
case
LOG
:
case
IHSIN
:
gain
=
0
.
318471
*
acos
(
1
-
2
*
gain
);
break
;
case
EXP
:
gain
=
pow
(
0
.
1
,
(
1
-
gain
)
*
5
.
0
);
gain
=
pow
(
0
.
1
,
(
1
-
gain
)
*
5
.
0
);
break
;
break
;
case
LOG
:
gain
=
av_clipd
(
0
.
0868589
*
log
(
100000
*
gain
),
0
,
1
.
0
);
break
;
case
PAR
:
case
PAR
:
gain
=
1
-
sqrt
(
1
-
gain
);
break
;
case
IPAR
:
gain
=
(
1
-
(
1
-
gain
)
*
(
1
-
gain
));
gain
=
(
1
-
(
1
-
gain
)
*
(
1
-
gain
));
break
;
break
;
case
QUA
:
case
QUA
:
...
@@ -154,6 +172,12 @@ static double fade_gain(int curve, int64_t index, int range)
...
@@ -154,6 +172,12 @@ static double fade_gain(int curve, int64_t index, int range)
case
CBR
:
case
CBR
:
gain
=
cbrt
(
gain
);
gain
=
cbrt
(
gain
);
break
;
break
;
case
DESE
:
gain
=
gain
<=
0
.
5
?
pow
(
2
*
gain
,
1
/
3
.)
/
2
:
1
-
pow
(
2
*
(
1
-
gain
),
1
/
3
.)
/
2
;
break
;
case
DESI
:
gain
=
gain
<=
0
.
5
?
pow
(
2
*
gain
,
3
)
/
2
:
1
-
pow
(
2
*
(
1
-
gain
),
3
)
/
2
;
break
;
}
}
return
gain
;
return
gain
;
...
...
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