mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
avfilter/vsrc_gradients: add square type
This commit is contained in:
parent
72390dea00
commit
f1acb0d843
@ -28260,9 +28260,18 @@ supposed to be generated forever.
|
||||
Set speed of gradients rotation.
|
||||
|
||||
@item type, t
|
||||
Set type of gradients, can be @code{linear} or @code{radial} or @code{circular} or @code{spiral}.
|
||||
Set type of gradients.
|
||||
Available values are:
|
||||
@table @samp
|
||||
@item linear
|
||||
@item radial
|
||||
@item circular
|
||||
@item spiral
|
||||
@item square
|
||||
@end table
|
||||
|
||||
Default type is @var{linear}.
|
||||
@end table
|
||||
|
||||
@section mandelbrot
|
||||
|
||||
|
@ -76,12 +76,13 @@ static const AVOption gradients_options[] = {
|
||||
{"duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
|
||||
{"d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
|
||||
{"speed", "set gradients rotation speed", OFFSET(speed), AV_OPT_TYPE_FLOAT,{.dbl=0.01}, 0.00001, 1, FLAGS },
|
||||
{"type", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "type" },
|
||||
{"t", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "type" },
|
||||
{"linear", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "type" },
|
||||
{"radial", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "type" },
|
||||
{"circular", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "type" },
|
||||
{"spiral", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "type" },
|
||||
{"type", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 4, FLAGS, "type" },
|
||||
{"t", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 4, FLAGS, "type" },
|
||||
{ "linear", "set linear gradient", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "type" },
|
||||
{ "radial", "set radial gradient", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "type" },
|
||||
{ "circular", "set circular gradient", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "type" },
|
||||
{ "spiral", "set spiral gradient", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "type" },
|
||||
{ "square", "set square gradient", 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "type" },
|
||||
{NULL},
|
||||
};
|
||||
|
||||
@ -219,6 +220,9 @@ static float project(float origin_x, float origin_y,
|
||||
case 3:
|
||||
od_s_q = M_PI * 2.f;
|
||||
break;
|
||||
case 4:
|
||||
od_s_q = fmaxf(fabsf(od_x), fabsf(od_y));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
@ -234,6 +238,9 @@ static float project(float origin_x, float origin_y,
|
||||
case 3:
|
||||
op_x_od = fmodf(atan2f(op_x, op_y) + M_PI + point_x / fmaxf(origin_x, dest_x), 2.f * M_PI);
|
||||
break;
|
||||
case 4:
|
||||
op_x_od = fmaxf(fabsf(op_x), fabsf(op_y));
|
||||
break;
|
||||
}
|
||||
|
||||
// Normalize and clamp range.
|
||||
@ -255,7 +262,7 @@ static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb
|
||||
for (int y = start; y < end; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, type);
|
||||
dst[x] = lerp_colors(s->color_rgba, s->nb_colors, s->nb_colors + (type >= 2), factor);
|
||||
dst[x] = lerp_colors(s->color_rgba, s->nb_colors, s->nb_colors + (type >= 2 && type <= 3), factor);
|
||||
}
|
||||
|
||||
dst += linesize;
|
||||
@ -279,7 +286,7 @@ static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int
|
||||
for (int y = start; y < end; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, type);
|
||||
dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, s->nb_colors + (type >= 2), factor);
|
||||
dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, s->nb_colors + (type >= 2 && type <= 3), factor);
|
||||
}
|
||||
|
||||
dst += linesize;
|
||||
@ -309,7 +316,7 @@ static int draw_gradients_slice32_planar(AVFilterContext *ctx, void *arg, int jo
|
||||
for (int y = start; y < end; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, type);
|
||||
lerp_colors32(s->color_rgbaf, s->nb_colors, s->nb_colors + (type >= 2), factor,
|
||||
lerp_colors32(s->color_rgbaf, s->nb_colors, s->nb_colors + (type >= 2 && type <= 3), factor,
|
||||
&dst_r[x], &dst_g[x], &dst_b[x], &dst_a[x]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user