|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tbasefx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tnotanimatableparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tflash.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//#define ALLOW_SHEAR
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TGeometryFx::TGeometryFx() { setName(L"Geometry"); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TGeometryFx::compute(TFlash &flash, int frame) {
|
|
Shinya Kitaoka |
120a6e |
flash.multMatrix(getPlacement(frame));
|
|
Shinya Kitaoka |
120a6e |
TRasterFx::compute(flash, frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TGeometryFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
Shinya Kitaoka |
120a6e |
TRasterFxPort *input = dynamic_cast<trasterfxport *="">(getInputPort(0));</trasterfxport>
|
|
Shinya Kitaoka |
120a6e |
assert(input);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!input->isConnected()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!getActiveTimeRegion().contains(frame)) {
|
|
Shinya Kitaoka |
120a6e |
TRasterFxP(input->getFx())->compute(tile, frame, ri);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!TRaster32P(tile.getRaster()) && !TRaster64P(tile.getRaster()))
|
|
Shinya Kitaoka |
120a6e |
throw TException("AffineFx unsupported pixel type");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff1 = getPlacement(frame);
|
|
Shinya Kitaoka |
120a6e |
TRenderSettings ri2(ri);
|
|
Shinya Kitaoka |
120a6e |
ri2.m_affine = ri2.m_affine * aff1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRasterFxP src = getInputPort("source")->getFx();
|
|
Shinya Kitaoka |
120a6e |
src->compute(tile, frame, ri2);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TGeometryFx::doGetBBox(double frame, TRectD &bBox,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &info) {
|
|
Shinya Kitaoka |
120a6e |
TRasterFxPort *input = dynamic_cast<trasterfxport *="">(getInputPort(0));</trasterfxport>
|
|
Shinya Kitaoka |
120a6e |
assert(input);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (input->isConnected()) {
|
|
Shinya Kitaoka |
120a6e |
TRasterFxP fx = input->getFx();
|
|
Shinya Kitaoka |
120a6e |
assert(fx);
|
|
Shinya Kitaoka |
120a6e |
bool ret = fx->doGetBBox(frame, bBox, info);
|
|
Shinya Kitaoka |
120a6e |
if (getActiveTimeRegion().contains(frame))
|
|
Shinya Kitaoka |
120a6e |
bBox = getPlacement(frame) * bBox;
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
bBox = TRectD();
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::string TGeometryFx::getAlias(double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &info) const {
|
|
Shinya Kitaoka |
120a6e |
TGeometryFx *tthis = const_cast<tgeometryfx *="">(this);</tgeometryfx>
|
|
Shinya Kitaoka |
120a6e |
TAffine affine = tthis->getPlacement(frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::string alias = getFxType();
|
|
Shinya Kitaoka |
120a6e |
alias += "[";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// alias degli effetti connessi alle porte di input separati da virgole
|
|
Shinya Kitaoka |
120a6e |
// una porta non connessa da luogo a un alias vuoto (stringa vuota)
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < getInputPortCount(); ++i) {
|
|
Shinya Kitaoka |
120a6e |
TFxPort *port = getInputPort(i);
|
|
Shinya Kitaoka |
120a6e |
if (port->isConnected()) {
|
|
Shinya Kitaoka |
120a6e |
TRasterFxP ifx = port->getFx();
|
|
Shinya Kitaoka |
120a6e |
assert(ifx);
|
|
Shinya Kitaoka |
120a6e |
alias += ifx->getAlias(frame, info);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
alias += ",";
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return alias +
|
|
Shinya Kitaoka |
120a6e |
(areAlmostEqual(affine.a11, 0) ? "0" : ::to_string(affine.a11, 5)) +
|
|
Shinya Kitaoka |
120a6e |
"," +
|
|
Shinya Kitaoka |
120a6e |
(areAlmostEqual(affine.a12, 0) ? "0" : ::to_string(affine.a12, 5)) +
|
|
Shinya Kitaoka |
120a6e |
"," +
|
|
Shinya Kitaoka |
120a6e |
(areAlmostEqual(affine.a13, 0) ? "0" : ::to_string(affine.a13, 5)) +
|
|
Shinya Kitaoka |
120a6e |
"," +
|
|
Shinya Kitaoka |
120a6e |
(areAlmostEqual(affine.a21, 0) ? "0" : ::to_string(affine.a21, 5)) +
|
|
Shinya Kitaoka |
120a6e |
"," +
|
|
Shinya Kitaoka |
120a6e |
(areAlmostEqual(affine.a22, 0) ? "0" : ::to_string(affine.a22, 5)) +
|
|
Shinya Kitaoka |
120a6e |
"," +
|
|
Shinya Kitaoka |
120a6e |
(areAlmostEqual(affine.a23, 0) ? "0" : ::to_string(affine.a23, 5)) +
|
|
Shinya Kitaoka |
120a6e |
"]";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TGeometryFx::transform(double frame, int port, const TRectD &rectOnOutput,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &infoOnOutput,
|
|
Shinya Kitaoka |
120a6e |
TRectD &rectOnInput, TRenderSettings &infoOnInput) {
|
|
Shinya Kitaoka |
120a6e |
rectOnInput = rectOnOutput;
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = getPlacement(frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
infoOnInput = infoOnOutput;
|
|
Shinya Kitaoka |
120a6e |
infoOnInput.m_affine = infoOnInput.m_affine * aff;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
NaAffineFx::NaAffineFx(bool isDpiAffine)
|
|
Shinya Kitaoka |
120a6e |
: m_aff(TAffine()), m_isDpiAffine(isDpiAffine) {
|
|
Shinya Kitaoka |
120a6e |
addInputPort("source", m_port);
|
|
Shinya Kitaoka |
120a6e |
setName(L"Geometry-NaAffineFx");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFx *NaAffineFx::clone(bool recursive) const {
|
|
Shinya Kitaoka |
120a6e |
NaAffineFx *clonedFx = dynamic_cast<naaffinefx *="">(TFx::clone(recursive));</naaffinefx>
|
|
Shinya Kitaoka |
120a6e |
assert(clonedFx);
|
|
Shinya Kitaoka |
120a6e |
clonedFx->m_aff = m_aff;
|
|
Shinya Kitaoka |
120a6e |
clonedFx->m_isDpiAffine = m_isDpiAffine;
|
|
Shinya Kitaoka |
120a6e |
return clonedFx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void NaAffineFx::compute(TFlash &flash, int frame) {
|
|
Shinya Kitaoka |
120a6e |
TGeometryFx::compute(flash, frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRasterFx::compute(TFlash &flash, int frame) {
|
|
Shinya Kitaoka |
120a6e |
for (int i = getInputPortCount() - 1; i >= 0; i--) {
|
|
Shinya Kitaoka |
120a6e |
TFxPort *port = getInputPort(i);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (port->isConnected() && !port->isaControlPort()) {
|
|
Shinya Kitaoka |
120a6e |
flash.pushMatrix();
|
|
Shinya Kitaoka |
120a6e |
((TRasterFxP)(port->getFx()))->compute(flash, frame);
|
|
Shinya Kitaoka |
120a6e |
flash.popMatrix();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_IDENTIFIER_IS_HIDDEN(NaAffineFx, "naAffineFx")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
// Geometric Fx
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class InvertFx : public TBaseRasterFx {
|
|
Shinya Kitaoka |
120a6e |
FX_DECLARATION(InvertFx)
|
|
Shinya Kitaoka |
120a6e |
TRasterFxPort m_input;
|
|
Shinya Kitaoka |
120a6e |
TBoolParamP m_redChan, m_greenChan, m_blueChan, m_alphaChan;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
InvertFx()
|
|
Shinya Kitaoka |
120a6e |
: m_redChan(true)
|
|
Shinya Kitaoka |
120a6e |
, m_greenChan(true)
|
|
Shinya Kitaoka |
120a6e |
, m_blueChan(true)
|
|
Shinya Kitaoka |
120a6e |
, m_alphaChan(false) {
|
|
Shinya Kitaoka |
120a6e |
addInputPort("source", m_input);
|
|
Shinya Kitaoka |
120a6e |
// bindParam(this, "red_channel" , m_redChan);
|
|
Shinya Kitaoka |
120a6e |
// bindParam(this, "green_channel", m_greenChan);
|
|
Shinya Kitaoka |
120a6e |
// bindParam(this, "blue_channel" , m_blueChan);
|
|
Shinya Kitaoka |
120a6e |
// bindParam(this, "alpha_channel", m_alphaChan);
|
|
Shinya Kitaoka |
120a6e |
setName(L"InvertFx");
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~InvertFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool canHandle(const TRenderSettings &info, double frame) override { return true; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
if (m_input.isConnected()) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = m_input->doGetBBox(frame, bBox, info);
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
bBox = TRectD();
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override {
|
|
Shinya Kitaoka |
120a6e |
if (!m_input.isConnected()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_input->compute(tile, frame, ri);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRop::invert(tile.getRaster(), m_redChan->getValue(),
|
|
Shinya Kitaoka |
120a6e |
m_greenChan->getValue(), m_blueChan->getValue(),
|
|
Shinya Kitaoka |
120a6e |
m_alphaChan->getValue());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
// Video Fx
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Geometric
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(ScaleFx, "scaleFx")
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(MoveFx, "moveFx")
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(AffineFx, "affineFx")
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(CropFx, "cropFx")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Color
|
|
Toshihiro Shimizu |
890ddd |
FX_IDENTIFIER(InvertFx, "invertFx")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Video
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(FieldFx, "fieldFx")
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(SwapFieldsFx, "swapFieldsFx")
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(DeInterlaceFx, "deInterlaceFx")
|
|
Shinya Kitaoka |
120a6e |
// FX_IDENTIFIER(InterlaceFx, "interlaceFx")
|