|
Toshihiro Shimizu |
890ddd |
#if defined _WIN32 && !defined NOMINMAX
|
|
Toshihiro Shimizu |
890ddd |
#define NOMINMAX
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <sstream> /* std::ostringstream */</sstream>
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxattributes.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ino_common.h"
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
class ino_motion_blur : public TStandardRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_DECLARATION(ino_motion_blur)
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_input;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TIntEnumParamP m_depend_move;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_x1;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_y1;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_x2;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_y2;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_scale;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_curve;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_zanzo_length;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_zanzo_power;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_alpha_rendering;
|
|
Toshihiro Shimizu |
890ddd |
// TBoolParamP m_spread;
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
ino_motion_blur()
|
|
Toshihiro Shimizu |
890ddd |
: m_depend_move(new TIntEnumParam(0, "P1 -> P2")), m_x1(0.0), m_y1(0.0), m_x2(1.0), m_y2(1.0), m_scale(1.0 * ino::param_range()), m_curve(1.0 * ino::param_range()), m_zanzo_length(0.0), m_zanzo_power(1.0 * ino::param_range()), m_alpha_rendering(true)
|
|
Toshihiro Shimizu |
890ddd |
// , m_spread(true)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
this->m_x1->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
this->m_y1->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
this->m_x2->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
this->m_y2->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
this->m_zanzo_length->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Source", this->m_input);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "depend_move", this->m_depend_move);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "x1", this->m_x1);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "y1", this->m_y1);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "x2", this->m_x2);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "y2", this->m_y2);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "scale", this->m_scale);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "curve", this->m_curve);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "zanzo_length", this->m_zanzo_length);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "zanzo_power", this->m_zanzo_power);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "alpha_rendering",
|
|
Toshihiro Shimizu |
890ddd |
this->m_alpha_rendering);
|
|
Toshihiro Shimizu |
890ddd |
// bindParam(this,"spread", this->m_spread);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->m_depend_move->addItem(1, "Motion");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->m_curve->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.1 * ino::param_range(), 10.0 * ino::param_range()); /* gamma値 */
|
|
Toshihiro Shimizu |
890ddd |
this->m_zanzo_length->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.0,
|
|
Toshihiro Shimizu |
890ddd |
1000.0);
|
|
Toshihiro Shimizu |
890ddd |
this->m_zanzo_power->setValueRange(
|
|
Toshihiro Shimizu |
890ddd |
0.0 * ino::param_range(),
|
|
Toshihiro Shimizu |
890ddd |
1.0 * ino::param_range());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
this->getAttributes()->setIsSpeedAware(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
void get_render_vector(
|
|
Toshihiro Shimizu |
890ddd |
const double frame, const TAffine affine, TPointD &rend_vect)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*--- ベクトルを得て、render用単位にする ---*/
|
|
Toshihiro Shimizu |
890ddd |
if (0 == this->m_depend_move->getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
rend_vect.x = this->m_x2->getValue(frame) -
|
|
Toshihiro Shimizu |
890ddd |
this->m_x1->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
rend_vect.y = this->m_y2->getValue(frame) -
|
|
Toshihiro Shimizu |
890ddd |
this->m_y1->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
rend_vect = rend_vect * ino::pixel_per_mm();
|
|
Toshihiro Shimizu |
890ddd |
/* 単位変換(mm --> render_pixel) */
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
rend_vect = -this->getAttributes()->getSpeed();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- 回転と拡大縮小のGeometryを反映させる ---*/
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
toonz/main/sources/stdfx/motionblurfx.cpp
|
|
Toshihiro Shimizu |
890ddd |
750-768行を参照して書いた
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
TAffine aff(affine);
|
|
Toshihiro Shimizu |
890ddd |
aff.a13 = aff.a23 = 0; /* 移動変換をしないで... */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
rend_vect = aff * rend_vect;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- ユーザー指定による、強弱を付加する ---*/
|
|
Toshihiro Shimizu |
890ddd |
rend_vect = rend_vect * (this->m_scale->getValue(frame) / ino::param_range());
|
|
Toshihiro Shimizu |
890ddd |
/*--- shrinkはGeometry(affine)に含まれる...らしい ---*/
|
|
Toshihiro Shimizu |
890ddd |
// rend_vect = rend_vect
|
|
Toshihiro Shimizu |
890ddd |
// * (1.0 / ((info.m_shrinkX + info.m_shrinkY)/2.));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int get_render_margin(
|
|
Toshihiro Shimizu |
890ddd |
const double frame, const TAffine affine)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD rend_vect;
|
|
Toshihiro Shimizu |
890ddd |
this->get_render_vector(frame, affine, rend_vect);
|
|
Toshihiro Shimizu |
890ddd |
return static_cast<int>(ceil(</int>
|
|
Toshihiro Shimizu |
890ddd |
(fabs(rend_vect.x) < fabs(rend_vect.y))
|
|
Toshihiro Shimizu |
890ddd |
? fabs(rend_vect.y)
|
|
Toshihiro Shimizu |
890ddd |
: fabs(rend_vect.x)) +
|
|
Toshihiro Shimizu |
890ddd |
0.5);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void get_render_enlarge(
|
|
Toshihiro Shimizu |
890ddd |
const double frame, const TAffine affine, TRectD &bBox)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const int margin = this->get_render_margin(frame, affine);
|
|
Toshihiro Shimizu |
890ddd |
if (0 < margin) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = bBox.enlarge(static_cast<double>(margin));</double>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(
|
|
Toshihiro Shimizu |
890ddd |
double frame, TRectD &bBox, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (false == this->m_input.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = TRectD();
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
const bool ret = this->m_input->doGetBBox(frame, bBox, info);
|
|
Toshihiro Shimizu |
890ddd |
this->get_render_enlarge(frame, info.m_affine, bBox);
|
|
Toshihiro Shimizu |
890ddd |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getMemoryRequirement(
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &rect, double frame, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD bBox(rect);
|
|
Toshihiro Shimizu |
890ddd |
this->get_render_enlarge(frame, info.m_affine, bBox);
|
|
Toshihiro Shimizu |
890ddd |
return TRasterFx::memorySize(bBox, info.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void transform(
|
|
Toshihiro Shimizu |
890ddd |
double frame, int port, const TRectD &rectOnOutput, const TRenderSettings &infoOnOutput, TRectD &rectOnInput, TRenderSettings &infoOnInput)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
rectOnInput = rectOnOutput;
|
|
Toshihiro Shimizu |
890ddd |
infoOnInput = infoOnOutput;
|
|
Toshihiro Shimizu |
890ddd |
this->get_render_enlarge(
|
|
Toshihiro Shimizu |
890ddd |
frame, infoOnOutput.m_affine, rectOnInput);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &info, double frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (0 == this->m_depend_move->getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
return isAlmostIsotropic(info.m_affine) ||
|
|
Toshihiro Shimizu |
890ddd |
m_scale->getValue(frame) == 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rend_sets);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(ino_motion_blur, "inoMotionBlurFx");
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#include "igs_motion_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
template <class class="" t="" u,=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void arr_to_ras_(
|
|
Toshihiro Shimizu |
890ddd |
const U *arr, const int channels, TRasterPT<t> ras, const int margin)</t>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
arr += (ras->getLx() + margin + margin) * margin * channels +
|
|
Toshihiro Shimizu |
890ddd |
margin * channels;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int yy = 0; yy < ras->getLy(); ++yy, arr += (ras->getLx() + margin + margin) * channels) {
|
|
Toshihiro Shimizu |
890ddd |
const U *arrx = arr;
|
|
Toshihiro Shimizu |
890ddd |
T *ras_sl = ras->pixels(yy);
|
|
Toshihiro Shimizu |
890ddd |
for (int xx = 0; xx < ras->getLx(); ++xx, arrx += channels) {
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].b = arrx[0];
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].g = arrx[1];
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].r = arrx[2];
|
|
Toshihiro Shimizu |
890ddd |
ras_sl[xx].m = arrx[3];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void vec_to_ras_(
|
|
Toshihiro Shimizu |
890ddd |
unsigned char *vec, const int channels, TRasterP ras, const int margin)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if ((TRaster32P)ras) {
|
|
Toshihiro Shimizu |
890ddd |
arr_to_ras_<unsigned char,="" tpixel32="">(</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
vec, channels, ras, margin);
|
|
Toshihiro Shimizu |
890ddd |
} else if ((TRaster64P)ras) {
|
|
Toshihiro Shimizu |
890ddd |
arr_to_ras_<unsigned short,="" tpixel64="">(</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
reinterpret_cast<unsigned *="" short="">(vec), channels, ras, margin);</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void fx_(
|
|
Toshihiro Shimizu |
890ddd |
const TRasterP in_ras // with margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int margin, TRasterP out_ras // no margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const double x_vector, const double y_vector, const double scale, const double curve, const int zanzo_length, const double zanzo_power, const bool alp_rend_sw)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/******
|
|
Toshihiro Shimizu |
890ddd |
std::vector<unsigned char=""> in_vec;</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
ino::ras_to_vec( in_ras, ino::channels(), in_vec );
|
|
Toshihiro Shimizu |
890ddd |
std::vector<unsigned char=""> out_vec(in_vec.size());</unsigned>
|
|
Toshihiro Shimizu |
890ddd |
******/
|
|
Toshihiro Shimizu |
890ddd |
/*** int out_size = in_ras->getLy()*in_ras->getLx()*ino::channels();
|
|
Toshihiro Shimizu |
890ddd |
if ((TRaster64P)in_ras) { out_size *= sizeof(unsigned short) ; }
|
|
Toshihiro Shimizu |
890ddd |
TRasterGR8P out_byt(out_size, 1);
|
|
Toshihiro Shimizu |
890ddd |
//TRasterGR8P out_byt; out_byt->create(out_size, 1);
|
|
Toshihiro Shimizu |
890ddd |
//TRasterP out_byt = TRasterGR8P(out_size, 1);
|
|
Toshihiro Shimizu |
890ddd |
out_byt->lock();
|
|
Toshihiro Shimizu |
890ddd |
if (0 == out_byt->getRawData()) {
|
|
Toshihiro Shimizu |
890ddd |
throw TRopException("Can not get TRasterGR8P->getRawData()");
|
|
Toshihiro Shimizu |
890ddd |
}***/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterGR8P out_gr8(
|
|
Toshihiro Shimizu |
890ddd |
in_ras->getLy(), in_ras->getLx() * ino::channels() *
|
|
Toshihiro Shimizu |
890ddd |
((TRaster64P)in_ras ? sizeof(unsigned short) : sizeof(unsigned char)));
|
|
Toshihiro Shimizu |
890ddd |
out_gr8->lock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
igs::motion_blur::convert(
|
|
Toshihiro Shimizu |
890ddd |
in_ras->getRawData() // BGRA
|
|
Toshihiro Shimizu |
890ddd |
//&in_vec.at(0) // RGBA
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//, out_byt->getRawData() // BGRA
|
|
Toshihiro Shimizu |
890ddd |
//, &out_vec.at(0) // RGBA
|
|
Toshihiro Shimizu |
890ddd |
//, out_ras->getRawData() // BGRA
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
out_gr8->getRawData()
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(in_ras)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
x_vector, y_vector, scale, curve, zanzo_length, zanzo_power, alp_rend_sw);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/******
|
|
Toshihiro Shimizu |
890ddd |
ino::vec_to_ras( out_vec, ino::channels(), out_ras, margin );
|
|
Toshihiro Shimizu |
890ddd |
in_vec.clear();
|
|
Toshihiro Shimizu |
890ddd |
******/
|
|
Toshihiro Shimizu |
890ddd |
/***vec_to_ras_(out_byt->getRawData(),ino::channels(),out_ras,margin);
|
|
Toshihiro Shimizu |
890ddd |
out_byt->unlock();***/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ino::arr_to_ras(
|
|
Toshihiro Shimizu |
890ddd |
out_gr8->getRawData(), ino::channels(), out_ras, margin);
|
|
Toshihiro Shimizu |
890ddd |
out_gr8->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
void ino_motion_blur::doCompute(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rend_sets)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 接続していなければ処理しない -------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (!this->m_input.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear(); /* 塗りつぶしクリア */
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ サポートしていないPixelタイプはエラーを投げる --- */
|
|
Toshihiro Shimizu |
890ddd |
if (!((TRaster32P)tile.getRaster()) &&
|
|
Toshihiro Shimizu |
890ddd |
!((TRaster64P)tile.getRaster())) {
|
|
Toshihiro Shimizu |
890ddd |
throw TRopException("unsupported input pixel type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ Render(Pixel)単位で動作パラメータを得る --------- */
|
|
Toshihiro Shimizu |
890ddd |
const int depend_move = this->m_depend_move->getValue();
|
|
Toshihiro Shimizu |
890ddd |
const double scale = this->m_scale->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const double curve = this->m_curve->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const int zanzo_length = this->m_zanzo_length->getValue(frame) *
|
|
Toshihiro Shimizu |
890ddd |
ino::pixel_per_mm() * sqrt(fabs(rend_sets.m_affine.det())) / ((rend_sets.m_shrinkX + rend_sets.m_shrinkY) / 2.0);
|
|
Toshihiro Shimizu |
890ddd |
const double zanzo_power = this->m_zanzo_power->getValue(frame) /
|
|
Toshihiro Shimizu |
890ddd |
ino::param_range();
|
|
Toshihiro Shimizu |
890ddd |
const bool alp_rend_sw = this->m_alpha_rendering->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 実際に処理するぼかしの方向vectorを生成 ---------- */
|
|
Toshihiro Shimizu |
890ddd |
TPointD rend_vect;
|
|
Toshihiro Shimizu |
890ddd |
this->get_render_vector(frame, rend_sets.m_affine, rend_vect);
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 参照マージンの大きさを得る ---------------------- */
|
|
Toshihiro Shimizu |
890ddd |
const int margin = static_cast<int>(ceil(</int>
|
|
Toshihiro Shimizu |
890ddd |
(fabs(rend_vect.x) < fabs(rend_vect.y))
|
|
Toshihiro Shimizu |
890ddd |
? fabs(rend_vect.y)
|
|
Toshihiro Shimizu |
890ddd |
: fabs(rend_vect.x)) +
|
|
Toshihiro Shimizu |
890ddd |
0.5);
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 参照マージン含めた画像を生成 -------------------- */
|
|
Toshihiro Shimizu |
890ddd |
TRectD bBox = TRectD(
|
|
Toshihiro Shimizu |
890ddd |
tile.m_pos /* Render画像上(Pixel単位)の位置 */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
TDimensionD(/* Render画像上(Pixel単位)のサイズ */
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->getLx(), tile.getRaster()->getLy()));
|
|
Toshihiro Shimizu |
890ddd |
if (0 < margin) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = bBox.enlarge(static_cast<double>(margin));</double>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTile enlarge_tile;
|
|
Toshihiro Shimizu |
890ddd |
this->m_input->allocateAndCompute(
|
|
Toshihiro Shimizu |
890ddd |
enlarge_tile, bBox.getP00(), TDimensionI(/* Pixel単位のdouble -> intにしてセット */
|
|
Toshihiro Shimizu |
890ddd |
static_cast<int>(bBox.getLx() + 0.5), static_cast<int>(bBox.getLy() + 0.5)),</int></int>
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster(), frame, rend_sets);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 保存すべき画像メモリを塗りつぶしクリア ---------- */
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear(); /* 塗りつぶしクリア */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ (app_begin)log記憶 ------------------------------ */
|
|
Toshihiro Shimizu |
890ddd |
const bool log_sw = ino::log_enable_sw();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::ostringstream os;
|
|
Toshihiro Shimizu |
890ddd |
os << "params"
|
|
Toshihiro Shimizu |
890ddd |
<< " depend_move_num " << depend_move
|
|
Toshihiro Shimizu |
890ddd |
<< " render_vector x " << rend_vect.x
|
|
Toshihiro Shimizu |
890ddd |
<< " y " << rend_vect.y
|
|
Toshihiro Shimizu |
890ddd |
<< " margin " << margin
|
|
Toshihiro Shimizu |
890ddd |
<< " scale " << scale
|
|
Toshihiro Shimizu |
890ddd |
<< " curve " << curve
|
|
Toshihiro Shimizu |
890ddd |
<< " z_len " << zanzo_length
|
|
Toshihiro Shimizu |
890ddd |
<< " z_pow " << zanzo_power
|
|
Toshihiro Shimizu |
890ddd |
<< " alp_rend_sw " << alp_rend_sw
|
|
Toshihiro Shimizu |
890ddd |
<< " tile w " << tile.getRaster()->getLx()
|
|
Toshihiro Shimizu |
890ddd |
<< " h " << tile.getRaster()->getLy()
|
|
Toshihiro Shimizu |
890ddd |
<< " pixbits " << ino::pixel_bits(tile.getRaster())
|
|
Toshihiro Shimizu |
890ddd |
<< " frame " << frame
|
|
Toshihiro Shimizu |
890ddd |
<< " rand_sets affine_det " << rend_sets.m_affine.det()
|
|
Toshihiro Shimizu |
890ddd |
<< " a11 " << rend_sets.m_affine.a11
|
|
Toshihiro Shimizu |
890ddd |
<< " a12 " << rend_sets.m_affine.a12
|
|
Toshihiro Shimizu |
890ddd |
<< " a13 " << rend_sets.m_affine.a13
|
|
Toshihiro Shimizu |
890ddd |
<< " a21 " << rend_sets.m_affine.a21
|
|
Toshihiro Shimizu |
890ddd |
<< " a22 " << rend_sets.m_affine.a22
|
|
Toshihiro Shimizu |
890ddd |
<< " a23 " << rend_sets.m_affine.a23
|
|
Toshihiro Shimizu |
890ddd |
<< " x " << rend_sets.m_shrinkX
|
|
Toshihiro Shimizu |
890ddd |
<< " y " << rend_sets.m_shrinkY;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ fx処理 ------------------------------------------ */
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->lock();
|
|
Toshihiro Shimizu |
890ddd |
fx_(enlarge_tile.getRaster() // in with margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
margin // margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster() // out with no margin
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
rend_vect.x, rend_vect.y, scale, curve, zanzo_length, zanzo_power, alp_rend_sw);
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ error処理 --------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
catch (std::bad_alloc &e) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::string str("std::bad_alloc <");
|
|
Toshihiro Shimizu |
890ddd |
str += e.what();
|
|
Toshihiro Shimizu |
890ddd |
str += '>';
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
throw;
|
|
Toshihiro Shimizu |
890ddd |
} catch (std::exception &e) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::string str("exception <");
|
|
Toshihiro Shimizu |
890ddd |
str += e.what();
|
|
Toshihiro Shimizu |
890ddd |
str += '>';
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
throw;
|
|
Toshihiro Shimizu |
890ddd |
} catch (...) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->unlock();
|
|
Toshihiro Shimizu |
890ddd |
if (log_sw) {
|
|
Toshihiro Shimizu |
890ddd |
std::string str("other exception");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
throw;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|