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"},
181 for(; *in_cidx < s->
cache_used; (*in_cidx)++){
189 if(color) color[x] = p->
val;
190 if(out_cidx && *out_cidx < s->cache_allocated)
198 uint32_t
ipol=0xFF000000;
201 if(!x || !y || x+1==s->
w || y+1==s->
h)
206 if(dist<(s->
w*s->
h>>3))
209 a=color[(x+1) + (y+0)*linesize];
210 b=color[(x-1) + (y+1)*linesize];
211 c=color[(x+0) + (y+1)*linesize];
212 d=color[(x+1) + (y+1)*linesize];
215 b= color[(x-1) + (y+0)*linesize];
216 d= color[(x+0) + (y-1)*linesize];
218 a= color[(x+1) + (y-1)*linesize];
219 c= color[(x-1) + (y-1)*linesize];
221 d= color[(x+0) + (y-1)*linesize];
222 a= color[(x-1) + (y+0)*linesize];
223 b= color[(x+1) + (y-1)*linesize];
225 c= color[(x-1) + (y-1)*linesize];
226 a= color[(x-1) + (y+0)*linesize];
227 b= color[(x+1) + (y-1)*linesize];
237 int ipolab= (ac + bc);
238 int ipolcd= (cc +
dc);
239 if(
FFABS(ipolab - ipolcd) > 5)
243 ipol |= ((ipolab + ipolcd + 2)/4)<<
s;
245 color[x + y*linesize]=
ipol;
252 int x,y,i, in_cidx=0, next_cidx=0, tmp_cidx;
257 memset(color, 0,
sizeof(*color)*s->
w);
258 for(y=0; y<s->
h; y++){
260 const double ci=s->
start_y+scale*(y-s->
h/2);
263 memset(color+linesize*y1, 0,
sizeof(*color)*s->
w);
267 for(x=0; x<s->
w; x++){
273 double dv= s->
dither / (double)(1LL<<32);
276 if(color[x + y*linesize] & 0xFF000000)
279 if(
interpol(s, color, x, y, linesize)){
280 if(next_cidx < s->cache_allocated){
292 use_zyklus= (x==0 || s->
inner!=
BLACK ||color[x-1 + y*linesize] == 0xFF000000);
294 epsilon= scale*(abs(x-s->
w/2) + abs(y-s->
h/2))/s->
w;
296 #define
Z_Z2_C(outr,outi,inr,ini)\
297 outr= inr*inr - ini*ini +
cr;\
298 outi= 2*inr*ini + ci;
300 #define Z_Z2_C_ZYKLUS(outr,outi,inr,ini, Z)\
301 Z_Z2_C(outr,outi,inr,ini)\
303 if(Z && fabs(s->zyklus[i>>1][0]-outr)+fabs(s->zyklus[i>>1][1]-outi) <= epsilon)\
306 s->zyklus[i][0]= outr;\
307 s->zyklus[i][1]= outi;\
328 if(zr*zr + zi*zi > s->
bailout){
333 if(zr*zr + zi*zi > s->
bailout){
340 zr = i +
log2(log(s->
bailout) / log(zr*zr + zi*zi));
349 c = (((int)(zr*128+128))&0xFF)*256 + (((int)(zi*128+128))&0xFF);
365 c= ((c<<5)&0xE0) + ((c<<10)&0xE000) + ((c<<15)&0xE00000);
368 c= floor(i*255.0/s->
maxiter+dv)*0x010101;
373 for(j=i-1; j>=0; j--)
378 closest = sqrt(closest);
379 c=
lrintf((s->
zyklus[closest_index][0]/closest+1)*127+dv) +
lrintf((s->
zyklus[closest_index][1]/closest+1)*127+dv)*256;
383 color[x + y*linesize]=
c;
384 if(next_cidx < s->cache_allocated){
423 .
name =
"mandelbrot",
426 .priv_class = &mandelbrot_class,
This structure describes decoded (raw) audio or video data.
static int query_formats(AVFilterContext *ctx)
AVFilter ff_vsrc_mandelbrot
static av_cold int init(AVFilterContext *ctx)
Main libavfilter public API header.
int h
agreed upon image height
static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static const AVOption mandelbrot_options[]
static av_cold void uninit(AVFilterContext *ctx)
const char * name
Pad name.
#define Z_Z2_C(outr, outi, inr, ini)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize, int64_t pts)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static const AVFilterPad mandelbrot_outputs[]
A filter pad used for either input or output.
A link between two filters.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
#define Z_Z2_C_ZYKLUS(outr, outi, inr, ini, Z)
#define AV_PIX_FMT_0BGR32
int w
agreed upon image width
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...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
AVFilterContext * src
source filter
static void fill_from_cache(AVFilterContext *ctx, uint32_t *color, int *in_cidx, int *out_cidx, double py, double scale)
static const AVFilterPad outputs[]
static int request_frame(AVFilterLink *link)
#define AV_LOG_INFO
Standard information.
static const AVFilterPad inputs[]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Describe the class of an AVClass context structure.
rational number numerator/denominator
offset must point to AVRational
const char * name
Filter name.
offset must point to two consecutive integers
static enum AVPixelFormat pix_fmts[]
static int64_t pts
Global timestamp for the audio frames.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVFILTER_DEFINE_CLASS(mandelbrot)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
static int ipol(uint8_t *src, int x, int y)
#define av_malloc_array(a, b)
#define FFSWAP(type, a, b)
static double cr(void *priv, double x, double y)
static int config_props(AVFilterLink *inlink)
AVPixelFormat
Pixel format.