void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *inputSocketImage = this->getInputSocket(0); InputSocket *inputSocketKey = this->getInputSocket(1); OutputSocket *outputSocketImage = this->getOutputSocket(0); OutputSocket *outputSocketMatte = this->getOutputSocket(1); NodeOperation *operation; bNode *editorsnode = getbNode(); NodeChroma *storage = (NodeChroma *)editorsnode->storage; /* work in RGB color space */ if (storage->channel == 1) { operation = new DistanceRGBMatteOperation(); ((DistanceRGBMatteOperation *) operation)->setSettings(storage); inputSocketImage->relinkConnections(operation->getInputSocket(0), 0, graph); inputSocketKey->relinkConnections(operation->getInputSocket(1), 1, graph); } /* work in YCbCr color space */ else { operation = new DistanceYCCMatteOperation(); ((DistanceYCCMatteOperation *) operation)->setSettings(storage); ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation(); inputSocketImage->relinkConnections(operationYCCImage->getInputSocket(0), 0, graph); addLink(graph, operationYCCImage->getOutputSocket(), operation->getInputSocket(0)); graph->addOperation(operationYCCImage); ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation(); inputSocketKey->relinkConnections(operationYCCMatte->getInputSocket(0), 1, graph); addLink(graph, operationYCCMatte->getOutputSocket(), operation->getInputSocket(1)); graph->addOperation(operationYCCMatte); } if (outputSocketMatte->isConnected()) { outputSocketMatte->relinkConnections(operation->getOutputSocket()); } graph->addOperation(operation); SetAlphaOperation *operationAlpha = new SetAlphaOperation(); addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); graph->addOperation(operationAlpha); addPreviewOperation(graph, context, operationAlpha->getOutputSocket()); if (outputSocketImage->isConnected()) { outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); } }
OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage) { ConvertRGBToYCCOperation *convertRGBToYCCOperation = new ConvertRGBToYCCOperation(); convertRGBToYCCOperation->setMode(0); /* ITU 601 */ inputImage->relinkConnections(convertRGBToYCCOperation->getInputSocket(0), 0, graph); graph->addOperation(convertRGBToYCCOperation); CombineChannelsOperation *combineOperation = new CombineChannelsOperation(); graph->addOperation(combineOperation); for (int channel = 0; channel < 4; channel++) { SeparateChannelOperation *separateOperation = new SeparateChannelOperation(); separateOperation->setChannel(channel); addLink(graph, convertRGBToYCCOperation->getOutputSocket(0), separateOperation->getInputSocket(0)); graph->addOperation(separateOperation); if (channel == 0 || channel == 3) { addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); } else { KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); blurXOperation->setSize(size); blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); blurXOperation->setbNode(this->getbNode()); blurYOperation->setSize(size); blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); blurYOperation->setbNode(this->getbNode()); addLink(graph, separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0)); addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); addLink(graph, blurYOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); graph->addOperation(blurXOperation); graph->addOperation(blurYOperation); } } ConvertYCCToRGBOperation *convertYCCToRGBOperation = new ConvertYCCToRGBOperation(); convertYCCToRGBOperation->setMode(0); /* ITU 601 */ addLink(graph, combineOperation->getOutputSocket(0), convertYCCToRGBOperation->getInputSocket(0)); graph->addOperation(convertYCCToRGBOperation); *originalImage = convertRGBToYCCOperation->getInputSocket(0)->getConnection()->getFromSocket(); return convertYCCToRGBOperation->getOutputSocket(0); }
void DistanceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const { bNode *editorsnode = getbNode(); NodeChroma *storage = (NodeChroma *)editorsnode->storage; NodeInput *inputSocketImage = this->getInputSocket(0); NodeInput *inputSocketKey = this->getInputSocket(1); NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *outputSocketMatte = this->getOutputSocket(1); SetAlphaOperation *operationAlpha = new SetAlphaOperation(); converter.addOperation(operationAlpha); /* work in RGB color space */ NodeOperation *operation; if (storage->channel == 1) { DistanceRGBMatteOperation *matte = new DistanceRGBMatteOperation(); matte->setSettings(storage); converter.addOperation(matte); converter.mapInputSocket(inputSocketImage, matte->getInputSocket(0)); converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); converter.mapInputSocket(inputSocketKey, matte->getInputSocket(1)); operation = matte; } /* work in YCbCr color space */ else { DistanceYCCMatteOperation *matte = new DistanceYCCMatteOperation(); matte->setSettings(storage); converter.addOperation(matte); ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation(); ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation(); operationYCCImage->setMode(0); /* BLI_YCC_ITU_BT601 */ operationYCCMatte->setMode(0); /* BLI_YCC_ITU_BT601 */ converter.addOperation(operationYCCImage); converter.addOperation(operationYCCMatte); converter.mapInputSocket(inputSocketImage, operationYCCImage->getInputSocket(0)); converter.addLink(operationYCCImage->getOutputSocket(), matte->getInputSocket(0)); converter.addLink(operationYCCImage->getOutputSocket(), operationAlpha->getInputSocket(0)); converter.mapInputSocket(inputSocketKey, operationYCCMatte->getInputSocket(0)); converter.addLink(operationYCCMatte->getOutputSocket(), matte->getInputSocket(1)); operation = matte; } converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); if (storage->channel != 1) { ConvertYCCToRGBOperation *inv_convert = new ConvertYCCToRGBOperation(); inv_convert->setMode(0); /* BLI_YCC_ITU_BT601 */ converter.addOperation(inv_convert); converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0)); converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket()); } else { converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); } converter.addPreview(operationAlpha->getOutputSocket()); }