Style cleanup in own compositor nodes
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "node_composite_util.h"
|
||||
|
||||
static bNodeSocketTemplate cmp_node_movieclip_out[]= {
|
||||
static bNodeSocketTemplate cmp_node_movieclip_out[] = {
|
||||
{ SOCK_RGBA, 0, "Image"},
|
||||
{ SOCK_FLOAT, 1, "Offset X"},
|
||||
{ SOCK_FLOAT, 1, "Offset Y"},
|
||||
@@ -49,50 +49,50 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov
|
||||
int type;
|
||||
|
||||
float *rect;
|
||||
int alloc= FALSE;
|
||||
int alloc = FALSE;
|
||||
|
||||
orig_ibuf= BKE_movieclip_get_ibuf(clip, user);
|
||||
orig_ibuf = BKE_movieclip_get_ibuf(clip, user);
|
||||
|
||||
if (orig_ibuf==NULL || (orig_ibuf->rect==NULL && orig_ibuf->rect_float==NULL)) {
|
||||
if (orig_ibuf == NULL || (orig_ibuf->rect == NULL && orig_ibuf->rect_float == NULL)) {
|
||||
IMB_freeImBuf(orig_ibuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ibuf= IMB_dupImBuf(orig_ibuf);
|
||||
ibuf = IMB_dupImBuf(orig_ibuf);
|
||||
IMB_freeImBuf(orig_ibuf);
|
||||
|
||||
if (ibuf->rect_float == NULL || ibuf->userflags&IB_RECT_INVALID) {
|
||||
if (ibuf->rect_float == NULL || (ibuf->userflags & IB_RECT_INVALID)) {
|
||||
IMB_float_from_rect(ibuf);
|
||||
ibuf->userflags&= ~IB_RECT_INVALID;
|
||||
ibuf->userflags &= ~IB_RECT_INVALID;
|
||||
}
|
||||
|
||||
/* now we need a float buffer from the image with matching color management */
|
||||
if (ibuf->channels == 4) {
|
||||
rect= node_composit_get_float_buffer(rd, ibuf, &alloc);
|
||||
rect = node_composit_get_float_buffer(rd, ibuf, &alloc);
|
||||
}
|
||||
else {
|
||||
/* non-rgba passes can't use color profiles */
|
||||
rect= ibuf->rect_float;
|
||||
rect = ibuf->rect_float;
|
||||
}
|
||||
/* done coercing into the correct color management */
|
||||
|
||||
if (!alloc) {
|
||||
rect= MEM_dupallocN(rect);
|
||||
alloc= 1;
|
||||
rect = MEM_dupallocN(rect);
|
||||
alloc = TRUE;
|
||||
}
|
||||
|
||||
type= ibuf->channels;
|
||||
type = ibuf->channels;
|
||||
|
||||
if (rd->scemode & R_COMP_CROP) {
|
||||
stackbuf= get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type);
|
||||
stackbuf = get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type);
|
||||
if (alloc)
|
||||
MEM_freeN(rect);
|
||||
}
|
||||
else {
|
||||
/* we put imbuf copy on stack, cbuf knows rect is from other ibuf when freed! */
|
||||
stackbuf= alloc_compbuf(ibuf->x, ibuf->y, type, FALSE);
|
||||
stackbuf->rect= rect;
|
||||
stackbuf->malloc= alloc;
|
||||
stackbuf = alloc_compbuf(ibuf->x, ibuf->y, type, FALSE);
|
||||
stackbuf->rect = rect;
|
||||
stackbuf->malloc = alloc;
|
||||
}
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
@@ -103,32 +103,32 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov
|
||||
static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
|
||||
{
|
||||
if (node->id) {
|
||||
RenderData *rd= data;
|
||||
MovieClip *clip= (MovieClip *)node->id;
|
||||
MovieClipUser *user= (MovieClipUser *)node->storage;
|
||||
CompBuf *stackbuf= NULL;
|
||||
RenderData *rd = data;
|
||||
MovieClip *clip = (MovieClip *)node->id;
|
||||
MovieClipUser *user = (MovieClipUser *)node->storage;
|
||||
CompBuf *stackbuf = NULL;
|
||||
|
||||
BKE_movieclip_user_set_frame(user, rd->cfra);
|
||||
|
||||
stackbuf= node_composit_get_movieclip(rd, clip, user);
|
||||
stackbuf = node_composit_get_movieclip(rd, clip, user);
|
||||
|
||||
if (stackbuf) {
|
||||
MovieTrackingStabilization *stab= &clip->tracking.stabilization;
|
||||
MovieTrackingStabilization *stab = &clip->tracking.stabilization;
|
||||
|
||||
/* put image on stack */
|
||||
out[0]->data= stackbuf;
|
||||
out[0]->data = stackbuf;
|
||||
|
||||
if (stab->flag&TRACKING_2D_STABILIZATION) {
|
||||
if (stab->flag & TRACKING_2D_STABILIZATION) {
|
||||
float loc[2], scale, angle;
|
||||
|
||||
BKE_tracking_stabilization_data(&clip->tracking, rd->cfra, stackbuf->x, stackbuf->y,
|
||||
loc, &scale, &angle);
|
||||
|
||||
out[1]->vec[0]= loc[0];
|
||||
out[2]->vec[0]= loc[1];
|
||||
out[1]->vec[0] = loc[0];
|
||||
out[2]->vec[0] = loc[1];
|
||||
|
||||
out[3]->vec[0]= scale;
|
||||
out[4]->vec[0]= angle;
|
||||
out[3]->vec[0] = scale;
|
||||
out[4]->vec[0] = angle;
|
||||
}
|
||||
|
||||
/* generate preview */
|
||||
@@ -139,10 +139,10 @@ static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **U
|
||||
|
||||
static void init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
|
||||
{
|
||||
MovieClipUser *user= MEM_callocN(sizeof(MovieClipUser), "node movie clip user");
|
||||
MovieClipUser *user = MEM_callocN(sizeof(MovieClipUser), "node movie clip user");
|
||||
|
||||
node->storage= user;
|
||||
user->framenr= 1;
|
||||
node->storage = user;
|
||||
user->framenr = 1;
|
||||
}
|
||||
|
||||
void register_node_type_cmp_movieclip(bNodeTreeType *ttype)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -37,12 +37,12 @@
|
||||
|
||||
/* **************** Translate ******************** */
|
||||
|
||||
static bNodeSocketTemplate cmp_node_moviedistortion_in[]= {
|
||||
static bNodeSocketTemplate cmp_node_moviedistortion_in[] = {
|
||||
{ SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static bNodeSocketTemplate cmp_node_moviedistortion_out[]= {
|
||||
static bNodeSocketTemplate cmp_node_moviedistortion_out[] = {
|
||||
{ SOCK_RGBA, 0, "Image"},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
@@ -51,63 +51,63 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
if (in[0]->data) {
|
||||
if (node->id) {
|
||||
MovieClip *clip= (MovieClip *)node->id;
|
||||
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
|
||||
CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 0);
|
||||
MovieClip *clip = (MovieClip *)node->id;
|
||||
CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
|
||||
CompBuf *stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 0);
|
||||
ImBuf *ibuf;
|
||||
|
||||
ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
|
||||
ibuf = IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
|
||||
|
||||
if (ibuf) {
|
||||
RenderData *rd= data;
|
||||
RenderData *rd = data;
|
||||
ImBuf *obuf;
|
||||
MovieTracking *tracking= &clip->tracking;
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
int width, height;
|
||||
float overscan= 0.0f;
|
||||
MovieClipUser user= {0};
|
||||
float overscan = 0.0f;
|
||||
MovieClipUser user = {0};
|
||||
|
||||
BKE_movieclip_user_set_frame(&user, rd->cfra);
|
||||
|
||||
ibuf->rect_float= cbuf->rect;
|
||||
ibuf->rect_float = cbuf->rect;
|
||||
|
||||
BKE_movieclip_get_size(clip, &user, &width, &height);
|
||||
|
||||
if (!node->storage)
|
||||
node->storage= BKE_tracking_distortion_create();
|
||||
node->storage = BKE_tracking_distortion_create();
|
||||
|
||||
if (node->custom1==0)
|
||||
if (node->custom1 == 0)
|
||||
obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 1);
|
||||
else
|
||||
obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 0);
|
||||
|
||||
stackbuf->rect= obuf->rect_float;
|
||||
stackbuf->malloc= 1;
|
||||
stackbuf->rect = obuf->rect_float;
|
||||
stackbuf->malloc = TRUE;
|
||||
|
||||
obuf->mall&= ~IB_rectfloat;
|
||||
obuf->rect_float= NULL;
|
||||
obuf->mall &= ~IB_rectfloat;
|
||||
obuf->rect_float = NULL;
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
IMB_freeImBuf(obuf);
|
||||
}
|
||||
|
||||
/* pass on output and free */
|
||||
out[0]->data= stackbuf;
|
||||
out[0]->data = stackbuf;
|
||||
|
||||
if (cbuf!=in[0]->data)
|
||||
if (cbuf != in[0]->data)
|
||||
free_compbuf(cbuf);
|
||||
}
|
||||
else {
|
||||
CompBuf *cbuf= in[0]->data;
|
||||
CompBuf *stackbuf= pass_on_compbuf(cbuf);
|
||||
CompBuf *cbuf = in[0]->data;
|
||||
CompBuf *stackbuf = pass_on_compbuf(cbuf);
|
||||
|
||||
out[0]->data= stackbuf;
|
||||
out[0]->data = stackbuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char *label(bNode *node)
|
||||
{
|
||||
if (node->custom1==0)
|
||||
if (node->custom1 == 0)
|
||||
return IFACE_("Undistortion");
|
||||
else
|
||||
return IFACE_("Distortion");
|
||||
@@ -124,7 +124,7 @@ static void storage_free(bNode *node)
|
||||
static void storage_copy(bNode *orig_node, bNode *new_node)
|
||||
{
|
||||
if (orig_node->storage)
|
||||
new_node->storage= BKE_tracking_distortion_copy(orig_node->storage);
|
||||
new_node->storage = BKE_tracking_distortion_copy(orig_node->storage);
|
||||
}
|
||||
|
||||
void register_node_type_cmp_moviedistortion(bNodeTreeType *ttype)
|
||||
|
||||
@@ -48,20 +48,20 @@ static bNodeSocketTemplate cmp_node_stabilize2d_out[]= {
|
||||
static void node_composit_exec_stabilize2d(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
if (in[0]->data && node->id) {
|
||||
RenderData *rd= data;
|
||||
MovieClip *clip= (MovieClip *)node->id;
|
||||
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
|
||||
RenderData *rd = data;
|
||||
MovieClip *clip = (MovieClip *)node->id;
|
||||
CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
|
||||
CompBuf *stackbuf;
|
||||
float loc[2], scale, angle;
|
||||
|
||||
BKE_tracking_stabilization_data(&clip->tracking, rd->cfra, cbuf->x, cbuf->y, loc, &scale, &angle);
|
||||
|
||||
stackbuf= node_composit_transform(cbuf, loc[0], loc[1], angle, scale, node->custom1);
|
||||
stackbuf = node_composit_transform(cbuf, loc[0], loc[1], angle, scale, node->custom1);
|
||||
|
||||
/* pass on output and free */
|
||||
out[0]->data= stackbuf;
|
||||
out[0]->data = stackbuf;
|
||||
|
||||
if (cbuf!=in[0]->data)
|
||||
if (cbuf != in[0]->data)
|
||||
free_compbuf(cbuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
/* **************** Transform ******************** */
|
||||
|
||||
static bNodeSocketTemplate cmp_node_transform_in[]= {
|
||||
static bNodeSocketTemplate cmp_node_transform_in[] = {
|
||||
{ SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
|
||||
{ SOCK_FLOAT, 1, "X", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
|
||||
{ SOCK_FLOAT, 1, "Y", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
|
||||
@@ -43,17 +43,17 @@ static bNodeSocketTemplate cmp_node_transform_in[]= {
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static bNodeSocketTemplate cmp_node_transform_out[]= {
|
||||
static bNodeSocketTemplate cmp_node_transform_out[] = {
|
||||
{ SOCK_RGBA, 0, "Image"},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, float scale, int filter_type)
|
||||
{
|
||||
CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1);
|
||||
CompBuf *stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, TRUE);
|
||||
ImBuf *ibuf, *obuf;
|
||||
float mat[4][4], lmat[4][4], rmat[4][4], smat[4][4], cmat[4][4], icmat[4][4];
|
||||
float svec[3]= {scale, scale, scale}, loc[2]= {x, y};
|
||||
float svec[3] = {scale, scale, scale}, loc[2] = {x, y};
|
||||
|
||||
unit_m4(rmat);
|
||||
unit_m4(lmat);
|
||||
@@ -61,8 +61,8 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f
|
||||
unit_m4(cmat);
|
||||
|
||||
/* image center as rotation center */
|
||||
cmat[3][0]= (float)cbuf->x/2.0f;
|
||||
cmat[3][1]= (float)cbuf->y/2.0f;
|
||||
cmat[3][0] = (float)cbuf->x/2.0f;
|
||||
cmat[3][1] = (float)cbuf->y/2.0f;
|
||||
invert_m4_m4(icmat, cmat);
|
||||
|
||||
size_to_mat4(smat, svec); /* scale matrix */
|
||||
@@ -74,18 +74,18 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f
|
||||
|
||||
invert_m4(mat);
|
||||
|
||||
ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
|
||||
obuf= IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0);
|
||||
ibuf = IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
|
||||
obuf = IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0);
|
||||
|
||||
if (ibuf && obuf) {
|
||||
int i, j;
|
||||
|
||||
ibuf->rect_float= cbuf->rect;
|
||||
obuf->rect_float= stackbuf->rect;
|
||||
ibuf->rect_float = cbuf->rect;
|
||||
obuf->rect_float = stackbuf->rect;
|
||||
|
||||
for (j=0; j<cbuf->y; j++) {
|
||||
for (i=0; i<cbuf->x;i++) {
|
||||
float vec[3]= {i, j, 0};
|
||||
for (j = 0; j < cbuf->y; j++) {
|
||||
for (i = 0; i < cbuf->x; i++) {
|
||||
float vec[3] = {i, j, 0};
|
||||
|
||||
mul_v3_m4v3(vec, mat, vec);
|
||||
|
||||
@@ -114,15 +114,15 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f
|
||||
static void node_composit_exec_transform(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
if (in[0]->data) {
|
||||
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
|
||||
CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
|
||||
CompBuf *stackbuf;
|
||||
|
||||
stackbuf= node_composit_transform(cbuf, in[1]->vec[0], in[2]->vec[0], in[3]->vec[0], in[4]->vec[0], node->custom1);
|
||||
stackbuf = node_composit_transform(cbuf, in[1]->vec[0], in[2]->vec[0], in[3]->vec[0], in[4]->vec[0], node->custom1);
|
||||
|
||||
/* pass on output and free */
|
||||
out[0]->data= stackbuf;
|
||||
out[0]->data = stackbuf;
|
||||
|
||||
if (cbuf!=in[0]->data)
|
||||
if (cbuf != in[0]->data)
|
||||
free_compbuf(cbuf);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user