FFmpeg
Loading...
Searching...
No Matches
vsrc_gradients.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Paul B Mahol
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "avfilter.h"
22#include "filters.h"
23#include "video.h"
24#include "libavutil/imgutils.h"
25#include "libavutil/opt.h"
26#include "libavutil/lfg.h"
28#include <float.h>
29#include <math.h>
30
31typedef struct GradientsContext {
32 const AVClass *class;
33 int w, h;
34 int type;
37 int64_t duration; ///< duration expressed in microseconds
38 float speed;
39 float angle;
40
41 uint8_t color_rgba[8][4];
42 float color_rgbaf[8][4];
44 int x0, y0, x1, y1;
45 float fx0, fy0, fx1, fy1;
46
48
50 int (*draw_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs);
52
53#define OFFSET(x) offsetof(GradientsContext, x)
54#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
55#define VFT AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
56
57static const AVOption gradients_options[] = {
58 {"size", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="640x480"}, 0, 0, FLAGS },
59 {"s", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="640x480"}, 0, 0, FLAGS },
60 {"rate", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
61 {"r", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
62 {"c0", "set 1st color", OFFSET(color_rgba[0]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
63 {"c1", "set 2nd color", OFFSET(color_rgba[1]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
64 {"c2", "set 3rd color", OFFSET(color_rgba[2]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
65 {"c3", "set 4th color", OFFSET(color_rgba[3]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
66 {"c4", "set 5th color", OFFSET(color_rgba[4]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
67 {"c5", "set 6th color", OFFSET(color_rgba[5]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
68 {"c6", "set 7th color", OFFSET(color_rgba[6]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
69 {"c7", "set 8th color", OFFSET(color_rgba[7]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
70 {"x0", "set gradient line source x0", OFFSET(x0), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
71 {"y0", "set gradient line source y0", OFFSET(y0), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
72 {"x1", "set gradient line destination x1", OFFSET(x1), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
73 {"y1", "set gradient line destination y1", OFFSET(y1), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
74 {"nb_colors", "set the number of colors", OFFSET(nb_colors), AV_OPT_TYPE_INT, {.i64=2}, 2, 8, FLAGS },
75 {"n", "set the number of colors", OFFSET(nb_colors), AV_OPT_TYPE_INT, {.i64=2}, 2, 8, FLAGS },
76 {"seed", "set the seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT32_MAX, FLAGS },
77 {"duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
78 {"d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },
79 {"speed", "set gradients rotation speed", OFFSET(speed), AV_OPT_TYPE_FLOAT,{.dbl=0.01}, 0, 1, VFT },
80 {"type", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 4, VFT, .unit = "type" },
81 {"t", "set gradient type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 4, VFT, .unit = "type" },
82 { "linear", "set linear gradient", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, VFT, .unit = "type" },
83 { "radial", "set radial gradient", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, VFT, .unit = "type" },
84 { "circular", "set circular gradient", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, VFT, .unit = "type" },
85 { "spiral", "set spiral gradient", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, VFT, .unit = "type" },
86 { "square", "set square gradient", 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, VFT, .unit = "type" },
87 {NULL},
88};
89
91
92static float lerpf(float a, float b, float x)
93{
94 const float y = 1.f - x;
95
96 return a * y + b * x;
97}
98
99static uint32_t lerp_color(uint8_t c0[4], uint8_t c1[4], float x)
100{
101 const float y = 1.f - x;
102
103 return (lrintf(c0[0] * y + c1[0] * x)) << 0 |
104 (lrintf(c0[1] * y + c1[1] * x)) << 8 |
105 (lrintf(c0[2] * y + c1[2] * x)) << 16 |
106 (lrintf(c0[3] * y + c1[3] * x)) << 24;
107}
108
109static uint64_t lerp_color16(uint8_t c0[4], uint8_t c1[4], float x)
110{
111 const float y = 1.f - x;
112
113 return ((uint64_t)llrintf((c0[0] * y + c1[0] * x) * 256)) << 0 |
114 ((uint64_t)llrintf((c0[1] * y + c1[1] * x) * 256)) << 16 |
115 ((uint64_t)llrintf((c0[2] * y + c1[2] * x) * 256)) << 32 |
116 ((uint64_t)llrintf((c0[3] * y + c1[3] * x) * 256)) << 48;
117}
118
119static uint32_t lerp_colors(uint8_t arr[8][4], int nb_colors, int nb_wrap_colors, float step)
120{
121 float scl;
122 int i, j;
123
124 if (nb_colors == 1 || step <= 0.0) {
125 return arr[0][0] | (arr[0][1] << 8) | (arr[0][2] << 16) | (arr[0][3] << 24);
126 } else if (step >= 1.0) {
127 i = nb_colors - 1;
128 return arr[i][0] | (arr[i][1] << 8) | (arr[i][2] << 16) | (arr[i][3] << 24);
129 }
130
131 scl = step * (nb_wrap_colors - 1);
132 i = floorf(scl);
133 j = i + 1;
134 if (i >= nb_colors - 1) {
135 i = nb_colors - 1;
136 j = 0;
137 }
138
139 return lerp_color(arr[i], arr[j], scl - i);
140}
141
142static uint64_t lerp_colors16(uint8_t arr[8][4], int nb_colors, int nb_wrap_colors, float step)
143{
144 float scl;
145 int i, j;
146
147 if (nb_colors == 1 || step <= 0.0) {
148 return ((uint64_t)arr[0][0] << 8) | ((uint64_t)arr[0][1] << 24) | ((uint64_t)arr[0][2] << 40) | ((uint64_t)arr[0][3] << 56);
149 } else if (step >= 1.0) {
150 i = nb_colors - 1;
151 return ((uint64_t)arr[i][0] << 8) | ((uint64_t)arr[i][1] << 24) | ((uint64_t)arr[i][2] << 40) | ((uint64_t)arr[i][3] << 56);
152 }
153
154 scl = step * (nb_wrap_colors - 1);
155 i = floorf(scl);
156 j = i + 1;
157 if (i >= nb_colors - 1) {
158 i = nb_colors - 1;
159 j = 0;
160 }
161
162 return lerp_color16(arr[i], arr[j], scl - i);
163}
164
165static void lerp_colors32(float arr[8][4], int nb_colors,
166 int nb_wrap_colors, float step,
167 float *r, float *g, float *b, float *a)
168{
169 float scl, x;
170 int i, j;
171
172 if (nb_colors == 1 || step <= 0.0) {
173 *r = arr[0][0];
174 *g = arr[0][1];
175 *b = arr[0][2];
176 *a = arr[0][3];
177 return;
178 } else if (step >= 1.0) {
179 i = nb_colors - 1;
180 *r = arr[i][0];
181 *g = arr[i][1];
182 *b = arr[i][2];
183 *a = arr[i][3];
184 return;
185 }
186
187 scl = step * (nb_wrap_colors - 1);
188 i = floorf(scl);
189 j = i + 1;
190 if (i >= nb_colors - 1) {
191 i = nb_colors - 1;
192 j = 0;
193 }
194 x = scl - i;
195
196 *r = lerpf(arr[i][0], arr[j][0], x);
197 *g = lerpf(arr[i][1], arr[j][1], x);
198 *b = lerpf(arr[i][2], arr[j][2], x);
199 *a = lerpf(arr[i][3], arr[j][3], x);
200}
201
202static float project(float origin_x, float origin_y,
203 float dest_x, float dest_y,
204 float point_x, float point_y, int type)
205{
206 float op_x = point_x - origin_x;
207 float op_y = point_y - origin_y;
208 float od_x = dest_x - origin_x;
209 float od_y = dest_y - origin_y;
210 float op_x_od;
211 float od_s_q;
212
213 switch (type) {
214 case 0:
215 od_s_q = od_x * od_x + od_y * od_y;
216 break;
217 case 1:
218 od_s_q = sqrtf(od_x * od_x + od_y * od_y);
219 break;
220 case 2:
221 case 3:
222 od_s_q = M_PI * 2.f;
223 break;
224 case 4:
225 od_s_q = fmaxf(fabsf(od_x), fabsf(od_y));
226 break;
227 }
228
229 switch (type) {
230 case 0:
231 op_x_od = op_x * od_x + op_y * od_y;
232 break;
233 case 1:
234 op_x_od = sqrtf(op_x * op_x + op_y * op_y);
235 break;
236 case 2:
237 op_x_od = atan2f(op_x, op_y) + M_PI;
238 break;
239 case 3:
240 op_x_od = fmodf(atan2f(op_x, op_y) + M_PI + point_x / fmaxf(origin_x, dest_x), 2.f * M_PI);
241 break;
242 case 4:
243 op_x_od = fmaxf(fabsf(op_x), fabsf(op_y));
244 break;
245 }
246
247 // Normalize and clamp range.
248 return av_clipf(op_x_od / od_s_q, 0.f, 1.f);
249}
250
251static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
252{
253 GradientsContext *s = ctx->priv;
254 AVFrame *frame = arg;
255 const int width = frame->width;
256 const int height = frame->height;
257 const int start = (height * job ) / nb_jobs;
258 const int end = (height * (job+1)) / nb_jobs;
259 const ptrdiff_t linesize = frame->linesize[0] / 4;
260 uint32_t *dst = (uint32_t *)frame->data[0] + start * linesize;
261 const int type = s->type;
262
263 for (int y = start; y < end; y++) {
264 for (int x = 0; x < width; x++) {
265 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, type);
266 dst[x] = lerp_colors(s->color_rgba, s->nb_colors, s->nb_colors + (type >= 2 && type <= 3), factor);
267 }
268
269 dst += linesize;
270 }
271
272 return 0;
273}
274
275static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
276{
277 GradientsContext *s = ctx->priv;
278 AVFrame *frame = arg;
279 const int width = frame->width;
280 const int height = frame->height;
281 const int start = (height * job ) / nb_jobs;
282 const int end = (height * (job+1)) / nb_jobs;
283 const ptrdiff_t linesize = frame->linesize[0] / 8;
284 uint64_t *dst = (uint64_t *)frame->data[0] + start * linesize;
285 const int type = s->type;
286
287 for (int y = start; y < end; y++) {
288 for (int x = 0; x < width; x++) {
289 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, type);
290 dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, s->nb_colors + (type >= 2 && type <= 3), factor);
291 }
292
293 dst += linesize;
294 }
295
296 return 0;
297}
298
299static int draw_gradients_slice32_planar(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
300{
301 GradientsContext *s = ctx->priv;
302 AVFrame *frame = arg;
303 const int width = frame->width;
304 const int height = frame->height;
305 const int start = (height * job ) / nb_jobs;
306 const int end = (height * (job+1)) / nb_jobs;
307 const ptrdiff_t linesize_g = frame->linesize[0] / 4;
308 const ptrdiff_t linesize_b = frame->linesize[1] / 4;
309 const ptrdiff_t linesize_r = frame->linesize[2] / 4;
310 const ptrdiff_t linesize_a = frame->linesize[3] / 4;
311 float *dst_g = (float *)frame->data[0] + start * linesize_g;
312 float *dst_b = (float *)frame->data[1] + start * linesize_b;
313 float *dst_r = (float *)frame->data[2] + start * linesize_r;
314 float *dst_a = (float *)frame->data[3] + start * linesize_a;
315 const int type = s->type;
316
317 for (int y = start; y < end; y++) {
318 for (int x = 0; x < width; x++) {
319 float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y, type);
320 lerp_colors32(s->color_rgbaf, s->nb_colors, s->nb_colors + (type >= 2 && type <= 3), factor,
321 &dst_r[x], &dst_g[x], &dst_b[x], &dst_a[x]);
322 }
323
324 dst_g += linesize_g;
325 dst_b += linesize_b;
326 dst_r += linesize_r;
327 dst_a += linesize_a;
328 }
329
330 return 0;
331}
332
333static int config_output(AVFilterLink *outlink)
334{
335 AVFilterContext *ctx = outlink->src;
336 FilterLink *l = ff_filter_link(outlink);
337 GradientsContext *s = ctx->priv;
339
340 if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
341 return AVERROR(EINVAL);
342
343 outlink->w = s->w;
344 outlink->h = s->h;
345 outlink->time_base = av_inv_q(s->frame_rate);
346 outlink->sample_aspect_ratio = (AVRational) {1, 1};
347 l->frame_rate = s->frame_rate;
348 if (s->seed == -1)
349 s->seed = av_get_random_seed();
350 av_lfg_init(&s->lfg, s->seed);
351
352 switch (desc->comp[0].depth) {
353 case 8:
354 s->draw_slice = draw_gradients_slice;
355 break;
356 case 16:
357 s->draw_slice = draw_gradients_slice16;
358 break;
359 case 32:
360 s->draw_slice = draw_gradients_slice32_planar;
361 break;
362 default:
363 return AVERROR_BUG;
364 }
365
366 if (s->x0 < 0 || s->x0 >= s->w)
367 s->x0 = av_lfg_get(&s->lfg) % s->w;
368 if (s->y0 < 0 || s->y0 >= s->h)
369 s->y0 = av_lfg_get(&s->lfg) % s->h;
370 if (s->x1 < 0 || s->x1 >= s->w)
371 s->x1 = av_lfg_get(&s->lfg) % s->w;
372 if (s->y1 < 0 || s->y1 >= s->h)
373 s->y1 = av_lfg_get(&s->lfg) % s->h;
374
375 for (int n = 0; n < 8; n++) {
376 for (int c = 0; c < 4; c++)
377 s->color_rgbaf[n][c] = s->color_rgba[n][c] / 255.f;
378 }
379
380 return 0;
381}
382
384{
385 GradientsContext *s = ctx->priv;
386 AVFilterLink *outlink = ctx->outputs[0];
387
388 if (s->duration >= 0 &&
389 av_rescale_q(s->pts, outlink->time_base, AV_TIME_BASE_Q) >= s->duration) {
390 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
391 return 0;
392 }
393
394 if (ff_outlink_frame_wanted(outlink)) {
395 AVFrame *frame = ff_get_video_buffer(outlink, s->w, s->h);
396 float angle = fmodf(s->angle, 2.f * M_PI);
397 const float w2 = s->w / 2.f;
398 const float h2 = s->h / 2.f;
399
400 s->angle = angle + s->speed;
401
402 s->fx0 = (s->x0 - w2) * cosf(angle) - (s->y0 - h2) * sinf(angle) + w2;
403 s->fy0 = (s->x0 - w2) * sinf(angle) + (s->y0 - h2) * cosf(angle) + h2;
404
405 s->fx1 = (s->x1 - w2) * cosf(angle) - (s->y1 - h2) * sinf(angle) + w2;
406 s->fy1 = (s->x1 - w2) * sinf(angle) + (s->y1 - h2) * cosf(angle) + h2;
407
408 if (!frame)
409 return AVERROR(ENOMEM);
410
411 frame->flags |= AV_FRAME_FLAG_KEY;
413 frame->pict_type = AV_PICTURE_TYPE_I;
414 frame->sample_aspect_ratio = (AVRational) {1, 1};
415 frame->pts = s->pts++;
416 frame->duration = 1;
417
418 ff_filter_execute(ctx, s->draw_slice, frame, NULL,
419 FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
420
421 return ff_filter_frame(outlink, frame);
422 }
423
424 return FFERROR_NOT_READY;
425}
426
428 {
429 .name = "default",
430 .type = AVMEDIA_TYPE_VIDEO,
431 .config_props = config_output,
432 },
433};
434
436 .p.name = "gradients",
437 .p.description = NULL_IF_CONFIG_SMALL("Draw a gradients."),
438 .p.priv_class = &gradients_class,
439 .p.inputs = NULL,
441 .priv_size = sizeof(GradientsContext),
444 .activate = activate,
445 .process_command = ff_filter_process_command,
446};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
const FFFilter ff_vsrc_gradients
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Definition avfilter.c:1690
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition avfilter.c:906
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1696
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:846
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:598
#define av_clipf
Definition common.h:145
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static __device__ float sqrtf(float a)
static __device__ float fabsf(float a)
static __device__ float floorf(float a)
static AVFrame * frame
float fmaxf(float, float)
static int64_t duration
Definition ffplay.c:330
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition opt.h:318
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition opt.h:262
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition opt.h:322
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition error.h:52
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition frame.h:695
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition frame.h:687
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition rational.h:159
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition imgutils.c:318
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition avutil.h:263
int a
cl_device_type type
misc image utilities
#define r
Definition input.c:42
#define b
Definition input.c:43
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
Definition lfg.c:32
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Definition lfg.h:53
const char * arg
Definition jacosubdec.c:65
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS(...)
Definition filters.h:250
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition filters.h:629
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
Definition filters.h:34
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
static const int factor[16]
Definition vf_pp7.c:98
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
#define sinf(x)
Definition libm.h:421
#define cosf(x)
Definition libm.h:80
#define atan2f(y, x)
Definition libm.h:47
#define llrintf(x)
Definition libm.h:401
#define lrintf(x)
Definition libm_mips.h:72
const char * desc
Definition libsvtav1.c:83
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
#define M_PI
Definition mathematics.h:67
static const uint64_t c1
Definition murmur3.c:52
AVOptions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_RGBA64
Definition pixfmt.h:535
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
#define AV_PIX_FMT_GBRAPF32
Definition pixfmt.h:585
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
Context structure for the Lagged Fibonacci PRNG.
Definition lfg.h:33
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
Rational number (pair of numerator and denominator).
Definition rational.h:58
int64_t duration
duration expressed in microseconds
int(* draw_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
AVRational frame_rate
uint8_t color_rgba[8][4]
float color_rgbaf[8][4]
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
#define VFT
Definition vf_amplify.c:243
const char * g
Definition vf_curves.c:128
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89
static unsigned int seed
Definition videogen.c:78
static float lerpf(float a, float b, float x)
static void lerp_colors32(float arr[8][4], int nb_colors, int nb_wrap_colors, float step, float *r, float *g, float *b, float *a)
static float project(float origin_x, float origin_y, float dest_x, float dest_y, float point_x, float point_y, int type)
static uint32_t lerp_colors(uint8_t arr[8][4], int nb_colors, int nb_wrap_colors, float step)
static uint64_t lerp_colors16(uint8_t arr[8][4], int nb_colors, int nb_wrap_colors, float step)
static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static int draw_gradients_slice32_planar(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static uint32_t lerp_color(uint8_t c0[4], uint8_t c1[4], float x)
static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static int activate(AVFilterContext *ctx)
static uint64_t lerp_color16(uint8_t c0[4], uint8_t c1[4], float x)
static const AVOption gradients_options[]
#define OFFSET(x)
static int config_output(AVFilterLink *outlink)
static const AVFilterPad gradients_outputs[]
static double c[64]