avfilter/vf_xfade: avoid some not needed dereferencing in inner loops

This commit is contained in:
Paul B Mahol 2023-05-22 08:23:26 +02:00
parent 0709680fc4
commit 6284afec07
1 changed files with 76 additions and 43 deletions

View File

@ -221,9 +221,10 @@ static void custom##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
\
double values[VAR_VARS_NB]; \
values[VAR_W] = out->width; \
values[VAR_W] = width; \
values[VAR_H] = out->height; \
values[VAR_PROGRESS] = progress; \
\
@ -236,7 +237,7 @@ static void custom##name##_transition(AVFilterContext *ctx,
\
for (int y = 0; y < height; y++) { \
values[VAR_Y] = slice_start + y; \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
values[VAR_X] = x; \
values[VAR_A] = xf0[x]; \
values[VAR_B] = xf1[x]; \
@ -280,6 +281,7 @@ static void fade##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
@ -287,7 +289,7 @@ static void fade##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = mix(xf0[x], xf1[x], progress); \
} \
\
@ -309,7 +311,8 @@ static void wipeleft##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int z = out->width * progress; \
const int width = out->width; \
const int z = width * progress; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
@ -317,7 +320,7 @@ static void wipeleft##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = x > z ? xf1[x] : xf0[x]; \
} \
\
@ -339,7 +342,8 @@ static void wiperight##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int z = out->width * (1.f - progress); \
const int width = out->width; \
const int z = width * (1.f - progress); \
\
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
@ -347,7 +351,7 @@ static void wiperight##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = x > z ? xf0[x] : xf1[x]; \
} \
\
@ -369,6 +373,7 @@ static void wipeup##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
const int z = out->height * progress; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -377,7 +382,7 @@ static void wipeup##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = slice_start + y > z ? xf1[x] : xf0[x]; \
} \
\
@ -399,6 +404,7 @@ static void wipedown##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
const int z = out->height * (1.f - progress); \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -407,7 +413,7 @@ static void wipedown##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = slice_start + y > z ? xf0[x] : xf1[x]; \
} \
\
@ -471,7 +477,7 @@ static void slideright##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
const int zx = z + x; \
const int zz = zx % width + width * (zx < 0); \
dst[x] = (zx >= 0) && (zx < width) ? xf1[zz] : xf0[zz]; \
@ -495,6 +501,7 @@ static void slideup##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = out->height; \
const int width = out->width; \
const int z = -progress * height; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -506,7 +513,7 @@ static void slideup##name##_transition(AVFilterContext *ctx,
const type *xf0 = (const type *)(a->data[p] + zz * a->linesize[p]); \
const type *xf1 = (const type *)(b->data[p] + zz * b->linesize[p]); \
\
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; \
} \
\
@ -526,6 +533,7 @@ static void slidedown##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = out->height; \
const int width = out->width; \
const int z = progress * height; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -537,7 +545,7 @@ static void slidedown##name##_transition(AVFilterContext *ctx,
const type *xf0 = (const type *)(a->data[p] + zz * a->linesize[p]); \
const type *xf1 = (const type *)(b->data[p] + zz * b->linesize[p]); \
\
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; \
} \
\
@ -660,6 +668,7 @@ static void fadeblack##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
const float phase = 0.2f; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -669,7 +678,7 @@ static void fadeblack##name##_transition(AVFilterContext *ctx,
const int bg = s->black[p]; \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = mix(mix(xf0[x], bg, smoothstep(1.f-phase, 1.f, progress)), \
mix(bg, xf1[x], smoothstep(phase, 1.f, progress)), \
progress); \
@ -693,6 +702,7 @@ static void fadewhite##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
const float phase = 0.2f; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -702,7 +712,7 @@ static void fadewhite##name##_transition(AVFilterContext *ctx,
const int bg = s->white[p]; \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = mix(mix(xf0[x], bg, smoothstep(1.f-phase, 1.f, progress)), \
mix(bg, xf1[x], smoothstep(phase, 1.f, progress)), \
progress); \
@ -948,13 +958,14 @@ static void vertclose##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
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++) { \
for (int p = 0; p < 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]); \
@ -975,13 +986,14 @@ static void horzopen##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
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++) { \
for (int p = 0; p < 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]); \
@ -1002,13 +1014,14 @@ static void horzclose##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
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++) { \
for (int p = 0; p < 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]); \
@ -1036,12 +1049,13 @@ static void dissolve##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
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++) { \
for (int p = 0; p < 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]); \
@ -1062,6 +1076,7 @@ static void pixelize##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int w = out->width; \
const int h = out->height; \
const float d = fminf(progress, 1.f - progress); \
@ -1073,7 +1088,7 @@ static void pixelize##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1094,6 +1109,7 @@ static void diagtl##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float w = width; \
const float h = out->height; \
@ -1102,7 +1118,7 @@ static void diagtl##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1123,6 +1139,7 @@ static void diagtr##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float w = width; \
const float h = out->height; \
@ -1131,7 +1148,7 @@ static void diagtr##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1152,6 +1169,7 @@ static void diagbl##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float w = width; \
const float h = out->height; \
@ -1160,7 +1178,7 @@ static void diagbl##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1181,6 +1199,7 @@ static void diagbr##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float w = width; \
const float h = out->height; \
@ -1190,7 +1209,7 @@ static void diagbr##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1211,6 +1230,7 @@ static void hlslice##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float w = width; \
\
@ -1219,7 +1239,7 @@ static void hlslice##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1240,6 +1260,7 @@ static void hrslice##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float w = width; \
\
@ -1249,7 +1270,7 @@ static void hrslice##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1270,6 +1291,7 @@ static void vuslice##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float h = out->height; \
\
@ -1278,7 +1300,7 @@ static void vuslice##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1299,6 +1321,7 @@ static void vdslice##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
const int width = out->width; \
const float h = out->height; \
\
@ -1308,7 +1331,7 @@ static void vdslice##name##_transition(AVFilterContext *ctx,
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++) { \
for (int p = 0; p < 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]); \
@ -1329,12 +1352,13 @@ static void hblur##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const int nb_planes = s->nb_planes; \
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++) { \
for (int p = 0; p < 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]); \
@ -1443,6 +1467,7 @@ static void wipetl##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
const int zw = out->width * progress; \
const int zh = out->height * progress; \
\
@ -1452,7 +1477,7 @@ static void wipetl##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = slice_start + y <= zh && \
x <= zw ? xf0[x] : xf1[x]; \
} \
@ -1475,7 +1500,8 @@ static void wipetr##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int zw = out->width * (1.f - progress); \
const int width = out->width; \
const int zw = width * (1.f - progress); \
const int zh = out->height * progress; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -1484,7 +1510,7 @@ static void wipetr##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = slice_start + y <= zh && \
x > zw ? xf0[x] : xf1[x]; \
} \
@ -1507,7 +1533,8 @@ static void wipebl##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int zw = out->width * progress; \
const int width = out->width; \
const int zw = width * progress; \
const int zh = out->height * (1.f - progress); \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -1516,7 +1543,7 @@ static void wipebl##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = slice_start + y > zh && \
x <= zw ? xf0[x] : xf1[x]; \
} \
@ -1540,7 +1567,8 @@ static void wipebr##name##_transition(AVFilterContext *ctx,
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int zh = out->height * (1.f - progress); \
const int zw = out->width * (1.f - progress); \
const int width = out->width; \
const int zw = width * (1.f - progress); \
\
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
@ -1548,7 +1576,7 @@ static void wipebr##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = slice_start + y > zh && \
x > zw ? xf0[x] : xf1[x]; \
} \
@ -1572,6 +1600,7 @@ static void squeezeh##name##_transition(AVFilterContext *ctx,
XFadeContext *s = ctx->priv; \
const float h = out->height; \
const int height = slice_end - slice_start; \
const int width = out->width; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \
@ -1581,13 +1610,13 @@ static void squeezeh##name##_transition(AVFilterContext *ctx,
const float z = .5f + ((slice_start + y) / h - .5f) / progress; \
\
if (z < 0.f || z > 1.f) { \
for (int x = 0; x < out->width; x++) \
for (int x = 0; x < width; x++) \
dst[x] = xf1[x]; \
} else { \
const int yy = lrintf(z * (h - 1.f)); \
const type *xf0 = (const type *)(a->data[p] + yy * a->linesize[p]); \
\
for (int x = 0; x < out->width; x++) \
for (int x = 0; x < width; x++) \
dst[x] = xf0[x]; \
} \
\
@ -1607,7 +1636,8 @@ static void squeezev##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const float w = out->width; \
const int width = out->width; \
const float w = width; \
const int height = slice_end - slice_start; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -1616,7 +1646,7 @@ static void squeezev##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
const float z = .5f + (x / w - .5f) / progress; \
\
if (z < 0.f || z > 1.f) { \
@ -1651,7 +1681,8 @@ static void zoomin##name##_transition(AVFilterContext *ctx,
int slice_start, int slice_end, int jobnr) \
{ \
XFadeContext *s = ctx->priv; \
const float w = out->width; \
const int width = out->width; \
const float w = width; \
const float h = out->height; \
const float zf = smoothstep(0.5f, 1.f, progress); \
\
@ -1661,7 +1692,7 @@ static void zoomin##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = slice_start; y < slice_end; y++) { \
for (int x = 0; x < w; x++) { \
for (int x = 0; x < width; x++) { \
float zv, u, v; \
int iu, iv; \
\
@ -1690,6 +1721,7 @@ static void fadefast##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
const float imax = 1.f / s->max_value; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -1698,7 +1730,7 @@ static void fadefast##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = mix(xf0[x], xf1[x], powf(progress, 1.f + \
logf(1.f+FFABS(xf0[x]-xf1[x])*imax)\
)); \
@ -1722,6 +1754,7 @@ static void fadeslow##name##_transition(AVFilterContext *ctx,
{ \
XFadeContext *s = ctx->priv; \
const int height = slice_end - slice_start; \
const int width = out->width; \
const float imax = 1.f / s->max_value; \
\
for (int p = 0; p < s->nb_planes; p++) { \
@ -1730,7 +1763,7 @@ static void fadeslow##name##_transition(AVFilterContext *ctx,
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
\
for (int y = 0; y < height; y++) { \
for (int x = 0; x < out->width; x++) { \
for (int x = 0; x < width; x++) { \
dst[x] = mix(xf0[x], xf1[x], powf(progress, 1.f + \
logf(2.f-FFABS(xf0[x]-xf1[x])*imax)\
)); \