Revision: 33645
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33645
Author: xat
Date: 2010-12-13 22:17:00 +0100 (Mon, 13 Dec 2010)
Log Message:
-----------
Compositor: Add an option to select the YCbCR conversion mode for the YCbCR
combine/separate nodes.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_node/drawnode.c
trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
trunk/blender/source/blender/makesrna/intern/rna_nodetree_types.h
trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c 2010-12-13
19:10:35 UTC (rev 33644)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c 2010-12-13
21:17:00 UTC (rev 33645)
@@ -1017,6 +1017,11 @@
uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0);
}
+static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C),
PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "mode", 0, "", 0);
+}
+
/* only once called */
static void node_composit_set_butfunc(bNodeType *ntype)
{
@@ -1161,6 +1166,10 @@
case CMP_NODE_ZCOMBINE:
ntype->uifunc=node_composit_buts_zcombine;
break;
+ case CMP_NODE_COMBYCCA:
+ case CMP_NODE_SEPYCCA:
+ ntype->uifunc=node_composit_buts_ycc;
+ break;
default:
ntype->uifunc= NULL;
}
Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2010-12-13
19:10:35 UTC (rev 33644)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2010-12-13
21:17:00 UTC (rev 33645)
@@ -630,6 +630,11 @@
{6, "SHADOW", 0, "Shadow", ""},
{0, NULL, 0, NULL, NULL}};
+static EnumPropertyItem node_ycc_items[] = {
+{ 0, "ITUBT601", 0, "ITU 601", ""},
+{ 1, "ITUBT709", 0, "ITU 709", ""},
+{ 2, "JFIF", 0, "Jpeg", ""},
+{0, NULL, 0, NULL, NULL}};
#define MaxNodes 1000
@@ -2203,7 +2208,18 @@
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
}
+static void def_cmp_ycc(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, node_ycc_items);
+ RNA_def_property_ui_text(prop, "Mode", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
/* -- Texture Nodes ---------------------------------------------------------
*/
static void def_tex_output(StructRNA *srna)
Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree_types.h
2010-12-13 19:10:35 UTC (rev 33644)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree_types.h
2010-12-13 21:17:00 UTC (rev 33645)
@@ -76,8 +76,8 @@
DefNode( CompositorNode, CMP_NODE_DILATEERODE, def_cmp_dilate_erode,
"DILATEERODE", DilateErode, "Dilate/Erode", "" )
DefNode( CompositorNode, CMP_NODE_ROTATE, def_cmp_rotate,
"ROTATE", Rotate, "Rotate", "" )
DefNode( CompositorNode, CMP_NODE_SCALE, def_cmp_scale,
"SCALE", Scale, "Scale", "" )
-DefNode( CompositorNode, CMP_NODE_SEPYCCA, 0,
"SEPYCCA", SepYCCA, "Separate YCCA", "" )
-DefNode( CompositorNode, CMP_NODE_COMBYCCA, 0,
"COMBYCCA", CombYCCA, "Combine YCCA", "" )
+DefNode( CompositorNode, CMP_NODE_SEPYCCA, def_cmp_ycc,
"SEPYCCA", SepYCCA, "Separate YCCA", "" )
+DefNode( CompositorNode, CMP_NODE_COMBYCCA, def_cmp_ycc,
"COMBYCCA", CombYCCA, "Combine YCCA", "" )
DefNode( CompositorNode, CMP_NODE_SEPYUVA, 0,
"SEPYUVA", SepYUVA, "Separate YUVA", "" )
DefNode( CompositorNode, CMP_NODE_COMBYUVA, 0,
"COMBYUVA", CombYUVA, "Combine YUVA", "" )
DefNode( CompositorNode, CMP_NODE_DIFF_MATTE, def_cmp_diff_matte,
"DIFF_MATTE", DiffMatte, "Difference Key", "" )
Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
2010-12-13 19:10:35 UTC (rev 33644)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
2010-12-13 21:17:00 UTC (rev 33645)
@@ -43,7 +43,7 @@
{ -1, 0, "" }
};
-static void do_sepycca(bNode *UNUSED(node), float *out, float *in)
+static void do_sepycca_601(bNode *UNUSED(node), float *out, float *in)
{
float y, cb, cr;
@@ -56,13 +56,51 @@
out[3]= in[3];
}
+static void do_sepycca_709(bNode *UNUSED(node), float *out, float *in)
+{
+ float y, cb, cr;
+
+ rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_ITU_BT709);
+
+ /*divided by 255 to normalize for viewing in */
+ out[0]= y/255.0;
+ out[1]= cb/255.0;
+ out[2]= cr/255.0;
+ out[3]= in[3];
+}
+
+static void do_sepycca_jfif(bNode *UNUSED(node), float *out, float *in)
+{
+ float y, cb, cr;
+
+ rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_JFIF_0_255);
+
+ /*divided by 255 to normalize for viewing in */
+ out[0]= y/255.0;
+ out[1]= cb/255.0;
+ out[2]= cr/255.0;
+ out[3]= in[3];
+}
+
static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node,
bNodeStack **in, bNodeStack **out)
{
/* 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, BLI_YCC_ITU_BT601);
+ switch(node->custom1)
+ {
+ case 1:
+ rgb_to_ycc(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2],
&y, &cb, &cr, BLI_YCC_ITU_BT709);
+ break;
+ case 2:
+ rgb_to_ycc(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2],
&y, &cb, &cr, BLI_YCC_JFIF_0_255);
+ break;
+ case 0:
+ default:
+ rgb_to_ycc(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2],
&y, &cb, &cr, BLI_YCC_ITU_BT601);
+ break;
+ }
/*divided by 255 to normalize for viewing in */
out[0]->vec[0] = y/255.0;
@@ -76,7 +114,19 @@
CompBuf *cbuf2=typecheck_compbuf(cbuf, CB_RGBA);
/* convert the RGB stackbuf to an HSV representation */
- composit1_pixel_processor(node, cbuf2, cbuf2, in[0]->vec,
do_sepycca, CB_RGBA);
+ switch(node->custom1)
+ {
+ case 1:
+ composit1_pixel_processor(node, cbuf2, cbuf2,
in[0]->vec, do_sepycca_709, CB_RGBA);
+ break;
+ case 2:
+ composit1_pixel_processor(node, cbuf2, cbuf2,
in[0]->vec, do_sepycca_jfif, CB_RGBA);
+ break;
+ case 0:
+ default:
+ composit1_pixel_processor(node, cbuf2, cbuf2,
in[0]->vec, do_sepycca_601, CB_RGBA);
+ break;
+ }
/* separate each of those channels */
if(out[0]->hasoutput)
@@ -100,7 +150,7 @@
/* type code */ CMP_NODE_SEPYCCA,
/* name */ "Separate YCbCrA",
/* width+range */ 80, 40, 140,
- /* class+opts */ NODE_CLASS_CONVERTOR, 0,
+ /* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS,
/* input sock */ cmp_node_sepycca_in,
/* output sock */ cmp_node_sepycca_out,
/* storage */ "",
@@ -116,8 +166,8 @@
/* **************** COMBINE YCCA ******************** */
static bNodeSocketType cmp_node_combycca_in[]= {
{ SOCK_VALUE, 1, "Y", 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f},
- { SOCK_VALUE, 1, "Cb", 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f},
- { SOCK_VALUE, 1, "Cr", 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f},
+ { SOCK_VALUE, 1, "Cb", 0.5f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f},
+ { SOCK_VALUE, 1, "Cr", 0.5f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f},
{ SOCK_VALUE, 1, "A", 1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f},
{ -1, 0, "" }
};
@@ -126,7 +176,7 @@
{ -1, 0, "" }
};
-static void do_comb_ycca(bNode *UNUSED(node), float *out, float *in1, float
*in2, float *in3, float *in4)
+static void do_comb_ycca_601(bNode *UNUSED(node), float *out, float *in1,
float *in2, float *in3, float *in4)
{
float r,g,b;
float y, cb, cr;
@@ -144,6 +194,42 @@
out[3] = in4[0];
}
+static void do_comb_ycca_709(bNode *UNUSED(node), float *out, float *in1,
float *in2, float *in3, float *in4)
+{
+ float r,g,b;
+ float y, cb, cr;
+
+ /*need to un-normalize the data*/
+ y=in1[0]*255;
+ cb=in2[0]*255;
+ cr=in3[0]*255;
+
+ ycc_to_rgb(y,cb,cr, &r, &g, &b, BLI_YCC_ITU_BT709);
+
+ out[0] = r;
+ out[1] = g;
+ out[2] = b;
+ out[3] = in4[0];
+}
+
+static void do_comb_ycca_jfif(bNode *UNUSED(node), float *out, float *in1,
float *in2, float *in3, float *in4)
+{
+ float r,g,b;
+ float y, cb, cr;
+
+ /*need to un-normalize the data*/
+ y=in1[0]*255;
+ cb=in2[0]*255;
+ cr=in3[0]*255;
+
+ ycc_to_rgb(y,cb,cr, &r, &g, &b, BLI_YCC_JFIF_0_255);
+
+ out[0] = r;
+ out[1] = g;
+ out[2] = b;
+ out[3] = in4[0];
+}
+
static void node_composit_exec_combycca(void *UNUSED(data), bNode *node,
bNodeStack **in, bNodeStack **out)
{
/* stack order out: 1 ycca channels */
@@ -151,9 +237,24 @@
/* 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];
+ 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 {
@@ -169,9 +270,27 @@
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_ycca,
CB_VAL, CB_VAL, CB_VAL, CB_VAL);
+
+ 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;
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs