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
1c2e5fc4
Commit
1c2e5fc4
authored
May 12, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_maskedmerge: add slice threading
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
9b6f8fb2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
17 deletions
+50
-17
vf_maskedmerge.c
libavfilter/vf_maskedmerge.c
+50
-17
No files found.
libavfilter/vf_maskedmerge.c
View file @
1c2e5fc4
...
...
@@ -63,12 +63,55 @@ static int query_formats(AVFilterContext *ctx)
return
ff_set_common_formats
(
ctx
,
ff_make_format_list
(
pix_fmts
));
}
typedef
struct
ThreadData
{
AVFrame
*
base
,
*
overlay
,
*
mask
;
AVFrame
*
out
;
}
ThreadData
;
static
int
filter_slice
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
MaskedMergeContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
base
=
td
->
base
;
AVFrame
*
overlay
=
td
->
overlay
;
AVFrame
*
mask
=
td
->
mask
;
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
))
{
av_image_copy_plane
(
out
->
data
[
p
]
+
slice_start
*
out
->
linesize
[
p
],
out
->
linesize
[
p
],
base
->
data
[
p
]
+
slice_start
*
base
->
linesize
[
p
],
base
->
linesize
[
p
],
s
->
linesize
[
p
],
slice_end
-
slice_start
);
continue
;
}
s
->
maskedmerge
(
base
->
data
[
p
]
+
slice_start
*
base
->
linesize
[
p
],
overlay
->
data
[
p
]
+
slice_start
*
overlay
->
linesize
[
p
],
mask
->
data
[
p
]
+
slice_start
*
mask
->
linesize
[
p
],
out
->
data
[
p
]
+
slice_start
*
out
->
linesize
[
p
],
base
->
linesize
[
p
],
overlay
->
linesize
[
p
],
mask
->
linesize
[
p
],
out
->
linesize
[
p
],
s
->
width
[
p
],
slice_end
-
slice_start
,
s
->
half
,
s
->
depth
);
}
return
0
;
}
static
int
process_frame
(
FFFrameSync
*
fs
)
{
AVFilterContext
*
ctx
=
fs
->
parent
;
MaskedMergeContext
*
s
=
fs
->
opaque
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AVFrame
*
out
,
*
base
,
*
overlay
,
*
mask
;
ThreadData
td
;
int
ret
;
if
((
ret
=
ff_framesync_get_frame
(
&
s
->
fs
,
0
,
&
base
,
0
))
<
0
||
...
...
@@ -81,27 +124,17 @@ static int process_frame(FFFrameSync *fs)
if
(
!
out
)
return
AVERROR
(
ENOMEM
);
}
else
{
int
p
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
return
AVERROR
(
ENOMEM
);
av_frame_copy_props
(
out
,
base
);
for
(
p
=
0
;
p
<
s
->
nb_planes
;
p
++
)
{
if
(
!
((
1
<<
p
)
&
s
->
planes
))
{
av_image_copy_plane
(
out
->
data
[
p
],
out
->
linesize
[
p
],
base
->
data
[
p
],
base
->
linesize
[
p
],
s
->
linesize
[
p
],
s
->
height
[
p
]);
continue
;
}
s
->
maskedmerge
(
base
->
data
[
p
],
overlay
->
data
[
p
],
mask
->
data
[
p
],
out
->
data
[
p
],
base
->
linesize
[
p
],
overlay
->
linesize
[
p
],
mask
->
linesize
[
p
],
out
->
linesize
[
p
],
s
->
width
[
p
],
s
->
height
[
p
],
s
->
half
,
s
->
depth
);
}
td
.
out
=
out
;
td
.
base
=
base
;
td
.
overlay
=
overlay
;
td
.
mask
=
mask
;
ctx
->
internal
->
execute
(
ctx
,
filter_slice
,
&
td
,
NULL
,
FFMIN
(
s
->
height
[
2
],
ff_filter_get_nb_threads
(
ctx
)));
}
out
->
pts
=
av_rescale_q
(
base
->
pts
,
s
->
fs
.
time_base
,
outlink
->
time_base
);
...
...
@@ -291,5 +324,5 @@ AVFilter ff_vf_maskedmerge = {
.
inputs
=
maskedmerge_inputs
,
.
outputs
=
maskedmerge_outputs
,
.
priv_class
=
&
maskedmerge_class
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
|
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