Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
ef217647
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,发现更多精彩内容 >>
提交
ef217647
编写于
7月 31, 2017
作者:
N
Nicolas George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vf_ssim: convert to framesync2.
上级
3bd11df4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
26 deletion
+28
-26
libavfilter/Makefile
libavfilter/Makefile
+1
-1
libavfilter/vf_ssim.c
libavfilter/vf_ssim.c
+27
-25
未找到文件。
libavfilter/Makefile
浏览文件 @
ef217647
...
@@ -301,7 +301,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER) += vf_smartblur.o
...
@@ -301,7 +301,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER) += vf_smartblur.o
OBJS-$(CONFIG_SOBEL_FILTER)
+=
vf_convolution.o
OBJS-$(CONFIG_SOBEL_FILTER)
+=
vf_convolution.o
OBJS-$(CONFIG_SPLIT_FILTER)
+=
split.o
OBJS-$(CONFIG_SPLIT_FILTER)
+=
split.o
OBJS-$(CONFIG_SPP_FILTER)
+=
vf_spp.o
OBJS-$(CONFIG_SPP_FILTER)
+=
vf_spp.o
OBJS-$(CONFIG_SSIM_FILTER)
+=
vf_ssim.o
dualinput.o framesync
.o
OBJS-$(CONFIG_SSIM_FILTER)
+=
vf_ssim.o
framesync2
.o
OBJS-$(CONFIG_STEREO3D_FILTER)
+=
vf_stereo3d.o
OBJS-$(CONFIG_STEREO3D_FILTER)
+=
vf_stereo3d.o
OBJS-$(CONFIG_STREAMSELECT_FILTER)
+=
f_streamselect.o framesync2.o
OBJS-$(CONFIG_STREAMSELECT_FILTER)
+=
f_streamselect.o framesync2.o
OBJS-$(CONFIG_SUBTITLES_FILTER)
+=
vf_subtitles.o
OBJS-$(CONFIG_SUBTITLES_FILTER)
+=
vf_subtitles.o
...
...
libavfilter/vf_ssim.c
浏览文件 @
ef217647
...
@@ -38,16 +38,16 @@
...
@@ -38,16 +38,16 @@
#include "libavutil/opt.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "avfilter.h"
#include "dualinput.h"
#include "drawutils.h"
#include "drawutils.h"
#include "formats.h"
#include "formats.h"
#include "framesync2.h"
#include "internal.h"
#include "internal.h"
#include "ssim.h"
#include "ssim.h"
#include "video.h"
#include "video.h"
typedef
struct
SSIMContext
{
typedef
struct
SSIMContext
{
const
AVClass
*
class
;
const
AVClass
*
class
;
FF
DualInputContext
dinput
;
FF
FrameSync
fs
;
FILE
*
stats_file
;
FILE
*
stats_file
;
char
*
stats_file_str
;
char
*
stats_file_str
;
int
nb_components
;
int
nb_components
;
...
@@ -78,7 +78,7 @@ static const AVOption ssim_options[] = {
...
@@ -78,7 +78,7 @@ static const AVOption ssim_options[] = {
{
NULL
}
{
NULL
}
};
};
AVFILTER_DEFINE_CLASS
(
ssim
);
FRAMESYNC_DEFINE_CLASS
(
ssim
,
SSIMContext
,
fs
);
static
void
set_meta
(
AVDictionary
**
metadata
,
const
char
*
key
,
char
comp
,
float
d
)
static
void
set_meta
(
AVDictionary
**
metadata
,
const
char
*
key
,
char
comp
,
float
d
)
{
{
...
@@ -282,13 +282,21 @@ static double ssim_db(double ssim, double weight)
...
@@ -282,13 +282,21 @@ static double ssim_db(double ssim, double weight)
return
10
*
log10
(
weight
/
(
weight
-
ssim
));
return
10
*
log10
(
weight
/
(
weight
-
ssim
));
}
}
static
AVFrame
*
do_ssim
(
AVFilterContext
*
ctx
,
AVFrame
*
main
,
static
int
do_ssim
(
FFFrameSync
*
fs
)
const
AVFrame
*
ref
)
{
{
AV
Dictionary
**
metadata
=
&
main
->
metadata
;
AV
FilterContext
*
ctx
=
fs
->
parent
;
SSIMContext
*
s
=
ctx
->
priv
;
SSIMContext
*
s
=
ctx
->
priv
;
AVFrame
*
main
,
*
ref
;
AVDictionary
**
metadata
;
float
c
[
4
],
ssimv
=
0
.
0
;
float
c
[
4
],
ssimv
=
0
.
0
;
int
i
;
int
ret
,
i
;
ret
=
ff_framesync2_dualinput_get
(
fs
,
&
main
,
&
ref
);
if
(
ret
<
0
)
return
ret
;
if
(
!
ref
)
return
ff_filter_frame
(
ctx
->
outputs
[
0
],
main
);
metadata
=
&
main
->
metadata
;
s
->
nb_frames
++
;
s
->
nb_frames
++
;
...
@@ -320,7 +328,7 @@ static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame *main,
...
@@ -320,7 +328,7 @@ static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame *main,
fprintf
(
s
->
stats_file
,
"All:%f (%f)
\n
"
,
ssimv
,
ssim_db
(
ssimv
,
1
.
0
));
fprintf
(
s
->
stats_file
,
"All:%f (%f)
\n
"
,
ssimv
,
ssim_db
(
ssimv
,
1
.
0
));
}
}
return
main
;
return
ff_filter_frame
(
ctx
->
outputs
[
0
],
main
)
;
}
}
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
...
@@ -343,9 +351,7 @@ static av_cold int init(AVFilterContext *ctx)
...
@@ -343,9 +351,7 @@ static av_cold int init(AVFilterContext *ctx)
}
}
}
}
s
->
dinput
.
process
=
do_ssim
;
s
->
fs
.
on_event
=
do_ssim
;
s
->
dinput
.
shortest
=
1
;
s
->
dinput
.
repeatlast
=
0
;
return
0
;
return
0
;
}
}
...
@@ -425,28 +431,25 @@ static int config_output(AVFilterLink *outlink)
...
@@ -425,28 +431,25 @@ static int config_output(AVFilterLink *outlink)
AVFilterLink
*
mainlink
=
ctx
->
inputs
[
0
];
AVFilterLink
*
mainlink
=
ctx
->
inputs
[
0
];
int
ret
;
int
ret
;
ret
=
ff_framesync2_init_dualinput
(
&
s
->
fs
,
ctx
);
if
(
ret
<
0
)
return
ret
;
outlink
->
w
=
mainlink
->
w
;
outlink
->
w
=
mainlink
->
w
;
outlink
->
h
=
mainlink
->
h
;
outlink
->
h
=
mainlink
->
h
;
outlink
->
time_base
=
mainlink
->
time_base
;
outlink
->
time_base
=
mainlink
->
time_base
;
outlink
->
sample_aspect_ratio
=
mainlink
->
sample_aspect_ratio
;
outlink
->
sample_aspect_ratio
=
mainlink
->
sample_aspect_ratio
;
outlink
->
frame_rate
=
mainlink
->
frame_rate
;
outlink
->
frame_rate
=
mainlink
->
frame_rate
;
if
((
ret
=
ff_
dualinput_init
(
ctx
,
&
s
->
dinput
))
<
0
)
if
((
ret
=
ff_
framesync2_configure
(
&
s
->
fs
))
<
0
)
return
ret
;
return
ret
;
return
0
;
return
0
;
}
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
buf
)
static
int
activate
(
AVFilterContext
*
ctx
)
{
{
SSIMContext
*
s
=
inlink
->
dst
->
priv
;
SSIMContext
*
s
=
ctx
->
priv
;
return
ff_dualinput_filter_frame
(
&
s
->
dinput
,
inlink
,
buf
);
return
ff_framesync2_activate
(
&
s
->
fs
);
}
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
SSIMContext
*
s
=
outlink
->
src
->
priv
;
return
ff_dualinput_request_frame
(
&
s
->
dinput
,
outlink
);
}
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
...
@@ -466,7 +469,7 @@ static av_cold void uninit(AVFilterContext *ctx)
...
@@ -466,7 +469,7 @@ static av_cold void uninit(AVFilterContext *ctx)
s
->
ssim_total
/
s
->
nb_frames
,
ssim_db
(
s
->
ssim_total
,
s
->
nb_frames
));
s
->
ssim_total
/
s
->
nb_frames
,
ssim_db
(
s
->
ssim_total
,
s
->
nb_frames
));
}
}
ff_
dualinput_uninit
(
&
s
->
dinput
);
ff_
framesync2_uninit
(
&
s
->
fs
);
if
(
s
->
stats_file
&&
s
->
stats_file
!=
stdout
)
if
(
s
->
stats_file
&&
s
->
stats_file
!=
stdout
)
fclose
(
s
->
stats_file
);
fclose
(
s
->
stats_file
);
...
@@ -478,11 +481,9 @@ static const AVFilterPad ssim_inputs[] = {
...
@@ -478,11 +481,9 @@ static const AVFilterPad ssim_inputs[] = {
{
{
.
name
=
"main"
,
.
name
=
"main"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
filter_frame
=
filter_frame
,
},{
},{
.
name
=
"reference"
,
.
name
=
"reference"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
filter_frame
=
filter_frame
,
.
config_props
=
config_input_ref
,
.
config_props
=
config_input_ref
,
},
},
{
NULL
}
{
NULL
}
...
@@ -493,7 +494,6 @@ static const AVFilterPad ssim_outputs[] = {
...
@@ -493,7 +494,6 @@ static const AVFilterPad ssim_outputs[] = {
.
name
=
"default"
,
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
config_props
=
config_output
,
.
config_props
=
config_output
,
.
request_frame
=
request_frame
,
},
},
{
NULL
}
{
NULL
}
};
};
...
@@ -501,9 +501,11 @@ static const AVFilterPad ssim_outputs[] = {
...
@@ -501,9 +501,11 @@ static const AVFilterPad ssim_outputs[] = {
AVFilter
ff_vf_ssim
=
{
AVFilter
ff_vf_ssim
=
{
.
name
=
"ssim"
,
.
name
=
"ssim"
,
.
description
=
NULL_IF_CONFIG_SMALL
(
"Calculate the SSIM between two video streams."
),
.
description
=
NULL_IF_CONFIG_SMALL
(
"Calculate the SSIM between two video streams."
),
.
preinit
=
ssim_framesync_preinit
,
.
init
=
init
,
.
init
=
init
,
.
uninit
=
uninit
,
.
uninit
=
uninit
,
.
query_formats
=
query_formats
,
.
query_formats
=
query_formats
,
.
activate
=
activate
,
.
priv_size
=
sizeof
(
SSIMContext
),
.
priv_size
=
sizeof
(
SSIMContext
),
.
priv_class
=
&
ssim_class
,
.
priv_class
=
&
ssim_class
,
.
inputs
=
ssim_inputs
,
.
inputs
=
ssim_inputs
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录