39 #define SQR(a) ((a)*(a))
86 #define OFFSET(x) offsetof(MBContext, x)
87 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
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 },
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"},
179 for(; *in_cidx < mb->
cache_used; (*in_cidx)++){
185 if(x<0 || x >= mb->
w)
187 if(color) color[x] = p->
val;
188 if(out_cidx && *out_cidx < mb->cache_allocated)
196 uint32_t
ipol=0xFF000000;
199 if(!x || !y || x+1==mb->
w || y+1==mb->
h)
204 if(dist<(mb->
w*mb->
h>>3))
207 a=color[(x+1) + (y+0)*linesize];
208 b=color[(x-1) + (y+1)*linesize];
209 c=color[(x+0) + (y+1)*linesize];
210 d=color[(x+1) + (y+1)*linesize];
213 b= color[(x-1) + (y+0)*linesize];
214 d= color[(x+0) + (y-1)*linesize];
216 a= color[(x+1) + (y-1)*linesize];
217 c= color[(x-1) + (y-1)*linesize];
219 d= color[(x+0) + (y-1)*linesize];
220 a= color[(x-1) + (y+0)*linesize];
221 b= color[(x+1) + (y-1)*linesize];
223 c= color[(x-1) + (y-1)*linesize];
224 a= color[(x-1) + (y+0)*linesize];
225 b= color[(x+1) + (y-1)*linesize];
235 int ipolab= (ac + bc);
236 int ipolcd= (cc +
dc);
237 if(
FFABS(ipolab - ipolcd) > 5)
241 ipol |= ((ipolab + ipolcd + 2)/4)<<
s;
243 color[x + y*linesize]=
ipol;
250 int x,
y,i, in_cidx=0, next_cidx=0, tmp_cidx;
255 memset(color, 0,
sizeof(*color)*mb->
w);
256 for(y=0; y<mb->
h; y++){
258 const double ci=mb->
start_y+scale*(y-mb->
h/2);
261 memset(color+linesize*y1, 0,
sizeof(*color)*mb->
w);
262 fill_from_cache(ctx, color+linesize*y1, &tmp_cidx, NULL, ci + 3*scale/2, scale);
265 for(x=0; x<mb->
w; x++){
267 const double cr=mb->
start_x+scale*(x-mb->
w/2);
271 double dv= mb->
dither / (double)(1LL<<32);
274 if(color[x + y*linesize] & 0xFF000000)
277 if(
interpol(mb, color, x, y, linesize)){
278 if(next_cidx < mb->cache_allocated){
290 use_zyklus= (x==0 || mb->
inner!=
BLACK ||color[x-1 + y*linesize] == 0xFF000000);
292 epsilon= scale*1*sqrt(
SQR(x-mb->
w/2) +
SQR(y-mb->
h/2))/mb->
w;
294 #define Z_Z2_C(outr,outi,inr,ini)\
295 outr= inr*inr - ini*ini + cr;\
296 outi= 2*inr*ini + ci;
298 #define Z_Z2_C_ZYKLUS(outr,outi,inr,ini, Z)\
299 Z_Z2_C(outr,outi,inr,ini)\
301 if(Z && fabs(mb->zyklus[i>>1][0]-outr)+fabs(mb->zyklus[i>>1][1]-outi) <= epsilon)\
304 mb->zyklus[i][0]= outr;\
305 mb->zyklus[i][1]= outi;\
309 for(i=0; i<mb->
maxiter-8; i++){
326 if(zr*zr + zi*zi > mb->
bailout){
331 if(zr*zr + zi*zi > mb->
bailout){
335 c =
lrintf((sin(zr)+1)*127) +
lrintf((sin(zr/1.234)+1)*127)*256*256 +
lrintf((sin(zr/100)+1)*127)*256;
338 zr = i +
log2(log(mb->
bailout) / log(zr*zr + zi*zi));
339 c =
lrintf((sin(zr)+1)*127) +
lrintf((sin(zr/1.234)+1)*127)*256*256 +
lrintf((sin(zr/100)+1)*127)*256;
347 c = (((int)(zr*128+128))&0xFF)*256 + (((int)(zi*128+128))&0xFF);
363 c= ((c<<5)&0xE0) + ((c<<10)&0xE000) + ((c<<15)&0xE00000);
366 c= floor(i*255.0/mb->
maxiter+dv)*0x010101;
371 for(j=i-1; j>=0; j--)
376 closest = sqrt(closest);
377 c=
lrintf((mb->
zyklus[closest_index][0]/closest+1)*127+dv) +
lrintf((mb->
zyklus[closest_index][1]/closest+1)*127+dv)*256;
381 color[x + y*linesize]=
c;
382 if(next_cidx < mb->cache_allocated){
421 .
name =
"mandelbrot",
424 .priv_class = &mandelbrot_class,