History

avfilter/vsrc_gradients: add spiral type

Paul B Mahol committed 4 years ago

Commit 21ca2211 parent 8e1cedb2 files · +11 −6Browse files

Unified · Split

2 files
  1. doc/filters.texi +1 −1
  2. libavfilter/vsrc_gradients.c +10 −5
doc/filters.texi+1−1
@@ -25874,7 +25874,7 @@ supposed to be generated forever. · 25873 unmodified lines
25874Set speed of gradients rotation.25874Set speed of gradients rotation.
25875 25875
25876@item type, t25876@item type, t
25877Set type of gradients, can be @code{linear} or @code{radial} or @code{circular}.25877Set type of gradients, can be @code{linear} or @code{radial} or @code{circular} or @code{spiral}.
25878@end table25878@end table
25879 25879
25880 25880
libavfilter/vsrc_gradients.c+10−5
@@ -79,11 +79,12 @@ static const AVOption gradients_options[] = { · 78 unmodified lines
79 {"duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },79 {"duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
80 {"d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },80 {"d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
81 {"speed", "set gradients rotation speed", OFFSET(speed), AV_OPT_TYPE_FLOAT,{.dbl=0.01}, 0.00001, 1, FLAGS },81 {"speed", "set gradients rotation speed", OFFSET(speed), AV_OPT_TYPE_FLOAT,{.dbl=0.01}, 0.00001, 1, FLAGS },
82 {"type", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "type" },82 {"type", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "type" },
83 {"t", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "type" },83 {"t", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "type" },
84 {"linear", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "type" },84 {"linear", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "type" },
85 {"radial", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "type" },85 {"radial", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "type" },
86 {"circular", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "type" },86 {"circular", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "type" },
87 {"spiral", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "type" },
87 {NULL},88 {NULL},
88};89};
89 90
@@ -218,6 +219,7 @@ static float project(float origin_x, float origin_y, · 128 unmodified lines
218 od_s_q = sqrtf(od_x * od_x + od_y * od_y);219 od_s_q = sqrtf(od_x * od_x + od_y * od_y);
219 break;220 break;
220 case 2:221 case 2:
222 case 3:
221 od_s_q = M_PI * 2.f;223 od_s_q = M_PI * 2.f;
222 break;224 break;
223 }225 }
@@ -232,6 +234,9 @@ static float project(float origin_x, float origin_y, · 8 unmodified lines
232 case 2:234 case 2:
233 op_x_od = atan2f(op_x, op_y) + M_PI;235 op_x_od = atan2f(op_x, op_y) + M_PI;
234 break;236 break;
237 case 3:
238 op_x_od = fmodf(atan2f(op_x, op_y) + M_PI + point_x / fmaxf(origin_x, dest_x), 2.f * M_PI);
239 break;
235 }240 }
236 241
237 // Normalize and clamp range.242 // Normalize and clamp range.
@@ -252,7 +257,7 @@ static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb · 14 unmodified lines
252 for (int y = start; y < end; y++) {257 for (int y = start; y < end; y++) {
253 for (int x = 0; x < width; x++) {258 for (int x = 0; x < width; x++) {
254 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, s->type);259 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, s->type);
255 dst[x] = lerp_colors(s->color_rgba, s->nb_colors, s->nb_colors + (s->type == 2), factor);260 dst[x] = lerp_colors(s->color_rgba, s->nb_colors, s->nb_colors + (s->type >= 2), factor);
256 }261 }
257 262
258 dst += linesize;263 dst += linesize;
@@ -275,7 +280,7 @@ static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int · 16 unmodified lines
275 for (int y = start; y < end; y++) {280 for (int y = start; y < end; y++) {
276 for (int x = 0; x < width; x++) {281 for (int x = 0; x < width; x++) {
277 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, s->type);282 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, s->type);
278 dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, s->nb_colors + s->type == 2, factor);283 dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, s->nb_colors + s->type >= 2, factor);
279 }284 }
280 285
281 dst += linesize;286 dst += linesize;
@@ -304,7 +309,7 @@ static int draw_gradients_slice32_planar(AVFilterContext *ctx, void *arg, int jo · 22 unmodified lines
304 for (int y = start; y < end; y++) {309 for (int y = start; y < end; y++) {
305 for (int x = 0; x < width; x++) {310 for (int x = 0; x < width; x++) {
306 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, s->type);311 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, s->type);
307 lerp_colors32(s->color_rgbaf, s->nb_colors, s->nb_colors + s->type == 2 ,factor,312 lerp_colors32(s->color_rgbaf, s->nb_colors, s->nb_colors + s->type >= 2 ,factor,
308 &dst_r[x], &dst_g[x], &dst_b[x], &dst_a[x]);313 &dst_r[x], &dst_g[x], &dst_b[x], &dst_a[x]);
309 }314 }
310 315

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t