Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -79,11 +79,12 @@ static const AVOption gradients_options[] = { · 78 unmodified lines | ||
| 79 | 79 | {"duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS }, |
| 80 | 80 | {"d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS }, |
| 81 | 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" }, | |
| 83 | − {"t", "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, 3, FLAGS, "type" }, | |
| 84 | 84 | {"linear", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "type" }, |
| 85 | 85 | {"radial", "set gradient type", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "type" }, |
| 86 | 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 | 88 | {NULL}, |
| 88 | 89 | }; |
| 89 | 90 | |
| @@ -218,6 +219,7 @@ static float project(float origin_x, float origin_y, · 128 unmodified lines | ||
| 218 | 219 | od_s_q = sqrtf(od_x * od_x + od_y * od_y); |
| 219 | 220 | break; |
| 220 | 221 | case 2: |
| 222 | + case 3: | |
| 221 | 223 | od_s_q = M_PI * 2.f; |
| 222 | 224 | break; |
| 223 | 225 | } |
| @@ -232,6 +234,9 @@ static float project(float origin_x, float origin_y, · 8 unmodified lines | ||
| 232 | 234 | case 2: |
| 233 | 235 | op_x_od = atan2f(op_x, op_y) + M_PI; |
| 234 | 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 | 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 | 257 | for (int y = start; y < end; y++) { |
| 253 | 258 | for (int x = 0; x < width; x++) { |
| 254 | 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 | 263 | dst += linesize; |
| @@ -275,7 +280,7 @@ static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int · 16 unmodified lines | ||
| 275 | 280 | for (int y = start; y < end; y++) { |
| 276 | 281 | for (int x = 0; x < width; x++) { |
| 277 | 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 | 286 | dst += linesize; |
| @@ -304,7 +309,7 @@ static int draw_gradients_slice32_planar(AVFilterContext *ctx, void *arg, int jo · 22 unmodified lines | ||
| 304 | 309 | for (int y = start; y < end; y++) { |
| 305 | 310 | for (int x = 0; x < width; x++) { |
| 306 | 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 | 313 | &dst_r[x], &dst_g[x], &dst_b[x], &dst_a[x]); |
| 309 | 314 | } |
| 310 | 315 | |