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
ef217647
Commit
ef217647
authored
Jul 31, 2017
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_ssim: convert to framesync2.
parent
3bd11df4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
26 deletions
+28
-26
Makefile
libavfilter/Makefile
+1
-1
vf_ssim.c
libavfilter/vf_ssim.c
+27
-25
No files found.
libavfilter/Makefile
View file @
ef217647
...
...
@@ -301,7 +301,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER) += vf_smartblur.o
OBJS-$(CONFIG_SOBEL_FILTER)
+=
vf_convolution.o
OBJS-$(CONFIG_SPLIT_FILTER)
+=
split.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_STREAMSELECT_FILTER)
+=
f_streamselect.o
framesync2.o
OBJS-$(CONFIG_SUBTITLES_FILTER)
+=
vf_subtitles.o
...
...
libavfilter/vf_ssim.c
View file @
ef217647
...
...
@@ -38,16 +38,16 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "dualinput.h"
#include "drawutils.h"
#include "formats.h"
#include "framesync2.h"
#include "internal.h"
#include "ssim.h"
#include "video.h"
typedef
struct
SSIMContext
{
const
AVClass
*
class
;
FF
DualInputContext
dinput
;
FF
FrameSync
fs
;
FILE
*
stats_file
;
char
*
stats_file_str
;
int
nb_components
;
...
...
@@ -78,7 +78,7 @@ static const AVOption ssim_options[] = {
{
NULL
}
};
AVFILTER_DEFINE_CLASS
(
ssim
);
FRAMESYNC_DEFINE_CLASS
(
ssim
,
SSIMContext
,
fs
);
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)
return
10
*
log10
(
weight
/
(
weight
-
ssim
));
}
static
AVFrame
*
do_ssim
(
AVFilterContext
*
ctx
,
AVFrame
*
main
,
const
AVFrame
*
ref
)
static
int
do_ssim
(
FFFrameSync
*
fs
)
{
AV
Dictionary
**
metadata
=
&
main
->
metadata
;
AV
FilterContext
*
ctx
=
fs
->
parent
;
SSIMContext
*
s
=
ctx
->
priv
;
AVFrame
*
main
,
*
ref
;
AVDictionary
**
metadata
;
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
++
;
...
...
@@ -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
));
}
return
main
;
return
ff_filter_frame
(
ctx
->
outputs
[
0
],
main
)
;
}
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
...
...
@@ -343,9 +351,7 @@ static av_cold int init(AVFilterContext *ctx)
}
}
s
->
dinput
.
process
=
do_ssim
;
s
->
dinput
.
shortest
=
1
;
s
->
dinput
.
repeatlast
=
0
;
s
->
fs
.
on_event
=
do_ssim
;
return
0
;
}
...
...
@@ -425,28 +431,25 @@ static int config_output(AVFilterLink *outlink)
AVFilterLink
*
mainlink
=
ctx
->
inputs
[
0
];
int
ret
;
ret
=
ff_framesync2_init_dualinput
(
&
s
->
fs
,
ctx
);
if
(
ret
<
0
)
return
ret
;
outlink
->
w
=
mainlink
->
w
;
outlink
->
h
=
mainlink
->
h
;
outlink
->
time_base
=
mainlink
->
time_base
;
outlink
->
sample_aspect_ratio
=
mainlink
->
sample_aspect_ratio
;
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
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
buf
)
static
int
activate
(
AVFilterContext
*
ctx
)
{
SSIMContext
*
s
=
inlink
->
dst
->
priv
;
return
ff_dualinput_filter_frame
(
&
s
->
dinput
,
inlink
,
buf
);
}
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
SSIMContext
*
s
=
outlink
->
src
->
priv
;
return
ff_dualinput_request_frame
(
&
s
->
dinput
,
outlink
);
SSIMContext
*
s
=
ctx
->
priv
;
return
ff_framesync2_activate
(
&
s
->
fs
);
}
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
));
}
ff_
dualinput_uninit
(
&
s
->
dinput
);
ff_
framesync2_uninit
(
&
s
->
fs
);
if
(
s
->
stats_file
&&
s
->
stats_file
!=
stdout
)
fclose
(
s
->
stats_file
);
...
...
@@ -478,11 +481,9 @@ static const AVFilterPad ssim_inputs[] = {
{
.
name
=
"main"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
filter_frame
=
filter_frame
,
},{
.
name
=
"reference"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
filter_frame
=
filter_frame
,
.
config_props
=
config_input_ref
,
},
{
NULL
}
...
...
@@ -493,7 +494,6 @@ static const AVFilterPad ssim_outputs[] = {
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
config_props
=
config_output
,
.
request_frame
=
request_frame
,
},
{
NULL
}
};
...
...
@@ -501,9 +501,11 @@ static const AVFilterPad ssim_outputs[] = {
AVFilter
ff_vf_ssim
=
{
.
name
=
"ssim"
,
.
description
=
NULL_IF_CONFIG_SMALL
(
"Calculate the SSIM between two video streams."
),
.
preinit
=
ssim_framesync_preinit
,
.
init
=
init
,
.
uninit
=
uninit
,
.
query_formats
=
query_formats
,
.
activate
=
activate
,
.
priv_size
=
sizeof
(
SSIMContext
),
.
priv_class
=
&
ssim_class
,
.
inputs
=
ssim_inputs
,
...
...
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