Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-15 13:58:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-15 13:58:52 +0400
commitec755bdfa7920c9db4dd771c065e85539b00d140 (patch)
treefc05b551bd397aae04c478a5fcb6ea7c0be05b2e /source/blender/nodes
parent3264db37972877184ead9785181722e5cf65f164 (diff)
style cleanup: composite/blur
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.c146
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_blur.c622
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehblur.c20
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_directionalblur.c74
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_vecBlur.c48
5 files changed, 455 insertions, 455 deletions
diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
index 196234d658f..62e8138f5e1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
@@ -32,71 +32,71 @@
#include "node_composite_util.h"
/* **************** BILATERALBLUR ******************** */
-static bNodeSocketTemplate cmp_node_bilateralblur_in[]= {
+static bNodeSocketTemplate cmp_node_bilateralblur_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_bilateralblur_out[]= {
+static bNodeSocketTemplate cmp_node_bilateralblur_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
#define INIT_C3 \
- mean0 = 1; \
- mean1[0] = src[0]; \
- mean1[1] = src[1]; \
- mean1[2] = src[2]; \
- mean1[3] = src[3]; \
- (void)0
+ mean0 = 1; \
+ mean1[0] = src[0]; \
+ mean1[1] = src[1]; \
+ mean1[2] = src[2]; \
+ mean1[3] = src[3]; \
+ (void)0
/* finds color distances */
#define COLOR_DISTANCE_C3(c1, c2) \
- ((c1[0] - c2[0])*(c1[0] - c2[0]) + \
- (c1[1] - c2[1])*(c1[1] - c2[1]) + \
- (c1[2] - c2[2])*(c1[2] - c2[2]) + \
- (c1[3] - c2[3])*(c1[3] - c2[3]))
+ ((c1[0] - c2[0]) * (c1[0] - c2[0]) + \
+ (c1[1] - c2[1]) * (c1[1] - c2[1]) + \
+ (c1[2] - c2[2]) * (c1[2] - c2[2]) + \
+ (c1[3] - c2[3]) * (c1[3] - c2[3]))
/* this is the main kernel function for comparing color distances
- and adding them weighted to the final color */
+ and adding them weighted to the final color */
#define KERNEL_ELEMENT_C3(k) \
- temp_color = src + deltas[k]; \
- ref_color = ref + deltas[k]; \
- w = weight_tab[k] + \
- (double)COLOR_DISTANCE_C3(ref, ref_color ) * i2sigma_color; \
- w = 1.0/(w*w + 1); \
- mean0 += w; \
- mean1[0] += (double)temp_color[0] * w; \
- mean1[1] += (double)temp_color[1] * w; \
- mean1[2] += (double)temp_color[2] * w; \
- mean1[3] += (double)temp_color[3] * w; \
- (void)0
+ temp_color = src + deltas[k]; \
+ ref_color = ref + deltas[k]; \
+ w = weight_tab[k] + \
+ (double)COLOR_DISTANCE_C3(ref, ref_color) * i2sigma_color; \
+ w = 1.0 / (w * w + 1); \
+ mean0 += w; \
+ mean1[0] += (double)temp_color[0] * w; \
+ mean1[1] += (double)temp_color[1] * w; \
+ mean1[2] += (double)temp_color[2] * w; \
+ mean1[3] += (double)temp_color[3] * w; \
+ (void)0
/* write blurred values to image */
#define UPDATE_OUTPUT_C3 \
- mean0 = 1.0/mean0; \
- dest[x * pix + 0] = mean1[0] * mean0; \
- dest[x * pix + 1] = mean1[1] * mean0; \
- dest[x * pix + 2] = mean1[2] * mean0; \
- dest[x * pix + 3] = mean1[3] * mean0; \
- (void)0
+ mean0 = 1.0 / mean0; \
+ dest[x * pix + 0] = mean1[0] * mean0; \
+ dest[x * pix + 1] = mean1[1] * mean0; \
+ dest[x * pix + 2] = mean1[2] * mean0; \
+ dest[x * pix + 3] = mean1[3] * mean0; \
+ (void)0
/* initializes deltas for fast access to neighbor pixels */
-#define INIT_3X3_DELTAS( deltas, step, nch ) \
- ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
- (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
- (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
- (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); \
- (void)0
+#define INIT_3X3_DELTAS(deltas, step, nch) \
+ ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
+ (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
+ (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
+ (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); \
+ (void)0
/* code of this node was heavily inspired by the smooth function of opencv library.
* The main change is an optional image input */
static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeBilateralBlurData *nbbd= node->storage;
- CompBuf *new, *source, *img= in[0]->data, *refimg= in[1]->data;
+ NodeBilateralBlurData *nbbd = node->storage;
+ CompBuf *new, *source, *img = in[0]->data, *refimg = in[1]->data;
double mean0, w, i2sigma_color, i2sigma_space;
double mean1[4];
double weight_tab[8];
@@ -104,46 +104,46 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
float sigma_color, sigma_space;
int imgx, imgy, x, y, pix, i, step;
int deltas[8];
- short found_determinator= 0;
+ short found_determinator = 0;
if (img == NULL || out[0]->hasoutput == 0)
return;
if (img->type != CB_RGBA) {
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
}
- imgx= img->x;
- imgy= img->y;
- pix= img->type;
- step= pix * imgx;
+ imgx = img->x;
+ imgy = img->y;
+ pix = img->type;
+ step = pix * imgx;
if (refimg) {
if (refimg->x == imgx && refimg->y == imgy) {
if (ELEM3(refimg->type, CB_VAL, CB_VEC2, CB_VEC3)) {
- refimg= typecheck_compbuf(in[1]->data, CB_RGBA);
- found_determinator= 1;
+ refimg = typecheck_compbuf(in[1]->data, CB_RGBA);
+ found_determinator = 1;
}
}
}
else {
- refimg= img;
+ refimg = img;
}
/* allocs */
- source= dupalloc_compbuf(img);
- new= alloc_compbuf(imgx, imgy, pix, 1);
+ source = dupalloc_compbuf(img);
+ new = alloc_compbuf(imgx, imgy, pix, 1);
/* accept image offsets from other nodes */
- new->xof= img->xof;
- new->yof= img->yof;
+ new->xof = img->xof;
+ new->yof = img->yof;
/* bilateral code properties */
- sigma_color= nbbd->sigma_color;
- sigma_space= nbbd->sigma_space;
+ sigma_color = nbbd->sigma_color;
+ sigma_space = nbbd->sigma_space;
- i2sigma_color= 1.0f / (sigma_color * sigma_color);
- i2sigma_space= 1.0f / (sigma_space * sigma_space);
+ i2sigma_color = 1.0f / (sigma_color * sigma_color);
+ i2sigma_space = 1.0f / (sigma_space * sigma_space);
INIT_3X3_DELTAS(deltas, step, pix);
@@ -151,13 +151,13 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
weight_tab[1] = weight_tab[3] = weight_tab[5] = weight_tab[7] = i2sigma_space * 2;
/* iterations */
- for (i= 0; i < nbbd->iter; i++) {
- src= source->rect;
- ref= refimg->rect;
- dest= new->rect;
+ for (i = 0; i < nbbd->iter; i++) {
+ src = source->rect;
+ ref = refimg->rect;
+ dest = new->rect;
/*goes through image, there are more loops for 1st/last line and all other lines*/
/*kernel element accumulates surrounding colors, which are then written with the update_output function*/
- for (x= 0; x < imgx; x++, src+= pix, ref+= pix) {
+ for (x = 0; x < imgx; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(6);
@@ -175,10 +175,10 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
}
- dest+= step;
+ dest += step;
- for (y= 1; y < imgy - 1; y++, dest+= step, src+= pix, ref+= pix) {
- x= 0;
+ for (y = 1; y < imgy - 1; y++, dest += step, src += pix, ref += pix) {
+ x = 0;
INIT_C3;
@@ -190,10 +190,10 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
- src+= pix;
- ref+= pix;
+ src += pix;
+ ref += pix;
- for (x= 1; x < imgx - 1; x++, src+= pix, ref+= pix) {
+ for (x = 1; x < imgx - 1; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(0);
@@ -219,7 +219,7 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
}
- for (x= 0; x < imgx; x++, src+= pix, ref+= pix) {
+ for (x = 0; x < imgx; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(2);
@@ -249,17 +249,17 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
free_compbuf(refimg);
}
- out[0]->data= source;
+ out[0]->data = source;
free_compbuf(new);
}
-static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeBilateralBlurData *nbbd= MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data");
- node->storage= nbbd;
- nbbd->sigma_color= 0.3;
- nbbd->sigma_space= 5.0;
+ NodeBilateralBlurData *nbbd = MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data");
+ node->storage = nbbd;
+ nbbd->sigma_color = 0.3;
+ nbbd->sigma_space = 5.0;
}
void register_node_type_cmp_bilateralblur(bNodeTreeType *ttype)
diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c
index f10e6bfe939..046623f5b26 100644
--- a/source/blender/nodes/composite/nodes/node_composite_blur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_blur.c
@@ -34,14 +34,14 @@
#include "node_composite_util.h"
/* **************** BLUR ******************** */
-static bNodeSocketTemplate cmp_node_blur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_blur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_blur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_blur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static float *make_gausstab(int filtertype, int rad)
@@ -55,14 +55,14 @@ static float *make_gausstab(int filtertype, int rad)
sum = 0.0f;
for (i = -rad; i <= rad; i++) {
- val= RE_filter_value(filtertype, (float)i/(float)rad);
+ val = RE_filter_value(filtertype, (float)i / (float)rad);
sum += val;
- gausstab[i+rad] = val;
+ gausstab[i + rad] = val;
}
- sum= 1.0f/sum;
- for (i=0; i<n; i++)
- gausstab[i]*= sum;
+ sum = 1.0f / sum;
+ for (i = 0; i < n; i++)
+ gausstab[i] *= sum;
return gausstab;
}
@@ -77,8 +77,8 @@ static float *make_bloomtab(int rad)
bloomtab = (float *) MEM_mallocN(n * sizeof(float), "bloom");
for (i = -rad; i <= rad; i++) {
- val = powf(1.0f - fabsf((float)i)/((float)rad), 4.0f);
- bloomtab[i+rad] = val;
+ val = powf(1.0f - fabsf((float)i) / ((float)rad), 4.0f);
+ bloomtab[i + rad] = val;
}
return bloomtab;
@@ -87,61 +87,61 @@ 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)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
CompBuf *work;
register float sum, val;
float rval, gval, bval, aval;
float *gausstab, *gausstabcent;
- int rad, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int rad, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, bigstep;
float *src, *dest;
/* helper image */
- work= alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */
+ work = alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */
/* horizontal */
if (nbd->sizex == 0) {
memcpy(work->rect, img->rect, sizeof(float) * img->type * imgx * imgy);
}
else {
- rad = scale*(float)nbd->sizex;
- if (rad>imgx/2)
- rad= imgx/2;
- else if (rad<1)
- rad= 1;
+ rad = scale * (float)nbd->sizex;
+ if (rad > imgx / 2)
+ rad = imgx / 2;
+ else if (rad < 1)
+ rad = 1;
- gausstab= make_gausstab(nbd->filtertype, rad);
- gausstabcent= gausstab+rad;
+ gausstab = make_gausstab(nbd->filtertype, rad);
+ gausstabcent = gausstab + rad;
for (y = 0; y < imgy; y++) {
- float *srcd= img->rect + pix*(y*img->x);
+ float *srcd = img->rect + pix * (y * img->x);
- dest = work->rect + pix*(y * img->x);
+ dest = work->rect + pix * (y * img->x);
- for (x = 0; x < imgx ; x++) {
- int minr= x-rad<0?-x:-rad;
- int maxr= x+rad>imgx?imgx-x:rad;
+ for (x = 0; x < imgx; x++) {
+ int minr = x - rad < 0 ? -x : -rad;
+ int maxr = x + rad > imgx ? imgx - x : rad;
- src= srcd + pix*(x+minr);
+ src = srcd + pix * (x + minr);
- sum= gval = rval= bval= aval= 0.0f;
- for (i= minr; i < maxr; i++) {
- val= gausstabcent[i];
- sum+= val;
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minr; i < maxr; i++) {
+ val = gausstabcent[i];
+ sum += val;
rval += val * (*src++);
- if (pix==4) {
+ if (pix == 4) {
gval += val * (*src++);
bval += val * (*src++);
aval += val * (*src++);
}
}
- sum= 1.0f/sum;
- *dest++ = rval*sum;
- if (pix==4) {
- *dest++ = gval*sum;
- *dest++ = bval*sum;
- *dest++ = aval*sum;
+ sum = 1.0f / sum;
+ *dest++ = rval * sum;
+ if (pix == 4) {
+ *dest++ = gval * sum;
+ *dest++ = bval * sum;
+ *dest++ = aval * sum;
}
}
if (node->exec & NODE_BREAK)
@@ -156,47 +156,47 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca
memcpy(new->rect, work->rect, sizeof(float) * img->type * imgx * imgy);
}
else {
- rad = scale*(float)nbd->sizey;
- if (rad>imgy/2)
- rad= imgy/2;
- else if (rad<1)
- rad= 1;
-
- gausstab= make_gausstab(nbd->filtertype, rad);
- gausstabcent= gausstab+rad;
+ rad = scale * (float)nbd->sizey;
+ if (rad > imgy / 2)
+ rad = imgy / 2;
+ else if (rad < 1)
+ rad = 1;
+
+ gausstab = make_gausstab(nbd->filtertype, rad);
+ gausstabcent = gausstab + rad;
- bigstep = pix*imgx;
+ bigstep = pix * imgx;
for (x = 0; x < imgx; x++) {
- float *srcd= work->rect + pix*x;
+ float *srcd = work->rect + pix * x;
- dest = new->rect + pix*x;
+ dest = new->rect + pix * x;
- for (y = 0; y < imgy ; y++) {
- int minr= y-rad<0?-y:-rad;
- int maxr= y+rad>imgy?imgy-y:rad;
+ for (y = 0; y < imgy; y++) {
+ int minr = y - rad < 0 ? -y : -rad;
+ int maxr = y + rad > imgy ? imgy - y : rad;
- src= srcd + bigstep*(y+minr);
+ src = srcd + bigstep * (y + minr);
- sum= gval = rval= bval= aval= 0.0f;
- for (i= minr; i < maxr; i++) {
- val= gausstabcent[i];
- sum+= val;
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minr; i < maxr; i++) {
+ val = gausstabcent[i];
+ sum += val;
rval += val * src[0];
- if (pix==4) {
+ if (pix == 4) {
gval += val * src[1];
bval += val * src[2];
aval += val * src[3];
}
src += bigstep;
}
- sum= 1.0f/sum;
- dest[0] = rval*sum;
- if (pix==4) {
- dest[1] = gval*sum;
- dest[2] = bval*sum;
- dest[3] = aval*sum;
+ sum = 1.0f / sum;
+ dest[0] = rval * sum;
+ if (pix == 4) {
+ dest[1] = gval * sum;
+ dest[2] = bval * sum;
+ dest[3] = aval * sum;
}
- dest+= bigstep;
+ dest += bigstep;
}
if (node->exec & NODE_BREAK)
break;
@@ -216,83 +216,83 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
float **maintabs;
float *gausstabx, *gausstabcenty;
float *gausstaby, *gausstabcentx;
- int radx, rady, imgx= img->x, imgy= img->y;
+ int radx, rady, imgx = img->x, imgy = img->y;
int x, y;
int i, j;
float *src, *dest, *wb;
- wbuf= alloc_compbuf(imgx, imgy, CB_VAL, 1);
+ wbuf = alloc_compbuf(imgx, imgy, CB_VAL, 1);
/* horizontal */
radx = (float)nbd->sizex;
- if (radx>imgx/2)
- radx= imgx/2;
- else if (radx<1)
- radx= 1;
+ if (radx > imgx / 2)
+ radx = imgx / 2;
+ else if (radx < 1)
+ radx = 1;
/* vertical */
rady = (float)nbd->sizey;
- if (rady>imgy/2)
- rady= imgy/2;
- else if (rady<1)
- rady= 1;
-
- x= MAX2(radx, rady);
- maintabs= MEM_mallocN(x*sizeof(void *), "gauss array");
- for (i= 0; i<x; i++)
- maintabs[i]= make_bloomtab(i+1);
+ if (rady > imgy / 2)
+ rady = imgy / 2;
+ else if (rady < 1)
+ rady = 1;
+
+ x = MAX2(radx, rady);
+ maintabs = MEM_mallocN(x * sizeof(void *), "gauss array");
+ for (i = 0; i < x; i++)
+ maintabs[i] = make_bloomtab(i + 1);
/* vars to store before we go */
// refd= ref->rect;
- src= img->rect;
+ src = img->rect;
- radxf= (float)radx;
- radyf= (float)rady;
+ radxf = (float)radx;
+ radyf = (float)rady;
for (y = 0; y < imgy; y++) {
- for (x = 0; x < imgx ; x++, src+=4) {//, refd++) {
+ for (x = 0; x < imgx; x++, src += 4) { //, refd++) {
// int refradx= (int)(refd[0]*radxf);
// int refrady= (int)(refd[0]*radyf);
- int refradx= (int)(radxf*0.3f*src[3]*(src[0]+src[1]+src[2]));
- int refrady= (int)(radyf*0.3f*src[3]*(src[0]+src[1]+src[2]));
-
- if (refradx>radx) refradx= radx;
- else if (refradx<1) refradx= 1;
- if (refrady>rady) refrady= rady;
- else if (refrady<1) refrady= 1;
+ int refradx = (int)(radxf * 0.3f * src[3] * (src[0] + src[1] + src[2]));
+ int refrady = (int)(radyf * 0.3f * src[3] * (src[0] + src[1] + src[2]));
- if (refradx==1 && refrady==1) {
- wb= wbuf->rect + ( y*imgx + x);
- dest= new->rect + 4*( y*imgx + x);
- wb[0]+= 1.0f;
+ if (refradx > radx) refradx = radx;
+ else if (refradx < 1) refradx = 1;
+ if (refrady > rady) refrady = rady;
+ else if (refrady < 1) refrady = 1;
+
+ if (refradx == 1 && refrady == 1) {
+ wb = wbuf->rect + (y * imgx + x);
+ dest = new->rect + 4 * (y * imgx + x);
+ wb[0] += 1.0f;
dest[0] += src[0];
dest[1] += src[1];
dest[2] += src[2];
dest[3] += src[3];
}
else {
- int minxr= x-refradx<0?-x:-refradx;
- int maxxr= x+refradx>imgx?imgx-x:refradx;
- int minyr= y-refrady<0?-y:-refrady;
- int maxyr= y+refrady>imgy?imgy-y:refrady;
-
- float *destd= new->rect + 4*( (y + minyr)*imgx + x + minxr);
- float *wbufd= wbuf->rect + ( (y + minyr)*imgx + x + minxr);
-
- gausstabx= maintabs[refradx-1];
- gausstabcentx= gausstabx+refradx;
- gausstaby= maintabs[refrady-1];
- gausstabcenty= gausstaby+refrady;
-
- for (i= minyr; i < maxyr; i++, destd+= 4*imgx, wbufd+= imgx) {
- dest= destd;
- wb= wbufd;
- for (j= minxr; j < maxxr; j++, dest+=4, wb++) {
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
+
+ float *destd = new->rect + 4 * ( (y + minyr) * imgx + x + minxr);
+ float *wbufd = wbuf->rect + ( (y + minyr) * imgx + x + minxr);
+
+ gausstabx = maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ for (i = minyr; i < maxyr; i++, destd += 4 * imgx, wbufd += imgx) {
+ dest = destd;
+ wb = wbufd;
+ for (j = minxr; j < maxxr; j++, dest += 4, wb++) {
- val= gausstabcenty[i]*gausstabcentx[j];
- wb[0]+= val;
+ val = gausstabcenty[i] * gausstabcentx[j];
+ wb[0] += val;
dest[0] += val * src[0];
dest[1] += val * src[1];
dest[2] += val * src[2];
@@ -303,23 +303,23 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
}
}
- x= imgx*imgy;
- dest= new->rect;
- wb= wbuf->rect;
+ x = imgx * imgy;
+ dest = new->rect;
+ wb = wbuf->rect;
while (x--) {
- val= 1.0f/wb[0];
- dest[0]*= val;
- dest[1]*= val;
- dest[2]*= val;
- dest[3]*= val;
+ val = 1.0f / wb[0];
+ dest[0] *= val;
+ dest[1] *= val;
+ dest[2] *= val;
+ dest[3] *= val;
wb++;
- dest+= 4;
+ dest += 4;
}
free_compbuf(wbuf);
- x= MAX2(radx, rady);
- for (i= 0; i<x; i++)
+ x = MAX2(radx, rady);
+ for (i = 0; i < x; i++)
MEM_freeN(maintabs[i]);
MEM_freeN(maintabs);
@@ -328,12 +328,12 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
#if 0
static float hexagon_filter(float fi, float fj)
{
- fi= fabs(fi);
- fj= fabs(fj);
+ fi = fabs(fi);
+ fj = fabs(fj);
- if (fj>0.33f) {
- fj= (fj-0.33f)/0.66f;
- if (fi+fj>1.0f)
+ if (fj > 0.33f) {
+ fj = (fj - 0.33f) / 0.66f;
+ if (fi + fj > 1.0f)
return 0.0f;
else
return 1.0f;
@@ -346,85 +346,85 @@ static float hexagon_filter(float fi, float fj)
/* both images same type, either 1 or 4 channels */
static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fac)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
register float val;
float radxf, radyf;
float *gausstab, *dgauss;
- int radx, rady, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int radx, rady, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, j, n;
- float *src= NULL, *dest, *srcd= NULL;
+ float *src = NULL, *dest, *srcd = NULL;
/* horizontal */
- radxf = fac*(float)nbd->sizex;
- if (radxf>imgx/2.0f)
- radxf= imgx/2.0f;
- else if (radxf<1.0f)
- radxf= 1.0f;
+ radxf = fac * (float)nbd->sizex;
+ if (radxf > imgx / 2.0f)
+ radxf = imgx / 2.0f;
+ else if (radxf < 1.0f)
+ radxf = 1.0f;
/* vertical */
- radyf = fac*(float)nbd->sizey;
- if (radyf>imgy/2.0f)
- radyf= imgy/2.0f;
- else if (radyf<1.0f)
- radyf= 1.0f;
+ radyf = fac * (float)nbd->sizey;
+ if (radyf > imgy / 2.0f)
+ radyf = imgy / 2.0f;
+ else if (radyf < 1.0f)
+ radyf = 1.0f;
- radx= ceil(radxf);
- rady= ceil(radyf);
+ radx = ceil(radxf);
+ rady = ceil(radyf);
- n = (2*radx+1)*(2*rady+1);
+ n = (2 * radx + 1) * (2 * rady + 1);
/* create a full filter image */
- gausstab= MEM_mallocN(sizeof(float)*n, "filter tab");
- dgauss= gausstab;
- val= 0.0f;
- for (j=-rady; j<=rady; j++) {
- for (i=-radx; i<=radx; i++, dgauss++) {
- float fj= (float)j/radyf;
- float fi= (float)i/radxf;
- float dist= sqrt(fj*fj + fi*fi);
-
- //*dgauss= hexagon_filter(fi, fj);
- *dgauss= RE_filter_value(nbd->filtertype, dist);
+ gausstab = MEM_mallocN(sizeof(float) * n, "filter tab");
+ dgauss = gausstab;
+ val = 0.0f;
+ for (j = -rady; j <= rady; j++) {
+ for (i = -radx; i <= radx; i++, dgauss++) {
+ float fj = (float)j / radyf;
+ float fi = (float)i / radxf;
+ float dist = sqrt(fj * fj + fi * fi);
- val+= *dgauss;
+ //*dgauss= hexagon_filter(fi, fj);
+ *dgauss = RE_filter_value(nbd->filtertype, dist);
+
+ val += *dgauss;
}
}
- if (val!=0.0f) {
- val= 1.0f/val;
- for (j= n -1; j>=0; j--)
- gausstab[j]*= val;
+ if (val != 0.0f) {
+ val = 1.0f / val;
+ for (j = n - 1; j >= 0; j--)
+ gausstab[j] *= val;
}
- else gausstab[4]= 1.0f;
-
- for (y = -rady+1; y < imgy+rady-1; y++) {
-
- if (y<=0) srcd= img->rect;
- else if (y<imgy) srcd+= pix*imgx;
- else srcd= img->rect + pix*(imgy-1)*imgx;
-
- for (x = -radx+1; x < imgx+radx-1 ; x++) {
- int minxr= x-radx<0?-x:-radx;
- int maxxr= x+radx>=imgx?imgx-x-1:radx;
- int minyr= y-rady<0?-y:-rady;
- int maxyr= y+rady>imgy-1?imgy-y-1:rady;
-
- float *destd= new->rect + pix*( (y + minyr)*imgx + x + minxr);
- float *dgausd= gausstab + (minyr+rady)*(2*radx+1) + minxr+radx;
-
- if (x<=0) src= srcd;
- else if (x<imgx) src+= pix;
- else src= srcd + pix*(imgx-1);
-
- for (i= minyr; i <=maxyr; i++, destd+= pix*imgx, dgausd+= 2*radx + 1) {
- dest= destd;
- dgauss= dgausd;
- for (j= minxr; j <=maxxr; j++, dest+=pix, dgauss++) {
- val= *dgauss;
- if (val!=0.0f) {
+ else gausstab[4] = 1.0f;
+
+ for (y = -rady + 1; y < imgy + rady - 1; y++) {
+
+ if (y <= 0) srcd = img->rect;
+ else if (y < imgy) srcd += pix * imgx;
+ else srcd = img->rect + pix * (imgy - 1) * imgx;
+
+ for (x = -radx + 1; x < imgx + radx - 1; x++) {
+ int minxr = x - radx < 0 ? -x : -radx;
+ int maxxr = x + radx >= imgx ? imgx - x - 1 : radx;
+ int minyr = y - rady < 0 ? -y : -rady;
+ int maxyr = y + rady > imgy - 1 ? imgy - y - 1 : rady;
+
+ float *destd = new->rect + pix * ( (y + minyr) * imgx + x + minxr);
+ float *dgausd = gausstab + (minyr + rady) * (2 * radx + 1) + minxr + radx;
+
+ if (x <= 0) src = srcd;
+ else if (x < imgx) src += pix;
+ else src = srcd + pix * (imgx - 1);
+
+ for (i = minyr; i <= maxyr; i++, destd += pix * imgx, dgausd += 2 * radx + 1) {
+ dest = destd;
+ dgauss = dgausd;
+ for (j = minxr; j <= maxxr; j++, dest += pix, dgauss++) {
+ val = *dgauss;
+ if (val != 0.0f) {
dest[0] += val * src[0];
- if (pix>1) {
+ if (pix > 1) {
dest[1] += val * src[1];
dest[2] += val * src[2];
dest[3] += val * src[3];
@@ -444,116 +444,116 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa
/* reference has to be mapped 0-1, and equal in size */
static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf *ref)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
CompBuf *blurbuf, *ref_use;
register float sum, val;
float rval, gval, bval, aval, radxf, radyf;
float **maintabs;
float *gausstabx, *gausstabcenty;
float *gausstaby, *gausstabcentx;
- int radx, rady, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int radx, rady, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, j;
float *src, *dest, *refd, *blurd;
- float defcol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* default color for compbuf_get_pixel */
- float proccol[4]; /* local color if compbuf is procedural */
+ float defcol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* default color for compbuf_get_pixel */
+ float proccol[4]; /* local color if compbuf is procedural */
int refradx, refrady;
- if (ref->x!=img->x || ref->y!=img->y)
+ if (ref->x != img->x || ref->y != img->y)
return;
- ref_use= typecheck_compbuf(ref, CB_VAL);
+ ref_use = typecheck_compbuf(ref, CB_VAL);
/* trick is; we blur the reference image... but only works with clipped values*/
- blurbuf= alloc_compbuf(imgx, imgy, CB_VAL, 1);
- blurbuf->xof= ref_use->xof;
- blurbuf->yof= ref_use->yof;
- blurd= blurbuf->rect;
- refd= ref_use->rect;
- for (x= imgx*imgy; x>0; x--, refd++, blurd++) {
- if (refd[0]<0.0f) blurd[0]= 0.0f;
- else if (refd[0]>1.0f) blurd[0]= 1.0f;
- else blurd[0]= refd[0];
+ blurbuf = alloc_compbuf(imgx, imgy, CB_VAL, 1);
+ blurbuf->xof = ref_use->xof;
+ blurbuf->yof = ref_use->yof;
+ blurd = blurbuf->rect;
+ refd = ref_use->rect;
+ for (x = imgx * imgy; x > 0; x--, refd++, blurd++) {
+ if (refd[0] < 0.0f) blurd[0] = 0.0f;
+ else if (refd[0] > 1.0f) blurd[0] = 1.0f;
+ else blurd[0] = refd[0];
}
blur_single_image(node, blurbuf, blurbuf, 1.0f);
/* horizontal */
radx = (float)nbd->sizex;
- if (radx>imgx/2)
- radx= imgx/2;
- else if (radx<1)
- radx= 1;
+ if (radx > imgx / 2)
+ radx = imgx / 2;
+ else if (radx < 1)
+ radx = 1;
/* vertical */
rady = (float)nbd->sizey;
- if (rady>imgy/2)
- rady= imgy/2;
- else if (rady<1)
- rady= 1;
-
- x= MAX2(radx, rady);
- maintabs= MEM_mallocN(x*sizeof(void *), "gauss array");
- for (i= 0; i<x; i++)
- maintabs[i]= make_gausstab(nbd->filtertype, i+1);
-
- dest= new->rect;
- radxf= (float)radx;
- radyf= (float)rady;
+ if (rady > imgy / 2)
+ rady = imgy / 2;
+ else if (rady < 1)
+ rady = 1;
+
+ x = MAX2(radx, rady);
+ maintabs = MEM_mallocN(x * sizeof(void *), "gauss array");
+ for (i = 0; i < x; i++)
+ maintabs[i] = make_gausstab(nbd->filtertype, i + 1);
+
+ dest = new->rect;
+ radxf = (float)radx;
+ radyf = (float)rady;
for (y = 0; y < imgy; y++) {
- for (x = 0; x < imgx ; x++, dest+=pix) {
- refd= compbuf_get_pixel(blurbuf, defcol, proccol, x-blurbuf->xrad, y-blurbuf->yrad, blurbuf->xrad, blurbuf->yrad);
- refradx= (int)(refd[0]*radxf);
- refrady= (int)(refd[0]*radyf);
-
- if (refradx>radx) refradx= radx;
- else if (refradx<1) refradx= 1;
- if (refrady>rady) refrady= rady;
- else if (refrady<1) refrady= 1;
-
- if (refradx==1 && refrady==1) {
- src= img->rect + pix*( y*imgx + x);
- if (pix==1)
- dest[0]= src[0];
+ for (x = 0; x < imgx; x++, dest += pix) {
+ refd = compbuf_get_pixel(blurbuf, defcol, proccol, x - blurbuf->xrad, y - blurbuf->yrad, blurbuf->xrad, blurbuf->yrad);
+ refradx = (int)(refd[0] * radxf);
+ refrady = (int)(refd[0] * radyf);
+
+ if (refradx > radx) refradx = radx;
+ else if (refradx < 1) refradx = 1;
+ if (refrady > rady) refrady = rady;
+ else if (refrady < 1) refrady = 1;
+
+ if (refradx == 1 && refrady == 1) {
+ src = img->rect + pix * (y * imgx + x);
+ if (pix == 1)
+ dest[0] = src[0];
else
copy_v4_v4(dest, src);
}
else {
- int minxr= x-refradx<0?-x:-refradx;
- int maxxr= x+refradx>imgx?imgx-x:refradx;
- int minyr= y-refrady<0?-y:-refrady;
- int maxyr= y+refrady>imgy?imgy-y:refrady;
-
- float *srcd= img->rect + pix*( (y + minyr)*imgx + x + minxr);
-
- gausstabx= maintabs[refradx-1];
- gausstabcentx= gausstabx+refradx;
- gausstaby= maintabs[refrady-1];
- gausstabcenty= gausstaby+refrady;
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
- sum= gval = rval= bval= aval= 0.0f;
-
- for (i= minyr; i < maxyr; i++, srcd+= pix*imgx) {
- src= srcd;
- for (j= minxr; j < maxxr; j++, src+=pix) {
+ float *srcd = img->rect + pix * ( (y + minyr) * imgx + x + minxr);
+
+ gausstabx = maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ sum = gval = rval = bval = aval = 0.0f;
+
+ for (i = minyr; i < maxyr; i++, srcd += pix * imgx) {
+ src = srcd;
+ for (j = minxr; j < maxxr; j++, src += pix) {
- val= gausstabcenty[i]*gausstabcentx[j];
- sum+= val;
+ val = gausstabcenty[i] * gausstabcentx[j];
+ sum += val;
rval += val * src[0];
- if (pix>1) {
+ if (pix > 1) {
gval += val * src[1];
bval += val * src[2];
aval += val * src[3];
}
}
}
- sum= 1.0f/sum;
- dest[0] = rval*sum;
- if (pix>1) {
- dest[1] = gval*sum;
- dest[2] = bval*sum;
- dest[3] = aval*sum;
+ sum = 1.0f / sum;
+ dest[0] = rval * sum;
+ if (pix > 1) {
+ dest[1] = gval * sum;
+ dest[2] = bval * sum;
+ dest[3] = aval * sum;
}
}
}
@@ -563,46 +563,46 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf
free_compbuf(blurbuf);
- x= MAX2(radx, rady);
- for (i= 0; i<x; i++)
+ x = MAX2(radx, rady);
+ for (i = 0; i < x; i++)
MEM_freeN(maintabs[i]);
MEM_freeN(maintabs);
- if (ref_use!=ref)
+ if (ref_use != ref)
free_compbuf(ref_use);
}
static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- CompBuf *new, *img= in[0]->data;
- NodeBlurData *nbd= node->storage;
+ CompBuf *new, *img = in[0]->data;
+ NodeBlurData *nbd = node->storage;
- if (img==NULL) return;
+ if (img == NULL) return;
/* store image in size that is needed for absolute/relative conversions on ui level */
- nbd->image_in_width= img->x;
- nbd->image_in_height= img->y;
+ nbd->image_in_width = img->x;
+ nbd->image_in_height = img->y;
- if (out[0]->hasoutput==0) return;
+ if (out[0]->hasoutput == 0) return;
if (nbd->relative) {
- if (nbd->aspect==CMP_NODE_BLUR_ASPECT_NONE) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+ if (nbd->aspect == CMP_NODE_BLUR_ASPECT_NONE) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_width);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_height);
}
- else if (nbd->aspect==CMP_NODE_BLUR_ASPECT_Y) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_width);
+ else if (nbd->aspect == CMP_NODE_BLUR_ASPECT_Y) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_width);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_width);
}
- else if (nbd->aspect==CMP_NODE_BLUR_ASPECT_X) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_height);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+ else if (nbd->aspect == CMP_NODE_BLUR_ASPECT_X) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_height);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_height);
}
}
- if (nbd->sizex==0 && nbd->sizey==0) {
- new= pass_on_compbuf(img);
- out[0]->data= new;
+ if (nbd->sizex == 0 && nbd->sizey == 0) {
+ new = pass_on_compbuf(img);
+ out[0]->data = new;
}
else if (nbd->filtertype == R_FILTER_FAST_GAUSS) {
if (in[1]->vec[0] < 0.001f) { /* time node inputs can be a tiny value */
@@ -610,10 +610,10 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
else {
// TODO: can this be mapped with reference, too?
- const float sx = ((float)nbd->sizex*in[1]->vec[0])/2.0f, sy = ((float)nbd->sizey*in[1]->vec[0])/2.0f;
+ const float sx = ((float)nbd->sizex * in[1]->vec[0]) / 2.0f, sy = ((float)nbd->sizey * in[1]->vec[0]) / 2.0f;
int c;
- if ((img==NULL) || (out[0]->hasoutput==0)) return;
+ if ((img == NULL) || (out[0]->hasoutput == 0)) return;
if (img->type == CB_VEC2)
new = typecheck_compbuf(img, CB_VAL);
@@ -623,16 +623,16 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
new = dupalloc_compbuf(img);
if ((sx == sy) && (sx > 0.f)) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sx, c, 3);
}
else {
if (sx > 0.f) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sx, c, 1);
}
if (sy > 0.f) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sy, c, 2);
}
}
@@ -641,8 +641,8 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
else {
/* All non fast gauss blur methods */
- if (img->type==CB_VEC2 || img->type==CB_VEC3) {
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ if (img->type == CB_VEC2 || img->type == CB_VEC3) {
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
}
/* if fac input, we do it different */
@@ -650,17 +650,17 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
CompBuf *gammabuf;
/* make output size of input image */
- new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
+ new = alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
/* accept image offsets from other nodes */
new->xof = img->xof;
new->yof = img->yof;
if (nbd->gamma) {
- gammabuf= dupalloc_compbuf(img);
+ gammabuf = dupalloc_compbuf(img);
gamma_correct_compbuf(gammabuf, 0);
}
- else gammabuf= img;
+ else gammabuf = img;
blur_with_reference(node, new, gammabuf, in[1]->data);
@@ -670,30 +670,30 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
if (node->exec & NODE_BREAK) {
free_compbuf(new);
- new= NULL;
+ new = NULL;
}
- out[0]->data= new;
+ out[0]->data = new;
}
else {
- if (in[1]->vec[0]<=0.001f) { /* time node inputs can be a tiny value */
- new= pass_on_compbuf(img);
+ if (in[1]->vec[0] <= 0.001f) { /* time node inputs can be a tiny value */
+ new = pass_on_compbuf(img);
}
else {
CompBuf *gammabuf;
/* make output size of input image */
- new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
+ new = alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
/* accept image offsets from other nodes */
new->xof = img->xof;
new->yof = img->yof;
if (nbd->gamma) {
- gammabuf= dupalloc_compbuf(img);
+ gammabuf = dupalloc_compbuf(img);
gamma_correct_compbuf(gammabuf, 0);
}
- else gammabuf= img;
+ else gammabuf = img;
if (nbd->bokeh)
bokeh_single_image(node, new, gammabuf, in[1]->vec[0]);
@@ -708,28 +708,28 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
if (node->exec & NODE_BREAK) {
free_compbuf(new);
- new= NULL;
+ new = NULL;
}
}
- out[0]->data= new;
+ out[0]->data = new;
}
- if (img!=in[0]->data)
+ if (img != in[0]->data)
free_compbuf(img);
}
generate_preview(data, node, out[0]->data);
}
-static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- node->storage= MEM_callocN(sizeof(NodeBlurData), "node blur data");
+ node->storage = MEM_callocN(sizeof(NodeBlurData), "node blur data");
}
void register_node_type_cmp_blur(bNodeTreeType *ttype)
{
static bNodeType ntype;
- node_type_base(ttype, &ntype, CMP_NODE_BLUR, "Blur", NODE_CLASS_OP_FILTER, NODE_PREVIEW|NODE_OPTIONS);
+ node_type_base(ttype, &ntype, CMP_NODE_BLUR, "Blur", NODE_CLASS_OP_FILTER, NODE_PREVIEW | NODE_OPTIONS);
node_type_socket_templates(&ntype, cmp_node_blur_in, cmp_node_blur_out);
node_type_size(&ntype, 120, 80, 200);
node_type_init(&ntype, node_composit_init_blur);
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
index 6b24bdb5c52..222ac7a5cdf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
@@ -36,20 +36,20 @@
#include "../node_composite_util.h"
/* **************** BLUR ******************** */
-static bNodeSocketTemplate cmp_node_bokehblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Bokeh"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
- { SOCK_FLOAT, 1, N_("Bounding box"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_bokehblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 1, N_("Bokeh"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+ { SOCK_FLOAT, 1, N_("Bounding box"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_bokehblur_out[]= {
- { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_bokehblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static void node_composit_init_bokehblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_bokehblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
node->custom3 = 4.0f;
node->custom4 = 16.0f;
diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
index 395fa154a89..73e28658309 100644
--- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
@@ -32,23 +32,23 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_dblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_dblur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
- float center_x, float center_y, float dist, float angle, float spin, float zoom)
+ float center_x, float center_y, float dist, float angle, float spin, float zoom)
{
if ((dist != 0.f) || (spin != 0.f) || (zoom != 0.f)) {
- void (*getpix)(CompBuf*, float, float, float*) = wrap ? qd_getPixelLerpWrap : qd_getPixelLerp;
- const float a= angle;
- const float itsc= 1.f / powf(2.f, (float)iterations);
+ void (*getpix)(CompBuf *, float, float, float *) = wrap ? qd_getPixelLerpWrap : qd_getPixelLerp;
+ const float a = angle;
+ const float itsc = 1.f / powf(2.f, (float)iterations);
float D;
float center_x_pix, center_y_pix;
float tx, ty;
@@ -56,36 +56,36 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
CompBuf *tmp;
int i, j;
- tmp= dupalloc_compbuf(img);
+ tmp = dupalloc_compbuf(img);
- D= dist * sqrtf(img->x * img->x + img->y * img->y);
- center_x_pix= center_x * img->x;
- center_y_pix= center_y * img->y;
+ D = dist * sqrtf(img->x * img->x + img->y * img->y);
+ center_x_pix = center_x * img->x;
+ center_y_pix = center_y * img->y;
- tx= itsc * D * cosf(a);
- ty= -itsc * D * sinf(a);
- sc= itsc * zoom;
- rot= itsc * spin;
+ tx = itsc * D * cosf(a);
+ ty = -itsc *D *sinf(a);
+ sc = itsc * zoom;
+ rot = itsc * spin;
/* blur the image */
- for (i= 0; i < iterations; ++i) {
- const float cs= cosf(rot), ss= sinf(rot);
- const float isc= 1.f / (1.f + sc);
+ for (i = 0; i < iterations; ++i) {
+ const float cs = cosf(rot), ss = sinf(rot);
+ const float isc = 1.f / (1.f + sc);
unsigned int x, y;
- float col[4]= {0, 0, 0, 0};
+ float col[4] = {0, 0, 0, 0};
- for (y= 0; y < img->y; ++y) {
- const float v= isc * (y - center_y_pix) + ty;
+ for (y = 0; y < img->y; ++y) {
+ const float v = isc * (y - center_y_pix) + ty;
- for (x= 0; x < img->x; ++x) {
- const float u= isc * (x - center_x_pix) + tx;
- unsigned int p= (x + y * img->x) * img->type;
+ for (x = 0; x < img->x; ++x) {
+ const float u = isc * (x - center_x_pix) + tx;
+ unsigned int p = (x + y * img->x) * img->type;
getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col);
/* mix img and transformed tmp */
- for (j= 0; j < 4; ++j) {
- img->rect[p + j]= 0.5f * (img->rect[p + j] + col[j]);
+ for (j = 0; j < 4; ++j) {
+ img->rect[p + j] = 0.5f * (img->rect[p + j] + col[j]);
}
}
}
@@ -109,8 +109,8 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeDBlurData *ndbd= node->storage;
- CompBuf *new, *img= in[0]->data;
+ NodeDBlurData *ndbd = node->storage;
+ CompBuf *new, *img = in[0]->data;
if ((img == NULL) || (out[0]->hasoutput == 0)) return;
@@ -119,15 +119,15 @@ static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack
else
new = dupalloc_compbuf(img);
- out[0]->data= dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom);
+ out[0]->data = dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom);
}
-static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeDBlurData *ndbd= MEM_callocN(sizeof(NodeDBlurData), "node dblur data");
- node->storage= ndbd;
- ndbd->center_x= 0.5;
- ndbd->center_y= 0.5;
+ NodeDBlurData *ndbd = MEM_callocN(sizeof(NodeDBlurData), "node dblur data");
+ node->storage = ndbd;
+ ndbd->center_x = 0.5;
+ ndbd->center_y = 0.5;
}
void register_node_type_cmp_dblur(bNodeTreeType *ttype)
diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
index fd2cc724b82..e1a20a65227 100644
--- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
@@ -34,63 +34,63 @@
/* **************** VECTOR BLUR ******************** */
-static bNodeSocketTemplate cmp_node_vecblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Z"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Speed"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_vecblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Z"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
+ { SOCK_VECTOR, 1, N_("Speed"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_vecblur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_vecblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeBlurData *nbd= node->storage;
- CompBuf *new, *img= in[0]->data, *vecbuf= in[2]->data, *zbuf= in[1]->data;
+ NodeBlurData *nbd = node->storage;
+ CompBuf *new, *img = in[0]->data, *vecbuf = in[2]->data, *zbuf = in[1]->data;
- if (img==NULL || vecbuf==NULL || zbuf==NULL || out[0]->hasoutput==0)
+ if (img == NULL || vecbuf == NULL || zbuf == NULL || out[0]->hasoutput == 0)
return;
- if (vecbuf->x!=img->x || vecbuf->y!=img->y) {
+ if (vecbuf->x != img->x || vecbuf->y != img->y) {
printf("ERROR: cannot do different sized vecbuf yet\n");
return;
}
- if (vecbuf->type!=CB_VEC4) {
+ if (vecbuf->type != CB_VEC4) {
printf("ERROR: input should be vecbuf\n");
return;
}
- if (zbuf->type!=CB_VAL) {
+ if (zbuf->type != CB_VAL) {
printf("ERROR: input should be zbuf\n");
return;
}
- if (zbuf->x!=img->x || zbuf->y!=img->y) {
+ if (zbuf->x != img->x || zbuf->y != img->y) {
printf("ERROR: cannot do different sized zbuf yet\n");
return;
}
/* allow the input image to be of another type */
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
- new= dupalloc_compbuf(img);
+ new = dupalloc_compbuf(img);
/* call special zbuffer version */
RE_zbuf_accumulate_vecblur(nbd, img->x, img->y, new->rect, img->rect, vecbuf->rect, zbuf->rect);
- out[0]->data= new;
+ out[0]->data = new;
- if (img!=in[0]->data)
+ if (img != in[0]->data)
free_compbuf(img);
}
-static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data");
- node->storage= nbd;
- nbd->samples= 32;
- nbd->fac= 1.0f;
+ NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur data");
+ node->storage = nbd;
+ nbd->samples = 32;
+ nbd->fac = 1.0f;
}
/* custom1: itterations, custom2: maxspeed (0 = nolimit) */