diff --git a/veejay-current/libvje/effects/average.c b/veejay-current/libvje/effects/average.c index d72528b2..81388eb3 100644 --- a/veejay-current/libvje/effects/average.c +++ b/veejay-current/libvje/effects/average.c @@ -23,12 +23,12 @@ #include "common.h" vj_effect *average_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = 100; ve->defaults[0] = 1; diff --git a/veejay-current/libvje/effects/bathroom.c b/veejay-current/libvje/effects/bathroom.c index 86f9dbfd..16591f40 100644 --- a/veejay-current/libvje/effects/bathroom.c +++ b/veejay-current/libvje/effects/bathroom.c @@ -33,12 +33,12 @@ static uint8_t *bathroom_frame[3]; vj_effect *bathroom_init(int width,int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 1; ve->limits[0][1] = 1; @@ -56,20 +56,20 @@ vj_effect *bathroom_init(int width,int height) int bathroom_malloc(int width, int height) { - bathroom_frame[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height); + bathroom_frame[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height * 3); if(!bathroom_frame[0]) return 0; - bathroom_frame[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height); - if(!bathroom_frame[1]) return 0; - bathroom_frame[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height); - if(!bathroom_frame[2]) return 0; - + + bathroom_frame[1] = bathroom_frame[0] + (width * height ); + bathroom_frame[2] = bathroom_frame[1] + (width * height ); return 1; } void bathroom_free() { - if(bathroom_frame[0]) free(bathroom_frame[0]); - if(bathroom_frame[1]) free(bathroom_frame[1]); - if(bathroom_frame[2]) free(bathroom_frame[2]); + if(bathroom_frame[0]) + free(bathroom_frame[0]); + bathroom_frame[0] = NULL; + bathroom_frame[1] = NULL; + bathroom_frame[2] = NULL; } void bathroom_verti_apply(VJFrame *frame, int width, int height, int val) diff --git a/veejay-current/libvje/effects/binaryoverlays.c b/veejay-current/libvje/effects/binaryoverlays.c index 661918f2..abe52b7c 100644 --- a/veejay-current/libvje/effects/binaryoverlays.c +++ b/veejay-current/libvje/effects/binaryoverlays.c @@ -24,11 +24,11 @@ vj_effect *binaryoverlay_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; ve->description = "Binary Overlays"; ve->limits[0][0] = 0; diff --git a/veejay-current/libvje/effects/blob.c b/veejay-current/libvje/effects/blob.c index e3d905bf..44d60e92 100644 --- a/veejay-current/libvje/effects/blob.c +++ b/veejay-current/libvje/effects/blob.c @@ -78,11 +78,11 @@ static int blob_type_ = 1; vj_effect *blob_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = 360; // radius ve->limits[0][1] = 1; @@ -122,12 +122,11 @@ int blob_malloc(int w, int h) blob_ = (uint8_t**) vj_malloc(sizeof(uint8_t*) * blob_dradius_ ); for(i = 0; i < blob_dradius_ ; i ++ ) { - blob_[i] = (uint8_t*) vj_malloc(sizeof(uint8_t) * blob_dradius_ ); + blob_[i] = (uint8_t*) vj_calloc(sizeof(uint8_t) * blob_dradius_ ); if(!blob_[i]) return 0; - memset( blob_[i], 0 , blob_dradius_ ); } - blobs_ = (blob_t*) vj_malloc(sizeof(blob_t) * blob_num_ ); + blobs_ = (blob_t*) vj_calloc(sizeof(blob_t) * blob_num_ ); if(!blobs_ ) return 0; blob_image_ = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); diff --git a/veejay-current/libvje/effects/boids.c b/veejay-current/libvje/effects/boids.c index f32a2701..fce91273 100644 --- a/veejay-current/libvje/effects/boids.c +++ b/veejay-current/libvje/effects/boids.c @@ -92,11 +92,11 @@ static int blob_home_radius_= 203; vj_effect *boids_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 8; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = w/2; // radius ve->limits[0][1] = 2; @@ -170,14 +170,14 @@ int boids_malloc(int w, int h) blob_ = (uint8_t**) vj_malloc(sizeof(uint8_t*) * blob_dradius_ ); for(i = 0; i < blob_dradius_ ; i ++ ) { - blob_[i] = (uint8_t*) vj_malloc(sizeof(uint8_t) * blob_dradius_ ); + blob_[i] = (uint8_t*) vj_calloc(sizeof(uint8_t) * blob_dradius_ ); if(!blob_[i]) return 0; } - blobs_ = (blob_t*) vj_malloc(sizeof(blob_t) * blob_num_ ); + blobs_ = (blob_t*) vj_calloc(sizeof(blob_t) * blob_num_ ); if(!blobs_ ) return 0; - blob_image_ = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + blob_image_ = (uint8_t*) vj_calloc(sizeof(uint8_t) * w * h ); if(!blob_image_) return 0; diff --git a/veejay-current/libvje/effects/borders.c b/veejay-current/libvje/effects/borders.c index 5cb8c653..b77c54a8 100644 --- a/veejay-current/libvje/effects/borders.c +++ b/veejay-current/libvje/effects/borders.c @@ -24,11 +24,11 @@ vj_effect *borders_init(int width,int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 41; ve->defaults[1] = 0; diff --git a/veejay-current/libvje/effects/bwselect.c b/veejay-current/libvje/effects/bwselect.c index 59bc70fd..bf85a96e 100644 --- a/veejay-current/libvje/effects/bwselect.c +++ b/veejay-current/libvje/effects/bwselect.c @@ -24,11 +24,11 @@ vj_effect *bwselect_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 16; ve->defaults[1] = 235; diff --git a/veejay-current/libvje/effects/cartonize.c b/veejay-current/libvje/effects/cartonize.c index 23b83dc3..ca1ec257 100644 --- a/veejay-current/libvje/effects/cartonize.c +++ b/veejay-current/libvje/effects/cartonize.c @@ -23,12 +23,12 @@ vj_effect *cartonize_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = 255; ve->limits[0][1] = 0; diff --git a/veejay-current/libvje/effects/chromamagick.c b/veejay-current/libvje/effects/chromamagick.c index c69a1977..63850a8d 100644 --- a/veejay-current/libvje/effects/chromamagick.c +++ b/veejay-current/libvje/effects/chromamagick.c @@ -33,11 +33,11 @@ vj_effect *chromamagick_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 7; ve->defaults[1] = 150; ve->description = "Chroma Magic"; diff --git a/veejay-current/libvje/effects/chromapalette.c b/veejay-current/libvje/effects/chromapalette.c index 2d7dec2e..d75d1cfa 100644 --- a/veejay-current/libvje/effects/chromapalette.c +++ b/veejay-current/libvje/effects/chromapalette.c @@ -25,12 +25,12 @@ vj_effect *chromapalette_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 6; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ //angle,r,g,b,cbc,crc ve->limits[0][0] = 1; diff --git a/veejay-current/libvje/effects/chromascratcher.c b/veejay-current/libvje/effects/chromascratcher.c index 00171e8e..9e9410b8 100644 --- a/veejay-current/libvje/effects/chromascratcher.c +++ b/veejay-current/libvje/effects/chromascratcher.c @@ -32,11 +32,11 @@ static VJFrame *_tmp; vj_effect *chromascratcher_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 25; /* uses the chromamagick effect for scratchign */ ve->limits[0][1] = 0; @@ -62,27 +62,24 @@ vj_effect *chromascratcher_init(int w, int h) int chromascratcher_malloc(int w, int h) { cframe[0] = - (uint8_t *) vj_malloc(w * h * sizeof(uint8_t) * 25 ); + (uint8_t *) vj_malloc(w * h * sizeof(uint8_t) * 25 * 3 ); if(!cframe[0]) return 0; - memset( cframe[0], 16, w * h * 25); - cframe[1] = - (uint8_t *) vj_malloc(w * h * sizeof(uint8_t) * 25 ); - if(!cframe[1]) return 0; - memset( cframe[1], 128, w * h * 25); - cframe[2] = - (uint8_t *) vj_malloc(w * h * sizeof(uint8_t) * 25); - if(!cframe[2]) return 0; - memset( cframe[2], 128, w * h * 25); + _tmp = (VJFrame*) vj_calloc(sizeof(VJFrame)); + + cframe[1] = cframe[0] + ( w * h * 25 ); + cframe[2] = cframe[1] + ( w * h * 25 ); - _tmp = (VJFrame*) vj_malloc(sizeof(VJFrame)); return 1; } void chromascratcher_free() { - if(cframe[0]) free(cframe[0]); - if(cframe[1]) free(cframe[1]); - if(cframe[2]) free(cframe[2]); + if(cframe[0]) + free(cframe[0]); if(_tmp) free(_tmp); + cframe[0] = NULL; + cframe[1] = NULL; + cframe[2] = NULL; + _tmp = NULL; } void chromastore_frame(uint8_t * yuv1[3], int w, int h, int n, diff --git a/veejay-current/libvje/effects/chromium.c b/veejay-current/libvje/effects/chromium.c index 0ed0ef69..104d3fc4 100644 --- a/veejay-current/libvje/effects/chromium.c +++ b/veejay-current/libvje/effects/chromium.c @@ -26,12 +26,12 @@ vj_effect *chromium_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 3; ve->defaults[0] = 0; diff --git a/veejay-current/libvje/effects/color.c b/veejay-current/libvje/effects/color.c index cb9958fe..98b8004c 100644 --- a/veejay-current/libvje/effects/color.c +++ b/veejay-current/libvje/effects/color.c @@ -22,11 +22,11 @@ #include vj_effect *color_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 150; ve->defaults[1] = 150; ve->defaults[2] = 150; diff --git a/veejay-current/libvje/effects/coloradjust.c b/veejay-current/libvje/effects/coloradjust.c index c337762d..286f2054 100644 --- a/veejay-current/libvje/effects/coloradjust.c +++ b/veejay-current/libvje/effects/coloradjust.c @@ -25,18 +25,25 @@ #include "common.h" vj_effect *coloradjust_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ - ve->limits[0][0] = -235; + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ + /* ve->limits[0][0] = -235; ve->limits[1][0] = 235; ve->limits[0][1] = 0; ve->limits[1][1] = 36000; ve->defaults[0] = 116; - ve->defaults[1] = 4500; - ve->description = "Saturation"; + ve->defaults[1] = 4500;*/ + ve->limits[0][0] = 0; + ve->limits[1][0] = 360; + ve->limits[0][1] = 0; + ve->limits[1][1] = 256; + ve->defaults[0] = 50; + ve->defaults[1] = 50; + + ve->description = "Hue and Saturation"; ve->extra_frame = 0; ve->sub_format = 0; ve->has_user = 0; @@ -74,8 +81,31 @@ void coloradjust_apply(VJFrame *frame, int width, int height, int val, const int len = frame->uv_len; uint8_t *Cb = frame->data[1]; uint8_t *Cr = frame->data[2]; +//@ Hue, Saturation, copied from AVIDEMUX! +//@ the commented out version is the same as the optimized version (?) +// - int cb, cr; + float hue = (float) ( (val/180.0) * M_PI); + float sat = (float) ( _degrees * 0.01 ); + + const int s = (int) rint( sin(hue) * (1<<16) * sat ); + const int c = (int) rint( cos(hue) * (1<<16) * sat ); + + for( i = 0 ; i < len ;i ++ ) + { + const int u = Cb[i] - 128; + const int v = Cr[i] - 128; + int new_u = (c * u - s * v + (1<<15) + (128<<16)) >> 16; + int new_v = (s * u + c * v + (1<<15) + (128<<16)) >> 16; + if( new_u & 768 ) new_u = (-new_u) >> 31; + if( new_v & 768 ) new_v = (-new_v) >> 31; + + Cb[i] = new_u; + Cr[i] = new_v; + } + + + /* int cb, cr; double dsaturation, dcolor; const double degrees = (_degrees / 100.0); double co, si; @@ -99,6 +129,6 @@ void coloradjust_apply(VJFrame *frame, int width, int height, int val, Cr[i] = co * dsaturation + 128; } } - +*/ } void coloradjust_free(){} diff --git a/veejay-current/libvje/effects/colorshift.c b/veejay-current/libvje/effects/colorshift.c index dff537c4..1a4cfdb6 100644 --- a/veejay-current/libvje/effects/colorshift.c +++ b/veejay-current/libvje/effects/colorshift.c @@ -24,11 +24,11 @@ vj_effect *colorshift_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 5; ve->defaults[1] = 235; diff --git a/veejay-current/libvje/effects/complexinvert.c b/veejay-current/libvje/effects/complexinvert.c index a5a4801d..547dce3a 100644 --- a/veejay-current/libvje/effects/complexinvert.c +++ b/veejay-current/libvje/effects/complexinvert.c @@ -31,11 +31,11 @@ vj_effect *complexinvert_init(int w, int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 5; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 300; /* angle */ ve->defaults[1] = 255; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/complexopacity.c b/veejay-current/libvje/effects/complexopacity.c index d4156b4f..b8b7cbb6 100644 --- a/veejay-current/libvje/effects/complexopacity.c +++ b/veejay-current/libvje/effects/complexopacity.c @@ -31,11 +31,11 @@ vj_effect *complexopacity_init(int w, int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 5; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 80; /* angle */ ve->defaults[1] = 0; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/complexsaturate.c b/veejay-current/libvje/effects/complexsaturate.c index ea90c04d..6eca71a6 100644 --- a/veejay-current/libvje/effects/complexsaturate.c +++ b/veejay-current/libvje/effects/complexsaturate.c @@ -29,17 +29,17 @@ vj_effect *complexsaturation_init(int w, int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 7; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 300; /* angle */ ve->defaults[1] = 255; /* r */ ve->defaults[2] = 0; /* g */ ve->defaults[3] = 0; /* b */ - ve->defaults[4] = -46; /* v_adjust */ - ve->defaults[5] = 26000; /* degrees */ + ve->defaults[4] = 50; /* v_adjust */ + ve->defaults[5] = 50; /* degrees */ ve->defaults[6] = 2400; /* noise suppression */ ve->limits[0][0] = 5; ve->limits[1][0] = 900; @@ -53,11 +53,11 @@ vj_effect *complexsaturation_init(int w, int h) ve->limits[0][3] = 0; ve->limits[1][3] = 255; - ve->limits[0][4] = -300; - ve->limits[1][4] = 300; + ve->limits[0][4] = 0; + ve->limits[1][4] = 360; - ve->limits[0][5] = 1; - ve->limits[1][5] = 36000; + ve->limits[0][5] = 0; + ve->limits[1][5] = 256; ve->limits[0][6] = 0; ve->limits[1][6] = 3500; @@ -74,8 +74,13 @@ void complexsaturation_apply(VJFrame *frame, int width, int b, int adjust_v, int adjust_degrees, int i_noise) { double dsaturation,dcolor; - double degrees = adjust_degrees * 0.01; - double dsat = adjust_v * 0.01; +// double degrees = adjust_degrees * 0.01; +// double dsat = adjust_v * 0.01; + + + float hue = (adjust_degrees/180.0)*M_PI; + float sat = (adjust_v * 0.01); + uint8_t *fg_y, *fg_cb, *fg_cr; uint8_t *bg_y, *bg_cb, *bg_cr; int accept_angle_tg, accept_angle_ctg, one_over_kc; @@ -120,7 +125,8 @@ void complexsaturation_apply(VJFrame *frame, int width, bg_y = frame->data[0]; bg_cb = frame->data[1]; bg_cr = frame->data[2]; - + const int s = (int) rint( sin(hue) * (1<<16) * sat ); + const int c = (int) rint( cos(hue) * (1<<16) * sat ); for (pos = 0; pos < frame->len; pos++) { short xx, yy; @@ -191,7 +197,7 @@ void complexsaturation_apply(VJFrame *frame, int width, int _cr = Cr[pos] - 128; if( _cb != 0 && _cr != 0) { - double co=0.0,si=0.0; + /* double co=0.0,si=0.0; //fast_sqrt( dsaturation, (double) (_cb * cr + _cr * _cr) ); dsaturation = ccolor_sqrt( (double) _cb, (double) _cr); dcolor = ccolor_sine( _cb, dsaturation); @@ -202,7 +208,21 @@ void complexsaturation_apply(VJFrame *frame, int width, dsaturation *= dsat; sin_cos( co, si , dcolor ); Cb[pos] = si * dsaturation + 128; - Cr[pos] = co * dsaturation + 128; + const int u = Cb[i] - 128; + const int v = Cr[i] - 128; + int new_u = (c * u - s * v + (1<<15) + (128<<16)) >> 16; + int new_v = (s * u + c * v + (1<<15) + (128<<16)) >> 16; + if( new_u & 768 ) new_u = (-new_u) >> 31; + if( new_v & 768 ) new_v = (-new_v) >> 31; +Cr[pos] = co * dsaturation + 128;*/ + const int u = Cb[pos] - 128; + const int v = Cr[pos] - 128; + int new_u = (c * u - s * v + (1<<15) + (128<<16)) >> 16; + int new_v = (s * u + c * v + (1<<15) + (128<<16)) >> 16; + if( new_u & 768 ) new_u = (-new_u) >> 31; + if( new_v & 768 ) new_v = (-new_v) >> 31; + Cb[pos] = new_u; + Cr[pos] = new_v; } } diff --git a/veejay-current/libvje/effects/complexsync.c b/veejay-current/libvje/effects/complexsync.c index e7e634ca..80b30b18 100644 --- a/veejay-current/libvje/effects/complexsync.c +++ b/veejay-current/libvje/effects/complexsync.c @@ -25,12 +25,12 @@ static uint8_t *c_outofsync_buffer[3]; vj_effect *complexsync_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = height-1; ve->limits[0][1] = 0; @@ -49,23 +49,19 @@ vj_effect *complexsync_init(int width, int height) int complexsync_malloc(int width, int height) { - c_outofsync_buffer[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height ); - memset( c_outofsync_buffer[0], 16, (width*height)); - if(!c_outofsync_buffer[0]) return 0; - c_outofsync_buffer[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * (width * height) ); - memset( c_outofsync_buffer[1], 128, (width*height)); - if(!c_outofsync_buffer[1]) return 0; - c_outofsync_buffer[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * (width * height) ); - memset( c_outofsync_buffer[2], 128, (width*height)); - if(!c_outofsync_buffer[2]) return 0; + c_outofsync_buffer[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height * 3 ); + c_outofsync_buffer[1] = c_outofsync_buffer[0] + (width * height ); + c_outofsync_buffer[2] = c_outofsync_buffer[1] + ( width * height ); return 1; } void complexsync_free() { - if(c_outofsync_buffer[0]) free(c_outofsync_buffer[0]); - if(c_outofsync_buffer[1]) free(c_outofsync_buffer[1]); - if(c_outofsync_buffer[2]) free(c_outofsync_buffer[2]); + if(c_outofsync_buffer[0]) + free(c_outofsync_buffer[0]); + c_outofsync_buffer[0] = NULL; + c_outofsync_buffer[1] = NULL; + c_outofsync_buffer[2] = NULL; } void complexsync_apply(VJFrame *frame, VJFrame *frame2, int width, int height, int val) { diff --git a/veejay-current/libvje/effects/complexthreshold.c b/veejay-current/libvje/effects/complexthreshold.c index 4897d380..e243bfd0 100644 --- a/veejay-current/libvje/effects/complexthreshold.c +++ b/veejay-current/libvje/effects/complexthreshold.c @@ -31,11 +31,11 @@ vj_effect *complexthreshold_init(int w, int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 6; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 80; /* angle */ ve->defaults[1] = 0; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/constantblend.c b/veejay-current/libvje/effects/constantblend.c index b1353da7..d36207fa 100644 --- a/veejay-current/libvje/effects/constantblend.c +++ b/veejay-current/libvje/effects/constantblend.c @@ -31,12 +31,12 @@ #include "common.h" vj_effect *constantblend_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 31; ve->limits[0][1] = 0; // scale from 0.0 to 5.0 (only luma) diff --git a/veejay-current/libvje/effects/contrast.c b/veejay-current/libvje/effects/contrast.c index a761b39c..0ef7bb3c 100644 --- a/veejay-current/libvje/effects/contrast.c +++ b/veejay-current/libvje/effects/contrast.c @@ -22,11 +22,11 @@ #include "common.h" vj_effect *contrast_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 2; /* type */ ve->defaults[1] = 125; ve->defaults[2] = 200; diff --git a/veejay-current/libvje/effects/crosspixel.c b/veejay-current/libvje/effects/crosspixel.c index 711a0cce..e3511276 100644 --- a/veejay-current/libvje/effects/crosspixel.c +++ b/veejay-current/libvje/effects/crosspixel.c @@ -26,12 +26,12 @@ static uint8_t *cross_pixels[3]; vj_effect *crosspixel_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 1; ve->limits[0][1] = 1; @@ -48,20 +48,18 @@ vj_effect *crosspixel_init(int w, int h) int crosspixel_malloc(int w, int h) { - cross_pixels[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h); - if(!cross_pixels[0]) return 0; - cross_pixels[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w *h); - if(!cross_pixels[1]) return 0; - cross_pixels[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h); - if(!cross_pixels[2]) return 0; - + cross_pixels[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h * 3); + cross_pixels[1] = cross_pixels[0] + (w * h ); + cross_pixels[2] = cross_pixels[1] + (w * h); return 1; } void crosspixel_free() { - if(cross_pixels[0]) free(cross_pixels[0]); - if(cross_pixels[1]) free(cross_pixels[1]); - if(cross_pixels[2]) free(cross_pixels[2]); + if(cross_pixels[0]) + free(cross_pixels[0]); + cross_pixels[0] = NULL; + cross_pixels[1] = NULL; + cross_pixels[2] = NULL; } void crosspixel_apply(VJFrame *frame, int w, int h, int t,int v) { diff --git a/veejay-current/libvje/effects/cutstop.c b/veejay-current/libvje/effects/cutstop.c index 02376b7b..060b8457 100644 --- a/veejay-current/libvje/effects/cutstop.c +++ b/veejay-current/libvje/effects/cutstop.c @@ -32,11 +32,11 @@ static unsigned int frq_cnt; vj_effect *cutstop_init(int width , int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 40; // treshold ve->defaults[1] = 50; // hold frame freq ve->defaults[2] = 0; // cut mode @@ -66,19 +66,18 @@ vj_effect *cutstop_init(int width , int height) int cutstop_malloc(int width, int height) { - vvcutstop_buffer[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height ); - if(!vvcutstop_buffer[0]) return 0; - vvcutstop_buffer[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height ); - if(!vvcutstop_buffer[1]) return 0; - vvcutstop_buffer[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height ); - if(!vvcutstop_buffer[2]) return 0; + vvcutstop_buffer[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height * 3); + vvcutstop_buffer[1] = vvcutstop_buffer[0] + (width * height ); + vvcutstop_buffer[2] = vvcutstop_buffer[1] + (width * height ); return 1; } void cutstop_free() { - if(vvcutstop_buffer[0]) free(vvcutstop_buffer[0]); - if(vvcutstop_buffer[1]) free(vvcutstop_buffer[1]); - if(vvcutstop_buffer[2]) free(vvcutstop_buffer[2]); + if(vvcutstop_buffer[0]) + free(vvcutstop_buffer[0]); + vvcutstop_buffer[0] = NULL; + vvcutstop_buffer[1] = NULL; + vvcutstop_buffer[2] = NULL; } diff --git a/veejay-current/libvje/effects/deinterlace.c b/veejay-current/libvje/effects/deinterlace.c index 1a3ee0c4..f862b017 100644 --- a/veejay-current/libvje/effects/deinterlace.c +++ b/veejay-current/libvje/effects/deinterlace.c @@ -24,11 +24,11 @@ vj_effect *deinterlace_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->defaults[0] = 0; diff --git a/veejay-current/libvje/effects/dices.c b/veejay-current/libvje/effects/dices.c index c95a67a9..b11224b3 100644 --- a/veejay-current/libvje/effects/dices.c +++ b/veejay-current/libvje/effects/dices.c @@ -50,11 +50,11 @@ typedef enum _dice_dir { vj_effect *dices_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 4; ve->limits[0][0] = 0; ve->limits[1][0] = 5; @@ -62,7 +62,7 @@ vj_effect *dices_init(int width, int height) ve->sub_format = 1; ve->extra_frame = 0; ve->has_user = 0; - g_dicemap = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height); + g_dicemap = (uint8_t *) vj_calloc(sizeof(uint8_t) * width * height); dice_create_map(width, height); return ve; } @@ -76,7 +76,9 @@ int dices_malloc(int width, int height) } void dices_free() { - if(g_dicemap) free(g_dicemap); + if(g_dicemap) + free(g_dicemap); + g_dicemap = NULL; } unsigned int dices_fastrand_val; @@ -166,6 +168,16 @@ void dices_apply( void* data, VJFrame *frame, int width, int height, } } break; + case Up: + for( dy = 0; dy < g_cube_size ; dy ++ ) + { + i = base + dy * width; + for( dx = 0; dx < g_cube_size ; dx ++ ) + { + Y[di] = Y[i]; Cb[di] = Cb[i]; Cr[di] = Cr[i]; i ++; + } + } + break; } map_i++; } diff --git a/veejay-current/libvje/effects/diff.c b/veejay-current/libvje/effects/diff.c index 8b19ad45..ae08aad0 100644 --- a/veejay-current/libvje/effects/diff.c +++ b/veejay-current/libvje/effects/diff.c @@ -34,11 +34,11 @@ typedef struct vj_effect *diff_init(int width, int height) { //int i,j; - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 9; ve->limits[0][1] = 0; /* threshold min */ @@ -65,14 +65,12 @@ int diff_malloc(void **d, int width, int height) { int i; diff_data *my; - *d = (void*) vj_malloc(sizeof(diff_data)); + *d = (void*) vj_calloc(sizeof(diff_data)); my = (diff_data*) *d; - my->static_bg[0] = (uint8_t*) vj_malloc(sizeof(uint8_t)* width * height); - memset( my->static_bg[0], 0 , (width*height)); - my->data = (uint8_t*) vj_malloc(sizeof(uint8_t) * width * height ); - memset(my->data, 0, width * height); + my->static_bg[0] = (uint8_t*) vj_calloc(sizeof(uint8_t)* width * height); + my->data = (uint8_t*) vj_calloc(sizeof(uint8_t) * width * height ); for(i=0; i < 256; i ++) - my->sqrt_table[i] = (double*)vj_malloc(sizeof(double)* 256); + my->sqrt_table[i] = (double*)vj_calloc(sizeof(double)* 256); my->has_bg = 0; return 1; diff --git a/veejay-current/libvje/effects/diffimg.c b/veejay-current/libvje/effects/diffimg.c index 2c89e7a9..9ac10e2b 100644 --- a/veejay-current/libvje/effects/diffimg.c +++ b/veejay-current/libvje/effects/diffimg.c @@ -24,11 +24,11 @@ vj_effect *diffimg_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 6;/* type */ ve->defaults[1] = 15; /* min */ ve->defaults[2] = 235; /* max */ diff --git a/veejay-current/libvje/effects/dissolve.c b/veejay-current/libvje/effects/dissolve.c index da17f26c..070a09a7 100644 --- a/veejay-current/libvje/effects/dissolve.c +++ b/veejay-current/libvje/effects/dissolve.c @@ -23,11 +23,11 @@ vj_effect *dissolve_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->defaults[0] = 150; diff --git a/veejay-current/libvje/effects/distort.c b/veejay-current/libvje/effects/distort.c index b3a6f89f..66bc15c2 100644 --- a/veejay-current/libvje/effects/distort.c +++ b/veejay-current/libvje/effects/distort.c @@ -31,19 +31,19 @@ static int plasma_pos2 = 0; vj_effect *distortion_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); int i; float rad; - plasma_table = (int *) vj_malloc(sizeof(int) * 512); + plasma_table = (int *) vj_calloc(sizeof(int) * 512); for (i = 0; i < 512; i++) { rad = ((float) i * 0.703125) * 0.0174532; plasma_table[i] = sin(rad) * (1024); } ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 5; ve->defaults[1] = 3; ve->limits[0][0] = 0; diff --git a/veejay-current/libvje/effects/dither.c b/veejay-current/libvje/effects/dither.c index 523f1f7b..1518d940 100644 --- a/veejay-current/libvje/effects/dither.c +++ b/veejay-current/libvje/effects/dither.c @@ -22,11 +22,11 @@ #include vj_effect *dither_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 2; ve->defaults[1] = 0; diff --git a/veejay-current/libvje/effects/dummy.c b/veejay-current/libvje/effects/dummy.c index 83ae8eaf..23900112 100644 --- a/veejay-current/libvje/effects/dummy.c +++ b/veejay-current/libvje/effects/dummy.c @@ -26,15 +26,15 @@ vj_effect *dummy_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ /* - ve->param_description = (char**)vj_malloc(sizeof(char)* ve->num_params); + ve->param_description = (char**)vj_calloc(sizeof(char)* ve->num_params); for(i=0; i < ve->num_params; i++) { - ve->param_description[i] = (char*)vj_malloc(sizeof(char) * 100); + ve->param_description[i] = (char*)vj_calloc(sizeof(char) * 100); } sprintf(ve->param_description[0], "Static color"); */ diff --git a/veejay-current/libvje/effects/dupmagic.c b/veejay-current/libvje/effects/dupmagic.c index 5f3a0fa7..68e37a29 100644 --- a/veejay-current/libvje/effects/dupmagic.c +++ b/veejay-current/libvje/effects/dupmagic.c @@ -26,11 +26,11 @@ vj_effect *dupmagic_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 5; ve->description = "Strong Luma Overlay"; ve->limits[0][0] = 1; diff --git a/veejay-current/libvje/effects/emboss.c b/veejay-current/libvje/effects/emboss.c index b6d00fab..b911a138 100644 --- a/veejay-current/libvje/effects/emboss.c +++ b/veejay-current/libvje/effects/emboss.c @@ -24,11 +24,11 @@ #include "common.h" vj_effect *emboss_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 10; ve->limits[0][0] = 0; ve->limits[1][0] = 10; diff --git a/veejay-current/libvje/effects/enhancemask.c b/veejay-current/libvje/effects/enhancemask.c index cbb62a93..07eb4946 100644 --- a/veejay-current/libvje/effects/enhancemask.c +++ b/veejay-current/libvje/effects/enhancemask.c @@ -23,11 +23,11 @@ #include "common.h" vj_effect *enhancemask_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 125; /* type */ // ve->defaults[1] = 255; /* yuvdenoise's default sharpen parameter */ ve->limits[0][0] = 0; diff --git a/veejay-current/libvje/effects/fibdownscale.c b/veejay-current/libvje/effects/fibdownscale.c index 32bd2d5a..c07ebc35 100644 --- a/veejay-current/libvje/effects/fibdownscale.c +++ b/veejay-current/libvje/effects/fibdownscale.c @@ -26,12 +26,12 @@ vj_effect *fibdownscale_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; ve->description = "Fibonacci Downscaler"; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; ve->defaults[1] = 1; ve->limits[0][0] = 0; diff --git a/veejay-current/libvje/effects/fisheye.c b/veejay-current/libvje/effects/fisheye.c index 9f25f57d..0d9800c1 100644 --- a/veejay-current/libvje/effects/fisheye.c +++ b/veejay-current/libvje/effects/fisheye.c @@ -24,12 +24,12 @@ #include vj_effect *fisheye_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = -1000; ve->limits[1][0] = 1000; ve->defaults[0] = 1; @@ -55,21 +55,18 @@ int fisheye_malloc(int w, int h) int w2=w/2; int p =0; - buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - if(!buf[0]) return -1; - buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - if(!buf[1]) return -1; + buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 3 ); + if(!buf[0]) return 0; + buf[1] = buf[0] + (w*h); + buf[2] = buf[1] + (w*h); - buf[2] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - if(!buf[2]) return -1; + polar_map = (double*) vj_calloc(sizeof(double) * w* h ); + if(!polar_map) return 0; + fish_angle = (double*) vj_calloc(sizeof(double) * w* h ); + if(!fish_angle) return 0; - polar_map = (double*) vj_malloc(sizeof(double) * w* h ); - if(!polar_map) return -1; - fish_angle = (double*) vj_malloc(sizeof(double) * w* h ); - if(!fish_angle) return -1; - - cached_coords = (int*) vj_malloc(sizeof(int) * w * h); - if(!cached_coords) return -1; + cached_coords = (int*) vj_calloc(sizeof(int) * w * h); + if(!cached_coords) return 0; for(y=(-1 *h2); y < (h-h2); y++) { @@ -89,10 +86,12 @@ int fisheye_malloc(int w, int h) void fisheye_free() { - if(buf[0]) free(buf[0]); - if(buf[1]) free(buf[1]); - if(buf[2]) free(buf[2]); - + if(buf[0]) + free(buf[0]); + buf[0] = NULL; + buf[1] = NULL; + buf[2] = NULL; + if(polar_map) free(polar_map); if(fish_angle) free(fish_angle); if(cached_coords) free(cached_coords); diff --git a/veejay-current/libvje/effects/flare.c b/veejay-current/libvje/effects/flare.c index 7881d4a1..e2ea2e7d 100644 --- a/veejay-current/libvje/effects/flare.c +++ b/veejay-current/libvje/effects/flare.c @@ -33,11 +33,11 @@ vj_effect *flare_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 3; ve->defaults[1] = 25; ve->defaults[2] = 100; @@ -59,15 +59,11 @@ static uint8_t *flare_buf[3]; int flare_malloc(int w, int h) { - flare_buf[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h ); + flare_buf[0] = (uint8_t*)vj_calloc(sizeof(uint8_t) * w * h * 3 ); if(!flare_buf[0]) return 0; - flare_buf[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h ); - if(!flare_buf[1]) - return 0; - flare_buf[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h ); - if(!flare_buf[2]) - return 0; + flare_buf[1] = flare_buf[0] + (w*h); + flare_buf[2] = flare_buf[1] + (w*h); return 1; } @@ -75,9 +71,7 @@ void flare_free(void) { if(flare_buf[0]) free(flare_buf[0]); flare_buf[0] = NULL; - if(flare_buf[1]) free(flare_buf[1]); flare_buf[1] = NULL; - if(flare_buf[2]) free(flare_buf[2]); flare_buf[2] = NULL; } diff --git a/veejay-current/libvje/effects/flip.c b/veejay-current/libvje/effects/flip.c index 76ef764e..1f93537b 100644 --- a/veejay-current/libvje/effects/flip.c +++ b/veejay-current/libvje/effects/flip.c @@ -23,11 +23,11 @@ vj_effect *flip_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; ve->limits[0][0] = 0; diff --git a/veejay-current/libvje/effects/frameborder.c b/veejay-current/libvje/effects/frameborder.c index bbcdef34..0e383ad8 100644 --- a/veejay-current/libvje/effects/frameborder.c +++ b/veejay-current/libvje/effects/frameborder.c @@ -25,11 +25,11 @@ vj_effect *frameborder_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = width/8; ve->limits[0][0] = 1; ve->limits[1][0] = height / 2; diff --git a/veejay-current/libvje/effects/gamma.c b/veejay-current/libvje/effects/gamma.c index dc89fbc8..f3b9d439 100644 --- a/veejay-current/libvje/effects/gamma.c +++ b/veejay-current/libvje/effects/gamma.c @@ -27,11 +27,11 @@ static uint8_t table[256]; vj_effect *gamma_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 124; ve->limits[0][0] = 0; ve->limits[1][0] = 500; diff --git a/veejay-current/libvje/effects/ghost.c b/veejay-current/libvje/effects/ghost.c index 0bd71347..ff331569 100644 --- a/veejay-current/libvje/effects/ghost.c +++ b/veejay-current/libvje/effects/ghost.c @@ -30,11 +30,11 @@ static int diff_period; vj_effect *ghost_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 16; ve->limits[1][0] = 255; // opacity ve->defaults[0] = 134; @@ -58,8 +58,7 @@ int ghost_malloc(int w, int h) return 0; memset( ghost_buf[i], (i ==0 ? 0: 128), len ); } - diff_map = (uint8_t*) vj_malloc( sizeof(uint8_t) * len); - memset( diff_map , 0, len ); + diff_map = (uint8_t*) vj_calloc( sizeof(uint8_t) * len); diff_period = 0; return 1; diff --git a/veejay-current/libvje/effects/greyselect.c b/veejay-current/libvje/effects/greyselect.c index 1f438738..7c456570 100644 --- a/veejay-current/libvje/effects/greyselect.c +++ b/veejay-current/libvje/effects/greyselect.c @@ -29,11 +29,11 @@ vj_effect *greyselect_init(int w, int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 300; /* angle */ ve->defaults[1] = 255; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/isolate.c b/veejay-current/libvje/effects/isolate.c index cd1112b2..52d02ac7 100644 --- a/veejay-current/libvje/effects/isolate.c +++ b/veejay-current/libvje/effects/isolate.c @@ -29,11 +29,11 @@ vj_effect *isolate_init(int w, int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 5; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 300; /* angle */ ve->defaults[1] = 255; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/keyselect.c b/veejay-current/libvje/effects/keyselect.c index 1054843e..7d83512e 100644 --- a/veejay-current/libvje/effects/keyselect.c +++ b/veejay-current/libvje/effects/keyselect.c @@ -29,11 +29,11 @@ vj_effect *keyselect_init(int w, int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 6; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 300; /* angle */ ve->defaults[1] = 255; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/killchroma.c b/veejay-current/libvje/effects/killchroma.c index 79faa706..e374e064 100644 --- a/veejay-current/libvje/effects/killchroma.c +++ b/veejay-current/libvje/effects/killchroma.c @@ -26,11 +26,11 @@ vj_effect *killchroma_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->sub_format = 0; ve->limits[0][0] = 0; ve->limits[1][0] = 2; diff --git a/veejay-current/libvje/effects/lumablend.c b/veejay-current/libvje/effects/lumablend.c index 493f005d..c460ab08 100644 --- a/veejay-current/libvje/effects/lumablend.c +++ b/veejay-current/libvje/effects/lumablend.c @@ -25,11 +25,11 @@ vj_effect *lumablend_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; /* type */ ve->limits[1][0] = 2; ve->limits[0][1] = 0; /* threshold 1 */ diff --git a/veejay-current/libvje/effects/lumakey.c b/veejay-current/libvje/effects/lumakey.c index fd5ed6af..462eff4b 100644 --- a/veejay-current/libvje/effects/lumakey.c +++ b/veejay-current/libvje/effects/lumakey.c @@ -25,11 +25,11 @@ vj_effect *lumakey_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 5; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; /* feather */ ve->limits[1][0] = 255; ve->limits[0][1] = 0; /* threshold min */ diff --git a/veejay-current/libvje/effects/lumamagick.c b/veejay-current/libvje/effects/lumamagick.c index 8038d0e4..8dd4eae3 100644 --- a/veejay-current/libvje/effects/lumamagick.c +++ b/veejay-current/libvje/effects/lumamagick.c @@ -27,12 +27,12 @@ vj_effect *lumamagick_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ - //ve->param_description = (char**)vj_malloc(sizeof(char)* ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ + //ve->param_description = (char**)vj_calloc(sizeof(char)* ve->num_params); ve->defaults[0] = 1; ve->defaults[1] = 100; ve->defaults[2] = 100; diff --git a/veejay-current/libvje/effects/lumamask.c b/veejay-current/libvje/effects/lumamask.c index 65d39b63..dcafc7df 100644 --- a/veejay-current/libvje/effects/lumamask.c +++ b/veejay-current/libvje/effects/lumamask.c @@ -38,11 +38,11 @@ static uint8_t *buf[3] = { NULL,NULL,NULL }; vj_effect *lumamask_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = width; ve->limits[0][1] = 1; @@ -60,12 +60,10 @@ vj_effect *lumamask_init(int width, int height) int lumamask_malloc(int width, int height) { - buf[0] = (uint8_t*)vj_malloc(sizeof(uint8_t)*width*height); + buf[0] = (uint8_t*)vj_calloc(sizeof(uint8_t)*width*height*3); if(!buf[0]) return 0; - buf[1] = (uint8_t*)vj_malloc(sizeof(uint8_t)*width*height); - if(!buf[1]) return 0; - buf[2] = (uint8_t*)vj_malloc(sizeof(uint8_t)*width*height); - if(!buf[2]) return 0; + buf[1] = buf[0] + (width *height); + buf[2] = buf[1] + (width *height); return 1; } @@ -116,8 +114,6 @@ void lumamask_apply( VJFrame *frame, VJFrame *frame2, int width, void lumamask_free() { if(buf[0]) free(buf[0]); - if(buf[1]) free(buf[1]); - if(buf[2]) free(buf[2]); buf[0] = NULL; buf[1] = NULL; buf[2] = NULL; diff --git a/veejay-current/libvje/effects/magicmirror.c b/veejay-current/libvje/effects/magicmirror.c index 09c9c699..323275ee 100644 --- a/veejay-current/libvje/effects/magicmirror.c +++ b/veejay-current/libvje/effects/magicmirror.c @@ -32,11 +32,11 @@ static unsigned int last[2] = {0,0}; vj_effect *magicmirror_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 76; ve->defaults[1] = 3; @@ -64,33 +64,25 @@ vj_effect *magicmirror_init(int w, int h) int magicmirror_malloc(int w, int h) { unsigned int i; - magicmirrorbuf[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h ); + magicmirrorbuf[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h * 3); if(!magicmirrorbuf[0]) return 0; - magicmirrorbuf[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h ); - if(!magicmirrorbuf[1]) return 0; - magicmirrorbuf[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h ); - if(!magicmirrorbuf[2]) return 0; - - funhouse_x = (double*)vj_malloc(sizeof(double) * w ); + magicmirrorbuf[1] = magicmirrorbuf[0] + (w*h); + magicmirrorbuf[2] = magicmirrorbuf[1] + (w*h); + + funhouse_x = (double*)vj_calloc(sizeof(double) * w ); if(!funhouse_x) return 0; - cache_x = (unsigned int *)vj_malloc(sizeof(unsigned int)*w); + cache_x = (unsigned int *)vj_calloc(sizeof(unsigned int)*w); if(!cache_x) return 0; - funhouse_y = (double*)vj_malloc(sizeof(double) * h ); + funhouse_y = (double*)vj_calloc(sizeof(double) * h ); if(!funhouse_y) return 0; - cache_y = (unsigned int*)vj_malloc(sizeof(unsigned int)*h); + cache_y = (unsigned int*)vj_calloc(sizeof(unsigned int)*h); if(!cache_y) return 0; memset(cache_x,0,w); memset(cache_y,0,h); - for ( i = 0; i < h ; i ++ ) - funhouse_y[i] = 0.0; - - for ( i = 0; i < w; i ++ ) - funhouse_x[i] = 0.0; - memset(magicmirrorbuf[0],16,w*h); memset(magicmirrorbuf[1],128,w*h); memset(magicmirrorbuf[2],128,w*h); @@ -100,12 +92,17 @@ int magicmirror_malloc(int w, int h) void magicmirror_free() { if(magicmirrorbuf[0]) free(magicmirrorbuf[0]); - if(magicmirrorbuf[1]) free(magicmirrorbuf[1]); - if(magicmirrorbuf[2]) free(magicmirrorbuf[2]); if(funhouse_x) free(funhouse_x); if(funhouse_y) free(funhouse_y); if(cache_x) free(cache_x); if(cache_y) free(cache_y); + magicmirrorbuf[0] = NULL; + magicmirrorbuf[1] = NULL; + magicmirrorbuf[2] = NULL; + cache_x = NULL; + cache_y = NULL; + funhouse_x = NULL; + funhouse_y = NULL; } void magicmirror_apply( VJFrame *frame, int w, int h, int vx, int vy, int d, int n ) diff --git a/veejay-current/libvje/effects/magicoverlays.c b/veejay-current/libvje/effects/magicoverlays.c index cca8ae62..2109bab8 100644 --- a/veejay-current/libvje/effects/magicoverlays.c +++ b/veejay-current/libvje/effects/magicoverlays.c @@ -25,11 +25,11 @@ #include "common.h" vj_effect *overlaymagic_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 7; ve->description = "Overlay Magic"; ve->limits[0][0] = 1; diff --git a/veejay-current/libvje/effects/magicphotos.c b/veejay-current/libvje/effects/magicphotos.c index cb04d04f..dcc38330 100644 --- a/veejay-current/libvje/effects/magicphotos.c +++ b/veejay-current/libvje/effects/magicphotos.c @@ -23,12 +23,12 @@ vj_effect *photoplay_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; // divider ve->limits[1][0] = max_power(w); ve->limits[0][1] = 0; diff --git a/veejay-current/libvje/effects/magicscratcher.c b/veejay-current/libvje/effects/magicscratcher.c index affe68ae..36d9c5c1 100644 --- a/veejay-current/libvje/effects/magicscratcher.c +++ b/veejay-current/libvje/effects/magicscratcher.c @@ -28,11 +28,11 @@ static int m_reverse = 0; vj_effect *magicscratcher_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 9; ve->limits[0][1] = 1; @@ -52,7 +52,7 @@ vj_effect *magicscratcher_init(int w, int h) int magicscratcher_malloc(int w, int h) { mframe = - (uint8_t *) vj_malloc(w * h * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); + (uint8_t *) vj_calloc(w * h * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); memset(mframe, 0, w * h * MAX_SCRATCH_FRAMES ); if(!mframe) return 0; return 1; diff --git a/veejay-current/libvje/effects/mask.c b/veejay-current/libvje/effects/mask.c index a3fe091f..08a40f6f 100644 --- a/veejay-current/libvje/effects/mask.c +++ b/veejay-current/libvje/effects/mask.c @@ -25,11 +25,11 @@ vj_effect *simplemask_init(int w, int h ) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->limits[0][1] = 0; diff --git a/veejay-current/libvje/effects/maskstop.c b/veejay-current/libvje/effects/maskstop.c index 24fd365e..cc521530 100644 --- a/veejay-current/libvje/effects/maskstop.c +++ b/veejay-current/libvje/effects/maskstop.c @@ -33,11 +33,11 @@ static unsigned int frq_mask; vj_effect *maskstop_init(int width , int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; // negate mask ve->defaults[1] = 0; // swap mask/frame ve->defaults[2] = 80; // hold frame freq @@ -69,19 +69,19 @@ vj_effect *maskstop_init(int width , int height) int maskstop_malloc(int width, int height) { int i; - for( i = 0; i < 6; i ++ ) - { - vvmaskstop_buffer[i] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height ); - if(!vvmaskstop_buffer[i]) return 0; - } + vvmaskstop_buffer[0] = (uint8_t*) vj_malloc( sizeof(uint8_t) * width * height * 6 ); + for( i = 1; i < 6; i ++ ) + vvmaskstop_buffer[i] = vvmaskstop_buffer[(i-1)] + (width * height); return 1; } void maskstop_free() { + if(vvmaskstop_buffer[0]) + free(vvmaskstop_buffer[0]); int i; - for(i = 0; i < 6; i ++ ) - if(vvmaskstop_buffer[i]) free(vvmaskstop_buffer[i]); + for(i = 0 ;i < 6 ; i++) + vvmaskstop_buffer[i] = NULL; } diff --git a/veejay-current/libvje/effects/mirrors.c b/veejay-current/libvje/effects/mirrors.c index 84d2b479..de0062ca 100644 --- a/veejay-current/libvje/effects/mirrors.c +++ b/veejay-current/libvje/effects/mirrors.c @@ -26,11 +26,11 @@ vj_effect *mirrors_init(int width,int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 1; ve->defaults[1] = 1; ve->limits[0][0] = 0; /* horizontal or vertical mirror */ diff --git a/veejay-current/libvje/effects/mirrors2.c b/veejay-current/libvje/effects/mirrors2.c index 9b3ea591..e9ab8b51 100644 --- a/veejay-current/libvje/effects/mirrors2.c +++ b/veejay-current/libvje/effects/mirrors2.c @@ -27,11 +27,11 @@ vj_effect *mirrors2_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 4; ve->limits[0][0] = 0; /* horizontal or vertical mirror */ ve->limits[1][0] = 5; diff --git a/veejay-current/libvje/effects/morphology.c b/veejay-current/libvje/effects/morphology.c index 4403af85..99e87c84 100644 --- a/veejay-current/libvje/effects/morphology.c +++ b/veejay-current/libvje/effects/morphology.c @@ -25,12 +25,12 @@ typedef uint8_t (*morph_func)(uint8_t *kernel, uint8_t mt[9] ); vj_effect *morphology_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; // threshold ve->limits[1][0] = 255; ve->limits[0][1] = 0; // morpology operator (dilate,erode, ... ) diff --git a/veejay-current/libvje/effects/motionblur.c b/veejay-current/libvje/effects/motionblur.c index dc832746..6e1149e7 100644 --- a/veejay-current/libvje/effects/motionblur.c +++ b/veejay-current/libvje/effects/motionblur.c @@ -25,11 +25,11 @@ static uint8_t *previous_frame[3]; vj_effect *motionblur_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 15; ve->limits[0][0] = 0; ve->limits[1][0] = 1000; /* time in frames */ @@ -42,20 +42,19 @@ vj_effect *motionblur_init(int width, int height) int motionblur_malloc(int width, int height) { - previous_frame[0] = (uint8_t*) vj_malloc( width * height * sizeof(uint8_t)); + previous_frame[0] = (uint8_t*) vj_calloc( width * height * 3 * sizeof(uint8_t)); if(!previous_frame[0]) return 0; - previous_frame[1] = (uint8_t*) vj_malloc( width * height * sizeof(uint8_t)); - if(!previous_frame[1]) return 0; - previous_frame[2] = (uint8_t*) vj_malloc( width * height * sizeof(uint8_t)); - if(!previous_frame[2]) return 0; - + previous_frame[1] = previous_frame[0] + (width * height); + previous_frame[2] = previous_frame[1] + (width * height); return 1; } void motionblur_free() { - if(previous_frame[0]) free(previous_frame[0]); - if(previous_frame[1]) free(previous_frame[1]); - if(previous_frame[2]) free(previous_frame[2]); + if(previous_frame[0]) + free(previous_frame[0]); + previous_frame[0] = NULL; + previous_frame[1] = NULL; + previous_frame[2] = NULL; } diff --git a/veejay-current/libvje/effects/mtracer.c b/veejay-current/libvje/effects/mtracer.c index 5d25c082..e7752f44 100644 --- a/veejay-current/libvje/effects/mtracer.c +++ b/veejay-current/libvje/effects/mtracer.c @@ -29,11 +29,11 @@ static int mtrace_counter = 0; vj_effect *mtracer_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 30; ve->limits[0][1] = 1; @@ -49,18 +49,16 @@ vj_effect *mtracer_init(int w, int h) // FIXME private void mtracer_free() { if(mtrace_buffer[0]) free(mtrace_buffer[0]); - if(mtrace_buffer[1]) free(mtrace_buffer[1]); - if(mtrace_buffer[2]) free(mtrace_buffer[2]); + mtrace_buffer[0] = NULL; + mtrace_buffer[1] = NULL; } int mtracer_malloc(int w, int h) { - mtrace_buffer[0] = (uint8_t *) vj_malloc(w * h * sizeof(uint8_t)); + mtrace_buffer[0] = (uint8_t *) vj_malloc(w * h * 3 * sizeof(uint8_t)); if(!mtrace_buffer[0]) return 0; - mtrace_buffer[1] = (uint8_t *) vj_malloc(w * h * sizeof(uint8_t)); - if(!mtrace_buffer[1]) return 0; - mtrace_buffer[2] = (uint8_t *) vj_malloc(w * h * sizeof(uint8_t)); - if(!mtrace_buffer[2]) return 0; + mtrace_buffer[1] = mtrace_buffer[0] + (w*h); + mtrace_buffer[2] = mtrace_buffer[1] + (w*h); return 1; } diff --git a/veejay-current/libvje/effects/negation.c b/veejay-current/libvje/effects/negation.c index d9f4b0c6..34252c54 100644 --- a/veejay-current/libvje/effects/negation.c +++ b/veejay-current/libvje/effects/negation.c @@ -23,12 +23,12 @@ vj_effect *negation_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->defaults[0] = 255; diff --git a/veejay-current/libvje/effects/neighbours.c b/veejay-current/libvje/effects/neighbours.c index 45e7ce7d..596c1d92 100644 --- a/veejay-current/libvje/effects/neighbours.c +++ b/veejay-current/libvje/effects/neighbours.c @@ -23,12 +23,12 @@ vj_effect *neighbours_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; ve->limits[1][0] = 16; /* brush size (shape is rectangle)*/ ve->limits[0][1] = 1; @@ -55,20 +55,25 @@ static uint8_t *chromacity[2]; int neighbours_malloc(int w, int h ) { - tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 2); if(!tmp_buf[0] ) return 0; - tmp_buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[1] = tmp_buf[0] + (w*h); + chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h *2); + if(!chromacity[0]) return 0; + chromacity[1] = chromacity[0] + (w*h); return 1; } void neighbours_free(void) { - if(tmp_buf[0]) free(tmp_buf[0]); - if(tmp_buf[1]) free(tmp_buf[1]); - if(chromacity[0]) free(chromacity[0]); - if(chromacity[1]) free(chromacity[1]); + if(tmp_buf[0]) + free(tmp_buf[0]); + if(chromacity[0]) + free(chromacity[0]); + tmp_buf[0] = NULL; + tmp_buf[1] = NULL; + chromacity[0] = NULL; + chromacity[1] = NULL; } static inline uint8_t evaluate_pixel( diff --git a/veejay-current/libvje/effects/neighbours2.c b/veejay-current/libvje/effects/neighbours2.c index 01069d20..597c6bf5 100644 --- a/veejay-current/libvje/effects/neighbours2.c +++ b/veejay-current/libvje/effects/neighbours2.c @@ -23,12 +23,12 @@ vj_effect *neighbours2_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; ve->limits[1][0] = 16; /* brush size (shape is rectangle)*/ ve->limits[0][1] = 1; @@ -55,20 +55,25 @@ static uint8_t *chromacity[2]; int neighbours2_malloc(int w, int h ) { - tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 2); if(!tmp_buf[0] ) return 0; - tmp_buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[1] = tmp_buf[0] + (w*h); + chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h *2); + if(!chromacity[0]) return 0; + chromacity[1] = chromacity[0] + (w*h); return 1; } void neighbours2_free(void) { - if(tmp_buf[0]) free(tmp_buf[0]); - if(tmp_buf[1]) free(tmp_buf[1]); - if(chromacity[0]) free(chromacity[0]); - if(chromacity[1]) free(chromacity[1]); + if(tmp_buf[0]) + free(tmp_buf[0]); + if(chromacity[0]) + free(chromacity[0]); + tmp_buf[0] = NULL; + tmp_buf[1] = NULL; + chromacity[0] = NULL; + chromacity[1] = NULL; } typedef struct diff --git a/veejay-current/libvje/effects/neighbours3.c b/veejay-current/libvje/effects/neighbours3.c index 79ad345e..362de38e 100644 --- a/veejay-current/libvje/effects/neighbours3.c +++ b/veejay-current/libvje/effects/neighbours3.c @@ -23,12 +23,12 @@ vj_effect *neighbours3_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; ve->limits[1][0] = 32; /* line size */ ve->limits[0][1] = 1; @@ -55,22 +55,26 @@ static uint8_t *chromacity[2]; int neighbours3_malloc(int w, int h ) { - tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 2); if(!tmp_buf[0] ) return 0; - tmp_buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[1] = tmp_buf[0] + (w*h); + chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h *2); + if(!chromacity[0]) return 0; + chromacity[1] = chromacity[0] + (w*h); return 1; } void neighbours3_free(void) { - if(tmp_buf[0]) free(tmp_buf[0]); - if(tmp_buf[1]) free(tmp_buf[1]); - if(chromacity[0]) free(chromacity[0]); - if(chromacity[1]) free(chromacity[1]); + if(tmp_buf[0]) + free(tmp_buf[0]); + if(chromacity[0]) + free(chromacity[0]); + tmp_buf[0] = NULL; + tmp_buf[1] = NULL; + chromacity[0] = NULL; + chromacity[1] = NULL; } - typedef struct { uint8_t y; diff --git a/veejay-current/libvje/effects/neighbours4.c b/veejay-current/libvje/effects/neighbours4.c index bc6f12d2..7c7f0455 100644 --- a/veejay-current/libvje/effects/neighbours4.c +++ b/veejay-current/libvje/effects/neighbours4.c @@ -23,12 +23,12 @@ vj_effect *neighbours4_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; ve->limits[1][0] = 32; /* radius */ ve->limits[0][1] = 1; @@ -69,13 +69,16 @@ typedef struct static relpoint_t points[2048]; + + int neighbours4_malloc(int w, int h ) { - tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 2); if(!tmp_buf[0] ) return 0; - tmp_buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[1] = tmp_buf[0] + (w*h); + chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h *2); + if(!chromacity[0]) return 0; + chromacity[1] = chromacity[0] + (w*h); int i; for(i = 0; i < w; i ++ ) { @@ -87,10 +90,14 @@ int neighbours4_malloc(int w, int h ) void neighbours4_free(void) { - if(tmp_buf[0]) free(tmp_buf[0]); - if(tmp_buf[1]) free(tmp_buf[1]); - if(chromacity[0]) free(chromacity[0]); - if(chromacity[1]) free(chromacity[1]); + if(tmp_buf[0]) + free(tmp_buf[0]); + if(chromacity[0]) + free(chromacity[0]); + tmp_buf[0] = NULL; + tmp_buf[1] = NULL; + chromacity[0] = NULL; + chromacity[1] = NULL; } static void create_circle( double radius, int depth, int w ) diff --git a/veejay-current/libvje/effects/neighbours5.c b/veejay-current/libvje/effects/neighbours5.c index f033e137..076669ad 100644 --- a/veejay-current/libvje/effects/neighbours5.c +++ b/veejay-current/libvje/effects/neighbours5.c @@ -23,12 +23,12 @@ vj_effect *neighbours5_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; ve->limits[1][0] = 32; /* line size */ ve->limits[0][1] = 1; @@ -55,20 +55,25 @@ static uint8_t *chromacity[2]; int neighbours5_malloc(int w, int h ) { - tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 2); if(!tmp_buf[0] ) return 0; - tmp_buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - chromacity[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + tmp_buf[1] = tmp_buf[0] + (w*h); + chromacity[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h *2); + if(!chromacity[0]) return 0; + chromacity[1] = chromacity[0] + (w*h); return 1; } void neighbours5_free(void) { - if(tmp_buf[0]) free(tmp_buf[0]); - if(tmp_buf[1]) free(tmp_buf[1]); - if(chromacity[0]) free(chromacity[0]); - if(chromacity[1]) free(chromacity[1]); + if(tmp_buf[0]) + free(tmp_buf[0]); + if(chromacity[0]) + free(chromacity[0]); + tmp_buf[0] = NULL; + tmp_buf[1] = NULL; + chromacity[0] = NULL; + chromacity[1] = NULL; } typedef struct diff --git a/veejay-current/libvje/effects/nervous.c b/veejay-current/libvje/effects/nervous.c index 4ad488a3..4db950c8 100644 --- a/veejay-current/libvje/effects/nervous.c +++ b/veejay-current/libvje/effects/nervous.c @@ -35,12 +35,12 @@ static int frames_elapsed; vj_effect *nervous_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = N_MAX; ve->defaults[0] = N_MAX; @@ -53,12 +53,11 @@ vj_effect *nervous_init(int w, int h) int nervous_malloc(int w, int h ) { - nervous_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * N_MAX); + nervous_buf[0] = (uint8_t*) vj_calloc(sizeof(uint8_t) * w * h * N_MAX * 3); + if(!nervous_buf[0]) return 0; - nervous_buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * N_MAX); - if(!nervous_buf[1]) return 0; - nervous_buf[2] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * N_MAX); - if(!nervous_buf[2]) return 0; + nervous_buf[1] = nervous_buf[0] + (w*h); + nervous_buf[2] = nervous_buf[1] + (w*h); frames_elapsed = 0; return 1; } @@ -66,8 +65,6 @@ int nervous_malloc(int w, int h ) void nervous_free(void) { if( nervous_buf[0] ) free(nervous_buf[0]); - if( nervous_buf[1] ) free(nervous_buf[1]); - if( nervous_buf[2] ) free(nervous_buf[2]); nervous_buf[0] = NULL; nervous_buf[1] = NULL; nervous_buf[2] = NULL; diff --git a/veejay-current/libvje/effects/noiseadd.c b/veejay-current/libvje/effects/noiseadd.c index 06343ee9..a0c7d560 100644 --- a/veejay-current/libvje/effects/noiseadd.c +++ b/veejay-current/libvje/effects/noiseadd.c @@ -24,11 +24,11 @@ static uint8_t *Yb_frame; vj_effect *noiseadd_init(int width , int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 0; /* type */ ve->defaults[1] = 1000; ve->limits[0][0] = 0; @@ -47,14 +47,14 @@ vj_effect *noiseadd_init(int width , int height) int noiseadd_malloc(int width, int height) { - Yb_frame = (uint8_t *) vj_malloc( sizeof(uint8_t) * width * height); - memset(Yb_frame, 0, width*height); + Yb_frame = (uint8_t *) vj_calloc( sizeof(uint8_t) * width * height); if(!Yb_frame) return 0; return 1; } void noiseadd_free() { if(Yb_frame) free(Yb_frame); + Yb_frame = NULL; } void noiseblur1x3_maskapply(uint8_t *src[3], int width, int height, int coeef ) { diff --git a/veejay-current/libvje/effects/noisepencil.c b/veejay-current/libvje/effects/noisepencil.c index b7874a06..c5546169 100644 --- a/veejay-current/libvje/effects/noisepencil.c +++ b/veejay-current/libvje/effects/noisepencil.c @@ -25,11 +25,11 @@ static uint8_t *Yb_frame; vj_effect *noisepencil_init(int width , int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 0; /* type */ ve->defaults[1] = 1000; ve->defaults[2] = 68; @@ -63,6 +63,7 @@ int noisepencil_malloc(int width,int height) void noisepencil_free() { if(Yb_frame) free(Yb_frame); + Yb_frame = NULL; } void noisepencil_1_apply(uint8_t *src[3], int width, int height, int coeef, int min_t, int max_t ) { diff --git a/veejay-current/libvje/effects/opacity.c b/veejay-current/libvje/effects/opacity.c index a0e06525..fa56b92f 100644 --- a/veejay-current/libvje/effects/opacity.c +++ b/veejay-current/libvje/effects/opacity.c @@ -22,11 +22,11 @@ vj_effect *opacity_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->defaults[0] = 150; diff --git a/veejay-current/libvje/effects/opacityadv.c b/veejay-current/libvje/effects/opacityadv.c index 50cadf0a..9d209f2a 100644 --- a/veejay-current/libvje/effects/opacityadv.c +++ b/veejay-current/libvje/effects/opacityadv.c @@ -22,11 +22,11 @@ vj_effect *opacityadv_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->limits[0][1] = 0; diff --git a/veejay-current/libvje/effects/opacitythreshold.c b/veejay-current/libvje/effects/opacitythreshold.c index fc8271c0..618afe94 100644 --- a/veejay-current/libvje/effects/opacitythreshold.c +++ b/veejay-current/libvje/effects/opacitythreshold.c @@ -23,11 +23,11 @@ vj_effect *opacitythreshold_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->limits[0][1] = 0; diff --git a/veejay-current/libvje/effects/overclock.c b/veejay-current/libvje/effects/overclock.c index d693aac6..a7a535fb 100644 --- a/veejay-current/libvje/effects/overclock.c +++ b/veejay-current/libvje/effects/overclock.c @@ -25,12 +25,12 @@ vj_effect *overclock_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; ve->limits[1][0] = (h/8); ve->limits[0][1] = 1; @@ -104,20 +104,14 @@ static inline void blur2(uint8_t *dst, uint8_t *src, int w, int radius, int powe int overclock_malloc(int w, int h) { const int len = w* h; - oc_buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * len ); + oc_buf[0] = (uint8_t*) vj_calloc(sizeof(uint8_t) * len ); if(oc_buf[0]==NULL) return 0; -// oc_buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * uv_len); -// if(oc_buf[1]==NULL) return 0; -// oc_buf[2] = (uint8_t*) vj_malloc(sizeof(uint8_t) * uv_len); -// if(oc_buf[2]==NULL) return 0; return 1; } void overclock_free() { if(oc_buf[0]) free( oc_buf[0] ); - if(oc_buf[1]) free( oc_buf[1] ); - if(oc_buf[2]) free( oc_buf[2] ); } void overclock_apply(VJFrame *frame, int width, int height, int n, int radius ) diff --git a/veejay-current/libvje/effects/pencilsketch.c b/veejay-current/libvje/effects/pencilsketch.c index 05678c08..23f125dd 100644 --- a/veejay-current/libvje/effects/pencilsketch.c +++ b/veejay-current/libvje/effects/pencilsketch.c @@ -22,11 +22,11 @@ vj_effect *pencilsketch_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 0;/* type */ ve->defaults[1] = pixel_Y_lo_; /* min */ ve->defaults[2] = pixel_Y_hi_; /* max */ diff --git a/veejay-current/libvje/effects/photoplay.c b/veejay-current/libvje/effects/photoplay.c index 73e47b9c..d59540ab 100644 --- a/veejay-current/libvje/effects/photoplay.c +++ b/veejay-current/libvje/effects/photoplay.c @@ -23,12 +23,12 @@ vj_effect *photoplay_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; // divider ve->limits[1][0] = max_power(w); ve->limits[0][1] = 1; @@ -56,7 +56,7 @@ static int prepare_filmstrip(int film_length, int w, int h) int picture_width = w / sqrt(film_length); int picture_height = h / sqrt(film_length); - photo_list = (picture_t**) vj_malloc(sizeof(picture_t*) * (film_length + 1) ); + photo_list = (picture_t**) vj_calloc(sizeof(picture_t*) * (film_length + 1) ); if(!photo_list) return 0; diff --git a/veejay-current/libvje/effects/picinpic.c b/veejay-current/libvje/effects/picinpic.c index 98f32198..255451e1 100644 --- a/veejay-current/libvje/effects/picinpic.c +++ b/veejay-current/libvje/effects/picinpic.c @@ -44,11 +44,11 @@ typedef struct vj_effect *picinpic_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 64; /* width of view port */ ve->defaults[1] = 64; /* height of viewport */ ve->defaults[2] = 64; /* x1 */ @@ -76,12 +76,10 @@ int picinpic_malloc(void **d, int w, int h) { int i; pic_t *my; - *d = (void*) vj_malloc(sizeof(pic_t)); + *d = (void*) vj_calloc(sizeof(pic_t)); my = (pic_t*) *d; my->scaler = NULL; - memset( &(my->frame), 0, sizeof(VJFrame)); - memset( &(my->template), 0, sizeof(sws_template) ); my->template.flags = 1; my->w = 0; my->h = 0; @@ -143,9 +141,9 @@ void picinpic_apply( void *user_data, VJFrame *frame, VJFrame *frame2, int width &(picture->template), yuv_sws_get_cpu_flags() ); - picture->frame.data[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * len ); - picture->frame.data[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * len ); - picture->frame.data[2] = (uint8_t*) vj_malloc(sizeof(uint8_t) * len ); + picture->frame.data[0] = (uint8_t*) vj_calloc(sizeof(uint8_t) * len ); + picture->frame.data[1] = (uint8_t*) vj_calloc(sizeof(uint8_t) * len ); + picture->frame.data[2] = (uint8_t*) vj_calloc(sizeof(uint8_t) * len ); picture->w = view_width; picture->h = view_height; diff --git a/veejay-current/libvje/effects/pixelate.c b/veejay-current/libvje/effects/pixelate.c index d2251c2b..19e218b4 100644 --- a/veejay-current/libvje/effects/pixelate.c +++ b/veejay-current/libvje/effects/pixelate.c @@ -25,7 +25,7 @@ static uint8_t values[512]; vj_effect *pixelate_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); int i; int nvalues=0; for(i=1; i < width; i++) @@ -39,9 +39,9 @@ vj_effect *pixelate_init(int width, int height) ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = nvalues-2; ve->defaults[0] = 8; diff --git a/veejay-current/libvje/effects/posterize.c b/veejay-current/libvje/effects/posterize.c index b7c316a3..98588093 100644 --- a/veejay-current/libvje/effects/posterize.c +++ b/veejay-current/libvje/effects/posterize.c @@ -22,11 +22,11 @@ #include vj_effect *posterize_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 4; ve->defaults[1] = 16; ve->defaults[2] = 235; diff --git a/veejay-current/libvje/effects/radialblur.c b/veejay-current/libvje/effects/radialblur.c index 8638600f..d79c1ec5 100644 --- a/veejay-current/libvje/effects/radialblur.c +++ b/veejay-current/libvje/effects/radialblur.c @@ -51,11 +51,11 @@ static uint8_t *radial_src[3]; vj_effect *radialblur_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 15; ve->defaults[1] = 0; ve->defaults[2] = 2; @@ -75,12 +75,10 @@ vj_effect *radialblur_init(int w,int h) int radialblur_malloc(int w, int h) { - radial_src[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); + radial_src[0] = (uint8_t*) vj_calloc(sizeof(uint8_t) * w * h * 3 ); if(!radial_src[0]) return 0; - radial_src[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * ((w*h))); - if(!radial_src[1]) return 0; - radial_src[2] = (uint8_t*) vj_malloc(sizeof(uint8_t) * ((w*h))); - if(!radial_src[2]) return 0; + radial_src[1] = radial_src[0] + (w * h); + radial_src[2] = radial_src[1] + (w * h); return 1; } @@ -146,9 +144,8 @@ void radialblur_apply(VJFrame *frame, int width, int height, int radius, int pow void radialblur_free() { - if( radial_src[0] ) free(radial_src[0]); - if( radial_src[1] ) free(radial_src[1]); - if( radial_src[2] ) free(radial_src[2]); + if( radial_src[0] ) + free(radial_src[0]); radial_src[0] = NULL; radial_src[1] = NULL; radial_src[2] = NULL; diff --git a/veejay-current/libvje/effects/raster.c b/veejay-current/libvje/effects/raster.c index 4b83d66b..f1f34800 100644 --- a/veejay-current/libvje/effects/raster.c +++ b/veejay-current/libvje/effects/raster.c @@ -25,12 +25,12 @@ vj_effect *raster_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 4; ve->limits[1][0] = h/4; ve->defaults[0] = 4; @@ -95,7 +95,7 @@ void raster_apply(VJFrame *frame, int w, int h, int v ) if(!buf) { - buf = (uint8_t*)vj_malloc(sizeof(uint8_t) * w * h ); + buf = (uint8_t*)vj_calloc(sizeof(uint8_t) * w * h ); if(!buf)return; } memcpy(buf, Y,(w*h)); diff --git a/veejay-current/libvje/effects/rawman.c b/veejay-current/libvje/effects/rawman.c index c0e0b10f..7f2dd774 100644 --- a/veejay-current/libvje/effects/rawman.c +++ b/veejay-current/libvje/effects/rawman.c @@ -22,11 +22,11 @@ #include vj_effect *rawman_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; ve->defaults[1] = 15; diff --git a/veejay-current/libvje/effects/rawval.c b/veejay-current/libvje/effects/rawval.c index 67bb00d5..0da1e938 100644 --- a/veejay-current/libvje/effects/rawval.c +++ b/veejay-current/libvje/effects/rawval.c @@ -23,11 +23,11 @@ #include vj_effect *rawval_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 232; ve->defaults[1] = 16; ve->defaults[2] = 16; diff --git a/veejay-current/libvje/effects/reflection.c b/veejay-current/libvje/effects/reflection.c index 7c20cda7..fae86952 100644 --- a/veejay-current/libvje/effects/reflection.c +++ b/veejay-current/libvje/effects/reflection.c @@ -54,11 +54,11 @@ static uint8_t *reflection_buffer; vj_effect *reflection_init(int width,int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 2; ve->defaults[1] = 5; ve->defaults[2] = 1; @@ -107,6 +107,7 @@ int reflection_malloc(int width, int height) void reflection_free() { if(reflection_buffer) free(reflection_buffer); + reflection_buffer = NULL; } diff --git a/veejay-current/libvje/effects/revtv.c b/veejay-current/libvje/effects/revtv.c index 8acbc20b..73866d36 100644 --- a/veejay-current/libvje/effects/revtv.c +++ b/veejay-current/libvje/effects/revtv.c @@ -24,11 +24,11 @@ #include vj_effect *revtv_init(int max_width, int max_height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 2; ve->defaults[1] = 42; ve->defaults[2] = 201; diff --git a/veejay-current/libvje/effects/rgbkey.c b/veejay-current/libvje/effects/rgbkey.c index a3416d5e..be9b548c 100644 --- a/veejay-current/libvje/effects/rgbkey.c +++ b/veejay-current/libvje/effects/rgbkey.c @@ -46,11 +46,11 @@ vj_effect *rgbkey_init(int w,int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 6; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 319; /* angle , 45 degrees*/ ve->defaults[1] = 0; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/rgbkeysmooth.c b/veejay-current/libvje/effects/rgbkeysmooth.c index dcaed8e5..de05e0de 100644 --- a/veejay-current/libvje/effects/rgbkeysmooth.c +++ b/veejay-current/libvje/effects/rgbkeysmooth.c @@ -31,11 +31,11 @@ vj_effect *rgbkeysmooth_init(int w,int h) { vj_effect *ve; - ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 6; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 290; /* angle */ ve->defaults[1] = 255; /* r */ ve->defaults[2] = 0; /* g */ diff --git a/veejay-current/libvje/effects/ripple.c b/veejay-current/libvje/effects/ripple.c index 6f34df0d..b6cdfffd 100644 --- a/veejay-current/libvje/effects/ripple.c +++ b/veejay-current/libvje/effects/ripple.c @@ -47,11 +47,11 @@ static int ripple_attn = 0; // FIXME private vj_effect *ripple_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = 3600; ve->limits[0][1] = 1; @@ -73,16 +73,16 @@ int ripple_malloc(int width, int height) int i; ripple_table = (double*) vj_malloc(sizeof(double) * width * height + 16); if(!ripple_table) return 0; - ripple_data[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height + 16); + ripple_data[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * (width * height * 3) + 64); if(!ripple_data[0]) return 0; - ripple_data[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height + 16); - if(!ripple_data[1]) return 0; - ripple_data[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height + 16); - if(!ripple_data[2]) return 0; + ripple_data[1] = ripple_data[0] + (width * height); + ripple_data[2] = ripple_data[1] + (width * height); + ripple_sin = (double*) vj_malloc(sizeof(double) * RIPPLE_DEGREES); if(!ripple_sin) return 0; ripple_cos = (double*) vj_malloc(sizeof(double) * RIPPLE_DEGREES); if(!ripple_cos) return 0; + for(i=0; i < RIPPLE_DEGREES; i++) { ripple_sin[i] = sin ((M_PI * i) / RIPPLE_VAL); ripple_cos[i] = sin ((M_PI * i) / RIPPLE_VAL); @@ -96,9 +96,14 @@ void ripple_free() { if(ripple_table) free(ripple_table); if(ripple_sin) free(ripple_sin); if(ripple_cos) free(ripple_cos); - if(ripple_data[0]) free(ripple_data[0]); - if(ripple_data[1]) free(ripple_data[1]); - if(ripple_data[2]) free(ripple_data[2]); + if(ripple_data[0]) + free(ripple_data[0]); + ripple_data[0] = NULL; + ripple_data[1] = NULL; + ripple_data[2] = NULL; + ripple_sin = NULL; + ripple_cos = NULL; + ripple_table = NULL; } diff --git a/veejay-current/libvje/effects/rotozoom.c b/veejay-current/libvje/effects/rotozoom.c index 37be6d3b..7b12e35f 100644 --- a/veejay-current/libvje/effects/rotozoom.c +++ b/veejay-current/libvje/effects/rotozoom.c @@ -38,11 +38,11 @@ vj_effect *rotozoom_init(int width, int height) { int i, j; - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; ve->defaults[1] = 1; ve->defaults[2] = 1; @@ -129,20 +129,21 @@ int rotozoom_malloc(int width, int height) { - rotobuffer[0] = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height ); - if(!rotobuffer[0]) return 0; - rotobuffer[1] = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height ); - if(!rotobuffer[1]) return 0; - rotobuffer[2] = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height ); - if(!rotobuffer[2]) return 0; + rotobuffer[0] = (uint8_t *) vj_calloc(sizeof(uint8_t) * width * height * 3); + if(!rotobuffer[0]) + return 0; + rotobuffer[1] = rotobuffer[0] + (width * height); + rotobuffer[2] = rotobuffer[1] + (width * height); return 1; } void rotozoom_free() { - if(rotobuffer[0]) free(rotobuffer[0]); - if(rotobuffer[1]) free(rotobuffer[1]); - if(rotobuffer[2]) free(rotobuffer[2]); + if(rotobuffer[0]) + free(rotobuffer[0]); + rotobuffer[0] = NULL; + rotobuffer[1] = NULL; + rotobuffer[2] = NULL; } /* rotozoomer, from the demo effects collection, works in supersampled YCbCr space. diff --git a/veejay-current/libvje/effects/scratcher.c b/veejay-current/libvje/effects/scratcher.c index a14212cf..b0283d02 100644 --- a/veejay-current/libvje/effects/scratcher.c +++ b/veejay-current/libvje/effects/scratcher.c @@ -30,11 +30,11 @@ static int nreverse = 0; vj_effect *scratcher_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->limits[0][1] = 1; @@ -55,28 +55,30 @@ vj_effect *scratcher_init(int w, int h) //FIXME private void scratcher_free() { - if(frame[0]) free(frame[0]); - if(frame[1]) free(frame[1]); - if(frame[2]) free(frame[2]); - + if(frame[0]) + free(frame[0]); + frame[0] = NULL; + frame[1] = NULL; + frame[2] = NULL; } int scratcher_malloc(int w, int h) { /* need memory for bounce mode ... */ frame[0] = - (uint8_t *) vj_malloc(w * h * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); + (uint8_t *) vj_malloc(w * h * 2 * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); if(!frame[0]) return 0; + memset( frame[0], pixel_Y_lo_, w * h * MAX_SCRATCH_FRAMES ); + frame[1] = - (uint8_t *) vj_malloc( ((w * h)/4) * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); - if(!frame[1]) return 0; - memset( frame[1], 128, ((w * h) / 4 ) * MAX_SCRATCH_FRAMES); + frame[0] + ( w * h * MAX_SCRATCH_FRAMES ); frame[2] = - (uint8_t *) vj_malloc( ((w * h)/4) * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); - if(!frame[2]) return 0; - memset( frame[2], 128, ((w * h)/4) * MAX_SCRATCH_FRAMES); - return 1; + frame[1] + ( ((w*h)/4) * MAX_SCRATCH_FRAMES ); + + memset( frame[1], 128, ((w * h)/4 ) * MAX_SCRATCH_FRAMES); + memset( frame[2], 128, ((w * h)/4) * MAX_SCRATCH_FRAMES); + return 1; } diff --git a/veejay-current/libvje/effects/sinoids.c b/veejay-current/libvje/effects/sinoids.c index 7b9ee950..dbdfb803 100644 --- a/veejay-current/libvje/effects/sinoids.c +++ b/veejay-current/libvje/effects/sinoids.c @@ -30,11 +30,11 @@ static uint8_t *sinoid_frame[3]; vj_effect *sinoids_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 1; ve->defaults[1] = 70; ve->limits[0][0] = 0; @@ -51,31 +51,33 @@ vj_effect *sinoids_init(int width, int height) int sinoids_malloc(int width, int height) { int i = 0; - sinoids_X = (int*) vj_malloc(sizeof(int) * width); + sinoids_X = (int*) vj_calloc(sizeof(int) * width); if(!sinoids_X) return 0; - sinoid_frame[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * height * width); - if(!sinoid_frame[0]) return 0; - sinoid_frame[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * height * width); - if(!sinoid_frame[1]) return 0; - sinoid_frame[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * height * width); - if(!sinoid_frame[2]) return 0; + sinoid_frame[0] = (uint8_t*)vj_calloc(sizeof(uint8_t) * 3 * height * width); + + if(!sinoid_frame[0]) return 0; + + sinoid_frame[1] = sinoid_frame[0] + (width * height); + sinoid_frame[2] = sinoid_frame[1] + (width * height); + + for(i=0; i < width; i++ ) { - //double si; - //fast_sin( si, ( ((double)i/(double)width)*2*3.1415926)); sinoids_X[i] = (int) ( sin( ((double)i/(double)width) * 2 * 3.1415926) * 1); - //sinoids_X[i] = (int) si; sinoids_X[i] *= 4; } + return 1; } void sinoids_free() { if(sinoids_X) free(sinoids_X); - if(sinoid_frame[0]) free(sinoid_frame[0]); - if(sinoid_frame[1]) free(sinoid_frame[1]); - if(sinoid_frame[2]) free(sinoid_frame[2]); + if(sinoid_frame[0]) + free(sinoid_frame[0]); + sinoid_frame[0] = NULL; + sinoid_frame[1] = NULL; + sinoid_frame[2] = NULL; } void sinoids_recalc(int width, int z) { diff --git a/veejay-current/libvje/effects/slice.c b/veejay-current/libvje/effects/slice.c index cdbd5437..d162c3c5 100644 --- a/veejay-current/libvje/effects/slice.c +++ b/veejay-current/libvje/effects/slice.c @@ -30,12 +30,12 @@ void slice_recalc(int width, int height, int val); vj_effect *slice_init(int width,int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; ve->limits[1][0] = 128; ve->limits[0][1] = 0; @@ -52,12 +52,11 @@ vj_effect *slice_init(int width,int height) int slice_malloc(int width, int height) { - slice_frame[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height); - if(!slice_frame[0]) return 0; - slice_frame[1] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height); - if(!slice_frame[1]) return 0; - slice_frame[2] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height); - if(!slice_frame[2]) return 0; + slice_frame[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height * 3); + if(!slice_frame[0]) + return 0; + slice_frame[1] = slice_frame[0] + (width * height); + slice_frame[2] = slice_frame[1] + (width * height); slice_xshift = (int*) vj_malloc(sizeof(int) * height); if(!slice_xshift) return 0; slice_yshift = (int*) vj_malloc(sizeof(int) * width); @@ -69,11 +68,17 @@ int slice_malloc(int width, int height) void slice_free() { - if(slice_frame[0]) free(slice_frame[0]); - if(slice_frame[1]) free(slice_frame[1]); - if(slice_frame[2]) free(slice_frame[2]); - if(slice_xshift) free(slice_xshift); - if(slice_yshift) free(slice_yshift); + if(slice_frame[0]) + free(slice_frame[0]); + slice_frame[0] = NULL; + slice_frame[1] = NULL; + slice_frame[2] = NULL; + if(slice_xshift) + free(slice_xshift); + if(slice_yshift) + free(slice_yshift); + slice_yshift = NULL; + slice_xshift = NULL; } /* much like the bathroom window, width height indicate block size within frame */ diff --git a/veejay-current/libvje/effects/smear.c b/veejay-current/libvje/effects/smear.c index 9b087c92..941f6e99 100644 --- a/veejay-current/libvje/effects/smear.c +++ b/veejay-current/libvje/effects/smear.c @@ -24,12 +24,12 @@ vj_effect *smear_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 3; ve->limits[0][1] = 0; diff --git a/veejay-current/libvje/effects/smuck.c b/veejay-current/libvje/effects/smuck.c index 43ca191c..94bb6edc 100644 --- a/veejay-current/libvje/effects/smuck.c +++ b/veejay-current/libvje/effects/smuck.c @@ -27,11 +27,11 @@ static int smuck_rand_val; vj_effect *smuck_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 1; ve->limits[0][0] = 0; ve->limits[1][0] = 14; diff --git a/veejay-current/libvje/effects/softblur.c b/veejay-current/libvje/effects/softblur.c index a21fc4de..e9fd4150 100644 --- a/veejay-current/libvje/effects/softblur.c +++ b/veejay-current/libvje/effects/softblur.c @@ -24,11 +24,11 @@ vj_effect *softblur_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; ve->limits[0][0] = 0; diff --git a/veejay-current/libvje/effects/solarize.c b/veejay-current/libvje/effects/solarize.c index b76facdc..973e4aec 100644 --- a/veejay-current/libvje/effects/solarize.c +++ b/veejay-current/libvje/effects/solarize.c @@ -22,11 +22,11 @@ #include vj_effect *solarize_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 16; ve->limits[0][0] = 1; /* threshold */ diff --git a/veejay-current/libvje/effects/split.c b/veejay-current/libvje/effects/split.c index 6e3dacfc..9ca90a1b 100644 --- a/veejay-current/libvje/effects/split.c +++ b/veejay-current/libvje/effects/split.c @@ -19,11 +19,11 @@ static uint8_t *split_fixme[3]; vj_effect *split_init(int width,int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 8; ve->defaults[1] = 1; @@ -41,11 +41,11 @@ vj_effect *split_init(int width,int height) } int split_malloc(int width, int height) { - split_fixme[0] = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height + 1); + split_fixme[0] = (uint8_t *) vj_calloc(sizeof(uint8_t) * width * height + 1); if(!split_fixme[0]) return 0; - split_fixme[1] = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height ); + split_fixme[1] = (uint8_t *) vj_calloc(sizeof(uint8_t) * width * height ); if(!split_fixme[1]) return 0; - split_fixme[2] = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height); + split_fixme[2] = (uint8_t *) vj_calloc(sizeof(uint8_t) * width * height); if(!split_fixme[2]) return 0; return 1; diff --git a/veejay-current/libvje/effects/swirl.c b/veejay-current/libvje/effects/swirl.c index 48e5a53d..fdcf099d 100644 --- a/veejay-current/libvje/effects/swirl.c +++ b/veejay-current/libvje/effects/swirl.c @@ -26,12 +26,12 @@ vj_effect *swirl_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = 360; ve->defaults[0] = 250; @@ -55,21 +55,18 @@ int swirl_malloc(int w, int h) int w2=w/2; int p = 0; - buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - if(!buf[0]) return -1; - buf[1] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - if(!buf[1]) return -1; + buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 3); + if(!buf[0]) return 0; + buf[1] = buf[0] + (w * h); + buf[2] = buf[1] + (w * h); + + polar_map = (double*) vj_calloc(sizeof(double) * w* h ); + if(!polar_map) return 0; + fish_angle = (double*) vj_calloc(sizeof(double) * w* h ); + if(!fish_angle) return 0; - buf[2] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h ); - if(!buf[2]) return -1; - - polar_map = (double*) vj_malloc(sizeof(double) * w* h ); - if(!polar_map) return -1; - fish_angle = (double*) vj_malloc(sizeof(double) * w* h ); - if(!fish_angle) return -1; - - cached_coords = (int*) vj_malloc(sizeof(int) * w * h ); - if(!cached_coords) return -1; + cached_coords = (int*) vj_calloc(sizeof(int) * w * h ); + if(!cached_coords) return 0; for(y=(-1 *h2); y < (h-h2); y++) { @@ -86,14 +83,15 @@ int swirl_malloc(int w, int h) void swirl_free() { - if(buf[0]) free(buf[0]); - if(buf[1]) free(buf[1]); - if(buf[2]) free(buf[2]); - - if(polar_map) free(polar_map); - if(fish_angle) free(fish_angle); - - + if(buf[0]) + free(buf[0]); + buf[1] = NULL; + buf[2] = NULL; + + if(polar_map) + free(polar_map); + if(fish_angle) + free(fish_angle); } diff --git a/veejay-current/libvje/effects/tracer.c b/veejay-current/libvje/effects/tracer.c index 6f060792..f2000408 100644 --- a/veejay-current/libvje/effects/tracer.c +++ b/veejay-current/libvje/effects/tracer.c @@ -26,11 +26,11 @@ static int trace_counter = 0; vj_effect *tracer_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->limits[0][1] = 1; @@ -46,19 +46,20 @@ vj_effect *tracer_init(int w, int h) int tracer_malloc(int w, int h) { - trace_buffer[0] = (uint8_t *) vj_malloc(w * h * sizeof(uint8_t)); - if(!trace_buffer[0]) return 0; - trace_buffer[1] = (uint8_t *) vj_malloc( ((w * h)) * sizeof(uint8_t)); - if(!trace_buffer[1]) return 0; - trace_buffer[2] = (uint8_t *) vj_malloc( ((w * h)) * sizeof(uint8_t)); - if(!trace_buffer[2]) return 0; - return 1; + trace_buffer[0] = (uint8_t *) vj_malloc(w * h * 3* sizeof(uint8_t)); + if(!trace_buffer[0]) return 0; + trace_buffer[1] = trace_buffer[0] + ( w * h ); + trace_buffer[2] = trace_buffer[1] + ( w * h ); + + return 1; } void tracer_free() { - if(trace_buffer[0]) free(trace_buffer[0]); - if(trace_buffer[1]) free(trace_buffer[1]); - if(trace_buffer[2]) free(trace_buffer[2]); + if(trace_buffer[0]) + free(trace_buffer[0]); + trace_buffer[0] = NULL; + trace_buffer[1] = NULL; + trace_buffer[2] = NULL; } void tracer_apply(VJFrame *frame, VJFrame *frame2, diff --git a/veejay-current/libvje/effects/transform.c b/veejay-current/libvje/effects/transform.c index 5cf6ee44..f360117e 100644 --- a/veejay-current/libvje/effects/transform.c +++ b/veejay-current/libvje/effects/transform.c @@ -24,11 +24,11 @@ vj_effect *transform_init(int width,int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 5; //ve->defaults[1] = 1; ve->limits[0][0] = 1; diff --git a/veejay-current/libvje/effects/tripplicity.c b/veejay-current/libvje/effects/tripplicity.c index 602c5d82..3ed3c419 100644 --- a/veejay-current/libvje/effects/tripplicity.c +++ b/veejay-current/libvje/effects/tripplicity.c @@ -26,11 +26,11 @@ #include "tripplicity.h" vj_effect *tripplicity_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; // opacity Y ve->limits[0][1] = 0; diff --git a/veejay-current/libvje/effects/uvcorrect.c b/veejay-current/libvje/effects/uvcorrect.c index 0e7f793b..0bc5688c 100644 --- a/veejay-current/libvje/effects/uvcorrect.c +++ b/veejay-current/libvje/effects/uvcorrect.c @@ -46,12 +46,12 @@ static uint8_t *chrominance; vj_effect *uvcorrect_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 7; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ //angle,r,g,b,cbc,crc ve->limits[0][0] = 1; @@ -83,7 +83,7 @@ vj_effect *uvcorrect_init(int w, int h) ve->has_help = 1; ve->has_user = 0; // FIXME: private - //chrominance = (uint8_t*) vj_malloc (sizeof(uint8_t) * 512 * 256 ); + //chrominance = (uint8_t*) vj_calloc (sizeof(uint8_t) * 512 * 256 ); return ve; } diff --git a/veejay-current/libvje/effects/videomask.c b/veejay-current/libvje/effects/videomask.c index 2d1b2a0a..0134dcb1 100644 --- a/veejay-current/libvje/effects/videomask.c +++ b/veejay-current/libvje/effects/videomask.c @@ -26,11 +26,11 @@ vj_effect *videomask_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 255; ve->defaults[0] = 150; /* threshold */ diff --git a/veejay-current/libvje/effects/videoplay.c b/veejay-current/libvje/effects/videoplay.c index 7610166f..e6196129 100644 --- a/veejay-current/libvje/effects/videoplay.c +++ b/veejay-current/libvje/effects/videoplay.c @@ -24,12 +24,12 @@ vj_effect *videoplay_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 2; // divider ve->limits[1][0] = max_power(w); ve->limits[0][1] = 1; @@ -57,7 +57,7 @@ static int prepare_filmstrip(int film_length, int w, int h) int picture_width = w / sqrt(film_length); int picture_height = h / sqrt(film_length); - video_list = (picture_t**) vj_malloc(sizeof(picture_t*) * (film_length + 1) ); + video_list = (picture_t**) vj_calloc(sizeof(picture_t*) * (film_length + 1) ); if(!video_list) return 0; @@ -68,14 +68,14 @@ static int prepare_filmstrip(int film_length, int w, int h) for ( i = 0; i < num_videos; i ++ ) { - video_list[i] = vj_malloc(sizeof(picture_t)); + video_list[i] = vj_calloc(sizeof(picture_t)); if(!video_list[i]) return 0; video_list[i]->w = picture_width; video_list[i]->h = picture_height; for( j = 0; j < 3; j ++ ) { - video_list[i]->data[j] = vj_malloc(sizeof(uint8_t) * picture_width * picture_height ); + video_list[i]->data[j] = vj_calloc(sizeof(uint8_t) * picture_width * picture_height ); if(!video_list[i]->data[j]) return 0; memset(video_list[i]->data[j], (j==0 ? pixel_Y_lo_ : 128), picture_width *picture_height ); diff --git a/veejay-current/libvje/effects/videowall.c b/veejay-current/libvje/effects/videowall.c index 18ca503c..f9d8764b 100644 --- a/veejay-current/libvje/effects/videowall.c +++ b/veejay-current/libvje/effects/videowall.c @@ -29,12 +29,12 @@ static inline int n_pics(int w, int h) vj_effect *videowall_init(int w, int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 0; // selector ve->limits[1][0] = n_pics(w,h); ve->limits[0][1] = 0; @@ -71,8 +71,7 @@ static int prepare_filmstrip(int w, int h) int picture_height = gcd(w,h); int film_length = n_pics(w,h); - photo_list = (picture_t**) vj_malloc(sizeof(picture_t*) * film_length ); - memset( photo_list, 0, sizeof(picture_t*) * film_length ); + photo_list = (picture_t**) vj_calloc(sizeof(picture_t*) * film_length ); if(!photo_list) return 0; @@ -83,34 +82,27 @@ static int prepare_filmstrip(int w, int h) for ( i = 0; i < num_photos; i ++ ) { - photo_list[i] = vj_malloc(sizeof(picture_t)); - memset( photo_list[i], 0, sizeof(picture_t)); + photo_list[i] = vj_calloc(sizeof(picture_t)); if(!photo_list[i]) return 0; photo_list[i]->w = picture_width; photo_list[i]->h = picture_height; for( j = 0; j < 3; j ++ ) { - photo_list[i]->data[j] = vj_malloc(sizeof(uint8_t) * picture_width * picture_height ); + photo_list[i]->data[j] = vj_calloc(sizeof(uint8_t) * picture_width * picture_height ); if(!photo_list[i]->data[j]) return 0; - memset(photo_list[i]->data[j], (j==0 ? inc : 128), picture_width *picture_height ); } val+= inc; } frame_counter = 0; - offset_table_x = (int*) vj_malloc(sizeof(int) * film_length); + offset_table_x = (int*) vj_calloc(sizeof(int) * film_length); if(!offset_table_x) return 0; - offset_table_y = (int*) vj_malloc(sizeof(int) * film_length); + offset_table_y = (int*) vj_calloc(sizeof(int) * film_length); if(!offset_table_y) return 0; - for( i =0 ; i < film_length; i ++) - { - offset_table_x[i] = 0; - offset_table_y[i] = 0; - } return 1; } diff --git a/veejay-current/libvje/effects/water.c b/veejay-current/libvje/effects/water.c index 963dcecf..298265f0 100644 --- a/veejay-current/libvje/effects/water.c +++ b/veejay-current/libvje/effects/water.c @@ -76,11 +76,11 @@ static void setTable() vj_effect *water_init(int width, int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->limits[0][0] = 1; ve->limits[1][0] = 3600; ve->limits[0][1] = 1; @@ -104,20 +104,16 @@ int water_malloc(int width, int height) if(!ripple_data[0]) return 0; memset( ripple_data[0], pixel_Y_lo_, width*height); - map_h = height / 2 + 1; map_w = width / 2 + 1; - map = (int*) vj_malloc (sizeof(int) * map_h * map_w * 3); + map = (int*) vj_calloc (sizeof(int) * map_h * map_w * 3); if(!map) return 0; - vtable = (signed char*) vj_malloc( sizeof(signed char) * map_w * map_h * 2); + vtable = (signed char*) vj_calloc( sizeof(signed char) * map_w * map_h * 2); if(!vtable) return 0; map3 = map + map_w * map_h * 2; setTable(); - memset(map, 0, map_h*map_w*3*sizeof(int)); - memset(vtable, 0, map_h*map_w*2*sizeof(signed char)); map1 = map; map2 = map + map_h*map_w; - stat = 1; return 1; diff --git a/veejay-current/libvje/effects/whiteframe.c b/veejay-current/libvje/effects/whiteframe.c index 76c204f9..85270cb9 100644 --- a/veejay-current/libvje/effects/whiteframe.c +++ b/veejay-current/libvje/effects/whiteframe.c @@ -23,7 +23,7 @@ vj_effect *whiteframe_init(int w,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 0; ve->defaults = NULL; /* default values */ ve->limits[0] = NULL; /* min */ diff --git a/veejay-current/libvje/effects/widthmirror.c b/veejay-current/libvje/effects/widthmirror.c index 5ae94b68..d02ed929 100644 --- a/veejay-current/libvje/effects/widthmirror.c +++ b/veejay-current/libvje/effects/widthmirror.c @@ -23,11 +23,11 @@ #include vj_effect *widthmirror_init(int max_width,int h) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 1; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 2; ve->limits[0][0] = 2; diff --git a/veejay-current/libvje/effects/zoom.c b/veejay-current/libvje/effects/zoom.c index 4854753e..1290c4bb 100644 --- a/veejay-current/libvje/effects/zoom.c +++ b/veejay-current/libvje/effects/zoom.c @@ -28,11 +28,11 @@ static uint8_t *zoom_buffer[3]; vj_effect *zoom_init(int width , int height) { - vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 3; - ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 0; ve->defaults[1] = 0; ve->defaults[2] = 1; diff --git a/veejay-current/libvje/transitions/3bar.c b/veejay-current/libvje/transitions/3bar.c index 06e41cbc..fdb5f0f2 100644 --- a/veejay-current/libvje/transitions/3bar.c +++ b/veejay-current/libvje/transitions/3bar.c @@ -22,11 +22,11 @@ vj_effect *bar_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 5; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *)vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 4; ve->defaults[1] = 1; ve->defaults[2] = 3; diff --git a/veejay-current/libvje/transitions/fadecolor.c b/veejay-current/libvje/transitions/fadecolor.c index 27846b67..9832d494 100644 --- a/veejay-current/libvje/transitions/fadecolor.c +++ b/veejay-current/libvje/transitions/fadecolor.c @@ -24,11 +24,11 @@ vj_effect *fadecolor_init(int w,int h) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 255; ve->defaults[1] = VJ_EFFECT_COLOR_BLACK; ve->defaults[2] = 15; diff --git a/veejay-current/libvje/transitions/fadecolorrgb.c b/veejay-current/libvje/transitions/fadecolorrgb.c index 2ee16eca..4874152d 100644 --- a/veejay-current/libvje/transitions/fadecolorrgb.c +++ b/veejay-current/libvje/transitions/fadecolorrgb.c @@ -23,11 +23,11 @@ vj_effect *fadecolorrgb_init(int w,int h) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 6; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 150; ve->defaults[1] = 0; ve->defaults[2] = 0; diff --git a/veejay-current/libvje/transitions/slidingdoor.c b/veejay-current/libvje/transitions/slidingdoor.c index 59e78566..1171a8a4 100644 --- a/veejay-current/libvje/transitions/slidingdoor.c +++ b/veejay-current/libvje/transitions/slidingdoor.c @@ -24,11 +24,11 @@ vj_effect *slidingdoor_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 0; - ve->defaults = (int *) malloc(sizeof(int) * 1); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * 1); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * 1); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * 1); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * 1); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * 1); /* max */ /* ve->defaults[0] = 1; ve->defaults[1] = 1; diff --git a/veejay-current/libvje/transitions/transblend.c b/veejay-current/libvje/transitions/transblend.c index d84c1a1b..46b9a4cd 100644 --- a/veejay-current/libvje/transitions/transblend.c +++ b/veejay-current/libvje/transitions/transblend.c @@ -24,11 +24,11 @@ vj_effect *transblend_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 7; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 1; ve->defaults[1] = 50; ve->defaults[2] = 50; diff --git a/veejay-current/libvje/transitions/transcarot.c b/veejay-current/libvje/transitions/transcarot.c index f9242544..e27d94fa 100644 --- a/veejay-current/libvje/transitions/transcarot.c +++ b/veejay-current/libvje/transitions/transcarot.c @@ -24,11 +24,11 @@ vj_effect *transcarot_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 6; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 180; /* opacity */ ve->defaults[1] = 0; /* type */ ve->defaults[2] = 100; /* point sizse */ diff --git a/veejay-current/libvje/transitions/transline.c b/veejay-current/libvje/transitions/transline.c index 31faaf73..a4f48d7c 100644 --- a/veejay-current/libvje/transitions/transline.c +++ b/veejay-current/libvje/transitions/transline.c @@ -23,12 +23,12 @@ vj_effect *transline_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); memset(ve,0,sizeof(vj_effect)); ve->num_params = 4; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 150; /* opacity */ ve->defaults[1] = 10; /* line width */ ve->defaults[2] = 3; /* distance */ diff --git a/veejay-current/libvje/transitions/transop.c b/veejay-current/libvje/transitions/transop.c index 06581918..ca4dd538 100644 --- a/veejay-current/libvje/transitions/transop.c +++ b/veejay-current/libvje/transitions/transop.c @@ -24,11 +24,11 @@ vj_effect *transop_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 7; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 150; /* opacity */ ve->defaults[1] = 265; /* width of view port */ ve->defaults[2] = 194; /* height of viewport */ diff --git a/veejay-current/libvje/transitions/vbar.c b/veejay-current/libvje/transitions/vbar.c index 1253810b..da1f3837 100644 --- a/veejay-current/libvje/transitions/vbar.c +++ b/veejay-current/libvje/transitions/vbar.c @@ -21,11 +21,11 @@ vj_effect *vbar_init(int width, int height) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 5; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); /* default values */ - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); /* min */ - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); /* max */ + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */ + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */ + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */ ve->defaults[0] = 4; ve->defaults[1] = 1; ve->defaults[2] = 3; diff --git a/veejay-current/libvje/transitions/wipe.c b/veejay-current/libvje/transitions/wipe.c index 68fffed1..0d4bd1c9 100644 --- a/veejay-current/libvje/transitions/wipe.c +++ b/veejay-current/libvje/transitions/wipe.c @@ -24,11 +24,11 @@ vj_effect *wipe_init(int w,int h) { - vj_effect *ve = (vj_effect *) malloc(sizeof(vj_effect)); + vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect)); ve->num_params = 2; - ve->defaults = (int *) malloc(sizeof(int) * ve->num_params); - ve->limits[0] = (int *) malloc(sizeof(int) * ve->num_params); - ve->limits[1] = (int *) malloc(sizeof(int) * ve->num_params); + ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); + ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); ve->defaults[0] = 150; ve->defaults[1] = 0;