FFmpeg  4.4.4
vsrc_mandelbrot.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Michael Niedermayer
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  * The vsrc_color filter from Stefano Sabatini was used as template to create
21  * this
22  */
23 
24 /**
25  * @file
26  * Mandelbrot fractal renderer
27  */
28 
29 #include "avfilter.h"
30 #include "formats.h"
31 #include "video.h"
32 #include "internal.h"
33 #include "libavutil/imgutils.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/parseutils.h"
36 #include <float.h>
37 #include <math.h>
38 
39 #define SQR(a) ((a)*(a))
40 
41 enum Outer{
46 };
47 
48 enum Inner{
53 };
54 
55 typedef struct Point {
56  double p[2];
57  uint32_t val;
58 } Point;
59 
60 typedef struct MBContext {
61  const AVClass *class;
62  int w, h;
64  uint64_t pts;
65  int maxiter;
66  double start_x;
67  double start_y;
68  double start_scale;
69  double end_scale;
70  double end_pts;
71  double bailout;
72  int outer;
73  int inner;
78  double (*zyklus)[2];
79  uint32_t dither;
80 
81  double morphxf;
82  double morphyf;
83  double morphamp;
84 } MBContext;
85 
86 #define OFFSET(x) offsetof(MBContext, x)
87 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
88 
89 static const AVOption mandelbrot_options[] = {
90  {"size", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="640x480"}, 0, 0, FLAGS },
91  {"s", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="640x480"}, 0, 0, FLAGS },
92  {"rate", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
93  {"r", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
94  {"maxiter", "set max iterations number", OFFSET(maxiter), AV_OPT_TYPE_INT, {.i64=7189}, 1, INT_MAX, FLAGS },
95  {"start_x", "set the initial x position", OFFSET(start_x), AV_OPT_TYPE_DOUBLE, {.dbl=-0.743643887037158704752191506114774}, -100, 100, FLAGS },
96  {"start_y", "set the initial y position", OFFSET(start_y), AV_OPT_TYPE_DOUBLE, {.dbl=-0.131825904205311970493132056385139}, -100, 100, FLAGS },
97  {"start_scale", "set the initial scale value", OFFSET(start_scale), AV_OPT_TYPE_DOUBLE, {.dbl=3.0}, 0, FLT_MAX, FLAGS },
98  {"end_scale", "set the terminal scale value", OFFSET(end_scale), AV_OPT_TYPE_DOUBLE, {.dbl=0.3}, 0, FLT_MAX, FLAGS },
99  {"end_pts", "set the terminal pts value", OFFSET(end_pts), AV_OPT_TYPE_DOUBLE, {.dbl=400}, 0, INT64_MAX, FLAGS },
100  {"bailout", "set the bailout value", OFFSET(bailout), AV_OPT_TYPE_DOUBLE, {.dbl=10}, 0, FLT_MAX, FLAGS },
101  {"morphxf", "set morph x frequency", OFFSET(morphxf), AV_OPT_TYPE_DOUBLE, {.dbl=0.01}, -FLT_MAX, FLT_MAX, FLAGS },
102  {"morphyf", "set morph y frequency", OFFSET(morphyf), AV_OPT_TYPE_DOUBLE, {.dbl=0.0123}, -FLT_MAX, FLT_MAX, FLAGS },
103  {"morphamp", "set morph amplitude", OFFSET(morphamp), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -FLT_MAX, FLT_MAX, FLAGS },
104 
105  {"outer", "set outer coloring mode", OFFSET(outer), AV_OPT_TYPE_INT, {.i64=NORMALIZED_ITERATION_COUNT}, 0, INT_MAX, FLAGS, "outer" },
106  {"iteration_count", "set iteration count mode", 0, AV_OPT_TYPE_CONST, {.i64=ITERATION_COUNT}, INT_MIN, INT_MAX, FLAGS, "outer" },
107  {"normalized_iteration_count", "set normalized iteration count mode", 0, AV_OPT_TYPE_CONST, {.i64=NORMALIZED_ITERATION_COUNT}, INT_MIN, INT_MAX, FLAGS, "outer" },
108  {"white", "set white mode", 0, AV_OPT_TYPE_CONST, {.i64=WHITE}, INT_MIN, INT_MAX, FLAGS, "outer" },
109  {"outz", "set outz mode", 0, AV_OPT_TYPE_CONST, {.i64=OUTZ}, INT_MIN, INT_MAX, FLAGS, "outer" },
110 
111  {"inner", "set inner coloring mode", OFFSET(inner), AV_OPT_TYPE_INT, {.i64=MINCOL}, 0, INT_MAX, FLAGS, "inner" },
112  {"black", "set black mode", 0, AV_OPT_TYPE_CONST, {.i64=BLACK}, INT_MIN, INT_MAX, FLAGS, "inner"},
113  {"period", "set period mode", 0, AV_OPT_TYPE_CONST, {.i64=PERIOD}, INT_MIN, INT_MAX, FLAGS, "inner"},
114  {"convergence", "show time until convergence", 0, AV_OPT_TYPE_CONST, {.i64=CONVTIME}, INT_MIN, INT_MAX, FLAGS, "inner"},
115  {"mincol", "color based on point closest to the origin of the iterations", 0, AV_OPT_TYPE_CONST, {.i64=MINCOL}, INT_MIN, INT_MAX, FLAGS, "inner"},
116 
117  {NULL},
118 };
119 
121 
123 {
124  MBContext *s = ctx->priv;
125 
126  s->bailout *= s->bailout;
127 
128  s->start_scale /=s->h;
129  s->end_scale /=s->h;
130 
131  s->cache_allocated = s->w * s->h * 3;
132  s->cache_used = 0;
133  s->point_cache= av_malloc_array(s->cache_allocated, sizeof(*s->point_cache));
134  s-> next_cache= av_malloc_array(s->cache_allocated, sizeof(*s-> next_cache));
135  s-> zyklus = av_malloc_array(s->maxiter + 16, sizeof(*s->zyklus));
136 
137  if (!s->point_cache || !s->next_cache || !s->zyklus)
138  return AVERROR(ENOMEM);
139 
140  return 0;
141 }
142 
144 {
145  MBContext *s = ctx->priv;
146 
147  av_freep(&s->point_cache);
148  av_freep(&s-> next_cache);
149  av_freep(&s->zyklus);
150 }
151 
153 {
154  static const enum AVPixelFormat pix_fmts[] = {
157  };
158 
160  if (!fmts_list)
161  return AVERROR(ENOMEM);
162  return ff_set_common_formats(ctx, fmts_list);
163 }
164 
165 static int config_props(AVFilterLink *inlink)
166 {
167  AVFilterContext *ctx = inlink->src;
168  MBContext *s = ctx->priv;
169 
170  if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
171  return AVERROR(EINVAL);
172 
173  inlink->w = s->w;
174  inlink->h = s->h;
175  inlink->time_base = av_inv_q(s->frame_rate);
176 
177  return 0;
178 }
179 
180 static void fill_from_cache(AVFilterContext *ctx, uint32_t *color, int *in_cidx, int *out_cidx, double py, double scale){
181  MBContext *s = ctx->priv;
182  if(s->morphamp)
183  return;
184  for(; *in_cidx < s->cache_used; (*in_cidx)++){
185  Point *p= &s->point_cache[*in_cidx];
186  int x;
187  if(p->p[1] > py)
188  break;
189  x= lrint((p->p[0] - s->start_x) / scale + s->w/2);
190  if(x<0 || x >= s->w)
191  continue;
192  if(color) color[x] = p->val;
193  if(out_cidx && *out_cidx < s->cache_allocated)
194  s->next_cache[(*out_cidx)++]= *p;
195  }
196 }
197 
198 static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
199 {
200  uint32_t a,b,c,d, i;
201  uint32_t ipol=0xFF000000;
202  int dist;
203 
204  if(!x || !y || x+1==s->w || y+1==s->h)
205  return 0;
206 
207  dist= FFMAX(FFABS(x-(s->w>>1))*s->h, FFABS(y-(s->h>>1))*s->w);
208 
209  if(dist<(s->w*s->h>>3))
210  return 0;
211 
212  a=color[(x+1) + (y+0)*linesize];
213  b=color[(x-1) + (y+1)*linesize];
214  c=color[(x+0) + (y+1)*linesize];
215  d=color[(x+1) + (y+1)*linesize];
216 
217  if(a&&c){
218  b= color[(x-1) + (y+0)*linesize];
219  d= color[(x+0) + (y-1)*linesize];
220  }else if(b&&d){
221  a= color[(x+1) + (y-1)*linesize];
222  c= color[(x-1) + (y-1)*linesize];
223  }else if(c){
224  d= color[(x+0) + (y-1)*linesize];
225  a= color[(x-1) + (y+0)*linesize];
226  b= color[(x+1) + (y-1)*linesize];
227  }else if(d){
228  c= color[(x-1) + (y-1)*linesize];
229  a= color[(x-1) + (y+0)*linesize];
230  b= color[(x+1) + (y-1)*linesize];
231  }else
232  return 0;
233 
234  for(i=0; i<3; i++){
235  int s= 8*i;
236  uint8_t ac= a>>s;
237  uint8_t bc= b>>s;
238  uint8_t cc= c>>s;
239  uint8_t dc= d>>s;
240  int ipolab= (ac + bc);
241  int ipolcd= (cc + dc);
242  if(FFABS(ipolab - ipolcd) > 5)
243  return 0;
244  if(FFABS(ac-bc)+FFABS(cc-dc) > 20)
245  return 0;
246  ipol |= ((ipolab + ipolcd + 2)/4)<<s;
247  }
248  color[x + y*linesize]= ipol;
249  return 1;
250 }
251 
252 static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize, int64_t pts)
253 {
254  MBContext *s = ctx->priv;
255  int x,y,i, in_cidx=0, next_cidx=0, tmp_cidx;
256  double scale= s->start_scale*pow(s->end_scale/s->start_scale, pts/s->end_pts);
257  int use_zyklus=0;
258  fill_from_cache(ctx, NULL, &in_cidx, NULL, s->start_y+scale*(-s->h/2-0.5), scale);
259  tmp_cidx= in_cidx;
260  memset(color, 0, sizeof(*color)*s->w);
261  for(y=0; y<s->h; y++){
262  int y1= y+1;
263  const double ci=s->start_y+scale*(y-s->h/2);
264  fill_from_cache(ctx, NULL, &in_cidx, &next_cidx, ci, scale);
265  if(y1<s->h){
266  memset(color+linesize*y1, 0, sizeof(*color)*s->w);
267  fill_from_cache(ctx, color+linesize*y1, &tmp_cidx, NULL, ci + 3*scale/2, scale);
268  }
269 
270  for(x=0; x<s->w; x++){
271  float av_uninit(epsilon);
272  const double cr=s->start_x+scale*(x-s->w/2);
273  double zr=cr;
274  double zi=ci;
275  uint32_t c=0;
276  double dv= s->dither / (double)(1LL<<32);
277  s->dither= s->dither*1664525+1013904223;
278 
279  if(color[x + y*linesize] & 0xFF000000)
280  continue;
281  if(!s->morphamp){
282  if(interpol(s, color, x, y, linesize)){
283  if(next_cidx < s->cache_allocated){
284  s->next_cache[next_cidx ].p[0]= cr;
285  s->next_cache[next_cidx ].p[1]= ci;
286  s->next_cache[next_cidx++].val = color[x + y*linesize];
287  }
288  continue;
289  }
290  }else{
291  zr += cos(pts * s->morphxf) * s->morphamp;
292  zi += sin(pts * s->morphyf) * s->morphamp;
293  }
294 
295  use_zyklus= (x==0 || s->inner!=BLACK ||color[x-1 + y*linesize] == 0xFF000000);
296  if(use_zyklus)
297  epsilon= scale*(abs(x-s->w/2) + abs(y-s->h/2))/s->w;
298 
299 #define Z_Z2_C(outr,outi,inr,ini)\
300  outr= inr*inr - ini*ini + cr;\
301  outi= 2*inr*ini + ci;
302 
303 #define Z_Z2_C_ZYKLUS(outr,outi,inr,ini, Z)\
304  Z_Z2_C(outr,outi,inr,ini)\
305  if(use_zyklus){\
306  if(Z && fabs(s->zyklus[i>>1][0]-outr)+fabs(s->zyklus[i>>1][1]-outi) <= epsilon)\
307  break;\
308  }\
309  s->zyklus[i][0]= outr;\
310  s->zyklus[i][1]= outi;\
311 
312 
313 
314  for(i=0; i<s->maxiter-8; i++){
315  double t;
316  Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
317  i++;
318  Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
319  i++;
320  Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
321  i++;
322  Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
323  i++;
324  Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
325  i++;
326  Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
327  i++;
328  Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
329  i++;
330  Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
331  if(zr*zr + zi*zi > s->bailout){
332  i-= FFMIN(7, i);
333  for(; i<s->maxiter; i++){
334  zr= s->zyklus[i][0];
335  zi= s->zyklus[i][1];
336  if(zr*zr + zi*zi > s->bailout){
337  switch(s->outer){
338  case ITERATION_COUNT:
339  zr = i;
340  c = lrintf((sinf(zr)+1)*127) + lrintf((sinf(zr/1.234)+1)*127)*256*256 + lrintf((sinf(zr/100)+1)*127)*256;
341  break;
343  zr = i + log2(log(s->bailout) / log(zr*zr + zi*zi));
344  c = lrintf((sinf(zr)+1)*127) + lrintf((sinf(zr/1.234)+1)*127)*256*256 + lrintf((sinf(zr/100)+1)*127)*256;
345  break;
346  case WHITE:
347  c = 0xFFFFFF;
348  break;
349  case OUTZ:
350  zr /= s->bailout;
351  zi /= s->bailout;
352  c = (((int)(zr*128+128))&0xFF)*256 + (((int)(zi*128+128))&0xFF);
353  }
354  break;
355  }
356  }
357  break;
358  }
359  }
360  if(!c){
361  if(s->inner==PERIOD){
362  int j;
363  for(j=i-1; j; j--)
364  if(SQR(s->zyklus[j][0]-zr) + SQR(s->zyklus[j][1]-zi) < epsilon*epsilon*10)
365  break;
366  if(j){
367  c= i-j;
368  c= ((c<<5)&0xE0) + ((c<<10)&0xE000) + ((c<<15)&0xE00000);
369  }
370  }else if(s->inner==CONVTIME){
371  c= floor(i*255.0/s->maxiter+dv)*0x010101;
372  } else if(s->inner==MINCOL){
373  int j;
374  double closest=9999;
375  int closest_index=0;
376  for(j=i-1; j>=0; j--)
377  if(SQR(s->zyklus[j][0]) + SQR(s->zyklus[j][1]) < closest){
378  closest= SQR(s->zyklus[j][0]) + SQR(s->zyklus[j][1]);
379  closest_index= j;
380  }
381  closest = sqrt(closest);
382  c= lrintf((s->zyklus[closest_index][0]/closest+1)*127+dv) + lrintf((s->zyklus[closest_index][1]/closest+1)*127+dv)*256;
383  }
384  }
385  c |= 0xFF000000;
386  color[x + y*linesize]= c;
387  if(next_cidx < s->cache_allocated){
388  s->next_cache[next_cidx ].p[0]= cr;
389  s->next_cache[next_cidx ].p[1]= ci;
390  s->next_cache[next_cidx++].val = c;
391  }
392  }
393  fill_from_cache(ctx, NULL, &in_cidx, &next_cidx, ci + scale/2, scale);
394  }
395  FFSWAP(void*, s->next_cache, s->point_cache);
396  s->cache_used = next_cidx;
397  if(s->cache_used == s->cache_allocated)
398  av_log(ctx, AV_LOG_INFO, "Mandelbrot cache is too small!\n");
399 }
400 
401 static int request_frame(AVFilterLink *link)
402 {
403  MBContext *s = link->src->priv;
404  AVFrame *picref = ff_get_video_buffer(link, s->w, s->h);
405  if (!picref)
406  return AVERROR(ENOMEM);
407 
408  picref->sample_aspect_ratio = (AVRational) {1, 1};
409  picref->pts = s->pts++;
410 
411  draw_mandelbrot(link->src, (uint32_t*)picref->data[0], picref->linesize[0]/4, picref->pts);
412  return ff_filter_frame(link, picref);
413 }
414 
415 static const AVFilterPad mandelbrot_outputs[] = {
416  {
417  .name = "default",
418  .type = AVMEDIA_TYPE_VIDEO,
419  .request_frame = request_frame,
420  .config_props = config_props,
421  },
422  { NULL }
423 };
424 
426  .name = "mandelbrot",
427  .description = NULL_IF_CONFIG_SMALL("Render a Mandelbrot fractal."),
428  .priv_size = sizeof(MBContext),
429  .priv_class = &mandelbrot_class,
430  .init = init,
431  .uninit = uninit,
433  .inputs = NULL,
435 };
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define av_uninit(x)
Definition: attributes.h:154
#define av_cold
Definition: attributes.h:88
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
uint8_t
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
Main libavfilter public API header.
#define s(width, name)
Definition: cbs_vp9.c:257
#define FFSWAP(type, a, b)
Definition: common.h:108
#define FFMIN(a, b)
Definition: common.h:105
#define FFMAX(a, b)
Definition: common.h:103
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define NULL
Definition: coverity.c:32
#define abs(x)
Definition: cuda_runtime.h:35
static __device__ float floor(float a)
Definition: cuda_runtime.h:173
int
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:587
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:235
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:238
@ AV_OPT_TYPE_INT
Definition: opt.h:225
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_INFO
Standard information.
Definition: log.h:205
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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:317
misc image utilities
int i
Definition: input.c:407
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:309
#define log2(x)
Definition: libm.h:404
#define sinf(x)
Definition: libm.h:419
#define lrintf(x)
Definition: libm_mips.h:70
uint8_t w
Definition: llviddspenc.c:39
AVOptions.
misc parsing utilities
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
#define AV_PIX_FMT_0BGR32
Definition: pixfmt.h:377
static int ipol(uint8_t *src, int x, int y)
Definition: rotozoom.c:65
Describe the class of an AVClass context structure.
Definition: log.h:67
An instance of a filter.
Definition: avfilter.h:341
void * priv
private data for use by the filter
Definition: avfilter.h:356
A list of supported formats for one end of a filter link.
Definition: formats.h:65
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:411
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:406
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
AVOption.
Definition: opt.h:248
Rational number (pair of numerator and denominator).
Definition: rational.h:58
Point * next_cache
AVRational frame_rate
double(* zyklus)[2]
double morphyf
double start_scale
double end_scale
double bailout
double end_pts
double morphamp
uint64_t pts
double morphxf
double start_x
double start_y
int cache_allocated
uint32_t dither
Point * point_cache
double p[2]
uint32_t val
#define lrint
Definition: tablegen.h:53
#define av_malloc_array(a, b)
#define av_freep(p)
#define av_log(a,...)
AVFormatContext * ctx
Definition: movenc.c:48
static int64_t pts
const char * b
Definition: vf_curves.c:118
static double cr(void *priv, double x, double y)
Definition: vf_geq.c:216
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104
Outer
@ OUTZ
@ WHITE
@ NORMALIZED_ITERATION_COUNT
@ ITERATION_COUNT
static const AVFilterPad mandelbrot_outputs[]
#define Z_Z2_C(outr, outi, inr, ini)
#define Z_Z2_C_ZYKLUS(outr, outi, inr, ini, Z)
AVFILTER_DEFINE_CLASS(mandelbrot)
static const AVOption mandelbrot_options[]
Inner
@ MINCOL
@ CONVTIME
@ PERIOD
@ BLACK
static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize, int64_t pts)
static int query_formats(AVFilterContext *ctx)
#define FLAGS
static int request_frame(AVFilterLink *link)
AVFilter ff_vsrc_mandelbrot
static int config_props(AVFilterLink *inlink)
static av_cold int init(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
#define OFFSET(x)
static void fill_from_cache(AVFilterContext *ctx, uint32_t *color, int *in_cidx, int *out_cidx, double py, double scale)
#define SQR(a)
static double c[64]