Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
9faec78b
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9faec78b
编写于
4月 27, 2018
作者:
P
Paul B Mahol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avfilter/vf_mix: add slice threading
Signed-off-by:
N
Paul B Mahol
<
onemda@gmail.com
>
上级
48330500
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
8 deletion
+29
-8
libavfilter/vf_mix.c
libavfilter/vf_mix.c
+29
-8
未找到文件。
libavfilter/vf_mix.c
浏览文件 @
9faec78b
...
...
@@ -120,15 +120,25 @@ static av_cold int init(AVFilterContext *ctx)
return
0
;
}
static
void
mix_frames
(
MixContext
*
s
,
AVFrame
**
in
,
AVFrame
*
out
)
typedef
struct
ThreadData
{
AVFrame
**
in
,
*
out
;
}
ThreadData
;
static
int
mix_frames
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
MixContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
**
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
int
i
,
p
,
x
,
y
;
if
(
s
->
depth
<=
8
)
{
for
(
p
=
0
;
p
<
s
->
nb_planes
;
p
++
)
{
uint8_t
*
dst
=
out
->
data
[
p
];
const
int
slice_start
=
(
s
->
height
[
p
]
*
jobnr
)
/
nb_jobs
;
const
int
slice_end
=
(
s
->
height
[
p
]
*
(
jobnr
+
1
))
/
nb_jobs
;
uint8_t
*
dst
=
out
->
data
[
p
]
+
slice_start
*
out
->
linesize
[
p
];
for
(
y
=
0
;
y
<
s
->
height
[
p
]
;
y
++
)
{
for
(
y
=
slice_start
;
y
<
slice_end
;
y
++
)
{
for
(
x
=
0
;
x
<
s
->
linesize
[
p
];
x
++
)
{
int
val
=
0
;
...
...
@@ -146,9 +156,11 @@ static void mix_frames(MixContext *s, AVFrame **in, AVFrame *out)
}
}
else
{
for
(
p
=
0
;
p
<
s
->
nb_planes
;
p
++
)
{
uint16_t
*
dst
=
(
uint16_t
*
)
out
->
data
[
p
];
const
int
slice_start
=
(
s
->
height
[
p
]
*
jobnr
)
/
nb_jobs
;
const
int
slice_end
=
(
s
->
height
[
p
]
*
(
jobnr
+
1
))
/
nb_jobs
;
uint16_t
*
dst
=
(
uint16_t
*
)(
out
->
data
[
p
]
+
slice_start
*
out
->
linesize
[
p
]);
for
(
y
=
0
;
y
<
s
->
height
[
p
]
;
y
++
)
{
for
(
y
=
slice_start
;
y
<
slice_end
;
y
++
)
{
for
(
x
=
0
;
x
<
s
->
linesize
[
p
]
/
2
;
x
++
)
{
int
val
=
0
;
...
...
@@ -165,6 +177,8 @@ static void mix_frames(MixContext *s, AVFrame **in, AVFrame *out)
}
}
}
return
0
;
}
static
int
process_frame
(
FFFrameSync
*
fs
)
...
...
@@ -174,6 +188,7 @@ static int process_frame(FFFrameSync *fs)
MixContext
*
s
=
fs
->
opaque
;
AVFrame
**
in
=
s
->
frames
;
AVFrame
*
out
;
ThreadData
td
;
int
i
,
ret
;
for
(
i
=
0
;
i
<
s
->
nb_inputs
;
i
++
)
{
...
...
@@ -186,7 +201,9 @@ static int process_frame(FFFrameSync *fs)
return
AVERROR
(
ENOMEM
);
out
->
pts
=
av_rescale_q
(
s
->
fs
.
pts
,
s
->
fs
.
time_base
,
outlink
->
time_base
);
mix_frames
(
s
,
in
,
out
);
td
.
in
=
in
;
td
.
out
=
out
;
ctx
->
internal
->
execute
(
ctx
,
mix_frames
,
&
td
,
NULL
,
FFMIN
(
s
->
height
[
0
],
ff_filter_get_nb_threads
(
ctx
)));
return
ff_filter_frame
(
outlink
,
out
);
}
...
...
@@ -312,7 +329,7 @@ AVFilter ff_vf_mix = {
.
init
=
init
,
.
uninit
=
uninit
,
.
activate
=
activate
,
.
flags
=
AVFILTER_FLAG_DYNAMIC_INPUTS
,
.
flags
=
AVFILTER_FLAG_DYNAMIC_INPUTS
|
AVFILTER_FLAG_SLICE_THREADS
,
};
#endif
/* CONFIG_MIX_FILTER */
...
...
@@ -323,6 +340,7 @@ static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
MixContext
*
s
=
ctx
->
priv
;
ThreadData
td
;
AVFrame
*
out
;
if
(
s
->
nb_frames
<
s
->
nb_inputs
)
{
...
...
@@ -340,7 +358,9 @@ static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in)
return
AVERROR
(
ENOMEM
);
out
->
pts
=
s
->
frames
[
0
]
->
pts
;
mix_frames
(
s
,
s
->
frames
,
out
);
td
.
out
=
out
;
td
.
in
=
s
->
frames
;
ctx
->
internal
->
execute
(
ctx
,
mix_frames
,
&
td
,
NULL
,
FFMIN
(
s
->
height
[
0
],
ff_filter_get_nb_threads
(
ctx
)));
return
ff_filter_frame
(
outlink
,
out
);
}
...
...
@@ -373,6 +393,7 @@ AVFilter ff_vf_tmix = {
.
inputs
=
inputs
,
.
init
=
init
,
.
uninit
=
uninit
,
.
flags
=
AVFILTER_FLAG_SLICE_THREADS
,
};
#endif
/* CONFIG_TMIX_FILTER */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录