diff options
Diffstat (limited to 'source/blender/nodes/intern/CMP_util.c')
-rw-r--r-- | source/blender/nodes/intern/CMP_util.c | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/source/blender/nodes/intern/CMP_util.c b/source/blender/nodes/intern/CMP_util.c index bcb038bccc3..28497b98197 100644 --- a/source/blender/nodes/intern/CMP_util.c +++ b/source/blender/nodes/intern/CMP_util.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -62,7 +62,7 @@ CompBuf *dupalloc_compbuf(CompBuf *cbuf) { CompBuf *dupbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); if(dupbuf) { - memcpy(dupbuf->rect, cbuf->rect, cbuf->type*sizeof(float)*cbuf->x*cbuf->y); + memmove(dupbuf->rect, cbuf->rect, cbuf->type*sizeof(float)*cbuf->x*cbuf->y); dupbuf->xof= cbuf->xof; dupbuf->yof= cbuf->yof; @@ -414,12 +414,12 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) return inbuf; } -float *compbuf_get_pixel(CompBuf *cbuf, float *rectf, int x, int y, int xrad, int yrad) +static float *compbuf_get_pixel(CompBuf *cbuf, float *defcol, float *use, int x, int y, int xrad, int yrad) { if(cbuf) { if(cbuf->rect_procedural) { - cbuf->rect_procedural(cbuf, rectf, (float)x/(float)xrad, (float)y/(float)yrad); - return rectf; + cbuf->rect_procedural(cbuf, use, (float)x/(float)xrad, (float)y/(float)yrad); + return use; } else { static float col[4]= {0.0f, 0.0f, 0.0f, 0.0f}; @@ -434,7 +434,7 @@ float *compbuf_get_pixel(CompBuf *cbuf, float *rectf, int x, int y, int xrad, in return cbuf->rect + cbuf->type*( (cbuf->yrad+y)*cbuf->x + (cbuf->xrad+x) ); } } - else return rectf; + else return defcol; } /* **************************************************** */ @@ -446,6 +446,7 @@ void composit1_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, floa { CompBuf *src_use; float *outfp=out->rect, *srcfp; + float color[4]; /* local color if compbuf is procedural */ int xrad, yrad, x, y; src_use= typecheck_compbuf(src_buf, src_type); @@ -455,7 +456,7 @@ void composit1_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, floa for(y= -yrad; y<-yrad+out->y; y++) { for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { - srcfp= compbuf_get_pixel(src_use, src_col, x, y, xrad, yrad); + srcfp= compbuf_get_pixel(src_use, src_col, color, x, y, xrad, yrad); func(node, outfp, srcfp); } } @@ -471,6 +472,7 @@ void composit2_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, floa { CompBuf *src_use, *fac_use; float *outfp=out->rect, *srcfp, *facfp; + float color[4]; /* local color if compbuf is procedural */ int xrad, yrad, x, y; src_use= typecheck_compbuf(src_buf, src_type); @@ -481,8 +483,8 @@ void composit2_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, floa for(y= -yrad; y<-yrad+out->y; y++) { for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { - srcfp= compbuf_get_pixel(src_use, src_col, x, y, xrad, yrad); - facfp= compbuf_get_pixel(fac_use, fac, x, y, xrad, yrad); + srcfp= compbuf_get_pixel(src_use, src_col, color, x, y, xrad, yrad); + facfp= compbuf_get_pixel(fac_use, fac, color, x, y, xrad, yrad); func(node, outfp, srcfp, facfp); } @@ -500,6 +502,7 @@ void composit3_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo { CompBuf *src1_use, *src2_use, *fac_use; float *outfp=out->rect, *src1fp, *src2fp, *facfp; + float color[4]; /* local color if compbuf is procedural */ int xrad, yrad, x, y; src1_use= typecheck_compbuf(src1_buf, src1_type); @@ -511,9 +514,9 @@ void composit3_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo for(y= -yrad; y<-yrad+out->y; y++) { for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { - src1fp= compbuf_get_pixel(src1_use, src1_col, x, y, xrad, yrad); - src2fp= compbuf_get_pixel(src2_use, src2_col, x, y, xrad, yrad); - facfp= compbuf_get_pixel(fac_use, fac, x, y, xrad, yrad); + src1fp= compbuf_get_pixel(src1_use, src1_col, color, x, y, xrad, yrad); + src2fp= compbuf_get_pixel(src2_use, src2_col, color, x, y, xrad, yrad); + facfp= compbuf_get_pixel(fac_use, fac, color, x, y, xrad, yrad); func(node, outfp, src1fp, src2fp, facfp); } @@ -535,6 +538,7 @@ void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo { CompBuf *src1_use, *src2_use, *fac1_use, *fac2_use; float *outfp=out->rect, *src1fp, *src2fp, *fac1fp, *fac2fp; + float color[4]; /* local color if compbuf is procedural */ int xrad, yrad, x, y; src1_use= typecheck_compbuf(src1_buf, src1_type); @@ -547,10 +551,10 @@ void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo for(y= -yrad; y<-yrad+out->y; y++) { for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { - src1fp= compbuf_get_pixel(src1_use, src1_col, x, y, xrad, yrad); - src2fp= compbuf_get_pixel(src2_use, src2_col, x, y, xrad, yrad); - fac1fp= compbuf_get_pixel(fac1_use, fac1, x, y, xrad, yrad); - fac2fp= compbuf_get_pixel(fac2_use, fac2, x, y, xrad, yrad); + src1fp= compbuf_get_pixel(src1_use, src1_col, color, x, y, xrad, yrad); + src2fp= compbuf_get_pixel(src2_use, src2_col, color, x, y, xrad, yrad); + fac1fp= compbuf_get_pixel(fac1_use, fac1, color, x, y, xrad, yrad); + fac2fp= compbuf_get_pixel(fac2_use, fac2, color, x, y, xrad, yrad); func(node, outfp, src1fp, fac1fp, src2fp, fac2fp); } @@ -662,59 +666,59 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) } } -void do_rgba_to_yuva(bNode *node, float *out, float *in) +void do_rgba_to_yuva(bNode *UNUSED(node), float *out, float *in) { rgb_to_yuv(in[0],in[1],in[2], &out[0], &out[1], &out[2]); out[3]=in[3]; } -void do_rgba_to_hsva(bNode *node, float *out, float *in) +void do_rgba_to_hsva(bNode *UNUSED(node), float *out, float *in) { rgb_to_hsv(in[0],in[1],in[2], &out[0], &out[1], &out[2]); out[3]=in[3]; } -void do_rgba_to_ycca(bNode *node, float *out, float *in) +void do_rgba_to_ycca(bNode *UNUSED(node), float *out, float *in) { rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); out[3]=in[3]; } -void do_yuva_to_rgba(bNode *node, float *out, float *in) +void do_yuva_to_rgba(bNode *UNUSED(node), float *out, float *in) { yuv_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2]); out[3]=in[3]; } -void do_hsva_to_rgba(bNode *node, float *out, float *in) +void do_hsva_to_rgba(bNode *UNUSED(node), float *out, float *in) { hsv_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2]); out[3]=in[3]; } -void do_ycca_to_rgba(bNode *node, float *out, float *in) +void do_ycca_to_rgba(bNode *UNUSED(node), float *out, float *in) { ycc_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); out[3]=in[3]; } -void do_copy_rgba(bNode *node, float *out, float *in) +void do_copy_rgba(bNode *UNUSED(node), float *out, float *in) { QUATCOPY(out, in); } -void do_copy_rgb(bNode *node, float *out, float *in) +void do_copy_rgb(bNode *UNUSED(node), float *out, float *in) { VECCOPY(out, in); out[3]= 1.0f; } -void do_copy_value(bNode *node, float *out, float *in) +void do_copy_value(bNode *UNUSED(node), float *out, float *in) { out[0]= in[0]; } -void do_copy_a_rgba(bNode *node, float *out, float *in, float *fac) +void do_copy_a_rgba(bNode *UNUSED(node), float *out, float *in, float *fac) { VECCOPY(out, in); out[3]= *fac; @@ -1303,7 +1307,7 @@ CompBuf* qd_downScaledCopy(CompBuf* src, int scale) void IIR_gauss(CompBuf* src, float sigma, int chan, int xy) { double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3]; - float *X, *Y, *W; + double *X, *Y, *W; int i, x, y, sz; // <0.5 not valid, though can have a possibly useful sort of sharpening effect @@ -1367,9 +1371,9 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy) // intermediate buffers sz = MAX2(src->x, src->y); - X = MEM_callocN(sz*sizeof(float), "IIR_gauss X buf"); - Y = MEM_callocN(sz*sizeof(float), "IIR_gauss Y buf"); - W = MEM_callocN(sz*sizeof(float), "IIR_gauss W buf"); + X = MEM_callocN(sz*sizeof(double), "IIR_gauss X buf"); + Y = MEM_callocN(sz*sizeof(double), "IIR_gauss Y buf"); + W = MEM_callocN(sz*sizeof(double), "IIR_gauss W buf"); if (xy & 1) { // H for (y=0; y<src->y; ++y) { const int yx = y*src->x; |