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:
-rw-r--r--source/blender/editors/space_node/drawnode.c9
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c16
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h4
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c145
4 files changed, 159 insertions, 15 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 471e5085c56..75eaa1d4988 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -1017,6 +1017,11 @@ static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C),
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 @@ static void node_composit_set_butfunc(bNodeType *ntype)
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;
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 012954d72ca..0001537bbb9 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -630,6 +630,11 @@ static EnumPropertyItem node_filter_items[] = {
{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,6 +2208,17 @@ static void def_cmp_zcombine(StructRNA *srna)
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 --------------------------------------------------------- */
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index 679a5fc0cdc..e74680280f8 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -76,8 +76,8 @@ DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBR
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", "" )
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
index 4b164729bbc..895d7799796 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
@@ -43,7 +43,7 @@ static bNodeSocketType cmp_node_sepycca_out[]= {
{ -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 @@ static void do_sepycca(bNode *UNUSED(node), float *out, float *in)
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 @@ static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeSta
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 @@ bNodeType cmp_node_sepycca= {
/* 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 @@ bNodeType cmp_node_sepycca= {
/* **************** 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 @@ static bNodeSocketType cmp_node_combycca_out[]= {
{ -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 @@ static void do_comb_ycca(bNode *UNUSED(node), float *out, float *in1, float *in2
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 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt
/* 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 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt
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;
+ 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;
}