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
06e990ce
Commit
06e990ce
authored
Sep 11, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_limiter: add slice threading
parent
7115ad53
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
16 deletions
+44
-16
vf_limiter.c
libavfilter/vf_limiter.c
+44
-16
No files found.
libavfilter/vf_limiter.c
View file @
06e990ce
...
...
@@ -28,6 +28,11 @@
#include "limiter.h"
#include "video.h"
typedef
struct
ThreadData
{
AVFrame
*
in
;
AVFrame
*
out
;
}
ThreadData
;
typedef
struct
LimiterContext
{
const
AVClass
*
class
;
int
min
;
...
...
@@ -161,13 +166,46 @@ static int config_props(AVFilterLink *inlink)
return
0
;
}
static
int
filter_slice
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
LimiterContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
int
p
;
for
(
p
=
0
;
p
<
s
->
nb_planes
;
p
++
)
{
const
int
h
=
s
->
height
[
p
];
const
int
slice_start
=
(
h
*
jobnr
)
/
nb_jobs
;
const
int
slice_end
=
(
h
*
(
jobnr
+
1
))
/
nb_jobs
;
if
(
!
((
1
<<
p
)
&
s
->
planes
))
{
if
(
out
!=
in
)
av_image_copy_plane
(
out
->
data
[
p
]
+
slice_start
*
out
->
linesize
[
p
],
out
->
linesize
[
p
],
in
->
data
[
p
]
+
slice_start
*
in
->
linesize
[
p
],
in
->
linesize
[
p
],
s
->
linesize
[
p
],
slice_end
-
slice_start
);
continue
;
}
s
->
dsp
.
limiter
(
in
->
data
[
p
]
+
slice_start
*
in
->
linesize
[
p
],
out
->
data
[
p
]
+
slice_start
*
out
->
linesize
[
p
],
in
->
linesize
[
p
],
out
->
linesize
[
p
],
s
->
width
[
p
],
slice_end
-
slice_start
,
s
->
min
,
s
->
max
);
}
return
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
LimiterContext
*
s
=
ctx
->
priv
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
ThreadData
td
;
AVFrame
*
out
;
int
p
;
if
(
av_frame_is_writable
(
in
))
{
out
=
in
;
...
...
@@ -180,20 +218,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
av_frame_copy_props
(
out
,
in
);
}
for
(
p
=
0
;
p
<
s
->
nb_planes
;
p
++
)
{
if
(
!
((
1
<<
p
)
&
s
->
planes
))
{
if
(
out
!=
in
)
av_image_copy_plane
(
out
->
data
[
p
],
out
->
linesize
[
p
],
in
->
data
[
p
],
in
->
linesize
[
p
],
s
->
linesize
[
p
],
s
->
height
[
p
]);
continue
;
}
s
->
dsp
.
limiter
(
in
->
data
[
p
],
out
->
data
[
p
],
in
->
linesize
[
p
],
out
->
linesize
[
p
],
s
->
width
[
p
],
s
->
height
[
p
],
s
->
min
,
s
->
max
);
}
td
.
out
=
out
;
td
.
in
=
in
;
ctx
->
internal
->
execute
(
ctx
,
filter_slice
,
&
td
,
NULL
,
FFMIN
(
s
->
height
[
2
],
ff_filter_get_nb_threads
(
ctx
)));
if
(
out
!=
in
)
av_frame_free
(
&
in
);
...
...
@@ -227,5 +255,5 @@ AVFilter ff_vf_limiter = {
.
query_formats
=
query_formats
,
.
inputs
=
inputs
,
.
outputs
=
outputs
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
|
AVFILTER_FLAG_SLICE_THREADS
,
};
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