Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -45,6 +45,7 @@ enum XFadeTransitions { · 44 unmodified lines | |||
| 45 | DISTANCE, | 45 | DISTANCE, |
| 46 | FADEBLACK, | 46 | FADEBLACK, |
| 47 | FADEWHITE, | 47 | FADEWHITE, |
| 48 | RADIAL, | ||
| 48 | NB_TRANSITIONS, | 49 | NB_TRANSITIONS, |
| 49 | }; | 50 | }; |
| 50 | 51 | ||
| @@ -141,6 +142,7 @@ static const AVOption xfade_options[] = { · 90 unmodified lines | |||
| 141 | { "distance", "distance transition", 0, AV_OPT_TYPE_CONST, {.i64=DISTANCE}, 0, 0, FLAGS, "transition" }, | 142 | { "distance", "distance transition", 0, AV_OPT_TYPE_CONST, {.i64=DISTANCE}, 0, 0, FLAGS, "transition" }, |
| 142 | { "fadeblack", "fadeblack transition", 0, AV_OPT_TYPE_CONST, {.i64=FADEBLACK}, 0, 0, FLAGS, "transition" }, | 143 | { "fadeblack", "fadeblack transition", 0, AV_OPT_TYPE_CONST, {.i64=FADEBLACK}, 0, 0, FLAGS, "transition" }, |
| 143 | { "fadewhite", "fadewhite transition", 0, AV_OPT_TYPE_CONST, {.i64=FADEWHITE}, 0, 0, FLAGS, "transition" }, | 144 | { "fadewhite", "fadewhite transition", 0, AV_OPT_TYPE_CONST, {.i64=FADEWHITE}, 0, 0, FLAGS, "transition" }, |
| 145 | { "radial", "radial transition", 0, AV_OPT_TYPE_CONST, {.i64=RADIAL}, 0, 0, FLAGS, "transition" }, | ||
| 144 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, | 146 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 145 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, | 147 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 146 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, | 148 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, |
| @@ -649,6 +651,34 @@ static void fadewhite##name##_transition(AVFilterContext *ctx, · 502 unmodified lines | |||
| 649 | FADEWHITE_TRANSITION(8, uint8_t, 1) | 651 | FADEWHITE_TRANSITION(8, uint8_t, 1) |
| 650 | FADEWHITE_TRANSITION(16, uint16_t, 2) | 652 | FADEWHITE_TRANSITION(16, uint16_t, 2) |
| 651 | 653 | ||
| 654 | #define RADIAL_TRANSITION(name, type, div) \ | ||
| 655 | static void radial##name##_transition(AVFilterContext *ctx, \ | ||
| 656 | const AVFrame *a, const AVFrame *b, AVFrame *out, \ | ||
| 657 | float progress, \ | ||
| 658 | int slice_start, int slice_end, int jobnr) \ | ||
| 659 | { \ | ||
| 660 | XFadeContext *s = ctx->priv; \ | ||
| 661 | const int width = out->width; \ | ||
| 662 | const int height = out->height; \ | ||
| 663 | \ | ||
| 664 | for (int y = slice_start; y < slice_end; y++) { \ | ||
| 665 | for (int x = 0; x < width; x++) { \ | ||
| 666 | const float smooth = atan2f(x - width / 2, y - height / 2) - \ | ||
| 667 | (progress - 0.5f) * (M_PI * 2.5f); \ | ||
| 668 | for (int p = 0; p < s->nb_planes; p++) { \ | ||
| 669 | const type *xf0 = (const type *)(a->data[p] + y * a->linesize[p]); \ | ||
| 670 | const type *xf1 = (const type *)(b->data[p] + y * b->linesize[p]); \ | ||
| 671 | type *dst = (type *)(out->data[p] + y * out->linesize[p]); \ | ||
| 672 | \ | ||
| 673 | dst[x] = mix(xf1[x], xf0[x], smoothstep(0.f, 1.f, smooth)); \ | ||
| 674 | } \ | ||
| 675 | } \ | ||
| 676 | } \ | ||
| 677 | } | ||
| 678 | |||
| 679 | RADIAL_TRANSITION(8, uint8_t, 1) | ||
| 680 | RADIAL_TRANSITION(16, uint16_t, 2) | ||
| 681 | |||
| 652 | static inline double getpix(void *priv, double x, double y, int plane, int nb) | 682 | static inline double getpix(void *priv, double x, double y, int plane, int nb) |
| 653 | { | 683 | { |
| 654 | XFadeContext *s = priv; | 684 | XFadeContext *s = priv; |
| @@ -754,6 +784,7 @@ static int config_output(AVFilterLink *outlink) · 99 unmodified lines | |||
| 754 | case DISTANCE: s->transitionf = s->depth <= 8 ? distance8_transition : distance16_transition; break; | 784 | case DISTANCE: s->transitionf = s->depth <= 8 ? distance8_transition : distance16_transition; break; |
| 755 | case FADEBLACK: s->transitionf = s->depth <= 8 ? fadeblack8_transition : fadeblack16_transition; break; | 785 | case FADEBLACK: s->transitionf = s->depth <= 8 ? fadeblack8_transition : fadeblack16_transition; break; |
| 756 | case FADEWHITE: s->transitionf = s->depth <= 8 ? fadewhite8_transition : fadewhite16_transition; break; | 786 | case FADEWHITE: s->transitionf = s->depth <= 8 ? fadewhite8_transition : fadewhite16_transition; break; |
| 787 | case RADIAL: s->transitionf = s->depth <= 8 ? radial8_transition : radial16_transition; break; | ||
| 757 | } | 788 | } |
| 758 | 789 | ||
| 759 | if (s->transition == CUSTOM) { | 790 | if (s->transition == CUSTOM) { |