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
efee86fa
Commit
efee86fa
authored
Feb 04, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_xfade: add circleopen & circleclose transition
parent
fb385534
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
filters.texi
doc/filters.texi
+2
-0
vf_xfade.c
libavfilter/vf_xfade.c
+64
-0
No files found.
doc/filters.texi
View file @
efee86fa
...
@@ -19929,6 +19929,8 @@ Set one of available transition effects:
...
@@ -19929,6 +19929,8 @@ Set one of available transition effects:
@item smoothright
@item smoothright
@item smoothup
@item smoothup
@item smoothdown
@item smoothdown
@item circleopen
@item circleclose
@end table
@end table
Default transition effect is fade.
Default transition effect is fade.
...
...
libavfilter/vf_xfade.c
View file @
efee86fa
...
@@ -49,6 +49,8 @@ enum XFadeTransitions {
...
@@ -49,6 +49,8 @@ enum XFadeTransitions {
SMOOTHRIGHT
,
SMOOTHRIGHT
,
SMOOTHUP
,
SMOOTHUP
,
SMOOTHDOWN
,
SMOOTHDOWN
,
CIRCLEOPEN
,
CIRCLECLOSE
,
NB_TRANSITIONS
,
NB_TRANSITIONS
,
};
};
...
@@ -150,6 +152,8 @@ static const AVOption xfade_options[] = {
...
@@ -150,6 +152,8 @@ static const AVOption xfade_options[] = {
{
"smoothright"
,
"smoothright transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SMOOTHRIGHT
},
0
,
0
,
FLAGS
,
"transition"
},
{
"smoothright"
,
"smoothright transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SMOOTHRIGHT
},
0
,
0
,
FLAGS
,
"transition"
},
{
"smoothup"
,
"smoothup transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SMOOTHUP
},
0
,
0
,
FLAGS
,
"transition"
},
{
"smoothup"
,
"smoothup transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SMOOTHUP
},
0
,
0
,
FLAGS
,
"transition"
},
{
"smoothdown"
,
"smoothdown transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SMOOTHDOWN
},
0
,
0
,
FLAGS
,
"transition"
},
{
"smoothdown"
,
"smoothdown transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SMOOTHDOWN
},
0
,
0
,
FLAGS
,
"transition"
},
{
"circleopen"
,
"circleopen transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CIRCLEOPEN
},
0
,
0
,
FLAGS
,
"transition"
},
{
"circleclose"
,
"circleclose transition"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CIRCLECLOSE
},
0
,
0
,
FLAGS
,
"transition"
},
{
"duration"
,
"set cross fade duration"
,
OFFSET
(
duration
),
AV_OPT_TYPE_DURATION
,
{.
i64
=
1000000
},
0
,
60000000
,
FLAGS
},
{
"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
},
{
"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
},
{
"expr"
,
"set expression for custom transition"
,
OFFSET
(
custom_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
,
FLAGS
},
...
@@ -796,6 +800,64 @@ static void smoothdown##name##_transition(AVFilterContext *ctx,
...
@@ -796,6 +800,64 @@ static void smoothdown##name##_transition(AVFilterContext *ctx,
SMOOTHDOWN_TRANSITION
(
8
,
uint8_t
,
1
)
SMOOTHDOWN_TRANSITION
(
8
,
uint8_t
,
1
)
SMOOTHDOWN_TRANSITION
(
16
,
uint16_t
,
2
)
SMOOTHDOWN_TRANSITION
(
16
,
uint16_t
,
2
)
#define CIRCLEOPEN_TRANSITION(name, type, div) \
static void circleopen##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 int height = out->height; \
const float z = hypotf(width / 2, height / 2); \
const float p = (progress - 0.5f) * 3.f; \
\
for (int y = slice_start; y < slice_end; y++) { \
for (int x = 0; x < width; x++) { \
const float smooth = hypotf(x - width / 2, y - height / 2) / z + p; \
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(xf0[x], xf1[x], smoothstep(0.f, 1.f, smooth)); \
} \
} \
} \
}
CIRCLEOPEN_TRANSITION
(
8
,
uint8_t
,
1
)
CIRCLEOPEN_TRANSITION
(
16
,
uint16_t
,
2
)
#define CIRCLECLOSE_TRANSITION(name, type, div) \
static void circleclose##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 int height = out->height; \
const float z = hypotf(width / 2, height / 2); \
const float p = (1.f - progress - 0.5f) * 3.f; \
\
for (int y = slice_start; y < slice_end; y++) { \
for (int x = 0; x < width; x++) { \
const float smooth = hypotf(x - width / 2, y - height / 2) / z + p; \
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)); \
} \
} \
} \
}
CIRCLECLOSE_TRANSITION
(
8
,
uint8_t
,
1
)
CIRCLECLOSE_TRANSITION
(
16
,
uint16_t
,
2
)
static
inline
double
getpix
(
void
*
priv
,
double
x
,
double
y
,
int
plane
,
int
nb
)
static
inline
double
getpix
(
void
*
priv
,
double
x
,
double
y
,
int
plane
,
int
nb
)
{
{
XFadeContext
*
s
=
priv
;
XFadeContext
*
s
=
priv
;
...
@@ -906,6 +968,8 @@ static int config_output(AVFilterLink *outlink)
...
@@ -906,6 +968,8 @@ static int config_output(AVFilterLink *outlink)
case
SMOOTHRIGHT
:
s
->
transitionf
=
s
->
depth
<=
8
?
smoothright8_transition
:
smoothright16_transition
;
break
;
case
SMOOTHRIGHT
:
s
->
transitionf
=
s
->
depth
<=
8
?
smoothright8_transition
:
smoothright16_transition
;
break
;
case
SMOOTHUP
:
s
->
transitionf
=
s
->
depth
<=
8
?
smoothup8_transition
:
smoothup16_transition
;
break
;
case
SMOOTHUP
:
s
->
transitionf
=
s
->
depth
<=
8
?
smoothup8_transition
:
smoothup16_transition
;
break
;
case
SMOOTHDOWN
:
s
->
transitionf
=
s
->
depth
<=
8
?
smoothdown8_transition
:
smoothdown16_transition
;
break
;
case
SMOOTHDOWN
:
s
->
transitionf
=
s
->
depth
<=
8
?
smoothdown8_transition
:
smoothdown16_transition
;
break
;
case
CIRCLEOPEN
:
s
->
transitionf
=
s
->
depth
<=
8
?
circleopen8_transition
:
circleopen16_transition
;
break
;
case
CIRCLECLOSE
:
s
->
transitionf
=
s
->
depth
<=
8
?
circleclose8_transition
:
circleclose16_transition
;
break
;
}
}
if
(
s
->
transition
==
CUSTOM
)
{
if
(
s
->
transition
==
CUSTOM
)
{
...
...
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