Toshihiro Shimizu 890ddd
#include <sstream> /* std::ostringstream */</sstream>
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ino_common.h"
Toshihiro Shimizu 890ddd
#include "igs_warp.h"
shun-iwasawa 481b59
#include "trop.h"
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka d1f6c4
class ino_warp_hv final : public TStandardRasterFx {
Shinya Kitaoka 120a6e
  FX_PLUGIN_DECLARATION(ino_warp_hv)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterFxPort m_input;
Shinya Kitaoka 120a6e
  TRasterFxPort m_hori;
Shinya Kitaoka 120a6e
  TRasterFxPort m_vert;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDoubleParamP m_h_maxlen;
Shinya Kitaoka 120a6e
  TDoubleParamP m_v_maxlen;
Shinya Kitaoka 120a6e
  TIntEnumParamP m_h_ref_mode;
Shinya Kitaoka 120a6e
  TIntEnumParamP m_v_ref_mode;
Shinya Kitaoka 120a6e
  TBoolParamP m_alpha_rendering;
Shinya Kitaoka 120a6e
  TBoolParamP m_anti_aliasing;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ino_warp_hv()
Shinya Kitaoka 120a6e
      : m_h_maxlen(0.0 * ino::param_range())
Shinya Kitaoka 120a6e
      , m_v_maxlen(0.0 * ino::param_range())
Shinya Kitaoka 120a6e
      , m_h_ref_mode(new TIntEnumParam(2, "Red"))
Shinya Kitaoka 120a6e
      , m_v_ref_mode(new TIntEnumParam(2, "Red"))
Shinya Kitaoka 120a6e
      , m_alpha_rendering(true)
Shinya Kitaoka 120a6e
      , m_anti_aliasing(true) {
Shinya Kitaoka 120a6e
    this->m_h_maxlen->setMeasureName("fxLength");
Shinya Kitaoka 120a6e
    this->m_v_maxlen->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    addInputPort("Source", this->m_input);
Shinya Kitaoka 120a6e
    addInputPort("Hori", this->m_hori);
Shinya Kitaoka 120a6e
    addInputPort("Vert", this->m_vert);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bindParam(this, "h_maxlen", this->m_h_maxlen);
Shinya Kitaoka 120a6e
    bindParam(this, "v_maxlen", this->m_v_maxlen);
Shinya Kitaoka 120a6e
    bindParam(this, "h_ref_mode", this->m_h_ref_mode);
Shinya Kitaoka 120a6e
    bindParam(this, "v_ref_mode", this->m_v_ref_mode);
Shinya Kitaoka 120a6e
    bindParam(this, "alpha_rendering", this->m_alpha_rendering);
Shinya Kitaoka 120a6e
    bindParam(this, "anti_aliasing", this->m_anti_aliasing);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    this->m_h_maxlen->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                    100.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_v_maxlen->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                    100.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_h_ref_mode->addItem(1, "Green");
Shinya Kitaoka 120a6e
    this->m_h_ref_mode->addItem(0, "Blue");
Shinya Kitaoka 120a6e
    this->m_h_ref_mode->addItem(3, "Alpha");
Shinya Kitaoka 120a6e
    this->m_v_ref_mode->addItem(1, "Green");
Shinya Kitaoka 120a6e
    this->m_v_ref_mode->addItem(0, "Blue");
Shinya Kitaoka 120a6e
    this->m_v_ref_mode->addItem(3, "Alpha");
shun-iwasawa 481b59
shun-iwasawa 481b59
    enableComputeInFloat(true);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void get_render_real_hv(const double frame, const TAffine affine,
Shinya Kitaoka 120a6e
                          double &h_maxlen, double &v_maxlen) {
Shinya Kitaoka 120a6e
    /*--- ベクトルにする(プラス値) --- */
Shinya Kitaoka 120a6e
    TPointD rend_vect;
Shinya Kitaoka 120a6e
    rend_vect.x = this->m_h_maxlen->getValue(frame);
Shinya Kitaoka 120a6e
    rend_vect.y = this->m_v_maxlen->getValue(frame);
Shinya Kitaoka 120a6e
    /*--- 単位変換(mm --> render_pixel)render用単位にする ---*/
Shinya Kitaoka 120a6e
    rend_vect = rend_vect * ino::pixel_per_mm();
Shinya Kitaoka 120a6e
    /*--- 拡大縮小(移動回転しないで)のGeometryを反映させる ---*/
Shinya Kitaoka 120a6e
    rend_vect = rend_vect * sqrt(fabs(affine.det()));
Shinya Kitaoka 120a6e
    /*--- 方向は無視して長さを返す(プラス値) ---*/
Shinya Kitaoka 120a6e
    h_maxlen = rend_vect.x;
Shinya Kitaoka 120a6e
    v_maxlen = rend_vect.y;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void get_render_enlarge(const double frame, const TAffine affine,
Shinya Kitaoka 120a6e
                          TRectD &bBox) {
Shinya Kitaoka 120a6e
    double h_maxlen = 0.0;
Shinya Kitaoka 120a6e
    double v_maxlen = 0.0;
Shinya Kitaoka 120a6e
    this->get_render_real_hv(frame, affine, h_maxlen, v_maxlen);
Shinya Kitaoka 120a6e
    const int margin =
Shinya Kitaoka 120a6e
        static_cast<int>(ceil((h_maxlen < v_maxlen) ? v_maxlen : h_maxlen));</int>
Shinya Kitaoka 120a6e
    if (0 < margin) {
Shinya Kitaoka 120a6e
      bBox = bBox.enlarge(static_cast<double>(margin));</double>
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 38fd86
  bool doGetBBox(double frame, TRectD &bBox,
Shinya Kitaoka 38fd86
                 const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    if (false == this->m_input.isConnected()) {
Shinya Kitaoka 120a6e
      bBox = TRectD();
Shinya Kitaoka 120a6e
      return false;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    const bool ret = this->m_input->doGetBBox(frame, bBox, info);
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, info.m_affine, bBox);
Shinya Kitaoka 120a6e
    return ret;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  int getMemoryRequirement(const TRectD &rect, double frame,
Shinya Kitaoka 473e70
                           const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    TRectD bBox(rect);
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, info.m_affine, bBox);
Shinya Kitaoka 120a6e
    return TRasterFx::memorySize(bBox, info.m_bpp);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void transform(double frame, int port, const TRectD &rectOnOutput,
Shinya Kitaoka 120a6e
                 const TRenderSettings &infoOnOutput, TRectD &rectOnInput,
Shinya Kitaoka 473e70
                 TRenderSettings &infoOnInput) override {
Shinya Kitaoka 120a6e
    rectOnInput = rectOnOutput;
Shinya Kitaoka 120a6e
    infoOnInput = infoOnOutput;
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, infoOnOutput.m_affine, rectOnInput);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  bool canHandle(const TRenderSettings &info, double frame) override {
Shinya Kitaoka 120a6e
    // return true;
Shinya Kitaoka 120a6e
    return false;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 38fd86
  void doCompute(TTile &tile, double frame,
Shinya Kitaoka 38fd86
                 const TRenderSettings &rend_sets) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(ino_warp_hv, "inoWarphvFx");
Toshihiro Shimizu 890ddd
//--------------------------------------------------------------------
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
template <class t=""></class>
Shinya Kitaoka 120a6e
void data_set_template_(const TRasterPT<t> in_ras  // with margin</t>
Shinya Kitaoka 120a6e
                        ,
Shinya Kitaoka 120a6e
                        const int margin, TRasterPT<t> out_ras  // no margin</t>
shun-iwasawa 481b59
) {
Shinya Kitaoka 120a6e
  for (int yy = 0; yy < out_ras->getLy(); ++yy) {
Shinya Kitaoka 120a6e
    const T *in_ras_sl = in_ras->pixels(yy + margin);
Shinya Kitaoka 120a6e
    T *out_ras_sl      = out_ras->pixels(yy);
Shinya Kitaoka 120a6e
    for (int xx = 0; xx < out_ras->getLx(); ++xx) {
Shinya Kitaoka 120a6e
      out_ras_sl[xx].r = in_ras_sl[xx + margin].r;
Shinya Kitaoka 120a6e
      out_ras_sl[xx].g = in_ras_sl[xx + margin].g;
Shinya Kitaoka 120a6e
      out_ras_sl[xx].b = in_ras_sl[xx + margin].b;
Shinya Kitaoka 120a6e
      out_ras_sl[xx].m = in_ras_sl[xx + margin].m;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Shinya Kitaoka 120a6e
void fx_(TRasterP in_ras  // with margin
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         const TRasterP hori_ras  // with margin
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         const TRasterP vert_ras  // with margin
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         const int margin, TRasterP out_ras  // no margin
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
         ,
Shinya Kitaoka 120a6e
         const double h_maxlen, const double v_maxlen, const int h_ref_mode,
Shinya Kitaoka 120a6e
         const int v_ref_mode, const bool alpha_rendering_sw,
Shinya Kitaoka 120a6e
         const bool anti_aliasing_sw) {
shun-iwasawa 481b59
  if (in_ras->getPixelSize() == 4 || in_ras->getPixelSize() == 8) {
shun-iwasawa 481b59
    TRasterGR8P in_gr8(in_ras->getLy(),
shun-iwasawa 481b59
                       in_ras->getLx() * ino::channels() * sizeof(float));
shun-iwasawa 481b59
    in_gr8->lock();
shun-iwasawa 481b59
    ino::ras_to_float_arr(in_ras, ino::channels(),
shun-iwasawa 481b59
                          reinterpret_cast<float *="">(in_gr8->getRawData()));</float>
shun-iwasawa 481b59
shun-iwasawa 481b59
    if (0 != hori_ras) {
shun-iwasawa 481b59
      TRasterGR8P hori_gr8(hori_ras->getLy(),
shun-iwasawa 481b59
                           hori_ras->getLx() * ino::channels() * sizeof(float));
shun-iwasawa 481b59
      hori_gr8->lock();
shun-iwasawa 481b59
      ino::ras_to_float_arr(hori_ras, ino::channels(),
shun-iwasawa 481b59
                            reinterpret_cast<float *="">(hori_gr8->getRawData()));</float>
shun-iwasawa 481b59
shun-iwasawa 481b59
      igs::warp::hori_change(
shun-iwasawa 481b59
          reinterpret_cast<float *="">(in_gr8->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          in_ras->getLy(), in_ras->getLx(), ino::channels(),
shun-iwasawa 481b59
          reinterpret_cast<float *="">(hori_gr8->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          ino::channels(), h_ref_mode,
shun-iwasawa 481b59
          -h_maxlen /* 移動方向と参照方向は逆 */
shun-iwasawa 481b59
              * 2.0,
shun-iwasawa 481b59
          alpha_rendering_sw, anti_aliasing_sw);
shun-iwasawa 481b59
      hori_gr8->unlock();
shun-iwasawa 481b59
    }
shun-iwasawa 481b59
    if (0 != vert_ras) {
shun-iwasawa 481b59
      TRasterGR8P vert_gr8(vert_ras->getLy(),
shun-iwasawa 481b59
                           vert_ras->getLx() * ino::channels() * sizeof(float));
shun-iwasawa 481b59
      vert_gr8->lock();
shun-iwasawa 481b59
      ino::ras_to_float_arr(vert_ras, ino::channels(),
shun-iwasawa 481b59
                            reinterpret_cast<float *="">(vert_gr8->getRawData()));</float>
shun-iwasawa 481b59
shun-iwasawa 481b59
      igs::warp::vert_change(
shun-iwasawa 481b59
          reinterpret_cast<float *="">(in_gr8->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          in_ras->getLy(), in_ras->getLx(), ino::channels(),
shun-iwasawa 481b59
          reinterpret_cast<float *="">(vert_gr8->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          ino::channels(), v_ref_mode,
shun-iwasawa 481b59
          -v_maxlen /* 移動方向と参照方向は逆 */
shun-iwasawa 481b59
              * 2.0,
shun-iwasawa 481b59
          alpha_rendering_sw, anti_aliasing_sw);
shun-iwasawa 481b59
      vert_gr8->unlock();
shun-iwasawa 481b59
    }
shun-iwasawa 481b59
shun-iwasawa 481b59
    in_gr8->unlock();
shun-iwasawa 481b59
    ino::float_arr_to_ras(in_gr8->getRawData(), ino::channels(), out_ras,
shun-iwasawa 481b59
                          margin);
shun-iwasawa 481b59
  } else if (in_ras->getPixelSize() == 16) {
shun-iwasawa 481b59
    if (0 != hori_ras) {
shun-iwasawa 481b59
      igs::warp::hori_change(
shun-iwasawa 481b59
          reinterpret_cast<float *="">(in_ras->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          in_ras->getLy(), in_ras->getLx(), ino::channels(),
shun-iwasawa 481b59
          reinterpret_cast<float *="">(hori_ras->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          ino::channels(), h_ref_mode,
shun-iwasawa 481b59
          -h_maxlen /* 移動方向と参照方向は逆 */
shun-iwasawa 481b59
              * 2.0,
shun-iwasawa 481b59
          alpha_rendering_sw, anti_aliasing_sw);
shun-iwasawa 481b59
    }
shun-iwasawa 481b59
    if (0 != vert_ras) {
shun-iwasawa 481b59
      igs::warp::vert_change(
shun-iwasawa 481b59
          reinterpret_cast<float *="">(in_ras->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          in_ras->getLy(), in_ras->getLx(), ino::channels(),
shun-iwasawa 481b59
          reinterpret_cast<float *="">(vert_ras->getRawData()),  // BGRA</float>
shun-iwasawa 481b59
          ino::channels(), v_ref_mode,
shun-iwasawa 481b59
          -v_maxlen /* 移動方向と参照方向は逆 */
shun-iwasawa 481b59
              * 2.0,
shun-iwasawa 481b59
          alpha_rendering_sw, anti_aliasing_sw);
shun-iwasawa 481b59
    }
shun-iwasawa 481b59
    data_set_template_<tpixelf>(in_ras, margin, out_ras);</tpixelf>
shun-iwasawa 481b59
  } else {
shun-iwasawa 481b59
    throw TRopException("unsupported input pixel type");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
shun-iwasawa 481b59
  /*
Shinya Kitaoka 120a6e
  if ((TRaster32P)in_ras) {
Shinya Kitaoka 120a6e
    data_set_template_<tpixel32>(in_ras, margin, out_ras);</tpixel32>
Shinya Kitaoka 120a6e
  } else if ((TRaster64P)in_ras) {
Shinya Kitaoka 120a6e
    data_set_template_<tpixel64>(in_ras, margin, out_ras);</tpixel64>
shun-iwasawa 481b59
  } else if ((TRasterFP)in_ras) {
shun-iwasawa 481b59
    data_set_template_<tpixelf>(in_ras, margin, out_ras);</tpixelf>
shun-iwasawa 481b59
  }*/
Toshihiro Shimizu 890ddd
}
shun-iwasawa 481b59
}  // namespace
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka 120a6e
void ino_warp_hv::doCompute(TTile &tile, double frame,
Shinya Kitaoka 120a6e
                            const TRenderSettings &rend_sets) {
Shinya Kitaoka 120a6e
  /*------ 接続していなければ処理しない ----------------------*/
Shinya Kitaoka 120a6e
  if (!this->m_input.isConnected()) {
Shinya Kitaoka 120a6e
    tile.getRaster()->clear(); /* 塗りつぶしクリア */
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*------ サポートしていないPixelタイプはエラーを投げる -----*/
shun-iwasawa 481b59
  if (!((TRaster32P)tile.getRaster()) && !((TRaster64P)tile.getRaster()) &&
shun-iwasawa 481b59
      !((TRasterFP)tile.getRaster())) {
Shinya Kitaoka 120a6e
    throw TRopException("unsupported input pixel type");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*------ 動作パラメータを得る ------------------------------*/
Shinya Kitaoka 120a6e
  const bool alp_rend_sw = this->m_alpha_rendering->getValue();
Shinya Kitaoka 120a6e
  const bool anti_ali_sw = this->m_anti_aliasing->getValue();
Shinya Kitaoka 120a6e
  double h_maxlen        = 0;
Shinya Kitaoka 120a6e
  double v_maxlen        = 0;
Shinya Kitaoka 120a6e
  this->get_render_real_hv(frame, rend_sets.m_affine, h_maxlen, v_maxlen);
Shinya Kitaoka 120a6e
  /*------ 表示の範囲を得る ----------------------------------*/
Shinya Kitaoka 120a6e
  TRectD bBox =
Shinya Kitaoka 120a6e
      TRectD(tile.m_pos /* Render画像上(Pixel単位)の位置 */
Shinya Kitaoka 120a6e
             ,
Shinya Kitaoka 120a6e
             TDimensionD(/* Render画像上(Pixel単位)のサイズ */
Shinya Kitaoka 120a6e
                         tile.getRaster()->getLx(), tile.getRaster()->getLy()));
Shinya Kitaoka 120a6e
  /*------ 歪み量分(=マージン)分表示範囲を広げる -------------*/
Shinya Kitaoka 120a6e
  const int margin =
Shinya Kitaoka 120a6e
      static_cast<int>(ceil((h_maxlen < v_maxlen) ? v_maxlen : h_maxlen));</int>
Shinya Kitaoka 120a6e
  if (0 < margin) {
Shinya Kitaoka 120a6e
    bBox = bBox.enlarge(static_cast<double>(margin));</double>
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ 広げた範囲の画像生成 ------------------------------*/
Shinya Kitaoka 120a6e
  TTile enlarge_tile;
Shinya Kitaoka 120a6e
  this->m_input->allocateAndCompute(
Shinya Kitaoka 120a6e
      enlarge_tile, bBox.getP00(),
Shinya Kitaoka 120a6e
      TDimensionI(/* Pixel単位のdouble -> intにしてセット */
Shinya Kitaoka 120a6e
                  static_cast<int>(bBox.getLx() + 0.5),</int>
Shinya Kitaoka 120a6e
                  static_cast<int>(bBox.getLy() + 0.5)),</int>
Shinya Kitaoka 120a6e
      tile.getRaster(), frame, rend_sets);
Shinya Kitaoka 120a6e
  /*------ 参照画像生成 --------------------------------------*/
Shinya Kitaoka 120a6e
  TTile hori_tile;
Shinya Kitaoka 120a6e
  TTile vert_tile;
Shinya Kitaoka 120a6e
  const bool hori_cn_is = this->m_hori.isConnected();
Shinya Kitaoka 120a6e
  const bool vert_cn_is = this->m_vert.isConnected();
shun-iwasawa 481b59
Shinya Kitaoka 120a6e
  if (hori_cn_is) {
Shinya Kitaoka 120a6e
    this->m_hori->allocateAndCompute(
Shinya Kitaoka 120a6e
        hori_tile, bBox.getP00(),
Shinya Kitaoka 120a6e
        TDimensionI(/* Pixel単位のdouble -> intにしてセット */
Shinya Kitaoka 120a6e
                    (int)(bBox.getLx() + 0.5), (int)(bBox.getLy() + 0.5)),
Shinya Kitaoka 120a6e
        tile.getRaster(), frame, rend_sets);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (vert_cn_is) {
Shinya Kitaoka 120a6e
    this->m_vert->allocateAndCompute(
Shinya Kitaoka 120a6e
        vert_tile, bBox.getP00(),
Shinya Kitaoka 120a6e
        TDimensionI(/* Pixel単位のdouble -> intにしてセット */
Shinya Kitaoka 120a6e
                    (int)(bBox.getLx() + 0.5), (int)(bBox.getLy() + 0.5)),
Shinya Kitaoka 120a6e
        tile.getRaster(), frame, rend_sets);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ 保存すべき画像メモリを塗りつぶしクリア ------------*/
Shinya Kitaoka 120a6e
  tile.getRaster()->clear(); /* 塗りつぶしクリア */
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*------ (app_begin)log記憶 --------------------------------*/
Shinya Kitaoka 120a6e
  const bool log_sw = ino::log_enable_sw();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (log_sw) {
Shinya Kitaoka 120a6e
    std::ostringstream os;
Shinya Kitaoka 120a6e
    os << "params"
Shinya Kitaoka 120a6e
       << "  h_maxlen " << h_maxlen << "  v_maxlen " << v_maxlen << "  margin "
Shinya Kitaoka 120a6e
       << margin << "  alp_rend_sw " << alp_rend_sw << "  anti_ali_sw "
Shinya Kitaoka 120a6e
       << anti_ali_sw
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
       << "   tile w " << tile.getRaster()->getLx() << "  h "
Shinya Kitaoka 120a6e
       << tile.getRaster()->getLy() << "  pixbits "
Shinya Kitaoka 120a6e
       << ino::pixel_bits(tile.getRaster());
Shinya Kitaoka 120a6e
    if (hori_cn_is) {
Shinya Kitaoka 120a6e
      os << "   htile w " << hori_tile.getRaster()->getLx() << "  h "
Shinya Kitaoka 120a6e
         << hori_tile.getRaster()->getLy() << "  pixbits "
Shinya Kitaoka 120a6e
         << ino::pixel_bits(hori_tile.getRaster());
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (vert_cn_is) {
Shinya Kitaoka 120a6e
      os << "   vtile w " << vert_tile.getRaster()->getLx() << "  h "
Shinya Kitaoka 120a6e
         << vert_tile.getRaster()->getLy() << "  pixbits "
Shinya Kitaoka 120a6e
         << ino::pixel_bits(vert_tile.getRaster());
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    os << "   frame " << frame << "   rand_sets affine_det "
Shinya Kitaoka 120a6e
       << rend_sets.m_affine.det() << "  shrink x " << rend_sets.m_shrinkX
Shinya Kitaoka 120a6e
       << "  y " << rend_sets.m_shrinkY;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ fx処理 ------------------------------------------ */
Shinya Kitaoka 120a6e
  try {
Shinya Kitaoka 120a6e
    tile.getRaster()->lock();
Shinya Kitaoka 120a6e
    if (hori_cn_is) {
Shinya Kitaoka 120a6e
      hori_tile.getRaster()->lock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (vert_cn_is) {
Shinya Kitaoka 120a6e
      vert_tile.getRaster()->lock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    fx_(enlarge_tile.getRaster()  // in with margin
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        (hori_cn_is ? hori_tile.getRaster() : nullptr)  // with margin
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        (vert_cn_is ? vert_tile.getRaster() : nullptr)  // with margin
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        margin  // margin
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        tile.getRaster()  // out with no margin
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        h_maxlen, v_maxlen, this->m_h_ref_mode->getValue(),
Shinya Kitaoka 120a6e
        this->m_v_ref_mode->getValue(), alp_rend_sw, anti_ali_sw);
Shinya Kitaoka 120a6e
    if (vert_cn_is) {
Shinya Kitaoka 120a6e
      vert_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (hori_cn_is) {
Shinya Kitaoka 120a6e
      hori_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ error処理 --------------------------------------- */
Shinya Kitaoka 120a6e
  catch (std::bad_alloc &e) {
Shinya Kitaoka 120a6e
    if (vert_cn_is) {
Shinya Kitaoka 120a6e
      vert_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (hori_cn_is) {
Shinya Kitaoka 120a6e
      hori_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("std::bad_alloc <");
Shinya Kitaoka 120a6e
      str += e.what();
Shinya Kitaoka 120a6e
      str += '>';
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  } catch (std::exception &e) {
Shinya Kitaoka 120a6e
    if (vert_cn_is) {
Shinya Kitaoka 120a6e
      vert_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (hori_cn_is) {
Shinya Kitaoka 120a6e
      hori_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("exception <");
Shinya Kitaoka 120a6e
      str += e.what();
Shinya Kitaoka 120a6e
      str += '>';
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  } catch (...) {
Shinya Kitaoka 120a6e
    if (vert_cn_is) {
Shinya Kitaoka 120a6e
      vert_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (hori_cn_is) {
Shinya Kitaoka 120a6e
      hori_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("other exception");
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}