Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -56,6 +56,7 @@ enum XFadeTransitions { · 55 unmodified lines | |||
| 56 | HORZOPEN, | 56 | HORZOPEN, |
| 57 | HORZCLOSE, | 57 | HORZCLOSE, |
| 58 | DISSOLVE, | 58 | DISSOLVE, |
| 59 | PIXELIZE, | ||
| 59 | NB_TRANSITIONS, | 60 | NB_TRANSITIONS, |
| 60 | }; | 61 | }; |
| 61 | 62 | ||
| @@ -164,6 +165,7 @@ static const AVOption xfade_options[] = { · 102 unmodified lines | |||
| 164 | { "horzopen", "horz open transition", 0, AV_OPT_TYPE_CONST, {.i64=HORZOPEN}, 0, 0, FLAGS, "transition" }, | 165 | { "horzopen", "horz open transition", 0, AV_OPT_TYPE_CONST, {.i64=HORZOPEN}, 0, 0, FLAGS, "transition" }, |
| 165 | { "horzclose", "horz close transition", 0, AV_OPT_TYPE_CONST, {.i64=HORZCLOSE}, 0, 0, FLAGS, "transition" }, | 166 | { "horzclose", "horz close transition", 0, AV_OPT_TYPE_CONST, {.i64=HORZCLOSE}, 0, 0, FLAGS, "transition" }, |
| 166 | { "dissolve", "dissolve transition", 0, AV_OPT_TYPE_CONST, {.i64=DISSOLVE}, 0, 0, FLAGS, "transition" }, | 167 | { "dissolve", "dissolve transition", 0, AV_OPT_TYPE_CONST, {.i64=DISSOLVE}, 0, 0, FLAGS, "transition" }, |
| 168 | { "pixelize", "pixelize transition", 0, AV_OPT_TYPE_CONST, {.i64=PIXELIZE}, 0, 0, FLAGS, "transition" }, | ||
| 167 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, | 169 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 168 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, | 170 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 169 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, | 171 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, |
| @@ -1009,6 +1011,38 @@ static void dissolve##name##_transition(AVFilterContext *ctx, · 839 unmodified lines | |||
| 1009 | DISSOLVE_TRANSITION(8, uint8_t, 1) | 1011 | DISSOLVE_TRANSITION(8, uint8_t, 1) |
| 1010 | DISSOLVE_TRANSITION(16, uint16_t, 2) | 1012 | DISSOLVE_TRANSITION(16, uint16_t, 2) |
| 1011 | 1013 | ||
| 1014 | #define PIXELIZE_TRANSITION(name, type, div) \ | ||
| 1015 | static void pixelize##name##_transition(AVFilterContext *ctx, \ | ||
| 1016 | const AVFrame *a, const AVFrame *b, AVFrame *out, \ | ||
| 1017 | float progress, \ | ||
| 1018 | int slice_start, int slice_end, int jobnr) \ | ||
| 1019 | { \ | ||
| 1020 | XFadeContext *s = ctx->priv; \ | ||
| 1021 | const int w = out->width; \ | ||
| 1022 | const int h = out->height; \ | ||
| 1023 | const float d = fminf(progress, 1.f - progress); \ | ||
| 1024 | const float dist = ceilf(d * 50.f) / 50.f; \ | ||
| 1025 | const float sqx = 2.f * dist * FFMIN(w, h) / 20.f; \ | ||
| 1026 | const float sqy = 2.f * dist * FFMIN(w, h) / 20.f; \ | ||
| 1027 | \ | ||
| 1028 | for (int y = slice_start; y < slice_end; y++) { \ | ||
| 1029 | for (int x = 0; x < w; x++) { \ | ||
| 1030 | int sx = dist > 0.f ? FFMIN((floorf(x / sqx) + .5f) * sqx, w - 1) : x; \ | ||
| 1031 | int sy = dist > 0.f ? FFMIN((floorf(y / sqy) + .5f) * sqy, h - 1) : y; \ | ||
| 1032 | for (int p = 0; p < s->nb_planes; p++) { \ | ||
| 1033 | const type *xf0 = (const type *)(a->data[p] + sy * a->linesize[p]); \ | ||
| 1034 | const type *xf1 = (const type *)(b->data[p] + sy * b->linesize[p]); \ | ||
| 1035 | type *dst = (type *)(out->data[p] + y * out->linesize[p]); \ | ||
| 1036 | \ | ||
| 1037 | dst[x] = mix(xf0[sx], xf1[sx], progress); \ | ||
| 1038 | } \ | ||
| 1039 | } \ | ||
| 1040 | } \ | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | PIXELIZE_TRANSITION(8, uint8_t, 1) | ||
| 1044 | PIXELIZE_TRANSITION(16, uint16_t, 2) | ||
| 1045 | |||
| 1012 | static inline double getpix(void *priv, double x, double y, int plane, int nb) | 1046 | static inline double getpix(void *priv, double x, double y, int plane, int nb) |
| 1013 | { | 1047 | { |
| 1014 | XFadeContext *s = priv; | 1048 | XFadeContext *s = priv; |
| @@ -1125,7 +1159,8 @@ static int config_output(AVFilterLink *outlink) · 110 unmodified lines | |||
| 1125 | case VERTCLOSE: s->transitionf = s->depth <= 8 ? vertclose8_transition : vertclose16_transition; break; | 1159 | case VERTCLOSE: s->transitionf = s->depth <= 8 ? vertclose8_transition : vertclose16_transition; break; |
| 1126 | case HORZOPEN: s->transitionf = s->depth <= 8 ? horzopen8_transition : horzopen16_transition; break; | 1160 | case HORZOPEN: s->transitionf = s->depth <= 8 ? horzopen8_transition : horzopen16_transition; break; |
| 1127 | case HORZCLOSE: s->transitionf = s->depth <= 8 ? horzclose8_transition : horzclose16_transition; break; | 1161 | case HORZCLOSE: s->transitionf = s->depth <= 8 ? horzclose8_transition : horzclose16_transition; break; |
| 1128 | case DISSOLVE: s->transitionf = s->depth <= 8 ? dissolve8_transition : dissolve16_transition; break; | 1162 | case DISSOLVE: s->transitionf = s->depth <= 8 ? dissolve8_transition : dissolve16_transition; break; |
| 1163 | case PIXELIZE: s->transitionf = s->depth <= 8 ? pixelize8_transition : pixelize16_transition; break; | ||
| 1129 | } | 1164 | } |
| 1130 | 1165 | ||
| 1131 | if (s->transition == CUSTOM) { | 1166 | if (s->transition == CUSTOM) { |