Toshihiro Shimizu 890ddd
#include <sstream> /* std::ostringstream */</sstream>
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Toshihiro Shimizu 890ddd
#include "tparamset.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ino_common.h"
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka d1f6c4
class ino_level_rgba final : public TStandardRasterFx {
Shinya Kitaoka 120a6e
  FX_PLUGIN_DECLARATION(ino_level_rgba)
Shinya Kitaoka 120a6e
  TRasterFxPort m_input;
Shinya Kitaoka 120a6e
  TRasterFxPort m_refer;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRangeParamP m_red_in;
Shinya Kitaoka 120a6e
  TRangeParamP m_red_out;
Shinya Kitaoka 120a6e
  TDoubleParamP m_red_gamma;
Shinya Kitaoka 120a6e
  TRangeParamP m_gre_in;
Shinya Kitaoka 120a6e
  TRangeParamP m_gre_out;
Shinya Kitaoka 120a6e
  TDoubleParamP m_gre_gamma;
Shinya Kitaoka 120a6e
  TRangeParamP m_blu_in;
Shinya Kitaoka 120a6e
  TRangeParamP m_blu_out;
Shinya Kitaoka 120a6e
  TDoubleParamP m_blu_gamma;
Shinya Kitaoka 120a6e
  TRangeParamP m_alp_in;
Shinya Kitaoka 120a6e
  TRangeParamP m_alp_out;
Shinya Kitaoka 120a6e
  TDoubleParamP m_alp_gamma;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TBoolParamP m_anti_alias;
Shinya Kitaoka 120a6e
  TIntEnumParamP m_ref_mode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ino_level_rgba()
Shinya Kitaoka 120a6e
      : m_red_in(DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_red_out(
Shinya Kitaoka 120a6e
            DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_red_gamma(1.0 * ino::param_range())
Shinya Kitaoka 120a6e
      , m_gre_in(DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_gre_out(
Shinya Kitaoka 120a6e
            DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_gre_gamma(1.0 * ino::param_range())
Shinya Kitaoka 120a6e
      , m_blu_in(DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_blu_out(
Shinya Kitaoka 120a6e
            DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_blu_gamma(1.0 * ino::param_range())
Shinya Kitaoka 120a6e
      , m_alp_in(DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_alp_out(
Shinya Kitaoka 120a6e
            DoublePair(0.0 * ino::param_range(), 1.0 * ino::param_range()))
Shinya Kitaoka 120a6e
      , m_alp_gamma(1.0 * ino::param_range())
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
      , m_anti_alias(true)
Shinya Kitaoka 120a6e
      , m_ref_mode(new TIntEnumParam(0, "Red")) {
Shinya Kitaoka 120a6e
    addInputPort("Source", this->m_input);
Shinya Kitaoka 120a6e
    addInputPort("Reference", this->m_refer);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bindParam(this, "red_in", this->m_red_in);
Shinya Kitaoka 120a6e
    bindParam(this, "red_out", this->m_red_out);
Shinya Kitaoka 120a6e
    bindParam(this, "red_gamma", this->m_red_gamma);
Shinya Kitaoka 120a6e
    bindParam(this, "gre_in", this->m_gre_in);
Shinya Kitaoka 120a6e
    bindParam(this, "gre_out", this->m_gre_out);
Shinya Kitaoka 120a6e
    bindParam(this, "gre_gamma", this->m_gre_gamma);
Shinya Kitaoka 120a6e
    bindParam(this, "blu_in", this->m_blu_in);
Shinya Kitaoka 120a6e
    bindParam(this, "blu_out", this->m_blu_out);
Shinya Kitaoka 120a6e
    bindParam(this, "blu_gamma", this->m_blu_gamma);
Shinya Kitaoka 120a6e
    bindParam(this, "alp_in", this->m_alp_in);
Shinya Kitaoka 120a6e
    bindParam(this, "alp_out", this->m_alp_out);
Shinya Kitaoka 120a6e
    bindParam(this, "alp_gamma", this->m_alp_gamma);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bindParam(this, "anti_alias", this->m_anti_alias);
Shinya Kitaoka 120a6e
    bindParam(this, "reference", this->m_ref_mode);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    this->m_red_in->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_red_in->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_red_out->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_red_out->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_red_gamma->setValueRange(
Shinya Kitaoka 120a6e
        0.1 * ino::param_range(), 10.0 * ino::param_range()); /* red_gamma値 */
Shinya Kitaoka 120a6e
    this->m_gre_in->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_gre_in->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_gre_out->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_gre_out->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_gre_gamma->setValueRange(
Shinya Kitaoka 120a6e
        0.1 * ino::param_range(), 10.0 * ino::param_range()); /* gre_gamma値 */
Shinya Kitaoka 120a6e
    this->m_blu_in->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_blu_in->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_blu_out->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_blu_out->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_blu_gamma->setValueRange(
Shinya Kitaoka 120a6e
        0.1 * ino::param_range(), 10.0 * ino::param_range()); /* blu_gamma値 */
Shinya Kitaoka 120a6e
    this->m_alp_in->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_alp_in->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                            1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_alp_out->getMin()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_alp_out->getMax()->setValueRange(0.0 * ino::param_range(),
Shinya Kitaoka 120a6e
                                             1.0 * ino::param_range());
Shinya Kitaoka 120a6e
    this->m_alp_gamma->setValueRange(
Shinya Kitaoka 120a6e
        0.1 * ino::param_range(), 10.0 * ino::param_range()); /* alp_gamma値 */
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(1, "Green");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(2, "Blue");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(3, "Alpha");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(4, "Luminance");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(-1, "Nothing");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 38fd86
  bool doGetBBox(double frame, TRectD &bBox,
Shinya Kitaoka 38fd86
                 const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    if (this->m_input.isConnected()) {
Shinya Kitaoka 120a6e
      return this->m_input->doGetBBox(frame, bBox, info);
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      bBox = TRectD();
Shinya Kitaoka 120a6e
      return false;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 38fd86
  bool canHandle(const TRenderSettings &info, double frame) override {
Shinya Kitaoka 38fd86
    return true;
Shinya Kitaoka 38fd86
  }
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_level_rgba, "inoLevelrgbaFx");
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Toshihiro Shimizu 890ddd
#include "igs_levels.h"
Shinya Kitaoka 120a6e
void ino_level_rgba::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タイプはエラーを投げる --- */
Shinya Kitaoka 120a6e
  if (!((TRaster32P)tile.getRaster()) && !((TRaster64P)tile.getRaster())) {
Shinya Kitaoka 120a6e
    throw TRopException("unsupported input pixel type");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /* ------ 動作パラメータを得る ---------------------------- */
Shinya Kitaoka 120a6e
  DoublePair v_red_in  = this->m_red_in->getValue(frame);
Shinya Kitaoka 120a6e
  DoublePair v_red_out = this->m_red_out->getValue(frame);
Shinya Kitaoka 120a6e
  double red_gamma = this->m_red_gamma->getValue(frame) / ino::param_range();
Shinya Kitaoka 120a6e
  v_red_in.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_red_in.second /= ino::param_range();
Shinya Kitaoka 120a6e
  v_red_out.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_red_out.second /= ino::param_range();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DoublePair v_gre_in  = this->m_gre_in->getValue(frame);
Shinya Kitaoka 120a6e
  DoublePair v_gre_out = this->m_gre_out->getValue(frame);
Shinya Kitaoka 120a6e
  double gre_gamma = this->m_gre_gamma->getValue(frame) / ino::param_range();
Shinya Kitaoka 120a6e
  v_gre_in.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_gre_in.second /= ino::param_range();
Shinya Kitaoka 120a6e
  v_gre_out.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_gre_out.second /= ino::param_range();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DoublePair v_blu_in  = this->m_blu_in->getValue(frame);
Shinya Kitaoka 120a6e
  DoublePair v_blu_out = this->m_blu_out->getValue(frame);
Shinya Kitaoka 120a6e
  double blu_gamma = this->m_blu_gamma->getValue(frame) / ino::param_range();
Shinya Kitaoka 120a6e
  v_blu_in.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_blu_in.second /= ino::param_range();
Shinya Kitaoka 120a6e
  v_blu_out.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_blu_out.second /= ino::param_range();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DoublePair v_alp_in  = this->m_alp_in->getValue(frame);
Shinya Kitaoka 120a6e
  DoublePair v_alp_out = this->m_alp_out->getValue(frame);
Shinya Kitaoka 120a6e
  double alp_gamma = this->m_alp_gamma->getValue(frame) / ino::param_range();
Shinya Kitaoka 120a6e
  v_alp_in.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_alp_in.second /= ino::param_range();
Shinya Kitaoka 120a6e
  v_alp_out.first /= ino::param_range();
Shinya Kitaoka 120a6e
  v_alp_out.second /= ino::param_range();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const bool anti_alias_sw = this->m_anti_alias->getValue();
masafumi-inoue 26f824
  const int refer_mode     = this->m_ref_mode->getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /* ------ 画像生成 ---------------------------------------- */
Shinya Kitaoka 120a6e
  this->m_input->compute(tile, frame, rend_sets);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*------ 参照画像生成 --------------------------------------*/
masafumi-inoue 26f824
  TTile refer_tile;
masafumi-inoue 26f824
  bool refer_sw = false;
Shinya Kitaoka 120a6e
  if (this->m_refer.isConnected()) {
masafumi-inoue 26f824
    refer_sw = true;
Shinya Kitaoka 120a6e
    this->m_refer->allocateAndCompute(
masafumi-inoue 26f824
        refer_tile, tile.m_pos,
Shinya Kitaoka 120a6e
        TDimensionI(/* Pixel単位 */
Shinya Kitaoka 120a6e
                    tile.getRaster()->getLx(), tile.getRaster()->getLy()),
Shinya Kitaoka 120a6e
        tile.getRaster(), frame, rend_sets);
Shinya Kitaoka 120a6e
  }
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
       << "  red_in_min " << v_red_in.first << "  red_in_max "
Shinya Kitaoka 120a6e
       << v_red_in.second << "  red_out_min " << v_red_out.first
Shinya Kitaoka 120a6e
       << "  red_out_max " << v_red_out.second << "  red_gamma " << red_gamma
Shinya Kitaoka 120a6e
       << "  gre_in_min " << v_gre_in.first << "  gre_in_max "
Shinya Kitaoka 120a6e
       << v_gre_in.second << "  gre_out_min " << v_gre_out.first
Shinya Kitaoka 120a6e
       << "  gre_out_max " << v_gre_out.second << "  gre_gamma " << gre_gamma
Shinya Kitaoka 120a6e
       << "  blu_in_min " << v_blu_in.first << "  blu_in_max "
Shinya Kitaoka 120a6e
       << v_blu_in.second << "  blu_out_min " << v_blu_out.first
Shinya Kitaoka 120a6e
       << "  blu_out_max " << v_blu_out.second << "  blu_gamma " << blu_gamma
Shinya Kitaoka 120a6e
       << "  alp_in_min " << v_alp_in.first << "  alp_in_max "
Shinya Kitaoka 120a6e
       << v_alp_in.second << "  alp_out_min " << v_alp_out.first
Shinya Kitaoka 120a6e
       << "  alp_out_max " << v_alp_out.second << "  alp_gamma " << alp_gamma
masafumi-inoue 26f824
       << "  anti_alias " << anti_alias_sw << "  reference " << refer_mode
Shinya Kitaoka 120a6e
       << "   tile w " << tile.getRaster()->getLx() << "  h "
Shinya Kitaoka 120a6e
       << tile.getRaster()->getLy() << "  pixbits "
Shinya Kitaoka 120a6e
       << ino::pixel_bits(tile.getRaster()) << "   frame " << frame;
masafumi-inoue 26f824
    if (refer_sw) {
masafumi-inoue 26f824
      os << "  refer_tile.m_pos " << refer_tile.m_pos << "  refer_tile_getLx "
masafumi-inoue 26f824
         << refer_tile.getRaster()->getLx() << "  y "
masafumi-inoue 26f824
         << refer_tile.getRaster()->getLy();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ fx処理 ------------------------------------------ */
Shinya Kitaoka 120a6e
  try {
Shinya Kitaoka 120a6e
    TRasterP in_ras = tile.getRaster();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    TRasterGR8P in_gr8(in_ras->getLy(),
Shinya Kitaoka 120a6e
                       in_ras->getLx() * ino::channels() *
Shinya Kitaoka 120a6e
                           ((TRaster64P)in_ras ? sizeof(unsigned short)
Shinya Kitaoka 120a6e
                                               : sizeof(unsigned char)));
masafumi-inoue 26f824
masafumi-inoue 26f824
    in_ras->lock();
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->lock();
masafumi-inoue 26f824
    }
Shinya Kitaoka 120a6e
    in_gr8->lock();
masafumi-inoue 26f824
Shinya Kitaoka 120a6e
    ino::ras_to_arr(in_ras, ino::channels(), in_gr8->getRawData());
Toshihiro Shimizu 890ddd
masafumi-inoue 26f824
    const TRasterP refer_ras = (refer_sw ? refer_tile.getRaster() : nullptr);
Shinya Kitaoka 120a6e
    igs::levels::change(
Shinya Kitaoka 120a6e
        in_gr8->getRawData()
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
            ,
Shinya Kitaoka 120a6e
        in_ras->getLy(), in_ras->getLx()  // Not use in_ras->getWrap()
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        ino::channels(), ino::bits(in_ras)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
                             ,
masafumi-inoue 26f824
        (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData()
masafumi-inoue 26f824
                                                       : nullptr)  // BGRA
Shinya Kitaoka 120a6e
        ,
masafumi-inoue 26f824
        (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras)
masafumi-inoue 26f824
                                                       : 0),
masafumi-inoue 26f824
        refer_mode
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        v_red_in.first, v_red_in.second, v_gre_in.first, v_gre_in.second,
Shinya Kitaoka 120a6e
        v_blu_in.first, v_blu_in.second, v_alp_in.first, v_alp_in.second,
Shinya Kitaoka 120a6e
        red_gamma, gre_gamma, blu_gamma, alp_gamma, v_red_out.first,
Shinya Kitaoka 120a6e
        v_red_out.second, v_gre_out.first, v_gre_out.second, v_blu_out.first,
Shinya Kitaoka 120a6e
        v_blu_out.second, v_alp_out.first, v_alp_out.second
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        true  // clamp_sw
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        true  // alpha_rendering_sw
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        anti_alias_sw  // --> add_blend_sw, default is true
Shinya Kitaoka 120a6e
        );
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    ino::arr_to_ras(in_gr8->getRawData(), ino::channels(), in_ras, 0);
Toshihiro Shimizu 890ddd
masafumi-inoue 26f824
    in_gr8->unlock();
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
Shinya Kitaoka 120a6e
    in_ras->unlock();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ error処理 --------------------------------------- */
Shinya Kitaoka 120a6e
  catch (std::bad_alloc &e) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
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) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
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 (...) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
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
}