52 #define OFFSET(x) offsetof(GradientsContext, x) 53 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 96 const float y = 1.f - x;
98 return (
lrint(c0[0] * y + c1[0] * x)) << 0 |
99 (
lrint(c0[1] * y + c1[1] * x)) << 8 |
100 (
lrint(c0[2] * y + c1[2] * x)) << 16 |
101 (
lrint(c0[3] * y + c1[3] * x)) << 24;
106 const float y = 1.f - x;
108 return (
llrint((c0[0] * y + c1[0] * x) * 256)) << 0 |
109 (
llrint((c0[1] * y + c1[1] * x) * 256)) << 16 |
110 (
llrint((c0[2] * y + c1[2] * x) * 256)) << 32 |
111 (
llrint((c0[3] * y + c1[3] * x) * 256)) << 48;
119 if (nb_colors == 1 || step <= 0.0) {
120 return arr[0][0] | (arr[0][1] << 8) | (arr[0][2] << 16) | (arr[0][3] << 24);
121 }
else if (step >= 1.0) {
123 return arr[
i][0] | (arr[
i][1] << 8) | (arr[i][2] << 16) | (arr[
i][3] << 24);
126 scl = step * (nb_colors - 1);
129 return lerp_color(arr[i], arr[i + 1], scl - i);
137 if (nb_colors == 1 || step <= 0.0) {
138 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);
139 }
else if (step >= 1.0) {
141 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);
144 scl = step * (nb_colors - 1);
150 static float project(
float origin_x,
float origin_y,
151 float dest_x,
float dest_y,
152 int point_x,
int point_y)
155 float od_x = dest_x - origin_x;
156 float od_y = dest_y - origin_y;
159 float od_s_q = od_x * od_x + od_y * od_y;
162 float op_x = point_x - origin_x;
163 float op_y = point_y - origin_y;
164 float op_x_od = op_x * od_x + op_y * od_y;
167 return av_clipf(op_x_od / od_s_q, 0.
f, 1.
f);
176 const int start = (height * job ) / nb_jobs;
177 const int end = (height * (job+1)) / nb_jobs;
178 const int linesize = frame->
linesize[0] / 4;
179 uint32_t *dst = (uint32_t *)frame->
data[0] + start * linesize;
181 for (
int y = start; y <
end; y++) {
182 for (
int x = 0; x <
width; x++) {
199 const int start = (height * job ) / nb_jobs;
200 const int end = (height * (job+1)) / nb_jobs;
201 const int linesize = frame->
linesize[0] / 8;
202 uint64_t *dst = (uint64_t *)frame->
data[0] + start * linesize;
204 for (
int y = start; y <
end; y++) {
205 for (
int x = 0; x <
width; x++) {
233 if (s->
x0 < 0 || s->
x0 >= s->
w)
235 if (s->
y0 < 0 || s->
y0 >= s->
h)
237 if (s->
x1 < 0 || s->
x1 >= s->
w)
239 if (s->
y1 < 0 || s->
y1 >= s->
h)
250 float angle = fmodf(s->
pts / 100.f, 2.f *
M_PI);
251 const float w2 = s->
w / 2.f;
252 const float h2 = s->
h / 2.f;
285 .priv_class = &gradients_class,
Context structure for the Lagged Fibonacci PRNG.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int draw_gradients_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
#define AV_PIX_FMT_RGBA64
int h
agreed upon image height
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int gradients_request_frame(AVFilterLink *outlink)
A filter pad used for either input or output.
A link between two filters.
#define i(width, name, range_min, range_max)
AVFilter ff_vsrc_gradients
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
static uint32_t lerp_colors(uint8_t arr[3][4], int nb_colors, float step)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static float project(float origin_x, float origin_y, float dest_x, float dest_y, int point_x, int point_y)
int w
agreed upon image width
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...
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
static const AVOption gradients_options[]
AVFilterContext * src
source filter
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int format
agreed upon media format
static int draw_gradients_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static uint32_t lerp_color(uint8_t c0[4], uint8_t c1[4], float x)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
offset must point to AVRational
static const int factor[16]
const char * name
Filter name.
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
offset must point to two consecutive integers
AVFILTER_DEFINE_CLASS(gradients)
static enum AVPixelFormat pix_fmts[]
#define flags(name, subs,...)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static int config_output(AVFilterLink *inlink)
static uint64_t lerp_colors16(uint8_t arr[3][4], int nb_colors, float step)
avfilter_execute_func * execute
static uint64_t lerp_color16(uint8_t c0[4], uint8_t c1[4], float x)
static const AVFilterPad gradients_outputs[]
int(* draw_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static int query_formats(AVFilterContext *ctx)
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
int depth
Number of bits in the component.
AVPixelFormat
Pixel format.