Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
683a1599
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,体验更适合开发者的 AI 搜索 >>
提交
683a1599
编写于
6月 21, 2020
作者:
P
Paul B Mahol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avfilter/af_ladspa: add latency compensation
上级
842bc312
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
3 deletion
+60
-3
doc/filters.texi
doc/filters.texi
+3
-0
libavfilter/af_ladspa.c
libavfilter/af_ladspa.c
+57
-3
未找到文件。
doc/filters.texi
浏览文件 @
683a1599
...
@@ -4197,6 +4197,9 @@ If not specified, or the expressed duration is negative, the audio is
...
@@ -4197,6 +4197,9 @@ If not specified, or the expressed duration is negative, the audio is
supposed to be generated forever.
supposed to be generated forever.
Only used if plugin have zero inputs.
Only used if plugin have zero inputs.
@item latency, l
Enable latency compensation, by default is disabled.
Only used if plugin have inputs.
@end table
@end table
@subsection Examples
@subsection Examples
...
...
libavfilter/af_ladspa.c
浏览文件 @
683a1599
...
@@ -64,6 +64,9 @@ typedef struct LADSPAContext {
...
@@ -64,6 +64,9 @@ typedef struct LADSPAContext {
int
nb_samples
;
int
nb_samples
;
int64_t
pts
;
int64_t
pts
;
int64_t
duration
;
int64_t
duration
;
int
in_trim
;
int
out_pad
;
int
latency
;
}
LADSPAContext
;
}
LADSPAContext
;
#define OFFSET(x) offsetof(LADSPAContext, x)
#define OFFSET(x) offsetof(LADSPAContext, x)
...
@@ -81,11 +84,28 @@ static const AVOption ladspa_options[] = {
...
@@ -81,11 +84,28 @@ static const AVOption ladspa_options[] = {
{
"n"
,
"set the number of samples per requested frame"
,
OFFSET
(
nb_samples
),
AV_OPT_TYPE_INT
,
{.
i64
=
1024
},
1
,
INT_MAX
,
FLAGS
},
{
"n"
,
"set the number of samples per requested frame"
,
OFFSET
(
nb_samples
),
AV_OPT_TYPE_INT
,
{.
i64
=
1024
},
1
,
INT_MAX
,
FLAGS
},
{
"duration"
,
"set audio duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
{
"duration"
,
"set audio duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
{
"d"
,
"set audio duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
{
"d"
,
"set audio duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=-
1
},
-
1
,
INT64_MAX
,
FLAGS
},
{
"latency"
,
"enable latency compensation"
,
OFFSET
(
latency
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"l"
,
"enable latency compensation"
,
OFFSET
(
latency
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
0
},
0
,
1
,
FLAGS
},
{
NULL
}
{
NULL
}
};
};
AVFILTER_DEFINE_CLASS
(
ladspa
);
AVFILTER_DEFINE_CLASS
(
ladspa
);
static
int
find_latency
(
AVFilterContext
*
ctx
,
LADSPAContext
*
s
)
{
int
latency
=
0
;
for
(
int
ctl
=
0
;
ctl
<
s
->
nb_outputcontrols
;
ctl
++
)
{
if
(
av_strcasecmp
(
"latency"
,
s
->
desc
->
PortNames
[
s
->
ocmap
[
ctl
]]))
continue
;
latency
=
lrintf
(
s
->
octlv
[
ctl
]);
break
;
}
return
latency
;
}
static
void
print_ctl_info
(
AVFilterContext
*
ctx
,
int
level
,
static
void
print_ctl_info
(
AVFilterContext
*
ctx
,
int
level
,
LADSPAContext
*
s
,
int
ctl
,
unsigned
long
*
map
,
LADSPAContext
*
s
,
int
ctl
,
unsigned
long
*
map
,
LADSPA_Data
*
values
,
int
print
)
LADSPA_Data
*
values
,
int
print
)
...
@@ -143,12 +163,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -143,12 +163,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterContext
*
ctx
=
inlink
->
dst
;
LADSPAContext
*
s
=
ctx
->
priv
;
LADSPAContext
*
s
=
ctx
->
priv
;
AVFrame
*
out
;
AVFrame
*
out
;
int
i
,
h
,
p
;
int
i
,
h
,
p
,
new_out_samples
;
av_assert0
(
in
->
channels
==
(
s
->
nb_inputs
*
s
->
nb_handles
));
av_assert0
(
in
->
channels
==
(
s
->
nb_inputs
*
s
->
nb_handles
));
if
(
!
s
->
nb_outputs
||
if
(
!
s
->
nb_outputs
||
(
av_frame_is_writable
(
in
)
&&
s
->
nb_inputs
==
s
->
nb_outputs
&&
(
av_frame_is_writable
(
in
)
&&
s
->
nb_inputs
==
s
->
nb_outputs
&&
s
->
in_trim
==
0
&&
s
->
out_pad
==
0
&&
!
(
s
->
desc
->
Properties
&
LADSPA_PROPERTY_INPLACE_BROKEN
)))
{
!
(
s
->
desc
->
Properties
&
LADSPA_PROPERTY_INPLACE_BROKEN
)))
{
out
=
in
;
out
=
in
;
}
else
{
}
else
{
...
@@ -176,6 +197,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -176,6 +197,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
}
s
->
desc
->
run
(
s
->
handles
[
h
],
in
->
nb_samples
);
s
->
desc
->
run
(
s
->
handles
[
h
],
in
->
nb_samples
);
if
(
s
->
latency
)
s
->
in_trim
=
s
->
out_pad
=
find_latency
(
ctx
,
s
);
s
->
latency
=
0
;
}
}
for
(
i
=
0
;
i
<
s
->
nb_outputcontrols
;
i
++
)
for
(
i
=
0
;
i
<
s
->
nb_outputcontrols
;
i
++
)
...
@@ -184,6 +208,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -184,6 +208,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
if
(
out
!=
in
)
if
(
out
!=
in
)
av_frame_free
(
&
in
);
av_frame_free
(
&
in
);
new_out_samples
=
out
->
nb_samples
;
if
(
s
->
in_trim
>
0
)
{
int
trim
=
FFMIN
(
new_out_samples
,
s
->
in_trim
);
new_out_samples
-=
trim
;
s
->
in_trim
-=
trim
;
}
if
(
new_out_samples
<=
0
)
{
av_frame_free
(
&
out
);
return
0
;
}
else
if
(
new_out_samples
<
out
->
nb_samples
)
{
int
offset
=
out
->
nb_samples
-
new_out_samples
;
for
(
int
ch
=
0
;
ch
<
out
->
channels
;
ch
++
)
memmove
(
out
->
extended_data
[
ch
],
out
->
extended_data
[
ch
]
+
sizeof
(
float
)
*
offset
,
sizeof
(
float
)
*
new_out_samples
);
out
->
nb_samples
=
new_out_samples
;
}
return
ff_filter_frame
(
ctx
->
outputs
[
0
],
out
);
return
ff_filter_frame
(
ctx
->
outputs
[
0
],
out
);
}
}
...
@@ -195,8 +238,19 @@ static int request_frame(AVFilterLink *outlink)
...
@@ -195,8 +238,19 @@ static int request_frame(AVFilterLink *outlink)
int64_t
t
;
int64_t
t
;
int
i
;
int
i
;
if
(
ctx
->
nb_inputs
)
if
(
ctx
->
nb_inputs
)
{
return
ff_request_frame
(
ctx
->
inputs
[
0
]);
int
ret
=
ff_request_frame
(
ctx
->
inputs
[
0
]);
if
(
ret
==
AVERROR_EOF
&&
s
->
out_pad
>
0
)
{
AVFrame
*
frame
=
ff_get_audio_buffer
(
outlink
,
FFMIN
(
2048
,
s
->
out_pad
));
if
(
!
frame
)
return
AVERROR
(
ENOMEM
);
s
->
out_pad
-=
frame
->
nb_samples
;
return
filter_frame
(
ctx
->
inputs
[
0
],
frame
);
}
return
ret
;
}
t
=
av_rescale
(
s
->
pts
,
AV_TIME_BASE
,
s
->
sample_rate
);
t
=
av_rescale
(
s
->
pts
,
AV_TIME_BASE
,
s
->
sample_rate
);
if
(
s
->
duration
>=
0
&&
t
>=
s
->
duration
)
if
(
s
->
duration
>=
0
&&
t
>=
s
->
duration
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录