Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
2d58fa6d
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,发现更多精彩内容 >>
提交
2d58fa6d
编写于
2月 05, 2020
作者:
P
Paul B Mahol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avfilter/vf_xfade: add horzopen/close transition
上级
10f4441a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
0 deletion
+62
-0
doc/filters.texi
doc/filters.texi
+2
-0
libavfilter/vf_xfade.c
libavfilter/vf_xfade.c
+60
-0
未找到文件。
doc/filters.texi
浏览文件 @
2d58fa6d
...
...
@@ -19944,6 +19944,8 @@ Set one of available transition effects:
@item circleclose
@item vertopen
@item vertclose
@item horzopen
@item horzclose
@end table
Default transition effect is fade.
...
...
libavfilter/vf_xfade.c
浏览文件 @
2d58fa6d
...
...
@@ -53,6 +53,8 @@ enum XFadeTransitions {
CIRCLECLOSE
,
VERTOPEN
,
VERTCLOSE
,
HORZOPEN
,
HORZCLOSE
,
NB_TRANSITIONS
,
};
...
...
@@ -158,6 +160,8 @@ static const AVOption xfade_options[] = {
{
"circleclose"
,
"circleclose transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CIRCLECLOSE
},
0
,
0
,
FLAGS
,
"transition"
},
{
"vertopen"
,
"vert open transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
VERTOPEN
},
0
,
0
,
FLAGS
,
"transition"
},
{
"vertclose"
,
"vert close transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
VERTCLOSE
},
0
,
0
,
FLAGS
,
"transition"
},
{
"horzopen"
,
"horz open transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HORZOPEN
},
0
,
0
,
FLAGS
,
"transition"
},
{
"horzclose"
,
"horz close transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HORZCLOSE
},
0
,
0
,
FLAGS
,
"transition"
},
{
"duration"
,
"set cross fade duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
1000000
},
0
,
60000000
,
FLAGS
},
{
"offset"
,
"set cross fade start relative to first input stream"
,
OFFSET
(
offset
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
0
},
INT64_MIN
,
INT64_MAX
,
FLAGS
},
{
"expr"
,
"set expression for custom transition"
,
OFFSET
(
custom_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
,
FLAGS
},
...
...
@@ -916,6 +920,60 @@ static void vertclose##name##_transition(AVFilterContext *ctx,
VERTCLOSE_TRANSITION
(
8
,
uint8_t
,
1
)
VERTCLOSE_TRANSITION
(
16
,
uint16_t
,
2
)
#define HORZOPEN_TRANSITION(name, type, div) \
static void horzopen##name##_transition(AVFilterContext *ctx, \
const AVFrame *a, const AVFrame *b, AVFrame *out, \
float progress, \
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int width = out->width; \
const float h2 = out->height / 2; \
\
for (int y = slice_start; y < slice_end; y++) { \
const float smooth = 2.f - fabsf((y - h2) / h2) - progress * 2.f; \
for (int x = 0; x < width; x++) { \
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + y * a->linesize[p]); \
const type *xf1 = (const type *)(b->data[p] + y * b->linesize[p]); \
type *dst = (type *)(out->data[p] + y * out->linesize[p]); \
\
dst[x] = mix(xf1[x], xf0[x], smoothstep(0.f, 1.f, smooth)); \
} \
} \
} \
}
HORZOPEN_TRANSITION
(
8
,
uint8_t
,
1
)
HORZOPEN_TRANSITION
(
16
,
uint16_t
,
2
)
#define HORZCLOSE_TRANSITION(name, type, div) \
static void horzclose##name##_transition(AVFilterContext *ctx, \
const AVFrame *a, const AVFrame *b, AVFrame *out, \
float progress, \
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int width = out->width; \
const float h2 = out->height / 2; \
\
for (int y = slice_start; y < slice_end; y++) { \
const float smooth = 1.f + fabsf((y - h2) / h2) - progress * 2.f; \
for (int x = 0; x < width; x++) { \
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + y * a->linesize[p]); \
const type *xf1 = (const type *)(b->data[p] + y * b->linesize[p]); \
type *dst = (type *)(out->data[p] + y * out->linesize[p]); \
\
dst[x] = mix(xf1[x], xf0[x], smoothstep(0.f, 1.f, smooth)); \
} \
} \
} \
}
HORZCLOSE_TRANSITION
(
8
,
uint8_t
,
1
)
HORZCLOSE_TRANSITION
(
16
,
uint16_t
,
2
)
static
inline
double
getpix
(
void
*
priv
,
double
x
,
double
y
,
int
plane
,
int
nb
)
{
XFadeContext
*
s
=
priv
;
...
...
@@ -1030,6 +1088,8 @@ static int config_output(AVFilterLink *outlink)
case
CIRCLECLOSE
:
s
->
transitionf
=
s
->
depth
<=
8
?
circleclose8_transition
:
circleclose16_transition
;
break
;
case
VERTOPEN
:
s
->
transitionf
=
s
->
depth
<=
8
?
vertopen8_transition
:
vertopen16_transition
;
break
;
case
VERTCLOSE
:
s
->
transitionf
=
s
->
depth
<=
8
?
vertclose8_transition
:
vertclose16_transition
;
break
;
case
HORZOPEN
:
s
->
transitionf
=
s
->
depth
<=
8
?
horzopen8_transition
:
horzopen16_transition
;
break
;
case
HORZCLOSE
:
s
->
transitionf
=
s
->
depth
<=
8
?
horzclose8_transition
:
horzclose16_transition
;
break
;
}
if
(
s
->
transition
==
CUSTOM
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录