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
be15304e
Commit
be15304e
authored
Dec 09, 2017
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_framerate: factorize get_scene_score
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
090b7406
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
47 deletions
+31
-47
vf_framerate.c
libavfilter/vf_framerate.c
+31
-47
No files found.
libavfilter/vf_framerate.c
View file @
be15304e
...
@@ -133,41 +133,35 @@ static av_always_inline int64_t sad_8x8_16(const uint16_t *src1, ptrdiff_t strid
...
@@ -133,41 +133,35 @@ static av_always_inline int64_t sad_8x8_16(const uint16_t *src1, ptrdiff_t strid
return
sum
;
return
sum
;
}
}
static
double
get_scene_score16
(
AVFilterContext
*
ctx
,
AVFrame
*
crnt
,
AVFrame
*
nex
t
)
static
int64_t
scene_sad16
(
FrameRateContext
*
s
,
const
uint16_t
*
p1
,
int
p1_linesize
,
const
uint16_t
*
p2
,
int
p2_linesize
,
int
heigh
t
)
{
{
FrameRateContext
*
s
=
ctx
->
priv
;
int64_t
sad
;
double
ret
=
0
;
int
x
,
y
;
for
(
sad
=
y
=
0
;
y
<
height
;
y
+=
8
)
{
ff_dlog
(
ctx
,
"get_scene_score16()
\n
"
);
for
(
x
=
0
;
x
<
p1_linesize
;
x
+=
8
)
{
sad
+=
sad_8x8_16
(
p1
+
y
*
p1_linesize
+
x
,
p1_linesize
,
p2
+
y
*
p2_linesize
+
x
,
p2_linesize
);
}
}
return
sad
;
}
if
(
crnt
&&
static
int64_t
scene_sad8
(
FrameRateContext
*
s
,
uint8_t
*
p1
,
int
p1_linesize
,
uint8_t
*
p2
,
int
p2_linesize
,
int
height
)
crnt
->
height
==
next
->
height
&&
{
crnt
->
width
==
next
->
width
)
{
int64_t
sad
;
int
x
,
y
;
int
x
,
y
;
int64_t
sad
;
for
(
sad
=
y
=
0
;
y
<
height
;
y
+=
8
)
{
double
mafd
,
diff
;
for
(
x
=
0
;
x
<
p1_linesize
;
x
+=
8
)
{
const
uint16_t
*
p1
=
(
const
uint16_t
*
)
crnt
->
data
[
0
];
sad
+=
s
->
sad
(
p1
+
y
*
p1_linesize
+
x
,
const
uint16_t
*
p2
=
(
const
uint16_t
*
)
next
->
data
[
0
];
p1_linesize
,
const
int
p1_linesize
=
crnt
->
linesize
[
0
]
/
2
;
p2
+
y
*
p2_linesize
+
x
,
const
int
p2_linesize
=
next
->
linesize
[
0
]
/
2
;
p2_linesize
);
ff_dlog
(
ctx
,
"get_scene_score16() process
\n
"
);
for
(
sad
=
y
=
0
;
y
<
crnt
->
height
;
y
+=
8
)
{
for
(
x
=
0
;
x
<
p1_linesize
;
x
+=
8
)
{
sad
+=
sad_8x8_16
(
p1
+
y
*
p1_linesize
+
x
,
p1_linesize
,
p2
+
y
*
p2_linesize
+
x
,
p2_linesize
);
}
}
}
mafd
=
sad
/
(
crnt
->
height
*
crnt
->
width
*
3
);
diff
=
fabs
(
mafd
-
s
->
prev_mafd
);
ret
=
av_clipf
(
FFMIN
(
mafd
,
diff
),
0
,
100
.
0
);
s
->
prev_mafd
=
mafd
;
}
}
ff_dlog
(
ctx
,
"get_scene_score16() result is:%f
\n
"
,
ret
);
emms_c
(
);
return
ret
;
return
sad
;
}
}
static
double
get_scene_score
(
AVFilterContext
*
ctx
,
AVFrame
*
crnt
,
AVFrame
*
next
)
static
double
get_scene_score
(
AVFilterContext
*
ctx
,
AVFrame
*
crnt
,
AVFrame
*
next
)
...
@@ -180,31 +174,21 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next
...
@@ -180,31 +174,21 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next
if
(
crnt
&&
if
(
crnt
&&
crnt
->
height
==
next
->
height
&&
crnt
->
height
==
next
->
height
&&
crnt
->
width
==
next
->
width
)
{
crnt
->
width
==
next
->
width
)
{
int
x
,
y
;
int64_t
sad
;
int64_t
sad
;
double
mafd
,
diff
;
double
mafd
,
diff
;
uint8_t
*
p1
=
crnt
->
data
[
0
];
uint8_t
*
p2
=
next
->
data
[
0
];
const
int
p1_linesize
=
crnt
->
linesize
[
0
];
const
int
p2_linesize
=
next
->
linesize
[
0
];
ff_dlog
(
ctx
,
"get_scene_score() process
\n
"
);
ff_dlog
(
ctx
,
"get_scene_score() process
\n
"
);
if
(
s
->
bitdepth
==
8
)
sad
=
scene_sad8
(
s
,
crnt
->
data
[
0
],
crnt
->
linesize
[
0
],
next
->
data
[
0
],
next
->
linesize
[
0
],
crnt
->
height
);
else
sad
=
scene_sad16
(
s
,
(
const
uint16_t
*
)
crnt
->
data
[
0
],
crnt
->
linesize
[
0
]
>>
1
,
(
const
uint16_t
*
)
next
->
data
[
0
],
next
->
linesize
[
0
]
>>
1
,
crnt
->
height
);
for
(
sad
=
y
=
0
;
y
<
crnt
->
height
;
y
+=
8
)
{
for
(
x
=
0
;
x
<
p1_linesize
;
x
+=
8
)
{
sad
+=
s
->
sad
(
p1
+
y
*
p1_linesize
+
x
,
p1_linesize
,
p2
+
y
*
p2_linesize
+
x
,
p2_linesize
);
}
}
emms_c
();
mafd
=
sad
/
(
crnt
->
height
*
crnt
->
width
*
3
);
mafd
=
sad
/
(
crnt
->
height
*
crnt
->
width
*
3
);
diff
=
fabs
(
mafd
-
s
->
prev_mafd
);
diff
=
fabs
(
mafd
-
s
->
prev_mafd
);
ret
=
av_clipf
(
FFMIN
(
mafd
,
diff
),
0
,
100
.
0
);
ret
=
av_clipf
(
FFMIN
(
mafd
,
diff
),
0
,
100
.
0
);
s
->
prev_mafd
=
mafd
;
s
->
prev_mafd
=
mafd
;
}
}
ff_dlog
(
ctx
,
"get_scene_score() result is:%f
\n
"
,
ret
);
ff_dlog
(
ctx
,
"get_scene_score() result is:%f
\n
"
,
ret
);
return
ret
;
return
ret
;
}
}
...
@@ -327,7 +311,7 @@ static int blend_frames(AVFilterContext *ctx, float interpolate,
...
@@ -327,7 +311,7 @@ static int blend_frames(AVFilterContext *ctx, float interpolate,
double
interpolate_scene_score
=
0
;
double
interpolate_scene_score
=
0
;
if
((
s
->
flags
&
FRAMERATE_FLAG_SCD
)
&&
copy_src2
)
{
if
((
s
->
flags
&
FRAMERATE_FLAG_SCD
)
&&
copy_src2
)
{
interpolate_scene_score
=
s
->
bitdepth
==
8
?
get_scene_score
(
ctx
,
copy_src1
,
copy_src2
)
:
get_scene_score16
(
ctx
,
copy_src1
,
copy_src2
);
interpolate_scene_score
=
get_scene_score
(
ctx
,
copy_src1
,
copy_src2
);
ff_dlog
(
ctx
,
"blend_frames() interpolate scene score:%f
\n
"
,
interpolate_scene_score
);
ff_dlog
(
ctx
,
"blend_frames() interpolate scene score:%f
\n
"
,
interpolate_scene_score
);
}
}
// decide if the shot-change detection allows us to blend two frames
// decide if the shot-change detection allows us to blend two frames
...
...
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