55 #define OFFSET(x) offsetof(GradientsContext, x)
56 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
102 const float y = 1.f - x;
104 return (
lrintf(c0[0] * y +
c1[0] * x)) << 0 |
105 (
lrintf(c0[1] * y +
c1[1] * x)) << 8 |
106 (
lrintf(c0[2] * y +
c1[2] * x)) << 16 |
107 (
lrintf(c0[3] * y +
c1[3] * x)) << 24;
112 const float y = 1.f - x;
114 return (
llrintf((c0[0] * y +
c1[0] * x) * 256)) << 0 |
115 (
llrintf((c0[1] * y +
c1[1] * x) * 256)) << 16 |
116 (
llrintf((c0[2] * y +
c1[2] * x) * 256)) << 32 |
117 (
llrintf((c0[3] * y +
c1[3] * x) * 256)) << 48;
125 if (nb_colors == 1 || step <= 0.0) {
126 return arr[0][0] | (arr[0][1] << 8) | (arr[0][2] << 16) | (arr[0][3] << 24);
127 }
else if (step >= 1.0) {
129 return arr[
i][0] | (arr[
i][1] << 8) | (arr[
i][2] << 16) | (arr[
i][3] << 24);
132 scl = step * (nb_colors - 1);
143 if (nb_colors == 1 || step <= 0.0) {
144 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);
145 }
else if (step >= 1.0) {
147 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);
150 scl = step * (nb_colors - 1);
156 static float project(
float origin_x,
float origin_y,
157 float dest_x,
float dest_y,
158 int point_x,
int point_y)
161 float od_x = dest_x - origin_x;
162 float od_y = dest_y - origin_y;
165 float od_s_q = od_x * od_x + od_y * od_y;
168 float op_x = point_x - origin_x;
169 float op_y = point_y - origin_y;
170 float op_x_od = op_x * od_x + op_y * od_y;
173 return av_clipf(op_x_od / od_s_q, 0.f, 1.f);
182 const int start = (
height * job ) / nb_jobs;
183 const int end = (
height * (job+1)) / nb_jobs;
185 uint32_t *dst = (uint32_t *)
frame->
data[0] + start * linesize;
187 for (
int y = start; y < end; y++) {
188 for (
int x = 0; x <
width; x++) {
205 const int start = (
height * job ) / nb_jobs;
206 const int end = (
height * (job+1)) / nb_jobs;
208 uint64_t *dst = (uint64_t *)
frame->
data[0] + start * linesize;
210 for (
int y = start; y < end; y++) {
211 for (
int x = 0; x <
width; x++) {
239 if (
s->x0 < 0 ||
s->x0 >=
s->w)
241 if (
s->y0 < 0 ||
s->y0 >=
s->h)
243 if (
s->x1 < 0 ||
s->x1 >=
s->w)
245 if (
s->y1 < 0 ||
s->y1 >=
s->h)
256 if (
s->duration >= 0 &&
264 float angle = fmodf(
s->pts *
s->speed, 2.f *
M_PI);
265 const float w2 =
s->w / 2.f;
266 const float h2 =
s->h / 2.f;
268 s->fx0 = (
s->x0 - w2) *
cosf(angle) - (
s->y0 - h2) *
sinf(angle) + w2;
269 s->fy0 = (
s->x0 - w2) *
sinf(angle) + (
s->y0 - h2) *
cosf(angle) + h2;
271 s->fx1 = (
s->x1 - w2) *
cosf(angle) - (
s->y1 - h2) *
sinf(angle) + w2;
272 s->fy1 = (
s->x1 - w2) *
sinf(angle) + (
s->y1 - h2) *
cosf(angle) + h2;
305 .priv_class = &gradients_class,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define flags(name, subs,...)
static __device__ float floorf(float a)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
#define AVERROR_EOF
End of file.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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...
@ AV_PICTURE_TYPE_I
Intra.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_RGBA64
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int interlaced_frame
The content of the picture is interlaced.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVPictureType pict_type
Picture type of the frame.
Context structure for the Lagged Fibonacci PRNG.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
int64_t duration
duration expressed in microseconds
int(* draw_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static const int factor[16]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static uint32_t lerp_colors(uint8_t arr[3][4], int nb_colors, float step)
AVFilter ff_vsrc_gradients
AVFILTER_DEFINE_CLASS(gradients)
static int config_output(AVFilterLink *inlink)
static int query_formats(AVFilterContext *ctx)
static int draw_gradients_slice16(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 float project(float origin_x, float origin_y, float dest_x, float dest_y, int point_x, int point_y)
static uint64_t lerp_colors16(uint8_t arr[3][4], int nb_colors, float step)
static uint64_t lerp_color16(uint8_t c0[4], uint8_t c1[4], float x)
static const AVOption gradients_options[]
static const AVFilterPad gradients_outputs[]