Unified · Split
| @@ -79,6 +79,7 @@ enum XFadeTransitions { · 78 unmodified lines | ||
| 79 | 79 | SLIDERIGHT, |
| 80 | 80 | CIRCLEOPEN, |
| 81 | 81 | CIRCLECLOSE, |
| 82 | + DISSOLVE, | |
| 82 | 83 | NB_TRANSITIONS, |
| 83 | 84 | }; |
| 84 | 85 | |
| @@ -212,6 +213,23 @@ static const char transition_circleclose[] = { · 127 unmodified lines | ||
| 212 | 213 | C(0, } ) |
| 213 | 214 | }; |
| 214 | 215 | |
| 216 | +#define SHADER_FRAND_FUNC \ | |
| 217 | + C(0, float frand(vec2 v) ) \ | |
| 218 | + C(0, { ) \ | |
| 219 | + C(1, return fract(sin(dot(v, vec2(12.9898, 78.233))) * 43758.545); ) \ | |
| 220 | + C(0, } ) | |
| 221 | + | |
| 222 | +static const char transition_dissolve[] = { | |
| 223 | + SHADER_FRAND_FUNC | |
| 224 | + C(0, void transition(int idx, ivec2 pos, float progress) ) | |
| 225 | + C(0, { ) | |
| 226 | + C(1, float sm = frand(pos) * 2.0 + (1.0 - progress) * 2.0 - 1.5; ) | |
| 227 | + C(1, vec4 a = texture(a_images[idx], pos); ) | |
| 228 | + C(1, vec4 b = texture(b_images[idx], pos); ) | |
| 229 | + C(1, imageStore(output_images[idx], pos, sm >= 0.5 ? a : b); ) | |
| 230 | + C(0, } ) | |
| 231 | +}; | |
| 232 | + | |
| 215 | 233 | static const char* transitions_map[NB_TRANSITIONS] = { |
| 216 | 234 | [FADE] = transition_fade, |
| 217 | 235 | [WIPELEFT] = transition_wipeleft, |
| @@ -224,6 +242,7 @@ static const char* transitions_map[NB_TRANSITIONS] = { · 6 unmodified lines | ||
| 224 | 242 | [SLIDERIGHT] = transition_slideright, |
| 225 | 243 | [CIRCLEOPEN] = transition_circleopen, |
| 226 | 244 | [CIRCLECLOSE] = transition_circleclose, |
| 245 | + [DISSOLVE] = transition_dissolve, | |
| 227 | 246 | }; |
| 228 | 247 | |
| 229 | 248 | static av_cold int init_vulkan(AVFilterContext *avctx) |
| @@ -576,6 +595,7 @@ static const AVOption xfade_vulkan_options[] = { · 346 unmodified lines | ||
| 576 | 595 | { "slideright", "slide right transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" }, |
| 577 | 596 | { "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, {.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" }, |
| 578 | 597 | { "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, {.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" }, |
| 598 | + { "dissolve", "dissolve transition", 0, AV_OPT_TYPE_CONST, {.i64=DISSOLVE}, 0, 0, FLAGS, "transition" }, | |
| 579 | 599 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 580 | 600 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 581 | 601 | { NULL } |