Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
bd5e92ef
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd5e92ef
编写于
6月 30, 2019
作者:
P
Paul B Mahol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avfilter: add deesser audio filter
上级
1b262004
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
284 addition
and
1 deletion
+284
-1
Changelog
Changelog
+1
-0
doc/filters.texi
doc/filters.texi
+36
-0
libavfilter/Makefile
libavfilter/Makefile
+1
-0
libavfilter/af_deesser.c
libavfilter/af_deesser.c
+244
-0
libavfilter/allfilters.c
libavfilter/allfilters.c
+1
-0
libavfilter/version.h
libavfilter/version.h
+1
-1
未找到文件。
Changelog
浏览文件 @
bd5e92ef
...
@@ -34,6 +34,7 @@ version <next>:
...
@@ -34,6 +34,7 @@ version <next>:
- VP4 video decoder
- VP4 video decoder
- IFV demuxer
- IFV demuxer
- derain filter
- derain filter
- deesser filter
version 4.1:
version 4.1:
...
...
doc/filters.texi
浏览文件 @
bd5e92ef
...
@@ -3045,6 +3045,42 @@ Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
...
@@ -3045,6 +3045,42 @@ Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
used to prevent clipping.
used to prevent clipping.
@end table
@end table
@section deesser
Apply de-essing to the audio samples.
@table @option
@item i
Set intensity for triggering de-essing. Allowed range is from 0 to 1.
Default is 0.
@item m
Set amount of ducking on treble part of sound. Allowed range is from 0 to 1.
Default is 0.5.
@item f
How much of original frequency content to keep when de-essing. Allowed range is from 0 to 1.
Default is 0.5.
@item s
Set the output mode.
It accepts the following values:
@table @option
@item i
Pass input unchanged.
@item o
Pass ess filtered out.
@item e
Pass only ess.
Default value is @var{o}.
@end table
@end table
@section drmeter
@section drmeter
Measure audio dynamic range.
Measure audio dynamic range.
...
...
libavfilter/Makefile
浏览文件 @
bd5e92ef
...
@@ -101,6 +101,7 @@ OBJS-$(CONFIG_COMPENSATIONDELAY_FILTER) += af_compensationdelay.o
...
@@ -101,6 +101,7 @@ OBJS-$(CONFIG_COMPENSATIONDELAY_FILTER) += af_compensationdelay.o
OBJS-$(CONFIG_CROSSFEED_FILTER)
+=
af_crossfeed.o
OBJS-$(CONFIG_CROSSFEED_FILTER)
+=
af_crossfeed.o
OBJS-$(CONFIG_CRYSTALIZER_FILTER)
+=
af_crystalizer.o
OBJS-$(CONFIG_CRYSTALIZER_FILTER)
+=
af_crystalizer.o
OBJS-$(CONFIG_DCSHIFT_FILTER)
+=
af_dcshift.o
OBJS-$(CONFIG_DCSHIFT_FILTER)
+=
af_dcshift.o
OBJS-$(CONFIG_DEESSER_FILTER)
+=
af_deesser.o
OBJS-$(CONFIG_DRMETER_FILTER)
+=
af_drmeter.o
OBJS-$(CONFIG_DRMETER_FILTER)
+=
af_drmeter.o
OBJS-$(CONFIG_DYNAUDNORM_FILTER)
+=
af_dynaudnorm.o
OBJS-$(CONFIG_DYNAUDNORM_FILTER)
+=
af_dynaudnorm.o
OBJS-$(CONFIG_EARWAX_FILTER)
+=
af_earwax.o
OBJS-$(CONFIG_EARWAX_FILTER)
+=
af_earwax.o
...
...
libavfilter/af_deesser.c
0 → 100644
浏览文件 @
bd5e92ef
/*
* Copyright (c) 2018 Chris Johnson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "audio.h"
#include "formats.h"
typedef
struct
DeesserChannel
{
double
s1
,
s2
,
s3
;
double
m1
,
m2
;
double
ratioA
,
ratioB
;
double
iirSampleA
,
iirSampleB
;
int
flip
;
}
DeesserChannel
;
typedef
struct
DeesserContext
{
const
AVClass
*
class
;
double
intensity
;
double
max
;
double
frequency
;
int
mode
;
DeesserChannel
*
chan
;
}
DeesserContext
;
enum
OutModes
{
IN_MODE
,
OUT_MODE
,
ESS_MODE
,
NB_MODES
};
#define OFFSET(x) offsetof(DeesserContext, x)
#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
deesser_options
[]
=
{
{
"i"
,
"set intensity"
,
OFFSET
(
intensity
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
0
},
0
.
0
,
1
.
0
,
A
},
{
"m"
,
"set max deessing"
,
OFFSET
(
max
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
5
},
0
.
0
,
1
.
0
,
A
},
{
"f"
,
"set frequency"
,
OFFSET
(
frequency
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
0
.
5
},
0
.
0
,
1
.
0
,
A
},
{
"s"
,
"set output mode"
,
OFFSET
(
mode
),
AV_OPT_TYPE_INT
,
{.
i64
=
OUT_MODE
},
0
,
NB_MODES
-
1
,
A
,
"mode"
},
{
"i"
,
"input"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
IN_MODE
},
0
,
0
,
A
,
"mode"
},
{
"o"
,
"output"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OUT_MODE
},
0
,
0
,
A
,
"mode"
},
{
"e"
,
"ess"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
ESS_MODE
},
0
,
0
,
A
,
"mode"
},
{
NULL
}
};
AVFILTER_DEFINE_CLASS
(
deesser
);
static
int
query_formats
(
AVFilterContext
*
ctx
)
{
AVFilterFormats
*
formats
=
NULL
;
AVFilterChannelLayouts
*
layouts
=
NULL
;
static
const
enum
AVSampleFormat
sample_fmts
[]
=
{
AV_SAMPLE_FMT_DBLP
,
AV_SAMPLE_FMT_NONE
};
int
ret
;
formats
=
ff_make_format_list
(
sample_fmts
);
if
(
!
formats
)
return
AVERROR
(
ENOMEM
);
ret
=
ff_set_common_formats
(
ctx
,
formats
);
if
(
ret
<
0
)
return
ret
;
layouts
=
ff_all_channel_counts
();
if
(
!
layouts
)
return
AVERROR
(
ENOMEM
);
ret
=
ff_set_common_channel_layouts
(
ctx
,
layouts
);
if
(
ret
<
0
)
return
ret
;
formats
=
ff_all_samplerates
();
return
ff_set_common_samplerates
(
ctx
,
formats
);
}
static
int
config_input
(
AVFilterLink
*
inlink
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
DeesserContext
*
s
=
ctx
->
priv
;
s
->
chan
=
av_calloc
(
inlink
->
channels
,
sizeof
(
*
s
->
chan
));
if
(
!
s
->
chan
)
return
AVERROR
(
ENOMEM
);
for
(
int
i
=
0
;
i
<
inlink
->
channels
;
i
++
)
{
DeesserChannel
*
chan
=
&
s
->
chan
[
i
];;
chan
->
ratioA
=
chan
->
ratioB
=
1
.
0
;
}
return
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
DeesserContext
*
s
=
ctx
->
priv
;
AVFrame
*
out
;
if
(
av_frame_is_writable
(
in
))
{
out
=
in
;
}
else
{
out
=
ff_get_audio_buffer
(
outlink
,
in
->
nb_samples
);
if
(
!
out
)
{
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
in
);
}
for
(
int
ch
=
0
;
ch
<
inlink
->
channels
;
ch
++
)
{
DeesserChannel
*
dec
=
&
s
->
chan
[
ch
];
double
*
src
=
(
double
*
)
in
->
extended_data
[
ch
];
double
*
dst
=
(
double
*
)
out
->
extended_data
[
ch
];
double
overallscale
=
inlink
->
sample_rate
<
44100
?
44100
.
0
/
inlink
->
sample_rate
:
inlink
->
sample_rate
/
44100
.
0
;
double
intensity
=
pow
(
s
->
intensity
,
5
)
*
(
8192
/
overallscale
);
double
maxdess
=
1
.
0
/
pow
(
10
.
0
,
((
s
->
max
-
1
.
0
)
*
48
.
0
)
/
20
);
double
iirAmount
=
pow
(
s
->
frequency
,
2
)
/
overallscale
;
double
offset
;
double
sense
;
double
recovery
;
double
attackspeed
;
for
(
int
i
=
0
;
i
<
in
->
nb_samples
;
i
++
)
{
double
sample
=
src
[
i
];
dec
->
s3
=
dec
->
s2
;
dec
->
s2
=
dec
->
s1
;
dec
->
s1
=
sample
;
dec
->
m1
=
(
dec
->
s1
-
dec
->
s2
)
*
((
dec
->
s1
-
dec
->
s2
)
/
1
.
3
);
dec
->
m2
=
(
dec
->
s2
-
dec
->
s3
)
*
((
dec
->
s1
-
dec
->
s2
)
/
1
.
3
);
sense
=
(
dec
->
m1
-
dec
->
m2
)
*
((
dec
->
m1
-
dec
->
m2
)
/
1
.
3
);
attackspeed
=
7
.
0
+
sense
*
1024
;
sense
=
1
.
0
+
intensity
*
intensity
*
sense
;
sense
=
FFMIN
(
sense
,
intensity
);
recovery
=
1
.
0
+
(
0
.
01
/
sense
);
offset
=
1
.
0
-
fabs
(
sample
);
if
(
dec
->
flip
)
{
dec
->
iirSampleA
=
(
dec
->
iirSampleA
*
(
1
.
0
-
(
offset
*
iirAmount
)))
+
(
sample
*
(
offset
*
iirAmount
));
if
(
dec
->
ratioA
<
sense
)
{
dec
->
ratioA
=
((
dec
->
ratioA
*
attackspeed
)
+
sense
)
/
(
attackspeed
+
1
.
0
);
}
else
{
dec
->
ratioA
=
1
.
0
+
((
dec
->
ratioA
-
1
.
0
)
/
recovery
);
}
dec
->
ratioA
=
FFMIN
(
dec
->
ratioA
,
maxdess
);
sample
=
dec
->
iirSampleA
+
((
sample
-
dec
->
iirSampleA
)
/
dec
->
ratioA
);
}
else
{
dec
->
iirSampleB
=
(
dec
->
iirSampleB
*
(
1
.
0
-
(
offset
*
iirAmount
)))
+
(
sample
*
(
offset
*
iirAmount
));
if
(
dec
->
ratioB
<
sense
)
{
dec
->
ratioB
=
((
dec
->
ratioB
*
attackspeed
)
+
sense
)
/
(
attackspeed
+
1
.
0
);
}
else
{
dec
->
ratioB
=
1
.
0
+
((
dec
->
ratioB
-
1
.
0
)
/
recovery
);
}
dec
->
ratioB
=
FFMIN
(
dec
->
ratioB
,
maxdess
);
sample
=
dec
->
iirSampleB
+
((
sample
-
dec
->
iirSampleB
)
/
dec
->
ratioB
);
}
dec
->
flip
=
!
dec
->
flip
;
if
(
ctx
->
is_disabled
)
sample
=
src
[
i
];
switch
(
s
->
mode
)
{
case
IN_MODE
:
dst
[
i
]
=
src
[
i
];
break
;
case
OUT_MODE
:
dst
[
i
]
=
sample
;
break
;
case
ESS_MODE
:
dst
[
i
]
=
src
[
i
]
-
sample
;
break
;
}
}
}
if
(
out
!=
in
)
av_frame_free
(
&
in
);
return
ff_filter_frame
(
outlink
,
out
);
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
DeesserContext
*
s
=
ctx
->
priv
;
av_freep
(
&
s
->
chan
);
}
static
const
AVFilterPad
inputs
[]
=
{
{
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
filter_frame
=
filter_frame
,
.
config_props
=
config_input
,
},
{
NULL
}
};
static
const
AVFilterPad
outputs
[]
=
{
{
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
},
{
NULL
}
};
AVFilter
ff_af_deesser
=
{
.
name
=
"deesser"
,
.
description
=
NULL_IF_CONFIG_SMALL
(
"Apply de-essing to the audio."
),
.
query_formats
=
query_formats
,
.
priv_size
=
sizeof
(
DeesserContext
),
.
priv_class
=
&
deesser_class
,
.
uninit
=
uninit
,
.
inputs
=
inputs
,
.
outputs
=
outputs
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
,
};
libavfilter/allfilters.c
浏览文件 @
bd5e92ef
...
@@ -93,6 +93,7 @@ extern AVFilter ff_af_compensationdelay;
...
@@ -93,6 +93,7 @@ extern AVFilter ff_af_compensationdelay;
extern
AVFilter
ff_af_crossfeed
;
extern
AVFilter
ff_af_crossfeed
;
extern
AVFilter
ff_af_crystalizer
;
extern
AVFilter
ff_af_crystalizer
;
extern
AVFilter
ff_af_dcshift
;
extern
AVFilter
ff_af_dcshift
;
extern
AVFilter
ff_af_deesser
;
extern
AVFilter
ff_af_drmeter
;
extern
AVFilter
ff_af_drmeter
;
extern
AVFilter
ff_af_dynaudnorm
;
extern
AVFilter
ff_af_dynaudnorm
;
extern
AVFilter
ff_af_earwax
;
extern
AVFilter
ff_af_earwax
;
...
...
libavfilter/version.h
浏览文件 @
bd5e92ef
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#include "libavutil/version.h"
#define LIBAVFILTER_VERSION_MAJOR 7
#define LIBAVFILTER_VERSION_MAJOR 7
#define LIBAVFILTER_VERSION_MINOR 5
5
#define LIBAVFILTER_VERSION_MINOR 5
6
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录