diff -Naur blender2.42/source/blender/blenkernel/BKE_node.h blender-work/source/blender/blenkernel/BKE_node.h --- blender2.42/source/blender/blenkernel/BKE_node.h 2006-07-03 05:49:12.000000000 -0400 +++ blender-work/source/blender/blenkernel/BKE_node.h 2006-07-18 02:01:02.000000000 -0400 @@ -88,6 +88,7 @@ #define NODE_CLASS_GROUP 6 #define NODE_CLASS_FILE 7 #define NODE_CLASS_CONVERTOR 8 +#define NODE_CLASS_MATTE 9 /* ************** GENERIC API, TREES *************** */ @@ -220,11 +221,18 @@ #define CMP_NODE_IMAGE 220 #define CMP_NODE_R_LAYERS 221 #define CMP_NODE_COMPOSITE 222 -#define CMP_NODE_OUTPUT_FILE 223 +#define CMP_NODE_OUTPUT_FILE 223 #define CMP_NODE_TEXTURE 224 #define CMP_NODE_TRANSLATE 225 #define CMP_NODE_ZCOMBINE 226 +#define CMP_NODE_SEPYUVA 228 +#define CMP_NODE_YUV_MATTE 229 +#define CMP_NODE_DIFF_MATTE 230 +#define CMP_NODE_CHROMA_MATTE 231 +#define CMP_NODE_BLUE_SPILL 232 +#define CMP_NODE_GREEN_SPILL 233 +#define CMP_NODE_SEPYCCA 234 /* filter types */ #define CMP_FILT_SOFT 0 diff -Naur blender2.42/source/blender/blenkernel/intern/node.c blender-work/source/blender/blenkernel/intern/node.c --- blender2.42/source/blender/blenkernel/intern/node.c 2006-07-09 07:54:41.000000000 -0400 +++ blender-work/source/blender/blenkernel/intern/node.c 2006-07-18 02:01:28.000000000 -0400 @@ -796,6 +796,27 @@ nhs->hue= 0.5f; nhs->sat= 1.0f; } + else if(type==CMP_NODE_YUV_MATTE){ + NodeChroma *c=MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage=c; + c->rt=0.01f; + c->bt=0.01f; + c->gt=0.01f; + } + else if(type==CMP_NODE_DIFF_MATTE){ + NodeChroma *c=MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage=c; + c->rt=0.01f; + c->bt=0.01f; + c->gt=0.01f; + } + else if(type==CMP_NODE_CHROMA_MATTE){ + NodeChroma *c=MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage=c; + c->rt=0.00f; + c->bt=0.00f; + c->gt=0.00f; + } } return node; diff -Naur blender2.42/source/blender/blenkernel/intern/node_composite.c blender-work/source/blender/blenkernel/intern/node_composite.c --- blender2.42/source/blender/blenkernel/intern/node_composite.c 2006-07-03 11:25:11.000000000 -0400 +++ blender-work/source/blender/blenkernel/intern/node_composite.c 2006-07-18 02:15:46.000000000 -0400 @@ -1925,6 +1925,162 @@ }; + +/* **************** SEPARATE YUVA ******************** */ +static bNodeSocketType cmp_node_sepyuva_in[]= { + { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; +static bNodeSocketType cmp_node_sepyuva_out[]= { + { SOCK_VALUE, 0, "Y", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 0, "U", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 0, "V", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 0, "A", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static void do_sepyuva(bNode *node, float *out, float *in) +{ + float y, u, v; + + rgb_to_yuv(in[0], in[1], in[2], &y, &u, &v); + + out[0]= y; + out[1]= u; + out[2]= v; + out[3]= in[3]; +} + +static void node_composit_exec_sepyuva(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + /* stack order out: bw channels */ + /* stack order in: col */ + + /* input no image? then only color operation */ + if(in[0]->data==NULL) { + float y, u, v; + + rgb_to_yuv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &y, &u, &v); + + out[0]->vec[0] = y; + out[1]->vec[0] = u; + out[2]->vec[0] = v; + out[3]->vec[0] = in[0]->vec[3]; + } + else if ((out[0]->hasoutput) || (out[1]->hasoutput) || (out[2]->hasoutput) || (out[3]->hasoutput)) { + /* make output size of input image */ + CompBuf *cbuf= in[0]->data; + + CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs + + /* convert the RGB stackbuf to an HSV representation */ + composit1_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, do_sepyuva, CB_RGBA); + + /* separate each of those channels */ + if(out[0]->hasoutput) + out[0]->data= valbuf_from_rgbabuf(stackbuf, CHAN_R); + if(out[1]->hasoutput) + out[1]->data= valbuf_from_rgbabuf(stackbuf, CHAN_G); + if(out[2]->hasoutput) + out[2]->data= valbuf_from_rgbabuf(stackbuf, CHAN_B); + if(out[3]->hasoutput) + out[3]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); + + free_compbuf(stackbuf); + } +} + +static bNodeType cmp_node_sepyuva= { + /* type code */ CMP_NODE_SEPYUVA, + /* name */ "Separate YUVA", + /* width+range */ 80, 40, 140, + /* class+opts */ NODE_CLASS_CONVERTOR, 0, + /* input sock */ cmp_node_sepyuva_in, + /* output sock */ cmp_node_sepyuva_out, + /* storage */ "", + /* execfunc */ node_composit_exec_sepyuva + +}; + +/* **************** SEPARATE YCCA ******************** */ +static bNodeSocketType cmp_node_sepycca_in[]= { + { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; +static bNodeSocketType cmp_node_sepycca_out[]= { + { SOCK_VALUE, 0, "Y", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 0, "Cb", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 0, "Cr", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_VALUE, 0, "A", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static void do_sepycca(bNode *node, float *out, float *in) +{ + float y, cb, cr; + + rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr); + + //divided by 255 to normalize for viewing in + out[0]= y/255; + out[1]= cb/255; + out[2]= cr/255; + out[3]= in[3]; +} + +static void node_composit_exec_sepycca(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + /* stack order out: bw channels */ + /* stack order in: col */ + + /* input no image? then only color operation */ + if(in[0]->data==NULL) { + float y, cb, cr; + + rgb_to_ycc(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &y, &cb, &cr); + + //divided by 255 to normalize for viewing in + out[0]->vec[0] = y/255; + out[1]->vec[0] = cb/255; + out[2]->vec[0] = cr/255; + out[3]->vec[0] = in[0]->vec[3]; + } + else if ((out[0]->hasoutput) || (out[1]->hasoutput) || (out[2]->hasoutput) || (out[3]->hasoutput)) { + /* make output size of input image */ + CompBuf *cbuf= in[0]->data; + + CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs + + /* convert the RGB stackbuf to an HSV representation */ + composit1_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, do_sepycca, CB_RGBA); + + /* separate each of those channels */ + if(out[0]->hasoutput) + out[0]->data= valbuf_from_rgbabuf(stackbuf, CHAN_R); + if(out[1]->hasoutput) + out[1]->data= valbuf_from_rgbabuf(stackbuf, CHAN_G); + if(out[2]->hasoutput) + out[2]->data= valbuf_from_rgbabuf(stackbuf, CHAN_B); + if(out[3]->hasoutput) + out[3]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); + + free_compbuf(stackbuf); + } +} + +static bNodeType cmp_node_sepycca= { + /* type code */ CMP_NODE_SEPYCCA, + /* name */ "Separate YCbCrA", + /* width+range */ 80, 40, 140, + /* class+opts */ NODE_CLASS_CONVERTOR, 0, + /* input sock */ cmp_node_sepycca_in, + /* output sock */ cmp_node_sepycca_out, + /* storage */ "", + /* execfunc */ node_composit_exec_sepycca + +}; + + /* **************** SET ALPHA ******************** */ static bNodeSocketType cmp_node_setalpha_in[]= { { SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, @@ -2884,6 +3040,435 @@ /* execfunc */ node_composit_exec_translate }; +/* ******************* YUV Difference Matte ********************************* */ +static bNodeSocketType cmp_node_YUV_matte_in[]={ + {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {SOCK_RGBA,1,"Key", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {-1,0,""}, +}; + +static bNodeSocketType cmp_node_YUV_matte_out[]={ + {SOCK_RGBA,0,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {SOCK_VALUE,0,"Matte",0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + {-1,0,""} +}; + +static void node_composit_exec_YUV_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + int i; + + float tolerance; + float yuvkey[3]; + + if(out[0]->hasoutput==0 || in[0]->hasinput==0) return; + if(in[0]->data==NULL) return; + + CompBuf *cbuf=in[0]->data; + + //is it an RGBA image or a value + if(cbuf->type==CB_RGBA) + { + NodeChroma *c=node->storage; + tolerance=c->rt; + CompBuf *yuvbuf=alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA,1); + CompBuf *rgbbuf=dupalloc_compbuf(cbuf); + CompBuf *matte=alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA,1); + + //convert RGB to YUV + int max=cbuf->x*cbuf->y*4; + for(i=0;irect[i+0],cbuf->rect[i+1],cbuf->rect[i+2],&yuvbuf->rect[i+0], &yuvbuf->rect[i+1], &yuvbuf->rect[i+2]); + } + + //convert key to YUV + rgb_to_yuv(in[1]->vec[0], in[1]->vec[1], in[1]->vec[2], &yuvkey[0], &yuvkey[1], &yuvkey[2]); + + for(i=0;irect[i+0])*(yuvkey[0]-yuvbuf->rect[i+0])+ + (yuvkey[1]-yuvbuf->rect[i+1])*(yuvkey[1]-yuvbuf->rect[i+1])+ + (yuvkey[2]-yuvbuf->rect[i+2])*(yuvkey[2]-yuvbuf->rect[i+2]))rect[i+3]=0.0; + //matte + matte->rect[i+0]=0.0; + matte->rect[i+1]=0.0; + matte->rect[i+2]=0.0; + matte->rect[i+3]=1.0; + + } + else + { + //premultipled + rgbbuf->rect[i+3]=1.0; + //matte + matte->rect[i+0]=1.0; + matte->rect[i+1]=1.0; + matte->rect[i+2]=1.0; + matte->rect[i+3]=1.0; + } + } + + //free the yuv image + free_compbuf(yuvbuf); + + out[0]->data=rgbbuf; + out[1]->data=matte; + + generate_preview(node, rgbbuf); + } + else + { + return; + } +} + +static bNodeType cmp_node_YUV_matte={ + /* type code */ CMP_NODE_YUV_MATTE, + /* name */ "YUV Difference Matte", + /* width+range */ 200, 80, 250, + /* class+opts */ NODE_CLASS_MATTE, NODE_PREVIEW|NODE_OPTIONS, + /* input sock */ cmp_node_YUV_matte_in, + /* output sock */ cmp_node_YUV_matte_out, + /* storage */ "NodeChroma", + /* execfunc */ node_composit_exec_YUV_matte +}; + + +/* ******************* RGB Difference Matte ********************************* */ +static bNodeSocketType cmp_node_diff_matte_in[]={ + {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {-1,0,""}, +}; + +static bNodeSocketType cmp_node_diff_matte_out[]={ + {SOCK_RGBA,0,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {SOCK_VALUE,0,"Matte",0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + {-1,0,""} +}; + +static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + int i; + int use_val=0; + + CompBuf *rgbbuf; + CompBuf *matte; + + //is anything connected? + if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; + //must have an image imput + if(in[0]->data==NULL) return; + //using an image or a color? + if(in[1]->data==NULL) use_val=1; + + if(use_val==0) + { + CompBuf *cbuf1=in[0]->data; + CompBuf *cbuf2=in[1]->data; + //same size? + if(cbuf1->x!=cbuf2->x || cbuf1->y!=cbuf2->y) return; + + NodeChroma *c=node->storage; + rgbbuf=dupalloc_compbuf(cbuf1); + matte=alloc_compbuf(cbuf1->x, cbuf1->y,CB_RGBA,1); + + //find min/max tolerances + float tolerance=c->rt; + int max=cbuf1->x*cbuf1->y*4; + + for(i=0;irect[i+0]-cbuf1->rect[i+0])*(cbuf2->rect[i+0]-cbuf1->rect[i+0])+ + (cbuf2->rect[i+1]-cbuf1->rect[i+1])*(cbuf2->rect[i+1]-cbuf1->rect[i+1])+ + (cbuf2->rect[i+2]-cbuf1->rect[i+2])*(cbuf2->rect[i+2]-cbuf1->rect[i+2]))rect[i+3]=0.0; + //matte + matte->rect[i+0]=0.0; + matte->rect[i+1]=0.0; + matte->rect[i+2]=0.0; + matte->rect[i+3]=1.0; + + } + else + { + //premultipled + rgbbuf->rect[i+3]=1.0; + //matte + matte->rect[i+0]=1.0; + matte->rect[i+1]=1.0; + matte->rect[i+2]=1.0; + matte->rect[i+3]=1.0; + } + } + } + //use the input color + else + { + CompBuf *cbuf1=in[0]->data; + NodeChroma *c=node->storage; + + rgbbuf=dupalloc_compbuf(cbuf1); + matte=alloc_compbuf(cbuf1->x, cbuf1->y,CB_RGBA,1); + float tolerance=c->rt; + + int max=cbuf1->x*cbuf1->y*4; + + for(i=0;ivec[0]-cbuf1->rect[i+0])*(in[1]->vec[0]-cbuf1->rect[i+0])+ + (in[1]->vec[1]-cbuf1->rect[i+1])*(in[1]->vec[1]-cbuf1->rect[i+1])+ + (in[1]->vec[2]-cbuf1->rect[i+2])*(in[1]->vec[2]-cbuf1->rect[i+2]))rect[i+3]=0.0; + //matte + matte->rect[i+0]=0.0; + matte->rect[i+1]=0.0; + matte->rect[i+2]=0.0; + matte->rect[i+3]=1.0; + } + else + { + //premultipled + rgbbuf->rect[i+3]=1.0; + //matte + matte->rect[i+0]=1.0; + matte->rect[i+1]=1.0; + matte->rect[i+2]=1.0; + matte->rect[i+3]=1.0; + } + } + } + + + out[0]->data=rgbbuf; + out[1]->data=matte; + generate_preview(node, rgbbuf); +} + +static bNodeType cmp_node_diff_matte={ + /* type code */ CMP_NODE_DIFF_MATTE, + /* name */ "RGB Difference Matte", + /* width+range */ 200, 80, 250, + /* class+opts */ NODE_CLASS_MATTE, NODE_PREVIEW|NODE_OPTIONS, + /* input sock */ cmp_node_diff_matte_in, + /* output sock */ cmp_node_diff_matte_out, + /* storage */ "NodeChroma", + /* execfunc */ node_composit_exec_diff_matte +}; + +/* ******************* Chroma Matte ********************************* */ +static bNodeSocketType cmp_node_chroma_matte_in[]={ + {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {SOCK_RGBA,1,"Key", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {-1,0,""}, +}; + +static bNodeSocketType cmp_node_chroma_matte_out[]={ + {SOCK_RGBA,0,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {SOCK_VALUE,0,"Matte",0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + {-1,0,""} +}; + + +static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + int i; + + float tolerance; + float ycckey[3]; + + if(out[0]->hasoutput==0 || in[0]->hasinput==0) return; + if(in[0]->data==NULL) return; + + CompBuf *cbuf=in[0]->data; + + //is it an RGBA image or a value + if(cbuf->type==CB_RGBA) + { + NodeChroma *c=node->storage; + tolerance=c->rt; + CompBuf *yccbuf=alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA,1); + CompBuf *rgbbuf=dupalloc_compbuf(cbuf); + CompBuf *matte=alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA,1); + + //convert RGB to YCC + int max=cbuf->x*cbuf->y*4; + for(i=0;irect[i+0],cbuf->rect[i+1],cbuf->rect[i+2],&yccbuf->rect[i+0], &yccbuf->rect[i+1], &yccbuf->rect[i+2]); + } + + //convert key to YCC + rgb_to_ycc(in[1]->vec[0], in[1]->vec[1], in[1]->vec[2], &ycckey[0], &ycckey[1], &ycckey[2]); + + for(i=0;irect[i+0])*(ycckey[0]-yccbuf->rect[i+0])+ + (ycckey[1]-yccbuf->rect[i+1])*(ycckey[1]-yccbuf->rect[i+1])+ + (ycckey[2]-yccbuf->rect[i+2])*(ycckey[2]-yccbuf->rect[i+2]))rect[i+3]=0.0; + //matte + matte->rect[i+0]=0.0; + matte->rect[i+1]=0.0; + matte->rect[i+2]=0.0; + matte->rect[i+3]=1.0; + + } + else + { + //premultipled + rgbbuf->rect[i+3]=1.0; + //matte + matte->rect[i+0]=1.0; + matte->rect[i+1]=1.0; + matte->rect[i+2]=1.0; + matte->rect[i+3]=1.0; + } + } + + //free the ycc image + free_compbuf(yccbuf); + + out[0]->data=rgbbuf; + out[1]->data=matte; + + generate_preview(node, rgbbuf); + } + else + { + return; + } +} + +static bNodeType cmp_node_chroma_matte={ + /* type code */ CMP_NODE_CHROMA_MATTE, + /* name */ "Chroma Difference Matte", + /* width+range */ 200, 80, 250, + /* class+opts */ NODE_CLASS_MATTE, NODE_PREVIEW|NODE_OPTIONS, + /* input sock */ cmp_node_chroma_matte_in, + /* output sock */ cmp_node_chroma_matte_out, + /* storage */ "NodeChroma", + /* execfunc */ node_composit_exec_chroma_matte +}; + +/* ******************* Blue Spill Supression ********************************* */ +static bNodeSocketType cmp_node_blue_spill_in[]={ + {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {-1,0,""}, +}; + +static bNodeSocketType cmp_node_blue_spill_out[]={ + {SOCK_RGBA,0,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {-1,0,""} +}; + + +static void node_composit_exec_blue_spill(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + int i; + + if(out[0]->hasoutput==0 || in[0]->hasinput==0) return; + if(in[0]->data==NULL) return; + + CompBuf *cbuf=in[0]->data; + + //is it an RGBA image or a value + if(cbuf->type==CB_RGBA) + { + CompBuf *rgbbuf=dupalloc_compbuf(cbuf); + + int max=cbuf->x*cbuf->y*4; + + for(i=0;irect[i+2]>cbuf->rect[i+1]) + { + rgbbuf->rect[i+2]=rgbbuf->rect[i+1]; + } + } + out[0]->data=rgbbuf; + } + else + { + return; + } +} + +static bNodeType cmp_node_blue_spill={ + /* type code */ CMP_NODE_BLUE_SPILL, + /* name */ "Blue Spill", + /* width+range */ 80, 40, 140, + /* class+opts */ NODE_CLASS_MATTE, NODE_OPTIONS, + /* input sock */ cmp_node_blue_spill_in, + /* output sock */ cmp_node_blue_spill_out, + /* storage */ "", + /* execfunc */ node_composit_exec_blue_spill +}; + +/* ******************* Green Spill Supression ********************************* */ +static bNodeSocketType cmp_node_green_spill_in[]={ + {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {-1,0,""}, +}; + +static bNodeSocketType cmp_node_green_spill_out[]={ + {SOCK_RGBA,0,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {-1,0,""} +}; + + +static void node_composit_exec_green_spill(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + int i; + + if(out[0]->hasoutput==0 || in[0]->hasinput==0) return; + if(in[0]->data==NULL) return; + + CompBuf *cbuf=in[0]->data; + + //is it an RGBA image or a value + if(cbuf->type==CB_RGBA) + { + CompBuf *rgbbuf=dupalloc_compbuf(cbuf); + + int max=cbuf->x*cbuf->y*4; + + for(i=0;irect[i+1]>cbuf->rect[i+2]) + { + rgbbuf->rect[i+1]=rgbbuf->rect[i+2]; + } + } + out[0]->data=rgbbuf; + } + else + { + return; + } +} + +static bNodeType cmp_node_green_spill={ + /* type code */ CMP_NODE_GREEN_SPILL, + /* name */ "Green Spill", + /* width+range */ 80, 40, 140, + /* class+opts */ NODE_CLASS_MATTE, NODE_OPTIONS, + /* input sock */ cmp_node_green_spill_in, + /* output sock */ cmp_node_green_spill_out, + /* storage */ "", + /* execfunc */ node_composit_exec_green_spill +}; /* ****************** types array for all shaders ****************** */ @@ -2911,10 +3496,17 @@ &cmp_node_rgbtobw, &cmp_node_seprgba, &cmp_node_sephsva, + &cmp_node_sepyuva, &cmp_node_setalpha, &cmp_node_texture, &cmp_node_translate, &cmp_node_zcombine, + &cmp_node_YUV_matte, + &cmp_node_diff_matte, + &cmp_node_chroma_matte, + &cmp_node_blue_spill, + &cmp_node_green_spill, + &cmp_node_sepycca, NULL }; diff -Naur blender2.42/source/blender/blenlib/BLI_arithb.h blender-work/source/blender/blenlib/BLI_arithb.h --- blender2.42/source/blender/blenlib/BLI_arithb.h 2006-06-03 13:21:45.000000000 -0400 +++ blender-work/source/blender/blenlib/BLI_arithb.h 2006-07-17 21:12:44.000000000 -0400 @@ -666,7 +666,13 @@ void hex_to_rgb(char *hexcol, float *r, float *g, float *b); - void +void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv); +void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb); + +void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb); +void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr); + +void rgb_to_hsv( float r, float g, float b, float *lh, float *ls, float *lv diff -Naur blender2.42/source/blender/blenlib/intern/arithb.c blender-work/source/blender/blenlib/intern/arithb.c --- blender2.42/source/blender/blenlib/intern/arithb.c 2006-07-05 00:03:40.000000000 -0400 +++ blender-work/source/blender/blenlib/intern/arithb.c 2006-07-18 01:15:29.000000000 -0400 @@ -2639,6 +2639,61 @@ } } +void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv) +{ + float y, u, v; + y= 0.299*r + 0.587*g + 0.114*b; + u=-0.147*r - 0.289*g + 0.436*b; + v= 0.615*r - 0.515*g - 0.100*b; + + *ly=y; + *lu=u; + *lv=v; +} + +void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb) +{ + float r, g, b; + r=y+1.140*v; + g=y-0.394*u - 0.581*v; + b=y+2.032*u; + + *lr=r; + *lg=g; + *lb=b; +} + +void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr) +{ + float sr,sg, sb; + float y, cr, cb; + + sr=255*r; + sg=255*g; + sb=255*b; + + //y-16, cb-128, cr-128 + y=(0.257*sr)+(0.504*sg)+(0.098*sb)+16; + cb=(-0.148*sr)-(0.291*sg)+(0.439*sb)+128; + cr=(0.439*sr)-(0.368*sg)-(0.071*sb)+128; + + *ly=y; + *lcb=cb; + *lcr=cr; +} + +void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb) +{ + float r,g,b; + + r=1.164*(y-16)+1.596*(cr-128); + g=1.164*(y-16)-0.813*(cr-128)-0.392*(cb-128); + b=1.164*(y-16)+2.017*(cb-128); + + *lr=r/255; + *lg=g/255; + *lb=b/255; +} void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv) { float h, s, v; diff -Naur blender2.42/source/blender/makesdna/DNA_node_types.h blender-work/source/blender/makesdna/DNA_node_types.h --- blender2.42/source/blender/makesdna/DNA_node_types.h 2006-06-17 09:04:09.000000000 -0400 +++ blender-work/source/blender/makesdna/DNA_node_types.h 2006-07-16 14:37:13.000000000 -0400 @@ -196,5 +196,9 @@ float hue, sat; } NodeHueSat; +typedef struct NodeChroma { + float rt, gt, bt; +} NodeChroma; + #endif diff -Naur blender2.42/source/blender/src/drawnode.c blender-work/source/blender/src/drawnode.c --- blender2.42/source/blender/src/drawnode.c 2006-07-03 05:49:12.000000000 -0400 +++ blender-work/source/blender/src/drawnode.c 2006-07-18 02:19:28.000000000 -0400 @@ -986,6 +986,49 @@ } +static int node_composit_buts_YUV_matte(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr) +{ + if(block) + { + NodeChroma *c= node->storage; + uiBlockBeginAlign(block); + + uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Tolerance ", + butr->xmin, butr->ymin, butr->xmax-butr->xmin, 19, + &c->rt, 0.0f, 1.0f, 100, 0, ""); + } + return 19; +} + +static int node_composit_buts_diff_matte(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr) +{ + if(block) + { + NodeChroma *c= node->storage; + uiBlockBeginAlign(block); + + uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Tolerance ", + butr->xmin, butr->ymin, butr->xmax-butr->xmin, 19, + &c->rt, 0.0f, 1.0f, 100, 0, ""); + } + return 19; +} + +static int node_composit_buts_chroma_matte(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr) +{ + if(block) + { + NodeChroma *c= node->storage; + uiBlockBeginAlign(block); + uiDefButF(block, NUMSLI, B_NODE_EXEC+node->nr, "Tolerance ", + butr->xmin, butr->ymin, butr->xmax-butr->xmin, 19, + &c->rt, 0.0f, 255.0f, 100, 0, ""); + } + return 19; +} + + + /* only once called */ static void node_composit_set_butfunc(bNodeType *ntype) { @@ -1044,6 +1087,15 @@ case CMP_NODE_TEXTURE: ntype->butfunc= node_buts_texture; break; + case CMP_NODE_YUV_MATTE: + ntype->butfunc=node_composit_buts_YUV_matte; + break; + case CMP_NODE_DIFF_MATTE: + ntype->butfunc=node_composit_buts_diff_matte; + break; + case CMP_NODE_CHROMA_MATTE: + ntype->butfunc=node_composit_buts_chroma_matte; + break; default: ntype->butfunc= NULL; } diff -Naur blender2.42/source/blender/src/header_node.c blender-work/source/blender/src/header_node.c --- blender2.42/source/blender/src/header_node.c 2006-06-26 07:01:09.000000000 -0400 +++ blender-work/source/blender/src/header_node.c 2006-07-17 13:01:37.000000000 -0400 @@ -368,6 +368,19 @@ return block; } +static uiBlock *node_add_mattemenu(void *arg_unused) +{ + SpaceNode *snode=curarea->spacedata.first; + uiBlock *block; + + block=uiNewBlock(&curarea->uiblocks, "node_add_mattemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); + uiBlockSetButmFunc(block,do_node_addmenu, NULL); + node_make_addmenu(snode, NODE_CLASS_MATTE, block); + uiBlockSetDirection(block, UI_RIGHT); + uiTextBoundsBlock(block,60); + return block; +} + static uiBlock *node_addmenu(void *arg_unused) { SpaceNode *snode= curarea->spacedata.first; @@ -394,6 +407,7 @@ uiDefIconTextBlockBut(block, node_add_filtermenu, NULL, ICON_RIGHTARROW_THIN, "Filter", 0, yco-=20, 120, 19, ""); uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); + uiDefIconTextBlockBut(block, node_add_mattemenu, NULL, ICON_RIGHTARROW_THIN, "Matte", 0, yco-=20, 120,19,""); } else uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); diff -Naur blender2.42/source/blender/src/toolbox.c blender-work/source/blender/src/toolbox.c --- blender2.42/source/blender/src/toolbox.c 2006-07-12 10:51:30.000000000 -0400 +++ blender-work/source/blender/src/toolbox.c 2006-07-17 13:14:07.000000000 -0400 @@ -1526,6 +1526,7 @@ #define TB_CMP_OP_FILTER 4 #define TB_CMP_CONVERTORS 5 #define TB_CMP_GROUPS 6 +#define TB_CMP_MATTE 7 static TBitem tb_node_addcomp[]= { { 0, "Input", 1, NULL}, @@ -1535,6 +1536,7 @@ { 0, "Filters", 5, NULL}, { 0, "Convertors", 6, NULL}, { 0, "Groups", 7, NULL}, + { 0, "Mattes", 8, NULL}, { -1, "", 0, NULL}}; /* do_node_addmenu() in header_node.c, prototype in BSE_headerbuttons.h */ @@ -1918,6 +1920,7 @@ node_add_op_vec= node_add_sublevel(&menu1[TB_CMP_OP_VECTOR].poin, snode->nodetree, NODE_CLASS_OP_VECTOR); node_add_con= node_add_sublevel(&menu1[TB_CMP_CONVERTORS].poin, snode->nodetree, NODE_CLASS_CONVERTOR); node_add_group= node_add_sublevel(&menu1[TB_CMP_GROUPS].poin, snode->nodetree, NODE_CLASS_GROUP); + node_add_group= node_add_sublevel(&menu1[TB_CMP_MATTE].poin,snode->nodetree, NODE_CLASS_MATTE); } dx= 96;