FFmpeg
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 "formats.h"
24 #include "video.h"
25 #include "internal.h"
26 #include "libavutil/imgutils.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/parseutils.h"
30 #include "libavutil/lfg.h"
31 #include "libavutil/random_seed.h"
32 #include <float.h>
33 #include <math.h>
34 
35 typedef struct GradientsContext {
36  const AVClass *class;
37  int w, h;
38  int type;
40  int64_t pts;
41  int64_t duration; ///< duration expressed in microseconds
42  float speed;
43 
44  uint8_t color_rgba[8][4];
45  int nb_colors;
46  int x0, y0, x1, y1;
47  float fx0, fy0, fx1, fy1;
48 
49  int64_t seed;
50 
52  int (*draw_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs);
54 
55 #define OFFSET(x) offsetof(GradientsContext, x)
56 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
57 
58 static const AVOption gradients_options[] = {
59  {"size", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="640x480"}, 0, 0, FLAGS },
60  {"s", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="640x480"}, 0, 0, FLAGS },
61  {"rate", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
62  {"r", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
63  {"c0", "set 1st color", OFFSET(color_rgba[0]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
64  {"c1", "set 2nd color", OFFSET(color_rgba[1]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
65  {"c2", "set 3rd color", OFFSET(color_rgba[2]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
66  {"c3", "set 4th color", OFFSET(color_rgba[3]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
67  {"c4", "set 5th color", OFFSET(color_rgba[4]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
68  {"c5", "set 6th color", OFFSET(color_rgba[5]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
69  {"c6", "set 7th color", OFFSET(color_rgba[6]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
70  {"c7", "set 8th color", OFFSET(color_rgba[7]), AV_OPT_TYPE_COLOR, {.str = "random"}, 0, 0, FLAGS },
71  {"x0", "set gradient line source x0", OFFSET(x0), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
72  {"y0", "set gradient line source y0", OFFSET(y0), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
73  {"x1", "set gradient line destination x1", OFFSET(x1), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
74  {"y1", "set gradient line destination y1", OFFSET(y1), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS },
75  {"nb_colors", "set the number of colors", OFFSET(nb_colors), AV_OPT_TYPE_INT, {.i64=2}, 2, 8, FLAGS },
76  {"n", "set the number of colors", OFFSET(nb_colors), AV_OPT_TYPE_INT, {.i64=2}, 2, 8, FLAGS },
77  {"seed", "set the seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT32_MAX, FLAGS },
78  {"duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },\
79  {"d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=-1}, -1, INT64_MAX, FLAGS },\
80  {"speed", "set gradients rotation speed", OFFSET(speed), AV_OPT_TYPE_FLOAT,{.dbl=0.01}, 0.00001, 1, FLAGS },\
81  {NULL},
82 };
83 
84 AVFILTER_DEFINE_CLASS(gradients);
85 
86 static uint32_t lerp_color(uint8_t c0[4], uint8_t c1[4], float x)
87 {
88  const float y = 1.f - x;
89 
90  return (lrintf(c0[0] * y + c1[0] * x)) << 0 |
91  (lrintf(c0[1] * y + c1[1] * x)) << 8 |
92  (lrintf(c0[2] * y + c1[2] * x)) << 16 |
93  (lrintf(c0[3] * y + c1[3] * x)) << 24;
94 }
95 
96 static uint64_t lerp_color16(uint8_t c0[4], uint8_t c1[4], float x)
97 {
98  const float y = 1.f - x;
99 
100  return (llrintf((c0[0] * y + c1[0] * x) * 256)) << 0 |
101  (llrintf((c0[1] * y + c1[1] * x) * 256)) << 16 |
102  (llrintf((c0[2] * y + c1[2] * x) * 256)) << 32 |
103  (llrintf((c0[3] * y + c1[3] * x) * 256)) << 48;
104 }
105 
106 static uint32_t lerp_colors(uint8_t arr[3][4], int nb_colors, float step)
107 {
108  float scl;
109  int i;
110 
111  if (nb_colors == 1 || step <= 0.0) {
112  return arr[0][0] | (arr[0][1] << 8) | (arr[0][2] << 16) | (arr[0][3] << 24);
113  } else if (step >= 1.0) {
114  i = nb_colors - 1;
115  return arr[i][0] | (arr[i][1] << 8) | (arr[i][2] << 16) | (arr[i][3] << 24);
116  }
117 
118  scl = step * (nb_colors - 1);
119  i = floorf(scl);
120 
121  return lerp_color(arr[i], arr[i + 1], scl - i);
122 }
123 
124 static uint64_t lerp_colors16(uint8_t arr[3][4], int nb_colors, float step)
125 {
126  float scl;
127  int i;
128 
129  if (nb_colors == 1 || step <= 0.0) {
130  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);
131  } else if (step >= 1.0) {
132  i = nb_colors - 1;
133  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);
134  }
135 
136  scl = step * (nb_colors - 1);
137  i = floorf(scl);
138 
139  return lerp_color16(arr[i], arr[i + 1], scl - i);
140 }
141 
142 static float project(float origin_x, float origin_y,
143  float dest_x, float dest_y,
144  int point_x, int point_y)
145 {
146  // Rise and run of line.
147  float od_x = dest_x - origin_x;
148  float od_y = dest_y - origin_y;
149 
150  // Distance-squared of line.
151  float od_s_q = od_x * od_x + od_y * od_y;
152 
153  // Rise and run of projection.
154  float op_x = point_x - origin_x;
155  float op_y = point_y - origin_y;
156  float op_x_od = op_x * od_x + op_y * od_y;
157 
158  // Normalize and clamp range.
159  return av_clipf(op_x_od / od_s_q, 0.f, 1.f);
160 }
161 
162 static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
163 {
164  GradientsContext *s = ctx->priv;
165  AVFrame *frame = arg;
166  const int width = frame->width;
167  const int height = frame->height;
168  const int start = (height * job ) / nb_jobs;
169  const int end = (height * (job+1)) / nb_jobs;
170  const int linesize = frame->linesize[0] / 4;
171  uint32_t *dst = (uint32_t *)frame->data[0] + start * linesize;
172 
173  for (int y = start; y < end; y++) {
174  for (int x = 0; x < width; x++) {
175  float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y);
176  dst[x] = lerp_colors(s->color_rgba, s->nb_colors, factor);
177  }
178 
179  dst += linesize;
180  }
181 
182  return 0;
183 }
184 
185 static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
186 {
187  GradientsContext *s = ctx->priv;
188  AVFrame *frame = arg;
189  const int width = frame->width;
190  const int height = frame->height;
191  const int start = (height * job ) / nb_jobs;
192  const int end = (height * (job+1)) / nb_jobs;
193  const int linesize = frame->linesize[0] / 8;
194  uint64_t *dst = (uint64_t *)frame->data[0] + start * linesize;
195 
196  for (int y = start; y < end; y++) {
197  for (int x = 0; x < width; x++) {
198  float factor = project(s->fx0, s->fy0, s->fx1, s->fy1, x, y);
199  dst[x] = lerp_colors16(s->color_rgba, s->nb_colors, factor);
200  }
201 
202  dst += linesize;
203  }
204 
205  return 0;
207 {
208  AVFilterContext *ctx = inlink->src;
209  GradientsContext *s = ctx->priv;
211 
212  if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
213  return AVERROR(EINVAL);
214 
215  inlink->w = s->w;
216  inlink->h = s->h;
217  inlink->time_base = av_inv_q(s->frame_rate);
218  inlink->sample_aspect_ratio = (AVRational) {1, 1};
219  if (s->seed == -1)
220  s->seed = av_get_random_seed();
221  av_lfg_init(&s->lfg, s->seed);
222 
223  s->draw_slice = desc->comp[0].depth == 16 ? draw_gradients_slice16 : draw_gradients_slice;
224 
225  if (s->x0 < 0 || s->x0 >= s->w)
226  s->x0 = av_lfg_get(&s->lfg) % s->w;
227  if (s->y0 < 0 || s->y0 >= s->h)
228  s->y0 = av_lfg_get(&s->lfg) % s->h;
229  if (s->x1 < 0 || s->x1 >= s->w)
230  s->x1 = av_lfg_get(&s->lfg) % s->w;
231  if (s->y1 < 0 || s->y1 >= s->h)
232  s->y1 = av_lfg_get(&s->lfg) % s->h;
233 
234  return 0;
235 }
236 
238 {
239  GradientsContext *s = ctx->priv;
240  AVFilterLink *outlink = ctx->outputs[0];
241 
242  if (s->duration >= 0 &&
243  av_rescale_q(s->pts, outlink->time_base, AV_TIME_BASE_Q) >= s->duration) {
244  ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
245  return 0;
246  }
247 
248  if (ff_outlink_frame_wanted(outlink)) {
249  AVFrame *frame = ff_get_video_buffer(outlink, s->w, s->h);
250  float angle = fmodf(s->pts * s->speed, 2.f * M_PI);
251  const float w2 = s->w / 2.f;
252  const float h2 = s->h / 2.f;
253 
254  s->fx0 = (s->x0 - w2) * cosf(angle) - (s->y0 - h2) * sinf(angle) + w2;
255  s->fy0 = (s->x0 - w2) * sinf(angle) + (s->y0 - h2) * cosf(angle) + h2;
256 
257  s->fx1 = (s->x1 - w2) * cosf(angle) - (s->y1 - h2) * sinf(angle) + w2;
258  s->fy1 = (s->x1 - w2) * sinf(angle) + (s->y1 - h2) * cosf(angle) + h2;
259 
260  if (!frame)
261  return AVERROR(ENOMEM);
262 
263  frame->key_frame = 1;
264  frame->interlaced_frame = 0;
265  frame->pict_type = AV_PICTURE_TYPE_I;
266  frame->sample_aspect_ratio = (AVRational) {1, 1};
267  frame->pts = s->pts++;
268 
269  ff_filter_execute(ctx, s->draw_slice, frame, NULL,
270  FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
271 
272  return ff_filter_frame(outlink, frame);
273  }
274 
275  return FFERROR_NOT_READY;
276 }
277 
278 static const AVFilterPad gradients_outputs[] = {
279  {
280  .name = "default",
281  .type = AVMEDIA_TYPE_VIDEO,
282  .config_props = config_output,
283  },
284 };
285 
287  .name = "gradients",
288  .description = NULL_IF_CONFIG_SMALL("Draw a gradients."),
289  .priv_size = sizeof(GradientsContext),
290  .priv_class = &gradients_class,
291  .inputs = NULL,
294  .activate = activate,
296 };
GradientsContext::nb_colors
int nb_colors
Definition: vsrc_gradients.c:45
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
GradientsContext::pts
int64_t pts
Definition: vsrc_gradients.c:40
av_lfg_init
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
Definition: lfg.c:32
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
ff_vsrc_gradients
const AVFilter ff_vsrc_gradients
Definition: vsrc_gradients.c:286
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:237
floorf
static __device__ float floorf(float a)
Definition: cuda_runtime.h:172
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:247
GradientsContext::lfg
AVLFG lfg
Definition: vsrc_gradients.c:51
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:238
float.h
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
c1
static const uint64_t c1
Definition: murmur3.c:51
video.h
av_get_random_seed
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:120
formats.h
cosf
#define cosf(x)
Definition: libm.h:78
lerp_colors
static uint32_t lerp_colors(uint8_t arr[3][4], int nb_colors, float step)
Definition: vsrc_gradients.c:106
config_output
static int config_output(AVFilterLink *inlink)
Definition: vsrc_gradients.c:206
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
GradientsContext::y0
int y0
Definition: vsrc_gradients.c:46
duration
int64_t duration
Definition: movenc.c:64
GradientsContext::fy0
float fy0
Definition: vsrc_gradients.c:47
ff_outlink_set_status
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:189
width
#define width
llrintf
#define llrintf(x)
Definition: libm.h:399
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
av_lfg_get
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Definition: lfg.h:53
lfg.h
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:225
filters.h
gradients_options
static const AVOption gradients_options[]
Definition: vsrc_gradients.c:58
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:141
f
#define f(width, name)
Definition: cbs_vp9.c:255
lerp_colors16
static uint64_t lerp_colors16(uint8_t arr[3][4], int nb_colors, float step)
Definition: vsrc_gradients.c:124
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
arg
const char * arg
Definition: jacosubdec.c:67
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:394
GradientsContext::seed
int64_t seed
Definition: vsrc_gradients.c:49
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
OFFSET
#define OFFSET(x)
Definition: vsrc_gradients.c:55
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
gradients_outputs
static const AVFilterPad gradients_outputs[]
Definition: vsrc_gradients.c:278
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:239
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:234
av_clipf
#define av_clipf
Definition: common.h:144
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
parseutils.h
GradientsContext::duration
int64_t duration
duration expressed in microseconds
Definition: vsrc_gradients.c:41
GradientsContext::y1
int y1
Definition: vsrc_gradients.c:46
sinf
#define sinf(x)
Definition: libm.h:419
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
seed
static unsigned int seed
Definition: videogen.c:78
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
GradientsContext::fx0
float fx0
Definition: vsrc_gradients.c:47
GradientsContext::w
int w
Definition: vsrc_gradients.c:37
AVLFG
Context structure for the Lagged Fibonacci PRNG.
Definition: lfg.h:33
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
FLAGS
#define FLAGS
Definition: vsrc_gradients.c:56
GradientsContext::h
int h
Definition: vsrc_gradients.c:37
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: internal.h:177
GradientsContext::x0
int x0
Definition: vsrc_gradients.c:46
GradientsContext::speed
float speed
Definition: vsrc_gradients.c:42
GradientsContext::x1
int x1
Definition: vsrc_gradients.c:46
height
#define height
draw_gradients_slice
static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vsrc_gradients.c:162
GradientsContext::fx1
float fx1
Definition: vsrc_gradients.c:47
M_PI
#define M_PI
Definition: mathematics.h:52
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
GradientsContext
Definition: vsrc_gradients.c:35
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:803
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
AVFilter
Filter definition.
Definition: avfilter.h:165
GradientsContext::fy1
float fy1
Definition: vsrc_gradients.c:47
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(gradients)
random_seed.h
GradientsContext::type
int type
Definition: vsrc_gradients.c:38
lerp_color16
static uint64_t lerp_color16(uint8_t c0[4], uint8_t c1[4], float x)
Definition: vsrc_gradients.c:96
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
factor
static const int factor[16]
Definition: vf_pp7.c:76
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
GradientsContext::draw_slice
int(* draw_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vsrc_gradients.c:52
GradientsContext::color_rgba
uint8_t color_rgba[8][4]
Definition: vsrc_gradients.c:44
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
activate
static int activate(AVFilterContext *ctx)
Definition: vsrc_gradients.c:237
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
GradientsContext::frame_rate
AVRational frame_rate
Definition: vsrc_gradients.c:39
imgutils.h
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
av_image_check_size
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
project
static float project(float origin_x, float origin_y, float dest_x, float dest_y, int point_x, int point_y)
Definition: vsrc_gradients.c:142
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:143
int
int
Definition: ffmpeg_filter.c:153
lerp_color
static uint32_t lerp_color(uint8_t c0[4], uint8_t c1[4], float x)
Definition: vsrc_gradients.c:86
draw_gradients_slice16
static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vsrc_gradients.c:185