39 #define SQR(a) ((a)*(a))
81 #define OFFSET(x) offsetof(MBContext, x)
82 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
90 {
"start_x",
"set the initial x position",
OFFSET(start_x),
AV_OPT_TYPE_DOUBLE, {.dbl=-0.743643887037158704752191506114774}, -100, 100,
FLAGS },
91 {
"start_y",
"set the initial y position",
OFFSET(start_y),
AV_OPT_TYPE_DOUBLE, {.dbl=-0.131825904205311970493132056385139}, -100, 100,
FLAGS },
105 {
"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"},
118 mb->
class = &mandelbrot_class;
182 for(; *in_cidx < mb->
cache_used; (*in_cidx)++){
188 if(x<0 || x >= mb->
w)
190 if(color) color[x] = p->
val;
191 if(out_cidx && *out_cidx < mb->cache_allocated)
199 uint32_t
ipol=0xFF000000;
202 if(!x || !y || x+1==mb->
w || y+1==mb->
h)
207 if(dist<(mb->
w*mb->
h>>3))
210 a=color[(x+1) + (y+0)*linesize];
211 b=color[(x-1) + (y+1)*linesize];
212 c=color[(x+0) + (y+1)*linesize];
213 d=color[(x+1) + (y+1)*linesize];
216 b= color[(x-1) + (y+0)*linesize];
217 d= color[(x+0) + (y-1)*linesize];
219 a= color[(x+1) + (y-1)*linesize];
220 c= color[(x-1) + (y-1)*linesize];
222 d= color[(x+0) + (y-1)*linesize];
223 a= color[(x-1) + (y+0)*linesize];
224 b= color[(x+1) + (y-1)*linesize];
226 c= color[(x-1) + (y-1)*linesize];
227 a= color[(x-1) + (y+0)*linesize];
228 b= color[(x+1) + (y-1)*linesize];
238 int ipolab= (ac + bc);
239 int ipolcd= (cc +
dc);
240 if(
FFABS(ipolab - ipolcd) > 5)
244 ipol |= ((ipolab + ipolcd + 2)/4)<<s;
246 color[x + y*linesize]=
ipol;
253 int x,
y,i, in_cidx=0, next_cidx=0, tmp_cidx;
258 memset(color, 0,
sizeof(*color)*mb->
w);
259 for(y=0; y<mb->
h; y++){
261 const double ci=mb->
start_y+scale*(y-mb->
h/2);
264 memset(color+linesize*y1, 0,
sizeof(*color)*mb->
w);
268 for(x=0; x<mb->
w; x++){
270 const double cr=mb->
start_x+scale*(x-mb->
w/2);
274 double dv= mb->
dither / (double)(1LL<<32);
277 if(color[x + y*linesize] & 0xFF000000)
279 if(
interpol(mb, color, x, y, linesize)){
280 if(next_cidx < mb->cache_allocated){
288 use_zyklus= (x==0 || mb->
inner!=
BLACK ||color[x-1 + y*linesize] == 0xFF000000);
290 epsilon= scale*1*sqrt(
SQR(x-mb->
w/2) +
SQR(y-mb->
h/2))/mb->
w;
292 #define Z_Z2_C(outr,outi,inr,ini)\
293 outr= inr*inr - ini*ini + cr;\
294 outi= 2*inr*ini + ci;
296 #define Z_Z2_C_ZYKLUS(outr,outi,inr,ini, Z)\
297 Z_Z2_C(outr,outi,inr,ini)\
299 if(Z && fabs(mb->zyklus[i>>1][0]-outr)+fabs(mb->zyklus[i>>1][1]-outi) <= epsilon)\
302 mb->zyklus[i][0]= outr;\
303 mb->zyklus[i][1]= outi;\
307 for(i=0; i<mb->
maxiter-8; i++){
324 if(zr*zr + zi*zi > mb->
bailout){
329 if(zr*zr + zi*zi > mb->
bailout){
334 c=
lrintf((sin(zr)+1)*127) +
lrintf((sin(zr/1.234)+1)*127)*256*256 +
lrintf((sin(zr/100)+1)*127)*256;
349 c= ((c<<5)&0xE0) + ((c<<10)&0xE000) + ((c<<15)&0xE00000);
352 c= floor(i*255.0/mb->
maxiter+dv)*0x010101;
357 for(j=i-1; j>=0; j--)
362 closest = sqrt(closest);
363 c=
lrintf((mb->
zyklus[closest_index][0]/closest+1)*127+dv) +
lrintf((mb->
zyklus[closest_index][1]/closest+1)*127+dv)*256;
367 color[x + y*linesize]=
c;
368 if(next_cidx < mb->cache_allocated){
407 .
name =
"mandelbrot",
417 .priv_class = &mandelbrot_class,