Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
8248f7b9
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 搜索 >>
提交
8248f7b9
编写于
1月 29, 2021
作者:
P
Paul B Mahol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avfilter/vf_blackdetect: fix bug when no final log would be displayed
上级
0bcba12a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
25 deletion
+22
-25
libavfilter/vf_blackdetect.c
libavfilter/vf_blackdetect.c
+22
-25
未找到文件。
libavfilter/vf_blackdetect.c
浏览文件 @
8248f7b9
...
...
@@ -44,6 +44,7 @@ typedef struct BlackDetectContext {
unsigned
int
pixel_black_th_i
;
unsigned
int
nb_black_pixels
;
///< number of black pixels counted so far
AVRational
time_base
;
}
BlackDetectContext
;
#define OFFSET(x) offsetof(BlackDetectContext, x)
...
...
@@ -91,7 +92,8 @@ static int config_input(AVFilterLink *inlink)
AVFilterContext
*
ctx
=
inlink
->
dst
;
BlackDetectContext
*
s
=
ctx
->
priv
;
s
->
black_min_duration
=
s
->
black_min_duration_time
/
av_q2d
(
inlink
->
time_base
);
s
->
time_base
=
inlink
->
time_base
;
s
->
black_min_duration
=
s
->
black_min_duration_time
/
av_q2d
(
s
->
time_base
);
s
->
pixel_black_th_i
=
ff_fmt_is_in
(
inlink
->
format
,
yuvj_formats
)
?
// luminance_minimum_value + pixel_black_th * luminance_range_size
...
...
@@ -100,7 +102,7 @@ static int config_input(AVFilterLink *inlink)
av_log
(
s
,
AV_LOG_VERBOSE
,
"black_min_duration:%s pixel_black_th:%f pixel_black_th_i:%d picture_black_ratio_th:%f
\n
"
,
av_ts2timestr
(
s
->
black_min_duration
,
&
inlink
->
time_base
),
av_ts2timestr
(
s
->
black_min_duration
,
&
s
->
time_base
),
s
->
pixel_black_th
,
s
->
pixel_black_th_i
,
s
->
picture_black_ratio_th
);
return
0
;
...
...
@@ -109,32 +111,16 @@ static int config_input(AVFilterLink *inlink)
static
void
check_black_end
(
AVFilterContext
*
ctx
)
{
BlackDetectContext
*
s
=
ctx
->
priv
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
if
((
s
->
black_end
-
s
->
black_start
)
>=
s
->
black_min_duration
)
{
av_log
(
s
,
AV_LOG_INFO
,
"black_start:%s black_end:%s black_duration:%s
\n
"
,
av_ts2timestr
(
s
->
black_start
,
&
inlink
->
time_base
),
av_ts2timestr
(
s
->
black_end
,
&
inlink
->
time_base
),
av_ts2timestr
(
s
->
black_end
-
s
->
black_start
,
&
inlink
->
time_base
));
av_ts2timestr
(
s
->
black_start
,
&
s
->
time_base
),
av_ts2timestr
(
s
->
black_end
,
&
s
->
time_base
),
av_ts2timestr
(
s
->
black_end
-
s
->
black_start
,
&
s
->
time_base
));
}
}
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
AVFilterContext
*
ctx
=
outlink
->
src
;
BlackDetectContext
*
s
=
ctx
->
priv
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
int
ret
=
ff_request_frame
(
inlink
);
if
(
ret
==
AVERROR_EOF
&&
s
->
black_started
)
{
// FIXME: black_end should be set to last_picref_pts + last_picref_duration
s
->
black_end
=
s
->
last_picref_pts
;
check_black_end
(
ctx
);
}
return
ret
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
picref
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
...
...
@@ -154,7 +140,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
av_log
(
ctx
,
AV_LOG_DEBUG
,
"frame:%"
PRId64
" picture_black_ratio:%f pts:%s t:%s type:%c
\n
"
,
inlink
->
frame_count_out
,
picture_black_ratio
,
av_ts2str
(
picref
->
pts
),
av_ts2timestr
(
picref
->
pts
,
&
inlink
->
time_base
),
av_ts2str
(
picref
->
pts
),
av_ts2timestr
(
picref
->
pts
,
&
s
->
time_base
),
av_get_picture_type_char
(
picref
->
pict_type
));
if
(
picture_black_ratio
>=
s
->
picture_black_ratio_th
)
{
...
...
@@ -163,7 +149,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
s
->
black_started
=
1
;
s
->
black_start
=
picref
->
pts
;
av_dict_set
(
&
picref
->
metadata
,
"lavfi.black_start"
,
av_ts2timestr
(
s
->
black_start
,
&
inlink
->
time_base
),
0
);
av_ts2timestr
(
s
->
black_start
,
&
s
->
time_base
),
0
);
}
}
else
if
(
s
->
black_started
)
{
/* black ends here */
...
...
@@ -171,7 +157,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
s
->
black_end
=
picref
->
pts
;
check_black_end
(
ctx
);
av_dict_set
(
&
picref
->
metadata
,
"lavfi.black_end"
,
av_ts2timestr
(
s
->
black_end
,
&
inlink
->
time_base
),
0
);
av_ts2timestr
(
s
->
black_end
,
&
s
->
time_base
),
0
);
}
s
->
last_picref_pts
=
picref
->
pts
;
...
...
@@ -179,6 +165,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
return
ff_filter_frame
(
inlink
->
dst
->
outputs
[
0
],
picref
);
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
BlackDetectContext
*
s
=
ctx
->
priv
;
if
(
s
->
black_started
)
{
// FIXME: black_end should be set to last_picref_pts + last_picref_duration
s
->
black_end
=
s
->
last_picref_pts
;
check_black_end
(
ctx
);
}
}
static
const
AVFilterPad
blackdetect_inputs
[]
=
{
{
.
name
=
"default"
,
...
...
@@ -193,7 +190,6 @@ static const AVFilterPad blackdetect_outputs[] = {
{
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
request_frame
=
request_frame
,
},
{
NULL
}
};
...
...
@@ -205,5 +201,6 @@ AVFilter ff_vf_blackdetect = {
.
query_formats
=
query_formats
,
.
inputs
=
blackdetect_inputs
,
.
outputs
=
blackdetect_outputs
,
.
uninit
=
uninit
,
.
priv_class
=
&
blackdetect_class
,
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录