56 #define OFFSET(x) offsetof(SierpinskiContext, x)
57 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
89 int pos_x = x +
s->pos_x;
90 int pos_y = y +
s->pos_y;
92 while (pos_x != 0 && pos_y != 0) {
93 if (
FFABS(pos_x % 3) == 1 &&
FFABS(pos_y % 3) == 1)
109 const int start = (
height * job ) / nb_jobs;
110 const int end = (
height * (job+1)) / nb_jobs;
113 for (
int y = start; y < end; y++) {
114 for (
int x = 0; x <
width; x++) {
115 if ((
s->pos_x + x) & (
s->pos_y + y)) {
116 AV_WL32(&dst[x*4], 0x00000000);
118 AV_WL32(&dst[x*4], 0xFFFFFFFF);
134 const int start = (
height * job ) / nb_jobs;
135 const int end = (
height * (job+1)) / nb_jobs;
138 for (
int y = start; y < end; y++) {
139 for (
int x = 0; x <
width; x++) {
141 AV_WL32(&dst[x*4], 0x00000000);
143 AV_WL32(&dst[x*4], 0xFFFFFFFF);
179 if (
s->pos_x ==
s->dest_x &&
s->pos_y ==
s->dest_y) {
181 int mod = 2 *
s->jump + 1;
183 s->dest_x += (
int)((
rnd & 0xffff) %
mod) -
s->jump;
184 s->dest_y += (
int)((
rnd >> 16) %
mod) -
s->jump;
186 if (
s->pos_x <
s->dest_x)
188 else if (
s->pos_x >
s->dest_x)
191 if (
s->pos_y <
s->dest_y)
193 else if (
s->pos_y >
s->dest_y)
227 .
name =
"sierpinski",
230 .priv_class = &sierpinski_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,...)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
@ 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.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
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_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[]
AVPixelFormat
Pixel format.
#define AV_PIX_FMT_0BGR32
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
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
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.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Context structure for the Lagged Fibonacci PRNG.
Rational number (pair of numerator and denominator).
int(* draw_slice)(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static int mod(int a, int b)
Modulo operation with only positive remainders.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int draw_carpet_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static void draw_sierpinski(AVFilterContext *ctx, AVFrame *frame)
static int sierpinski_request_frame(AVFilterLink *link)
static int draw_triangle_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static int config_output(AVFilterLink *inlink)
static int query_formats(AVFilterContext *ctx)
AVFILTER_DEFINE_CLASS(sierpinski)
static const AVFilterPad sierpinski_outputs[]
AVFilter ff_vsrc_sierpinski
static const AVOption sierpinski_options[]
static int fill_sierpinski(SierpinskiContext *s, int x, int y)