Index: source/blender/nodes/intern/CMP_nodes/CMP_blur.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/nodes/intern/CMP_nodes/CMP_blur.c,v retrieving revision 1.6 diff -u -p -r1.6 CMP_blur.c --- source/blender/nodes/intern/CMP_nodes/CMP_blur.c 4 Apr 2007 13:58:09 -0000 1.6 +++ source/blender/nodes/intern/CMP_nodes/CMP_blur.c 17 Apr 2007 13:55:15 -0000 @@ -83,7 +83,7 @@ static float *make_bloomtab(int rad) } /* both input images of same type, either 4 or 1 channel */ -static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float scale) +static int blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float scale) { NodeBlurData *nbd= node->storage; CompBuf *work; @@ -92,9 +92,11 @@ static void blur_single_image(bNode *nod float *gausstab, *gausstabcent; int rad, imgx= img->x, imgy= img->y; int x, y, pix= img->type; - int i, bigstep; + int i, bigstep, ret; float *src, *dest; + ret= 0; + /* helper image */ work= alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */ @@ -138,8 +140,10 @@ static void blur_single_image(bNode *nod *dest++ = aval*sum; } } - if(node->exec & NODE_BREAK) + if(node->exec & NODE_BREAK) { + ret= 1; break; + } } /* vertical */ @@ -187,12 +191,15 @@ static void blur_single_image(bNode *nod } dest+= bigstep; } - if(node->exec & NODE_BREAK) + if(node->exec & NODE_BREAK) { + ret= 1; break; + } } free_compbuf(work); MEM_freeN(gausstab); + return(ret); } /* reference has to be mapped 0-1, and equal in size */ @@ -332,7 +339,7 @@ static float hexagon_filter(float fi, fl /* uses full filter, no horizontal/vertical optimize possible */ /* both images same type, either 1 or 4 channels */ -static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fac) +static int bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fac) { NodeBlurData *nbd= node->storage; register float val; @@ -340,8 +347,10 @@ static void bokeh_single_image(bNode *no float *gausstab, *dgauss; int radx, rady, imgx= img->x, imgy= img->y; int x, y, pix= img->type; - int i, j, n; + int i, j, n, ret; float *src= NULL, *dest, *srcd= NULL; + + ret= 0; /* horizontal */ radxf = fac*(float)nbd->sizex; @@ -421,16 +430,19 @@ static void bokeh_single_image(bNode *no } } } - if(node->exec & NODE_BREAK) + if(node->exec & NODE_BREAK) { + ret= 1; break; + } } MEM_freeN(gausstab); + return(ret); } /* reference has to be mapped 0-1, and equal in size */ -static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf *ref) +static int blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf *ref) { NodeBlurData *nbd= node->storage; CompBuf *blurbuf, *ref_use; @@ -441,11 +453,13 @@ static void blur_with_reference(bNode *n float *gausstaby, *gausstabcentx; int radx, rady, imgx= img->x, imgy= img->y; int x, y, pix= img->type; - int i, j; + int i, j, ret; float *src, *dest, *refd, *blurd; + ret= 0; + if(ref->x!=img->x && ref->y!=img->y) - return; + return(ret); ref_use= typecheck_compbuf(ref, CB_VAL); @@ -459,7 +473,7 @@ static void blur_with_reference(bNode *n else blurd[0]= refd[0]; } - blur_single_image(node, blurbuf, blurbuf, 1.0f); + ret= blur_single_image(node, blurbuf, blurbuf, 1.0f); /* horizontal */ radx = (float)nbd->sizex; @@ -540,8 +554,10 @@ static void blur_with_reference(bNode *n } } } - if(node->exec & NODE_BREAK) + if(node->exec & NODE_BREAK) { + ret= 1; break; + } } free_compbuf(blurbuf); @@ -553,6 +569,7 @@ static void blur_with_reference(bNode *n if(ref_use!=ref) free_compbuf(ref_use); + return(ret); } @@ -560,6 +577,7 @@ static void blur_with_reference(bNode *n static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { CompBuf *new, *img= in[0]->data; + int val; if(img==NULL || out[0]->hasoutput==0) return; @@ -567,6 +585,8 @@ static void node_composit_exec_blur(void if(img->type==CB_VEC2 || img->type==CB_VEC3) { img= typecheck_compbuf(in[0]->data, CB_RGBA); } + + val= 0; /* if fac input, we do it different */ if(in[1]->data) { @@ -578,8 +598,11 @@ static void node_composit_exec_blur(void new->xof = img->xof; new->yof = img->yof; - blur_with_reference(node, new, img, in[1]->data); - + val= blur_with_reference(node, new, img, in[1]->data); + if(val) { + free_compbuf(new); + new= NULL; + } out[0]->data= new; } else { @@ -605,9 +628,9 @@ static void node_composit_exec_blur(void else gammabuf= img; if(nbd->bokeh) - bokeh_single_image(node, new, gammabuf, in[1]->vec[0]); + val= bokeh_single_image(node, new, gammabuf, in[1]->vec[0]); else if(1) - blur_single_image(node, new, gammabuf, in[1]->vec[0]); + val= blur_single_image(node, new, gammabuf, in[1]->vec[0]); else /* bloom experimental... */ bloom_with_reference(new, gammabuf, NULL, in[1]->vec[0], nbd); @@ -615,6 +638,10 @@ static void node_composit_exec_blur(void gamma_correct_compbuf(new, 1); free_compbuf(gammabuf); } + } + if(val) { + free_compbuf(new); + new= NULL; } out[0]->data= new; } Index: source/blender/nodes/intern/CMP_nodes/CMP_defocus.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c,v retrieving revision 1.5 diff -u -p -r1.5 CMP_defocus.c --- source/blender/nodes/intern/CMP_nodes/CMP_defocus.c 4 Apr 2007 13:58:09 -0000 1.5 +++ source/blender/nodes/intern/CMP_nodes/CMP_defocus.c 17 Apr 2007 13:55:16 -0000 @@ -234,7 +234,7 @@ static void IIR_gauss(CompBuf* buf, floa #undef YVV } -static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, float inpval) +static int defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, float inpval) { NodeDefocus *nqd = node->storage; CompBuf *wts; // weights buffer @@ -245,10 +245,12 @@ static void defocus_blur(bNode *node, Co float *ctcol, u, v, iZ, ct_crad, bcrad, lwt, wt=0, cR2=0; float dof_sp, maxfgc, nmaxc, scf, bk_hn_theta=0, inradsq=0; float cam_fdist=1, cam_invfdist=1, cam_lens=35; - int x, y, sx, sy, len_bkh=0; + int x, y, sx, sy, len_bkh=0, val; float aspect, aperture; int minsz; + val= 0; + // get some required params from the current scene camera // (ton) this is wrong, needs fixed Object* camob = G.scene->camera; @@ -346,8 +348,10 @@ static void defocus_blur(bNode *node, Co wts->rect[px] = 0.f; } // esc set by main calling process - if(node->exec & NODE_BREAK) + if(node->exec & NODE_BREAK) { + val= 1; break; + } } } @@ -361,8 +365,10 @@ static void defocus_blur(bNode *node, Co fflush(stdout); } // esc set by main calling process - if(node->exec & NODE_BREAK) + if(node->exec & NODE_BREAK) { + val= 1; break; + } zp = y * img->x; for (x=0; xx; x++) { @@ -746,6 +752,7 @@ static void defocus_blur(bNode *node, Co free_compbuf(wts); printf("Done\n"); + return(val); } @@ -753,6 +760,7 @@ static void node_composit_exec_defocus(v { CompBuf *new, *old, *zbuf_use = NULL, *img = in[0]->data, *zbuf = in[1]->data; NodeDefocus *nqd = node->storage; + int val; if ((img==NULL) || (out[0]->hasoutput==0)) return; @@ -785,11 +793,16 @@ static void node_composit_exec_defocus(v } new = alloc_compbuf(old->x, old->y, old->type, 1); - defocus_blur(node, new, old, zbuf_use, in[1]->vec[0]*nqd->scale); - + val= defocus_blur(node, new, old, zbuf_use, in[1]->vec[0]*nqd->scale); + if (nqd->gamco) { gamma_correct_compbuf(new, 1); free_compbuf(old); + } + + if(val) { + free_compbuf(new); + new= NULL; } out[0]->data = new;