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
5bfc433a
Commit
5bfc433a
authored
May 01, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_neighbor: add slice threading
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
ddf844d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
16 deletions
+38
-16
vf_neighbor.c
libavfilter/vf_neighbor.c
+38
-16
No files found.
libavfilter/vf_neighbor.c
View file @
5bfc433a
...
...
@@ -27,6 +27,10 @@
#include "internal.h"
#include "video.h"
typedef
struct
ThreadData
{
AVFrame
*
in
,
*
out
;
}
ThreadData
;
typedef
struct
NContext
{
const
AVClass
*
class
;
int
planeheight
[
4
];
...
...
@@ -148,36 +152,31 @@ static int config_input(AVFilterLink *inlink)
return
0
;
}
static
int
filter_
frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
static
int
filter_
slice
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
NContext
*
s
=
ctx
->
priv
;
AVFrame
*
out
;
ThreadData
*
td
=
arg
;
AVFrame
*
out
=
td
->
out
;
AVFrame
*
in
=
td
->
in
;
int
plane
,
y
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
in
);
for
(
plane
=
0
;
plane
<
s
->
nb_planes
;
plane
++
)
{
const
int
threshold
=
s
->
threshold
[
plane
];
const
int
stride
=
in
->
linesize
[
plane
];
const
int
dstride
=
out
->
linesize
[
plane
];
const
uint8_t
*
src
=
in
->
data
[
plane
];
uint8_t
*
dst
=
out
->
data
[
plane
];
const
int
height
=
s
->
planeheight
[
plane
];
const
int
width
=
s
->
planewidth
[
plane
];
const
int
slice_start
=
(
height
*
jobnr
)
/
nb_jobs
;
const
int
slice_end
=
(
height
*
(
jobnr
+
1
))
/
nb_jobs
;
const
uint8_t
*
src
=
(
const
uint8_t
*
)
in
->
data
[
plane
]
+
slice_start
*
stride
;
uint8_t
*
dst
=
out
->
data
[
plane
]
+
slice_start
*
dstride
;
if
(
!
threshold
)
{
av_image_copy_plane
(
dst
,
dstride
,
src
,
stride
,
width
,
heigh
t
);
av_image_copy_plane
(
dst
,
dstride
,
src
,
stride
,
width
,
slice_end
-
slice_star
t
);
continue
;
}
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
y
=
slice_start
;
y
<
slice_end
;
y
++
)
{
const
int
nh
=
y
>
0
;
const
int
ph
=
y
<
height
-
1
;
const
uint8_t
*
coordinates
[]
=
{
src
-
nh
*
stride
,
src
+
1
-
nh
*
stride
,
src
+
2
-
nh
*
stride
,
...
...
@@ -201,6 +200,28 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
}
return
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
NContext
*
s
=
ctx
->
priv
;
ThreadData
td
;
AVFrame
*
out
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
in
);
td
.
in
=
in
;
td
.
out
=
out
;
ctx
->
internal
->
execute
(
ctx
,
filter_slice
,
&
td
,
NULL
,
FFMIN
(
s
->
planeheight
[
1
],
ff_filter_get_nb_threads
(
ctx
)));
av_frame_free
(
&
in
);
return
ff_filter_frame
(
outlink
,
out
);
}
...
...
@@ -237,7 +258,8 @@ AVFilter ff_vf_##name_ = { \
.query_formats = query_formats, \
.inputs = neighbor_inputs, \
.outputs = neighbor_outputs, \
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, \
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC| \
AVFILTER_FLAG_SLICE_THREADS, \
}
#if CONFIG_EROSION_FILTER
...
...
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