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
d8429981
Commit
d8429981
authored
Feb 09, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_asoftclip: add slice threading support
parent
9b9f441a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
9 deletions
+39
-9
af_asoftclip.c
libavfilter/af_asoftclip.c
+39
-9
No files found.
libavfilter/af_asoftclip.c
View file @
d8429981
...
...
@@ -42,7 +42,7 @@ typedef struct ASoftClipContext {
double
param
;
void
(
*
filter
)(
struct
ASoftClipContext
*
s
,
void
**
dst
,
const
void
**
src
,
int
nb_samples
,
int
channels
);
int
nb_samples
,
int
channels
,
int
start
,
int
end
);
}
ASoftClipContext
;
#define OFFSET(x) offsetof(ASoftClipContext, x)
...
...
@@ -97,11 +97,12 @@ static int query_formats(AVFilterContext *ctx)
static
void
filter_flt
(
ASoftClipContext
*
s
,
void
**
dptr
,
const
void
**
sptr
,
int
nb_samples
,
int
channels
)
int
nb_samples
,
int
channels
,
int
start
,
int
end
)
{
float
param
=
s
->
param
;
for
(
int
c
=
0
;
c
<
channels
;
c
++
)
{
for
(
int
c
=
start
;
c
<
end
;
c
++
)
{
const
float
*
src
=
sptr
[
c
];
float
*
dst
=
dptr
[
c
];
...
...
@@ -153,11 +154,12 @@ static void filter_flt(ASoftClipContext *s,
static
void
filter_dbl
(
ASoftClipContext
*
s
,
void
**
dptr
,
const
void
**
sptr
,
int
nb_samples
,
int
channels
)
int
nb_samples
,
int
channels
,
int
start
,
int
end
)
{
double
param
=
s
->
param
;
for
(
int
c
=
0
;
c
<
channels
;
c
++
)
{
for
(
int
c
=
start
;
c
<
end
;
c
++
)
{
const
double
*
src
=
sptr
[
c
];
double
*
dst
=
dptr
[
c
];
...
...
@@ -222,12 +224,35 @@ static int config_input(AVFilterLink *inlink)
return
0
;
}
typedef
struct
ThreadData
{
AVFrame
*
in
,
*
out
;
int
nb_samples
;
int
channels
;
}
ThreadData
;
static
int
filter_channels
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
ASoftClipContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
out
=
td
->
out
;
AVFrame
*
in
=
td
->
in
;
const
int
channels
=
td
->
channels
;
const
int
nb_samples
=
td
->
nb_samples
;
const
int
start
=
(
channels
*
jobnr
)
/
nb_jobs
;
const
int
end
=
(
channels
*
(
jobnr
+
1
))
/
nb_jobs
;
s
->
filter
(
s
,
(
void
**
)
out
->
extended_data
,
(
const
void
**
)
in
->
extended_data
,
nb_samples
,
channels
,
start
,
end
);
return
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
ASoftClipContext
*
s
=
ctx
->
priv
;
int
nb_samples
,
channels
;
ThreadData
td
;
AVFrame
*
out
;
if
(
av_frame_is_writable
(
in
))
{
...
...
@@ -249,8 +274,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
channels
=
1
;
}
s
->
filter
(
s
,
(
void
**
)
out
->
extended_data
,
(
const
void
**
)
in
->
extended_data
,
nb_samples
,
channels
);
td
.
in
=
in
;
td
.
out
=
out
;
td
.
nb_samples
=
nb_samples
;
td
.
channels
=
channels
;
ctx
->
internal
->
execute
(
ctx
,
filter_channels
,
&
td
,
NULL
,
FFMIN
(
channels
,
ff_filter_get_nb_threads
(
ctx
)));
if
(
out
!=
in
)
av_frame_free
(
&
in
);
...
...
@@ -284,5 +313,6 @@ AVFilter ff_af_asoftclip = {
.
priv_class
=
&
asoftclip_class
,
.
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