static void node_composit_exec_combyuva(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { /* stack order out: 1 rgba channels */ /* stack order in: 4 value channels */ /* input no image? then only color operation */ if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { out[0]->vec[0] = in[0]->vec[0]; out[0]->vec[1] = in[1]->vec[0]; out[0]->vec[2] = in[2]->vec[0]; out[0]->vec[3] = in[3]->vec[0]; } else { /* make output size of first available input image */ CompBuf *cbuf; CompBuf *stackbuf; /* allocate a CompBuf the size of the first available input */ if (in[0]->data) cbuf = in[0]->data; else if (in[1]->data) cbuf = in[1]->data; else if (in[2]->data) cbuf = in[2]->data; else cbuf = in[3]->data; stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, do_comb_yuva, CB_VAL, CB_VAL, CB_VAL, CB_VAL); out[0]->data= stackbuf; } }
static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { /* stack order out: 1 ycca channels */ /* stack order in: 4 value channels */ /* input no image? then only color operation */ if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { float y = in[0]->vec[0] * 255; float cb = in[1]->vec[0] * 255; float cr = in[2]->vec[0] * 255; switch(node->custom1) { case 1: ycc_to_rgb(y, cb, cr, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2], BLI_YCC_ITU_BT709); break; case 2: ycc_to_rgb(y, cb, cr, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2], BLI_YCC_JFIF_0_255); break; case 0: default: ycc_to_rgb(y, cb, cr, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2], BLI_YCC_ITU_BT601); break; } out[0]->vec[3] = in[3]->vec[0]; } else { /* make output size of first available input image */ CompBuf *cbuf; CompBuf *stackbuf; /* allocate a CompBuf the size of the first available input */ if (in[0]->data) cbuf = in[0]->data; else if (in[1]->data) cbuf = in[1]->data; else if (in[2]->data) cbuf = in[2]->data; else cbuf = in[3]->data; stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ switch(node->custom1) { case 1: composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, do_comb_ycca_709, CB_VAL, CB_VAL, CB_VAL, CB_VAL); break; case 2: composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, do_comb_ycca_jfif, CB_VAL, CB_VAL, CB_VAL, CB_VAL); break; case 0: default: composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, do_comb_ycca_601, CB_VAL, CB_VAL, CB_VAL, CB_VAL); break; } out[0]->data= stackbuf; } }
static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { RenderData *rd= data; CompBuf *cbuf= in[0]->data; CompBuf *zbuf; /* stack order in: col z col z */ /* stack order out: col z */ if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; /* no input image; do nothing now */ if (in[0]->data==NULL) { return; } if (out[1]->hasoutput) { /* copy or make a buffer for for the first z value, here we write result in */ if (in[1]->data) zbuf= dupalloc_compbuf(in[1]->data); else { float *zval; int tot= cbuf->x*cbuf->y; zbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); for (zval= zbuf->rect; tot; tot--, zval++) *zval= in[1]->vec[0]; } /* lazy coder hack */ node->custom2= 1; out[1]->data= zbuf; } else { node->custom2= 0; zbuf= in[1]->data; } if (rd->scemode & R_FULL_SAMPLE) { /* make output size of first input image */ CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, zbuf, in[1]->vec, in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, do_zcombine, CB_RGBA, CB_VAL, CB_RGBA, CB_VAL); out[0]->data= stackbuf; } else { /* make output size of first input image */ CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ CompBuf *mbuf; float *fp; int x; char *aabuf; /* make a mask based on comparison, optionally write zvalue */ mbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); composit2_pixel_processor(node, mbuf, zbuf, in[1]->vec, in[3]->data, in[3]->vec, do_zcombine_mask, CB_VAL, CB_VAL); /* convert to char */ aabuf= MEM_mallocN(cbuf->x*cbuf->y, "aa buf"); fp= mbuf->rect; for (x= cbuf->x*cbuf->y-1; x>=0; x--) if (fp[x]==0.0f) aabuf[x]= 0; else aabuf[x]= 255; antialias_tagbuf(cbuf->x, cbuf->y, aabuf); /* convert to float */ fp= mbuf->rect; for (x= cbuf->x*cbuf->y-1; x>=0; x--) if (aabuf[x]>1) fp[x]= (1.0f/255.0f)*(float)aabuf[x]; composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[2]->data, in[2]->vec, mbuf, NULL, do_zcombine_add, CB_RGBA, CB_RGBA, CB_VAL); /* free */ free_compbuf(mbuf); MEM_freeN(aabuf); out[0]->data= stackbuf; } }