+#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)
+
+#define VERTOPEN_TRANSITION(name, type, div) \
+static void vertopen##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 w2 = out->width / 2; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = 2.f - fabsf((x - w2) / w2) - progress * 2.f; \
+ 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)); \
+ } \
+ } \
+ } \
+}
+
+VERTOPEN_TRANSITION(8, uint8_t, 1)
+VERTOPEN_TRANSITION(16, uint16_t, 2)
+
+#define VERTCLOSE_TRANSITION(name, type, div) \
+static void vertclose##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 w2 = out->width / 2; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = 1.f + fabsf((x - w2) / w2) - progress * 2.f; \
+ 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)); \
+ } \
+ } \
+ } \
+}
+
+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 float frand(int x, int y)
+{
+ const float r = sinf(x * 12.9898f + y * 78.233f) * 43758.545f;
+
+ return r - floorf(r);
+}
+
+#define DISSOLVE_TRANSITION(name, type, div) \
+static void dissolve##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; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = frand(x, y) * 2.f + progress * 2.f - 1.5f; \
+ 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] = smooth >= 0.5f ? xf0[x] : xf1[x]; \
+ } \
+ } \
+ } \
+}
+
+DISSOLVE_TRANSITION(8, uint8_t, 1)
+DISSOLVE_TRANSITION(16, uint16_t, 2)
+
+#define PIXELIZE_TRANSITION(name, type, div) \
+static void pixelize##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 w = out->width; \
+ const int h = out->height; \
+ const float d = fminf(progress, 1.f - progress); \
+ const float dist = ceilf(d * 50.f) / 50.f; \
+ const float sqx = 2.f * dist * FFMIN(w, h) / 20.f; \
+ const float sqy = 2.f * dist * FFMIN(w, h) / 20.f; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < w; x++) { \
+ int sx = dist > 0.f ? FFMIN((floorf(x / sqx) + .5f) * sqx, w - 1) : x; \
+ int sy = dist > 0.f ? FFMIN((floorf(y / sqy) + .5f) * sqy, h - 1) : y; \
+ for (int p = 0; p < s->nb_planes; p++) { \
+ const type *xf0 = (const type *)(a->data[p] + sy * a->linesize[p]); \
+ const type *xf1 = (const type *)(b->data[p] + sy * b->linesize[p]); \
+ type *dst = (type *)(out->data[p] + y * out->linesize[p]); \
+ \
+ dst[x] = mix(xf0[sx], xf1[sx], progress); \
+ } \
+ } \
+ } \
+}
+
+PIXELIZE_TRANSITION(8, uint8_t, 1)
+PIXELIZE_TRANSITION(16, uint16_t, 2)
+
+#define DIAGTL_TRANSITION(name, type, div) \
+static void diagtl##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 w = width; \
+ const float h = out->height; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = 1.f + x / w * y / h - progress * 2.f; \
+ \
+ 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)); \
+ } \
+ } \
+ } \
+}
+
+DIAGTL_TRANSITION(8, uint8_t, 1)
+DIAGTL_TRANSITION(16, uint16_t, 2)
+
+#define DIAGTR_TRANSITION(name, type, div) \
+static void diagtr##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 w = width; \
+ const float h = out->height; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = 1.f + (w - 1 - x) / w * y / h - progress * 2.f; \
+ \
+ 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)); \
+ } \
+ } \
+ } \
+}
+
+DIAGTR_TRANSITION(8, uint8_t, 1)
+DIAGTR_TRANSITION(16, uint16_t, 2)
+
+#define DIAGBL_TRANSITION(name, type, div) \
+static void diagbl##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 w = width; \
+ const float h = out->height; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = 1.f + x / w * (h - 1 - y) / h - progress * 2.f; \
+ \
+ 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)); \
+ } \
+ } \
+ } \
+}
+
+DIAGBL_TRANSITION(8, uint8_t, 1)
+DIAGBL_TRANSITION(16, uint16_t, 2)
+
+#define DIAGBR_TRANSITION(name, type, div) \
+static void diagbr##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 w = width; \
+ const float h = out->height; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = 1.f + (w - 1 - x) / w * (h - 1 - y) / h - \
+ progress * 2.f; \
+ \
+ 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)); \
+ } \
+ } \
+ } \
+}
+
+DIAGBR_TRANSITION(8, uint8_t, 1)
+DIAGBR_TRANSITION(16, uint16_t, 2)
+
+#define HLSLICE_TRANSITION(name, type, div) \
+static void hlslice##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 w = width; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float smooth = smoothstep(-0.5f, 0.f, x / w - progress * 1.5f); \
+ const float ss = smooth <= fract(10.f * x / w) ? 0.f : 1.f; \
+ \
+ 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], ss); \
+ } \
+ } \
+ } \
+}
+
+HLSLICE_TRANSITION(8, uint8_t, 1)
+HLSLICE_TRANSITION(16, uint16_t, 2)
+
+#define HRSLICE_TRANSITION(name, type, div) \
+static void hrslice##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 w = width; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ const float xx = (w - 1 - x) / w; \
+ const float smooth = smoothstep(-0.5f, 0.f, xx - progress * 1.5f); \
+ const float ss = smooth <= fract(10.f * xx) ? 0.f : 1.f; \
+ \
+ 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], ss); \
+ } \
+ } \
+ } \
+}
+
+HRSLICE_TRANSITION(8, uint8_t, 1)
+HRSLICE_TRANSITION(16, uint16_t, 2)
+
+#define VUSLICE_TRANSITION(name, type, div) \
+static void vuslice##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 h = out->height; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ const float smooth = smoothstep(-0.5f, 0.f, y / h - progress * 1.5f); \
+ const float ss = smooth <= fract(10.f * y / h) ? 0.f : 1.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], ss); \
+ } \
+ } \
+ } \
+}
+
+VUSLICE_TRANSITION(8, uint8_t, 1)
+VUSLICE_TRANSITION(16, uint16_t, 2)
+
+#define VDSLICE_TRANSITION(name, type, div) \
+static void vdslice##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 h = out->height; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ const float yy = (h - 1 - y) / h; \
+ const float smooth = smoothstep(-0.5f, 0.f, yy - progress * 1.5f); \
+ const float ss = smooth <= fract(10.f * yy) ? 0.f : 1.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], ss); \
+ } \
+ } \
+ } \
+}
+
+VDSLICE_TRANSITION(8, uint8_t, 1)
+VDSLICE_TRANSITION(16, uint16_t, 2)
+
+#define HBLUR_TRANSITION(name, type, div) \
+static void hblur##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 prog = progress <= 0.5f ? progress * 2.f : (1.f - progress) * 2.f; \
+ const int size = 1 + (width / 2) * prog; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ 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]); \
+ float sum0 = 0.f; \
+ float sum1 = 0.f; \
+ float cnt = size; \
+ \
+ for (int x = 0; x < size; x++) { \
+ sum0 += xf0[x]; \
+ sum1 += xf1[x]; \
+ } \
+ \
+ for (int x = 0; x < width; x++) { \
+ dst[x] = mix(sum0 / cnt, sum1 / cnt, progress); \
+ \
+ if (x + size < width) { \
+ sum0 += xf0[x + size] - xf0[x]; \
+ sum1 += xf1[x + size] - xf1[x]; \
+ } else { \
+ sum0 -= xf0[x]; \
+ sum1 -= xf1[x]; \
+ cnt--; \
+ } \
+ } \
+ } \
+ } \
+}
+
+HBLUR_TRANSITION(8, uint8_t, 1)
+HBLUR_TRANSITION(16, uint16_t, 2)
+
+#define FADEGRAYS_TRANSITION(name, type, div) \
+static void fadegrays##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 is_rgb = s->is_rgb; \
+ const int mid = (s->max_value + 1) / 2; \
+ const float phase = 0.2f; \
+ \
+ for (int y = slice_start; y < slice_end; y++) { \
+ for (int x = 0; x < width; x++) { \
+ int bg[2][4]; \
+ if (is_rgb) { \
+ 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]); \
+ bg[0][0] += xf0[x]; \
+ bg[1][0] += xf1[x]; \
+ if (p == 3) { \
+ bg[0][3] = xf0[x]; \
+ bg[1][3] = xf1[x]; \
+ } \
+ } \
+ bg[0][0] = bg[0][0] / s->nb_planes; \
+ bg[1][0] = bg[1][0] / s->nb_planes; \
+ bg[0][1] = bg[0][2] = bg[0][0]; \
+ bg[1][1] = bg[1][2] = bg[1][0]; \
+ } else { \
+ const type *yf0 = (const type *)(a->data[0] + \
+ y * a->linesize[0]); \
+ const type *yf1 = (const type *)(b->data[0] + \
+ y * a->linesize[0]); \
+ bg[0][0] = yf0[x]; \
+ bg[1][0] = yf1[x]; \
+ if (s->nb_planes == 4) { \
+ const type *af0 = (const type *)(a->data[3] + \
+ y * a->linesize[3]); \
+ const type *af1 = (const type *)(b->data[3] + \
+ y * a->linesize[3]); \
+ bg[0][3] = af0[x]; \
+ bg[1][3] = af1[x]; \
+ } \
+ bg[0][1] = bg[1][1] = mid; \
+ bg[0][2] = bg[1][2] = mid; \
+ } \
+ \
+ 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(mix(xf0[x], bg[0][p], \
+ smoothstep(1.f-phase, 1.f, progress)), \
+ mix(bg[1][p], xf1[x], smoothstep(phase, 1.f, progress)), \
+ progress); \
+ } \
+ } \
+ } \
+}
+
+FADEGRAYS_TRANSITION(8, uint8_t, 1)
+FADEGRAYS_TRANSITION(16, uint16_t, 2)
+