From 26f824c67c6b03017b905437bae549ae03a32d6b Mon Sep 17 00:00:00 2001 From: masafumi-inoue Date: Aug 25 2017 09:04:40 +0000 Subject: Debug about "HLSNoiseIno assertion error". And some refactoring. (#1427) * Add cheching getRaster(), and referctoring --- diff --git a/toonz/sources/stdfx/ino_blur.cpp b/toonz/sources/stdfx/ino_blur.cpp index 7f7e240..0fba236 100644 --- a/toonz/sources/stdfx/ino_blur.cpp +++ b/toonz/sources/stdfx/ino_blur.cpp @@ -99,12 +99,9 @@ namespace { void fx_(const TRasterP in_ras // with margin , TRasterP out_ras // no margin - - , - const TRasterP refer_ras, const int ref_mode - , - const int int_radius, const double real_radius) { + const TRasterP refer_ras, const int refer_mode, const int int_radius, + const double real_radius) { TRasterGR8P out_buffer(out_ras->getLy(), out_ras->getLx() * ino::channels() * ((TRaster64P)in_ras ? sizeof(unsigned short) @@ -129,14 +126,14 @@ void fx_(const TRasterP in_ras // with margin ino::bits(in_ras) // const int bits , - (((0 <= ref_mode) && (0 != refer_ras)) ? refer_ras->getRawData() - : 0) // BGRA - // const unsigned char *ref + (((refer_ras != nullptr) && (0 <= refer_mode)) + ? refer_ras->getRawData() + : nullptr) // BGRA // const unsigned char *ref , - (((0 <= ref_mode) && (0 != refer_ras)) ? ino::bits(refer_ras) : 0) - // const int ref_bits + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0) // const int ref_bits , - ref_mode // const int ref_mode + refer_mode // const int refer_mode , cvt_buffer->getRawData() // void *buffer @@ -146,8 +143,7 @@ void fx_(const TRasterP in_ras // with margin , int_radius // const int int_radius , - real_radius // const double real_radius - // , 0.25 + real_radius // const double real_radius // , 0.25 ); ino::arr_to_ras(out_buffer->getRawData(), ino::channels(), out_ras, 0); cvt_buffer->unlock(); @@ -176,7 +172,7 @@ void ino_blur::doCompute(TTile &tile, double frame, return; } /*------- 動作パラメータを得る -----------------------------*/ - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /*------ 表示の範囲を得る ----------------------------------*/ TRectD bBox = @@ -209,12 +205,12 @@ TTile &tile tile.getRaster(), frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile ref_tile; - bool ref_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - ref_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - ref_tile, tile.m_pos /* TPointD */ + refer_tile, tile.m_pos /* TPointD */ , tile.getRaster()->getSize() /* Pixel単位 */ , @@ -231,8 +227,8 @@ TTile &tile std::ostringstream os; os << "params" << " usr_radius " << this->m_radius->getValue(frame) << " real_radius " - << real_radius << " int_radius " << int_radius << " ref_mode " - << ref_mode << " tile" + << real_radius << " int_radius " << int_radius << " refer_mode " + << refer_mode << " tile" << " pos " << tile.m_pos << " w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " enl_tile" << " w " << enlarge_tile.getRaster()->getLx() << " h " @@ -241,30 +237,43 @@ TTile &tile << " affine a11 " << rend_sets.m_affine.a11 << " a12 " << rend_sets.m_affine.a12 << " a21 " << rend_sets.m_affine.a21 << " a22 " << rend_sets.m_affine.a22; - if (ref_sw) { - os << " ref_tile" - << " pos " << ref_tile.m_pos << " x " << ref_tile.getRaster()->getLx() - << " y " << ref_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile" + << " pos " << refer_tile.m_pos << " x " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); + enlarge_tile.getRaster()->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } fx_(enlarge_tile.getRaster() // in with margin , tile.getRaster() // out with no margin , - ref_tile.getRaster(), ref_mode + refer_tile.getRaster(), refer_mode , int_radius // margin , real_radius); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -273,6 +282,10 @@ TTile &tile } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -281,6 +294,10 @@ TTile &tile } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_density.cpp b/toonz/sources/stdfx/ino_density.cpp index 89f728c..9eb2d32 100644 --- a/toonz/sources/stdfx/ino_density.cpp +++ b/toonz/sources/stdfx/ino_density.cpp @@ -52,7 +52,7 @@ FX_PLUGIN_IDENTIFIER(ino_density, "inoDensityFx"); #include "igs_density.h" namespace { -void fx_(TRasterP in_ras, TRasterP ref_ras, const int ref_mode, +void fx_(TRasterP in_ras, TRasterP refer_ras, const int refer_mode, const double density) { TRasterGR8P in_gr8(in_ras->getLy(), in_ras->getLx() * ino::channels() * @@ -69,9 +69,12 @@ void fx_(TRasterP in_ras, TRasterP ref_ras, const int ref_mode, ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && ref_ras) ? ref_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && ref_ras) ? ino::bits(ref_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , density); @@ -96,18 +99,18 @@ void ino_density::doCompute(TTile &tile, double frame, /* ------ 動作パラメータを得る ---------------------------- */ const double density = this->m_density->getValue(frame) / ino::param_range(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile ref_tile; - bool ref_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - ref_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - ref_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -119,25 +122,33 @@ void ino_density::doCompute(TTile &tile, double frame, if (log_sw) { std::ostringstream os; os << "params" - << " den " << density << " ref_mode " << ref_mode << " tile w " + << " den " << density << " refer_mode " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " << frame; - if (ref_sw) { - os << " ref_tile.m_pos " << ref_tile.m_pos << " ref_tile_getLx " - << ref_tile.getRaster()->getLx() << " y " - << ref_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - fx_(tile.getRaster(), (ref_sw ? ref_tile.getRaster() : nullptr), ref_mode, - density); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(tile.getRaster(), refer_tile.getRaster(), refer_mode, density); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -146,6 +157,9 @@ void ino_density::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -154,6 +168,9 @@ void ino_density::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_hls_add.cpp b/toonz/sources/stdfx/ino_hls_add.cpp index 54fe413..ef7781e 100644 --- a/toonz/sources/stdfx/ino_hls_add.cpp +++ b/toonz/sources/stdfx/ino_hls_add.cpp @@ -86,12 +86,9 @@ FX_PLUGIN_IDENTIFIER(ino_hls_add, "inohlsAddFx"); #include "igs_hls_add.h" namespace { void fx_(TRasterP in_ras, const TRasterP noise_ras, const TRasterP refer_ras, - const int ref_mode - - , - const int xoffset, const int yoffset, const int from_rgba, - const double offset, const double hue_scale, const double lig_scale, - const double sat_scale, const double alp_scale, + const int refer_mode, const int xoffset, const int yoffset, + const int from_rgba, const double offset, const double hue_scale, + const double lig_scale, const double sat_scale, const double alp_scale, const bool anti_alias_sw) { /***std::vector in_vec; ino::ras_to_vec( in_ras, ino::channels(), in_vec ); @@ -132,11 +129,12 @@ void fx_(TRasterP in_ras, const TRasterP noise_ras, const TRasterP refer_ras, ino::bits(noise_ras) , - (((0 <= ref_mode) && (0 != refer_ras)) ? refer_ras->getRawData() - : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && (0 != refer_ras)) ? ino::bits(refer_ras) : 0), - ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , xoffset, yoffset, from_rgba, offset, hue_scale, lig_scale, sat_scale, @@ -180,7 +178,7 @@ void ino_hls_add::doCompute(TTile &tile, double frame, const double sat_scale = this->m_sat->getValue(frame) / ino::param_range(); const double alp_scale = this->m_alp->getValue(frame) / ino::param_range(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); @@ -191,12 +189,12 @@ void ino_hls_add::doCompute(TTile &tile, double frame, tile.getRaster()->getSize(), tile.getRaster(), frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster() @@ -215,36 +213,42 @@ void ino_hls_add::doCompute(TTile &tile, double frame, << " xo " << xoffset << " yo " << yoffset << " rgba " << from_rgba << " offs " << offset << " h " << hue_scale << " l " << lig_scale << " s " << sat_scale << " a " << alp_scale << " anti_alias " - << anti_alias_sw << " reference " << ref_mode << " tile w " + << anti_alias_sw << " reference " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " noise_tile w " << noise_tile.getRaster()->getLx() << " h " << noise_tile.getRaster()->getLy() << " frame " << frame; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); noise_tile.getRaster()->lock(); - reference_tile.getRaster()->lock(); - fx_(tile.getRaster(), noise_tile.getRaster(), reference_tile.getRaster(), - ref_mode + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(tile.getRaster(), noise_tile.getRaster(), refer_tile.getRaster(), + refer_mode , xoffset, yoffset, from_rgba, offset, hue_scale, lig_scale, sat_scale, alp_scale, anti_alias_sw // --> add_blend_sw, default is true ); - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { @@ -254,7 +258,9 @@ void ino_hls_add::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { @@ -264,7 +270,9 @@ void ino_hls_add::doCompute(TTile &tile, double frame, } throw; } catch (...) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { diff --git a/toonz/sources/stdfx/ino_hls_adjust.cpp b/toonz/sources/stdfx/ino_hls_adjust.cpp index 1d784d4..8ab7985 100644 --- a/toonz/sources/stdfx/ino_hls_adjust.cpp +++ b/toonz/sources/stdfx/ino_hls_adjust.cpp @@ -89,7 +89,7 @@ FX_PLUGIN_IDENTIFIER(ino_hls_adjust, "inohlsAdjustFx"); //------------------------------------------------------------ #include "igs_hls_adjust.h" namespace { -void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode, +void fx_(TRasterP in_ras, const TRasterP refer_ras, const int refer_mode, const double hue_pivot, const double hue_scale, const double hue_shift, const double lig_pivot, const double lig_scale, const double lig_shift, const double sat_pivot, const double sat_scale, const double sat_shift, @@ -115,11 +115,12 @@ void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode, ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && (0 != refer_ras)) ? refer_ras->getRawData() - : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && (0 != refer_ras)) ? ino::bits(refer_ras) : 0), - ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , hue_pivot, hue_scale, hue_shift, lig_pivot, lig_scale, lig_shift, @@ -167,18 +168,18 @@ void ino_hls_adjust::doCompute(TTile &tile, double frame, const double sat_shift = this->m_sat_shift->getValue(frame) / ino::param_range(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -194,28 +195,37 @@ void ino_hls_adjust::doCompute(TTile &tile, double frame, << hue_shift << " l_pvt " << lig_pivot << " l_scl " << lig_scale << " l_sft " << lig_shift << " s_pvt " << sat_pivot << " s_scl " << sat_scale << " s_sft " << sat_shift << " anti_alias " - << anti_alias_sw << " reference " << ref_mode << " tile w " + << anti_alias_sw << " reference " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " << frame; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - fx_(tile.getRaster(), (reference_sw ? reference_tile.getRaster() : nullptr), - ref_mode, hue_pivot, hue_scale, hue_shift, lig_pivot, lig_scale, - lig_shift, sat_pivot, sat_scale, sat_shift, + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(tile.getRaster(), refer_tile.getRaster(), refer_mode, hue_pivot, + hue_scale, hue_shift, lig_pivot, lig_scale, lig_shift, sat_pivot, + sat_scale, sat_shift, anti_alias_sw // --> add_blend_sw, default is true ); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -224,6 +234,9 @@ void ino_hls_adjust::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -232,6 +245,9 @@ void ino_hls_adjust::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_hls_noise.cpp b/toonz/sources/stdfx/ino_hls_noise.cpp index 2e3fc2c..1122cc9 100644 --- a/toonz/sources/stdfx/ino_hls_noise.cpp +++ b/toonz/sources/stdfx/ino_hls_noise.cpp @@ -109,9 +109,7 @@ FX_PLUGIN_IDENTIFIER(ino_hls_noise, "inohlsNoiseFx"); //------------------------------------------------------------ #include "igs_hls_noise.h" namespace { -void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode - - , +void fx_(TRasterP in_ras, const TRasterP refer_ras, const int refer_mode, double hue_range, double lig_range, double sat_range, double alp_range, unsigned long random_seed, double near_blur, double effective, double center, int type, const int camera_x, const int camera_y, @@ -134,11 +132,12 @@ void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && (0 != refer_ras)) ? refer_ras->getRawData() - : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && (0 != refer_ras)) ? ino::bits(refer_ras) : 0), - ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , camera_x, camera_y, camera_w, camera_h @@ -189,7 +188,7 @@ void ino_hls_noise::doCompute(TTile &tile, double frame, const double term_effective = this->m_term_effective->getValue(frame) / ino::param_range(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); @@ -219,12 +218,12 @@ void ino_hls_noise::doCompute(TTile &tile, double frame, camera_h = tile.getRaster()->getLy(); } /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -239,36 +238,42 @@ void ino_hls_noise::doCompute(TTile &tile, double frame, << " a " << mat_range << " seed " << random_seed << " nblur " << near_blur << " effective " << term_effective << " center " << term_center << " type " << term_type << " frame " << frame - << " anti_alias " << anti_alias_sw << " reference " << ref_mode + << " anti_alias " << anti_alias_sw << " reference " << refer_mode << " pixbits " << ino::pixel_bits(tile.getRaster()) << " tile.m_pos " << tile.m_pos << " tile_getLx " << tile.getRaster()->getLx() << " y " << tile.getRaster()->getLy() << " rend_sets.m_cameraBox " << rend_sets.m_cameraBox << " rend_sets.m_affine " << rend_sets.m_affine << " camera x " << camera_x << " y " << camera_y << " w " << camera_w << " h " << camera_h; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - reference_tile.getRaster()->lock(); - fx_(tile.getRaster(), reference_tile.getRaster(), ref_mode + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(tile.getRaster(), refer_tile.getRaster(), refer_mode , hue_range, lig_range, sat_range, mat_range, random_seed, near_blur, term_effective, term_center, term_type, camera_x, camera_y, camera_w, camera_h, anti_alias_sw // --> add_blend_sw, default is true ); - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -277,7 +282,9 @@ void ino_hls_noise::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -286,7 +293,9 @@ void ino_hls_noise::doCompute(TTile &tile, double frame, } throw; } catch (...) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_hsv_add.cpp b/toonz/sources/stdfx/ino_hsv_add.cpp index a7aa589..81200d6 100644 --- a/toonz/sources/stdfx/ino_hsv_add.cpp +++ b/toonz/sources/stdfx/ino_hsv_add.cpp @@ -86,7 +86,7 @@ FX_PLUGIN_IDENTIFIER(ino_hsv_add, "inohsvAddFx"); #include "igs_hsv_add.h" namespace { void fx_(TRasterP in_ras, const TRasterP noise_ras, const TRasterP refer_ras, - const int ref_mode + const int refer_mode , const int xoffset, const int yoffset, const int from_rgba, @@ -132,11 +132,12 @@ void fx_(TRasterP in_ras, const TRasterP noise_ras, const TRasterP refer_ras, ino::bits(noise_ras) , - (((0 <= ref_mode) && (0 != refer_ras)) ? refer_ras->getRawData() - : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && (0 != refer_ras)) ? ino::bits(refer_ras) : 0), - ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , xoffset, yoffset, from_rgba, offset, hue_scale, sat_scale, val_scale, @@ -180,7 +181,7 @@ void ino_hsv_add::doCompute(TTile &tile, double frame, const double val_scale = this->m_val->getValue(frame) / ino::param_range(); const double alp_scale = this->m_alp->getValue(frame) / ino::param_range(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); @@ -191,12 +192,12 @@ void ino_hsv_add::doCompute(TTile &tile, double frame, tile.getRaster()->getSize(), tile.getRaster(), frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -211,36 +212,42 @@ void ino_hsv_add::doCompute(TTile &tile, double frame, << " xo " << xoffset << " yo " << yoffset << " rgba " << from_rgba << " offs " << offset << " h " << hue_scale << " s " << sat_scale << " v " << val_scale << " a " << alp_scale << " anti_alias " - << anti_alias_sw << " reference " << ref_mode << " tile w " + << anti_alias_sw << " reference " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " noise_tile w " << noise_tile.getRaster()->getLx() << " h " << noise_tile.getRaster()->getLy() << " frame " << frame; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); noise_tile.getRaster()->lock(); - reference_tile.getRaster()->lock(); - fx_(tile.getRaster(), noise_tile.getRaster(), reference_tile.getRaster(), - ref_mode + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(tile.getRaster(), noise_tile.getRaster(), refer_tile.getRaster(), + refer_mode , xoffset, yoffset, from_rgba, offset, hue_scale, sat_scale, val_scale, alp_scale, anti_alias_sw // --> add_blend_sw, default is true ); - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { @@ -250,7 +257,9 @@ void ino_hsv_add::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { @@ -260,7 +269,9 @@ void ino_hsv_add::doCompute(TTile &tile, double frame, } throw; } catch (...) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } noise_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { diff --git a/toonz/sources/stdfx/ino_hsv_adjust.cpp b/toonz/sources/stdfx/ino_hsv_adjust.cpp index 23c909a..b826420 100644 --- a/toonz/sources/stdfx/ino_hsv_adjust.cpp +++ b/toonz/sources/stdfx/ino_hsv_adjust.cpp @@ -89,7 +89,7 @@ FX_PLUGIN_IDENTIFIER(ino_hsv_adjust, "inohsvAdjustFx"); //------------------------------------------------------------ #include "igs_hsv_adjust.h" namespace { -void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode, +void fx_(TRasterP in_ras, const TRasterP refer_ras, const int refer_mode, const double hue_pivot, const double hue_scale, const double hue_shift, const double sat_pivot, const double sat_scale, const double sat_shift, const double val_pivot, const double val_scale, const double val_shift, @@ -115,11 +115,12 @@ void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode, ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && (0 != refer_ras)) ? refer_ras->getRawData() - : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && (0 != refer_ras)) ? ino::bits(refer_ras) : 0), - ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , hue_pivot, hue_scale, hue_shift, sat_pivot, sat_scale, sat_shift, @@ -168,18 +169,18 @@ void ino_hsv_adjust::doCompute(TTile &tile, double frame, this->m_val_shift->getValue(frame) / ino::param_range(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -195,28 +196,37 @@ void ino_hsv_adjust::doCompute(TTile &tile, double frame, << hue_shift << " s_pvt " << sat_pivot << " s_scl " << sat_scale << " s_sft " << sat_shift << " v_pvt " << val_pivot << " v_scl " << val_scale << " v_sft " << val_shift << " anti_alias " - << anti_alias_sw << " reference " << ref_mode << " tile w " + << anti_alias_sw << " reference " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " << frame; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - fx_(tile.getRaster(), (reference_sw ? reference_tile.getRaster() : nullptr), - ref_mode, hue_pivot, hue_scale, hue_shift, sat_pivot, sat_scale, - sat_shift, val_pivot, val_scale, val_shift, + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(tile.getRaster(), refer_tile.getRaster(), refer_mode, hue_pivot, + hue_scale, hue_shift, sat_pivot, sat_scale, sat_shift, val_pivot, + val_scale, val_shift, anti_alias_sw // --> add_blend_sw, default is true ); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -225,6 +235,9 @@ void ino_hsv_adjust::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -233,6 +246,9 @@ void ino_hsv_adjust::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_hsv_noise.cpp b/toonz/sources/stdfx/ino_hsv_noise.cpp index 62eefa2..82ff665 100644 --- a/toonz/sources/stdfx/ino_hsv_noise.cpp +++ b/toonz/sources/stdfx/ino_hsv_noise.cpp @@ -109,7 +109,7 @@ FX_PLUGIN_IDENTIFIER(ino_hsv_noise, "inohsvNoiseFx"); //------------------------------------------------------------ #include "igs_hsv_noise.h" namespace { -void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode +void fx_(TRasterP in_ras, const TRasterP refer_ras, const int refer_mode , double hue_range, double sat_range, double val_range, double alp_range, @@ -134,11 +134,12 @@ void fx_(TRasterP in_ras, const TRasterP refer_ras, const int ref_mode ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && (0 != refer_ras)) ? refer_ras->getRawData() - : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && (0 != refer_ras)) ? ino::bits(refer_ras) : 0), - ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , camera_x, camera_y, camera_w, camera_h @@ -189,7 +190,7 @@ void ino_hsv_noise::doCompute(TTile &tile, double frame, const double term_effective = this->m_term_effective->getValue(frame) / ino::param_range(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); @@ -219,12 +220,12 @@ void ino_hsv_noise::doCompute(TTile &tile, double frame, camera_h = tile.getRaster()->getLy(); } /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -239,36 +240,42 @@ void ino_hsv_noise::doCompute(TTile &tile, double frame, << " a " << mat_range << " seed " << random_seed << " nblur " << near_blur << " effective " << term_effective << " center " << term_center << " type " << term_type << " frame " << frame - << " anti_alias " << anti_alias_sw << " reference " << ref_mode + << " anti_alias " << anti_alias_sw << " reference " << refer_mode << " pixbits " << ino::pixel_bits(tile.getRaster()) << " tile.m_pos " << tile.m_pos << " tile_getLx " << tile.getRaster()->getLx() << " y " << tile.getRaster()->getLy() << " rend_sets.m_cameraBox " << rend_sets.m_cameraBox << " rend_sets.m_affine " << rend_sets.m_affine << " camera x " << camera_x << " y " << camera_y << " w " << camera_w << " h " << camera_h; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - reference_tile.getRaster()->lock(); - fx_(tile.getRaster(), reference_tile.getRaster(), ref_mode + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(tile.getRaster(), refer_tile.getRaster(), refer_mode , hue_range, sat_range, val_range, mat_range, random_seed, near_blur, term_effective, term_center, term_type, camera_x, camera_y, camera_w, camera_h, anti_alias_sw // --> add_blend_sw, default is true ); - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -277,7 +284,9 @@ void ino_hsv_noise::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -286,7 +295,9 @@ void ino_hsv_noise::doCompute(TTile &tile, double frame, } throw; } catch (...) { - reference_tile.getRaster()->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_level_master.cpp b/toonz/sources/stdfx/ino_level_master.cpp index aab5e30..12d5bfd 100644 --- a/toonz/sources/stdfx/ino_level_master.cpp +++ b/toonz/sources/stdfx/ino_level_master.cpp @@ -92,7 +92,7 @@ void ino_level_master::doCompute(TTile &tile, double frame, double gamma = this->m_gamma->getValue(frame) / ino::param_range(); const bool alp_rend_sw = this->m_alpha_rendering->getValue(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); v_in.first /= ino::param_range(); v_in.second /= ino::param_range(); v_out.first /= ino::param_range(); @@ -102,12 +102,12 @@ void ino_level_master::doCompute(TTile &tile, double frame, this->m_input->compute(tile, frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -122,31 +122,33 @@ void ino_level_master::doCompute(TTile &tile, double frame, << " in_min " << v_in.first << " in_max " << v_in.second << " out_min " << v_out.first << " out_max " << v_out.second << " gamma " << gamma << " alp_rend_sw " << alp_rend_sw - << " anti_alias " << anti_alias_sw << " reference " << ref_mode + << " anti_alias " << anti_alias_sw << " reference " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " << frame; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { TRasterP in_ras = tile.getRaster(); - - in_ras->lock(); - TRasterGR8P in_gr8(in_ras->getLy(), in_ras->getLx() * ino::channels() * ((TRaster64P)in_ras ? sizeof(unsigned short) : sizeof(unsigned char))); + + in_ras->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } in_gr8->lock(); + ino::ras_to_arr(in_ras, ino::channels(), in_gr8->getRawData()); - const TRasterP refer_ras = - (reference_sw ? reference_tile.getRaster() : nullptr); + const TRasterP refer_ras = (refer_sw ? refer_tile.getRaster() : nullptr); igs::levels::change( in_gr8->getRawData() @@ -156,9 +158,12 @@ void ino_level_master::doCompute(TTile &tile, double frame, ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , v_in.first, v_in.second, v_in.first, v_in.second, v_in.first, @@ -173,12 +178,18 @@ void ino_level_master::doCompute(TTile &tile, double frame, ); ino::arr_to_ras(in_gr8->getRawData(), ino::channels(), in_ras, 0); - in_gr8->unlock(); + in_gr8->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } in_ras->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -187,6 +198,9 @@ void ino_level_master::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -195,6 +209,9 @@ void ino_level_master::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_level_rgba.cpp b/toonz/sources/stdfx/ino_level_rgba.cpp index 74a9dfc..afe060c 100644 --- a/toonz/sources/stdfx/ino_level_rgba.cpp +++ b/toonz/sources/stdfx/ino_level_rgba.cpp @@ -178,18 +178,18 @@ void ino_level_rgba::doCompute(TTile &tile, double frame, v_alp_out.second /= ino::param_range(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 画像生成 ---------------------------------------- */ this->m_input->compute(tile, frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile.m_pos, + refer_tile, tile.m_pos, TDimensionI(/* Pixel単位 */ tile.getRaster()->getLx(), tile.getRaster()->getLy()), tile.getRaster(), frame, rend_sets); @@ -213,31 +213,34 @@ void ino_level_rgba::doCompute(TTile &tile, double frame, << " alp_in_min " << v_alp_in.first << " alp_in_max " << v_alp_in.second << " alp_out_min " << v_alp_out.first << " alp_out_max " << v_alp_out.second << " alp_gamma " << alp_gamma - << " anti_alias " << anti_alias_sw << " reference " << ref_mode + << " anti_alias " << anti_alias_sw << " reference " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " << frame; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { TRasterP in_ras = tile.getRaster(); - in_ras->lock(); - TRasterGR8P in_gr8(in_ras->getLy(), in_ras->getLx() * ino::channels() * ((TRaster64P)in_ras ? sizeof(unsigned short) : sizeof(unsigned char))); + + in_ras->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } in_gr8->lock(); + ino::ras_to_arr(in_ras, ino::channels(), in_gr8->getRawData()); - const TRasterP refer_ras = - (reference_sw ? reference_tile.getRaster() : nullptr); + const TRasterP refer_ras = (refer_sw ? refer_tile.getRaster() : nullptr); igs::levels::change( in_gr8->getRawData() @@ -247,9 +250,12 @@ void ino_level_rgba::doCompute(TTile &tile, double frame, ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , v_red_in.first, v_red_in.second, v_gre_in.first, v_gre_in.second, @@ -267,12 +273,18 @@ void ino_level_rgba::doCompute(TTile &tile, double frame, ); ino::arr_to_ras(in_gr8->getRawData(), ino::channels(), in_ras, 0); - in_gr8->unlock(); + in_gr8->unlock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } in_ras->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -281,6 +293,9 @@ void ino_level_rgba::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -289,6 +304,9 @@ void ino_level_rgba::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_maxmin.cpp b/toonz/sources/stdfx/ino_maxmin.cpp index cf2a3ae..e431e0e 100644 --- a/toonz/sources/stdfx/ino_maxmin.cpp +++ b/toonz/sources/stdfx/ino_maxmin.cpp @@ -100,7 +100,7 @@ void fx_(const TRasterP in_ras // with margin const int margin, TRasterP out_ras // no margin , - const TRasterP refer_ras, const int ref_mode + const TRasterP refer_ras, const int refer_mode , const int min_sw, const double radius, const double smoothing_edge, @@ -123,12 +123,13 @@ void fx_(const TRasterP in_ras // with margin in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) : 0) - , - radius, smoothing_edge // smooth_outer_range + , + refer_mode, radius, smoothing_edge // smooth_outer_range , npolygon, degree + 180.0 @@ -168,7 +169,7 @@ void ino_maxmin::doCompute(TTile &tile, double frame, const double degree = this->m_degree->getValue(frame); const bool alp_rend_sw = this->m_alpha_rendering->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* tcomposer(RenderManager)でRenderingするときはthreadは1つ、 toonz(Desktop)でPreview,Outputするなら-1を指定 @@ -220,12 +221,12 @@ void ino_maxmin::doCompute(TTile &tile, double frame, tile.getRaster(), frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile ref_tile; - bool ref_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - ref_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - ref_tile, enlarge_tile.m_pos, + refer_tile, enlarge_tile.m_pos, TDimensionI(/* Pixel単位 */ enlarge_tile.getRaster()->getLx(), enlarge_tile.getRaster()->getLy()), @@ -243,21 +244,24 @@ void ino_maxmin::doCompute(TTile &tile, double frame, << " min_sw " << min_sw << " radius " << radius << " npolygon " << npolygon << " degree " << degree << " alp_rend_sw " << alp_rend_sw << " smoothing_edge " << smoothing_edge_ << " nthread " << nthread - << " ref_mode " << ref_mode << " tile w " << tile.getRaster()->getLx() - << " h " << tile.getRaster()->getLy() << " pixbits " - << ino::pixel_bits(tile.getRaster()) << " frame " << frame - << " rand_sets affine_det " << rend_sets.m_affine.det() + << " refer_mode " << refer_mode << " tile w " + << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() + << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " + << frame << " rand_sets affine_det " << rend_sets.m_affine.det() << " shrink x " << rend_sets.m_shrinkX << " y " << rend_sets.m_shrinkY; - if (ref_sw) { - os << " ref_tile.m_pos " << ref_tile.m_pos << " ref_tile_getLx " - << ref_tile.getRaster()->getLx() << " y " - << ref_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - const TRasterP refer_ras = (ref_sw ? ref_tile.getRaster() : nullptr); + enlarge_tile.getRaster()->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } fx_(enlarge_tile.getRaster() // in with margin , enlarge_pixel // margin @@ -265,17 +269,25 @@ void ino_maxmin::doCompute(TTile &tile, double frame, tile.getRaster() // out with no margin , - refer_ras, ref_mode + refer_tile.getRaster(), refer_mode , min_sw, radius, smoothing_edge_, npolygon, degree, alp_rend_sw , nthread); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -284,6 +296,10 @@ void ino_maxmin::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -292,6 +308,10 @@ void ino_maxmin::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_median.cpp b/toonz/sources/stdfx/ino_median.cpp index 9ccaf23..ca8b374 100644 --- a/toonz/sources/stdfx/ino_median.cpp +++ b/toonz/sources/stdfx/ino_median.cpp @@ -87,7 +87,7 @@ void fx_(const TRasterP in_ras // with margin const int margin, TRasterP out_ras // no margin , - const TRasterP refer_ras, const int ref_mode + const TRasterP refer_ras, const int refer_mode , const double radius, const int channel) { @@ -106,9 +106,12 @@ void fx_(const TRasterP in_ras // with margin in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , channel, radius, 0 /* 0=Spread:外は淵のピクセル値が続いているとする */ @@ -146,8 +149,8 @@ void ino_median::doCompute(TTile &tile, double frame, /* ------ Pixel単位で動作パラメータを得る ----------------- */ const double radius = this->m_radius->getValue(frame) * mm2scale_shrink_pixel; /* 動作パラメータを得る */ - const int channel = this->m_channel->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int channel = this->m_channel->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 参照マージン含めた画像生成 ---------------------- */ /* Rendering画像のBBox値 --> Pixel単位のdouble値 */ @@ -194,12 +197,12 @@ void ino_median::doCompute(TTile &tile, double frame, tile.getRaster(), frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile ref_tile; - bool ref_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - ref_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - ref_tile, enlarge_tile.m_pos, + refer_tile, enlarge_tile.m_pos, TDimensionI(/* Pixel単位 */ enlarge_tile.getRaster()->getLx(), enlarge_tile.getRaster()->getLy()), @@ -214,22 +217,25 @@ void ino_median::doCompute(TTile &tile, double frame, if (log_sw) { std::ostringstream os; os << "params" - << " radius " << radius << " channel " << channel << " ref_mode " - << ref_mode << " tile w " << tile.getRaster()->getLx() << " h " + << " radius " << radius << " channel " << channel << " refer_mode " + << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " << frame << " rand_sets affine_det " << rend_sets.m_affine.det() << " shrink x " << rend_sets.m_shrinkX << " y " << rend_sets.m_shrinkY; - if (ref_sw) { - os << " ref_tile.m_pos " << ref_tile.m_pos << " ref_tile_getLx " - << ref_tile.getRaster()->getLx() << " y " - << ref_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - const TRasterP refer_ras = (ref_sw ? ref_tile.getRaster() : nullptr); + enlarge_tile.getRaster()->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } fx_(enlarge_tile.getRaster() // in with margin , enlarge_pixel // margin @@ -237,14 +243,22 @@ void ino_median::doCompute(TTile &tile, double frame, tile.getRaster() // out with no margin , - refer_ras, ref_mode + refer_tile.getRaster(), refer_mode , radius, channel); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -253,6 +267,10 @@ void ino_median::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -261,6 +279,10 @@ void ino_median::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_median_filter.cpp b/toonz/sources/stdfx/ino_median_filter.cpp index 9e90011..2d7b797 100644 --- a/toonz/sources/stdfx/ino_median_filter.cpp +++ b/toonz/sources/stdfx/ino_median_filter.cpp @@ -72,7 +72,7 @@ void fx_(const TRasterP in_ras // with margin const int margin, TRasterP out_ras // no margin , - const TRasterP refer_ras, const int ref_mode + const TRasterP refer_ras, const int refer_mode , const double radius, const int channel) { @@ -91,9 +91,12 @@ void fx_(const TRasterP in_ras // with margin in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(in_ras) , - (((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , channel, radius, 0 /* 0=Spread:外は淵のピクセル値が続いているとする */ @@ -119,9 +122,9 @@ void ino_median_filter::doCompute(TTile &tile, double frame, /* ------ Pixel単位で動作パラメータを得る ----------------- */ /* 動作パラメータを得る */ - const double radius = this->m_radius->getValue(frame); - const int channel = this->m_channel->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const double radius = this->m_radius->getValue(frame); + const int channel = this->m_channel->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 参照マージン含めた画像生成 ---------------------- */ /* Rendering画像のBBox値 --> Pixel単位のdouble値 */ @@ -168,12 +171,12 @@ void ino_median_filter::doCompute(TTile &tile, double frame, tile.getRaster(), frame, rend_sets); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, enlarge_tile.m_pos, + refer_tile, enlarge_tile.m_pos, TDimensionI(/* Pixel単位 */ enlarge_tile.getRaster()->getLx(), enlarge_tile.getRaster()->getLy()), @@ -188,23 +191,25 @@ void ino_median_filter::doCompute(TTile &tile, double frame, if (log_sw) { std::ostringstream os; os << "params" - << " radius " << radius << " channel " << channel << " ref_mode " - << ref_mode << " tile w " << tile.getRaster()->getLx() << " h " + << " radius " << radius << " channel " << channel << " refer_mode " + << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()) << " frame " << frame << " rand_sets affine_det " << rend_sets.m_affine.det() << " shrink x " << rend_sets.m_shrinkX << " y " << rend_sets.m_shrinkY; - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - const TRasterP refer_ras = - (reference_sw ? reference_tile.getRaster() : nullptr); + enlarge_tile.getRaster()->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } fx_(enlarge_tile.getRaster() // in with margin , enlarge_pixel // margin @@ -212,14 +217,22 @@ void ino_median_filter::doCompute(TTile &tile, double frame, tile.getRaster() // out with no margin , - refer_ras, ref_mode + refer_tile.getRaster(), refer_mode , radius, channel); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -228,6 +241,10 @@ void ino_median_filter::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -236,6 +253,10 @@ void ino_median_filter::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_motion_wind.cpp b/toonz/sources/stdfx/ino_motion_wind.cpp index d642e0a..a4adf19 100644 --- a/toonz/sources/stdfx/ino_motion_wind.cpp +++ b/toonz/sources/stdfx/ino_motion_wind.cpp @@ -173,7 +173,7 @@ void fx_(const TRasterP in_ras // with margin , const TRasterP refer_ras // with margin , - const int ref_mode, const int margin, TRasterP out_ras // no margin + const int refer_mode, const int margin, TRasterP out_ras // no margin , const int direction, const bool dark_sw, const bool alpha_rendering_sw @@ -204,7 +204,7 @@ void fx_(const TRasterP in_ras // with margin in_gr8->lock(); ino::ras_to_arr(in_ras, ino::channels(), in_gr8->getRawData()); - if (0 != refer_ras) { + if (refer_ras != nullptr) { TRasterGR8P refer_gr8(refer_ras->getLy(), refer_ras->getLx() * ino::channels() * ((TRaster64P)refer_ras ? sizeof(unsigned short) @@ -228,18 +228,14 @@ void fx_(const TRasterP in_ras // with margin ino::bits(refer_ras) , - ref_mode + refer_mode , direction, dark_sw, alpha_rendering_sw , - length_seed, length_min, length_max, length_bias, length_ref_sw - - , - force_seed, force_min, force_max, force_bias, force_ref_sw - - , + length_seed, length_min, length_max, length_bias, length_ref_sw, + force_seed, force_min, force_max, force_bias, force_ref_sw, density_seed, density_min, density_max, density_bias, density_ref_sw); /***ino::vec_to_ras( refer_vec, 0, 0 ); ino::vec_to_ras( in_vec, ino::channels(), out_ras, margin );***/ @@ -340,7 +336,7 @@ void ino_motion_wind::doCompute(TTile &tile, double frame, this->m_density_bias->getValue(frame) / ino::param_range(); const unsigned long density_seed = this->m_density_seed->getValue(frame); const bool density_ref_sw = this->m_density_ref->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); /* ------ 参照マージン含めた画像生成 ---------------------- */ /* Rendering画像のBBox値 --> Pixel単位のdouble値 */ @@ -392,8 +388,8 @@ void ino_motion_wind::doCompute(TTile &tile, double frame, /* ------ 参照画像生成 ------------------------------------ */ TTile refer_tile; - const bool refer_cn_is = this->m_refer.isConnected(); - if (refer_cn_is) { + const bool refer_sw = this->m_refer.isConnected(); + if (refer_sw) { this->m_refer->allocateAndCompute( refer_tile // tile.m_pos, @@ -425,12 +421,12 @@ void ino_motion_wind::doCompute(TTile &tile, double frame, << " den_min " << density_min << " den_max " << density_max << " den_bias " << density_bias << " den_seed " << density_seed - << " den_ref_sw " << density_ref_sw << " reference " << ref_mode + << " den_ref_sw " << density_ref_sw << " reference " << refer_mode << " tile w " << tile.getRaster()->getLx() << " h " << tile.getRaster()->getLy() << " pixbits " << ino::pixel_bits(tile.getRaster()); - if (refer_cn_is) { + if (refer_sw) { os << " rtile w " << refer_tile.getRaster()->getLx() << " h " << refer_tile.getRaster()->getLy(); } @@ -441,14 +437,15 @@ void ino_motion_wind::doCompute(TTile &tile, double frame, /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - if (refer_cn_is) { + enlarge_tile.getRaster()->lock(); + if (refer_tile.getRaster() != nullptr) { refer_tile.getRaster()->lock(); } fx_(enlarge_tile.getRaster() // in with margin , - (refer_cn_is ? refer_tile.getRaster() : nullptr) // with margin + refer_tile.getRaster() // with margin , - ref_mode, enlarge_pixel // margin + refer_mode, enlarge_pixel // margin , tile.getRaster() // out with no margin @@ -456,23 +453,21 @@ void ino_motion_wind::doCompute(TTile &tile, double frame, direction, dark_sw, alp_rend_sw , - length_min, length_max, length_bias, length_seed, length_ref_sw - - , - force_min, force_max, force_bias, force_seed, force_ref_sw - - , - density_min, density_max, density_bias, density_seed, density_ref_sw); - if (refer_cn_is) { + length_min, length_max, length_bias, length_seed, length_ref_sw, + force_min, force_max, force_bias, force_seed, force_ref_sw, density_min, + density_max, density_bias, density_seed, density_ref_sw); + if (refer_tile.getRaster() != nullptr) { refer_tile.getRaster()->unlock(); } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { - if (refer_cn_is) { + if (refer_tile.getRaster() != nullptr) { refer_tile.getRaster()->unlock(); } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -481,9 +476,10 @@ void ino_motion_wind::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { - if (refer_cn_is) { + if (refer_tile.getRaster() != nullptr) { refer_tile.getRaster()->unlock(); } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -492,9 +488,10 @@ void ino_motion_wind::doCompute(TTile &tile, double frame, } throw; } catch (...) { - if (refer_cn_is) { + if (refer_tile.getRaster() != nullptr) { refer_tile.getRaster()->unlock(); } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_radial_blur.cpp b/toonz/sources/stdfx/ino_radial_blur.cpp index b2e6888..6cbd8ef 100644 --- a/toonz/sources/stdfx/ino_radial_blur.cpp +++ b/toonz/sources/stdfx/ino_radial_blur.cpp @@ -167,7 +167,7 @@ void fx_(const TRasterP in_ras // with margin , const TRasterP refer_ras // no margin , - const int ref_mode + const int refer_mode , TRasterP out_ras // no margin @@ -188,9 +188,12 @@ void fx_(const TRasterP in_ras // with margin 0 /* margin機能は使っていない、のでinとref画像は同サイズ */ , - (((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , in_gr8->getRawData() // BGRA @@ -229,7 +232,7 @@ void ino_radial_blur::doCompute(TTile &tile, double frame, // const double twist_radius = this->m_twist_radius->getValue(frame)*scale; const bool alpha_rend_sw = this->m_alpha_rendering->getValue(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); TPointD center = this->m_center->getValue(frame); TPointD render_center( @@ -251,20 +254,20 @@ void ino_radial_blur::doCompute(TTile &tile, double frame, tile_with_margin = tile_with_margin.enlarge(margin); } /*------ 入力画像生成 --------------------------------------*/ - TTile tile_allocated; + TTile enlarge_tile; this->m_input->allocateAndCompute( - tile_allocated, tile_with_margin.getP00(), + enlarge_tile, tile_with_margin.getP00(), TDimensionI(/* Pixel単位で四捨五入 */ static_cast(tile_with_margin.getLx() + 0.5), static_cast(tile_with_margin.getLy() + 0.5)), tile.getRaster(), frame, ri); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, tile_with_margin.getP00(), + refer_tile, tile_with_margin.getP00(), TDimensionI(/* Pixel単位で四捨五入 */ static_cast(tile_with_margin.getLx() + 0.5), static_cast(tile_with_margin.getLy() + 0.5)), @@ -281,7 +284,7 @@ void ino_radial_blur::doCompute(TTile &tile, double frame, << " cx " << center.x << " cy " << center.y << " blur " << blur << " radius " << radius << " twist " << twist // << " twist_radius " << twist_radius - << " reference " << ref_mode << " alpha_rendering " << alpha_rend_sw + << " reference " << refer_mode << " alpha_rendering " << alpha_rend_sw << " anti_alias " << anti_alias_sw << " render_center " << render_center << " frame " << frame << " pixbits " << ino::pixel_bits(tile.getRaster()) << " tile.m_pos " << tile.m_pos @@ -290,22 +293,26 @@ void ino_radial_blur::doCompute(TTile &tile, double frame, << " ri.m_affine " << ri.m_affine << " ri_m_affine_det " << ri.m_affine.det() << " shrink_x " << ri.m_shrinkX << " shrink_y " << ri.m_shrinkY << " tile_with_margin " << tile_with_margin - << " tile_allocated.m_pos " << tile_allocated.m_pos - << " tile_allocated_getLx " << tile_allocated.getRaster()->getLx() - << " y " << tile_allocated.getRaster()->getLy(); - if (reference_sw) { - os << " reference_tile.m_pos " << reference_tile.m_pos - << " reference_tile_getLx " << reference_tile.getRaster()->getLx() - << " y " << reference_tile.getRaster()->getLy(); + << " enlarge_tile.m_pos " << enlarge_tile.m_pos + << " tile_allocated_getLx " << enlarge_tile.getRaster()->getLx() + << " y " << enlarge_tile.getRaster()->getLy(); + if (refer_sw) { + os << " refer_tile.m_pos " << refer_tile.m_pos << " refer_tile_getLx " + << refer_tile.getRaster()->getLx() << " y " + << refer_tile.getRaster()->getLy(); } } /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - fx_(tile_allocated.getRaster(), margin + enlarge_tile.getRaster()->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(enlarge_tile.getRaster(), margin , - (reference_sw ? reference_tile.getRaster() : nullptr), ref_mode + refer_tile.getRaster(), refer_mode , tile.getRaster() @@ -314,10 +321,18 @@ void ino_radial_blur::doCompute(TTile &tile, double frame, render_center.x, render_center.y, twist, 0.0 // twist_radius , blur, radius, alpha_rend_sw, anti_alias_sw); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -326,6 +341,10 @@ void ino_radial_blur::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -334,6 +353,10 @@ void ino_radial_blur::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception"); diff --git a/toonz/sources/stdfx/ino_spin_blur.cpp b/toonz/sources/stdfx/ino_spin_blur.cpp index 4a019bb..e22989c 100644 --- a/toonz/sources/stdfx/ino_spin_blur.cpp +++ b/toonz/sources/stdfx/ino_spin_blur.cpp @@ -151,7 +151,7 @@ void fx_(const TRasterP in_ras // with margin , const TRasterP refer_ras // no margin , - const int ref_mode + const int refer_mode , TRasterP out_ras // no margin @@ -172,9 +172,12 @@ void fx_(const TRasterP in_ras // with margin 0 /* margin機能は使っていない、のでinとref画像は同サイズ */ , - (((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA + (((refer_ras != nullptr) && (0 <= refer_mode)) ? refer_ras->getRawData() + : nullptr) // BGRA , - (((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode + (((refer_ras != nullptr) && (0 <= refer_mode)) ? ino::bits(refer_ras) + : 0), + refer_mode , in_gr8->getRawData() // BGRA @@ -183,10 +186,11 @@ void fx_(const TRasterP in_ras // with margin in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(out_ras) , - xp + margin, yp + margin, blur /*degree*/, radius, - ((0 < type) ? 0.0 : (out_ras->getLy() / 2.0)) + xp + margin, yp + margin, blur /*degree*/ + , + radius, ((0 < type) ? 0.0 : (out_ras->getLy() / 2.0)) - , + , (anti_alias_sw ? 4 : 1), alpha_rendering_sw); ino::arr_to_ras(in_gr8->getRawData(), ino::channels(), out_ras, margin); @@ -212,7 +216,7 @@ void ino_spin_blur::doCompute(TTile &tile, double frame, const int type = this->m_type->getValue(); const bool alpha_rend_sw = this->m_alpha_rendering->getValue(); const bool anti_alias_sw = this->m_anti_alias->getValue(); - const int ref_mode = this->m_ref_mode->getValue(); + const int refer_mode = this->m_ref_mode->getValue(); TPointD center = this->m_center->getValue(frame); TPointD render_center( @@ -234,20 +238,20 @@ void ino_spin_blur::doCompute(TTile &tile, double frame, bBox = bBox.enlarge(margin); } /*------ 入力画像生成 --------------------------------------*/ - TTile in_enlarge_tile; + TTile enlarge_tile; this->m_input->allocateAndCompute( - in_enlarge_tile, bBox.getP00(), + enlarge_tile, bBox.getP00(), TDimensionI(/* Pixel単位で四捨五入 */ static_cast(bBox.getLx() + 0.5), static_cast(bBox.getLy() + 0.5)), tile.getRaster(), frame, ri); /*------ 参照画像生成 --------------------------------------*/ - TTile reference_tile; - bool reference_sw = false; + TTile refer_tile; + bool refer_sw = false; if (this->m_refer.isConnected()) { - reference_sw = true; + refer_sw = true; this->m_refer->allocateAndCompute( - reference_tile, bBox.getP00(), + refer_tile, bBox.getP00(), TDimensionI(/* Pixel単位で四捨五入 */ static_cast(bBox.getLx() + 0.5), static_cast(bBox.getLy() + 0.5)), @@ -263,22 +267,20 @@ void ino_spin_blur::doCompute(TTile &tile, double frame, os << "params" << " cx " << center.x << " cy " << center.y << " blur " << blur << " radius " << radius << " type " << type << " reference " - << ref_mode << " alpha_rendering " << alpha_rend_sw << " anti_alias " + << refer_mode << " alpha_rendering " << alpha_rend_sw << " anti_alias " << anti_alias_sw << " rend_cx " << render_center.x << " rend_cy " << render_center.y << " tx " << tile.m_pos.x << " ty " << tile.m_pos.y << " tw " << tile.getRaster()->getLx() << " th " << tile.getRaster()->getLy() << " tb " << ino::pixel_bits(tile.getRaster()) << " margin " << margin << " bx0 " << bBox.x0 << " by0 " << bBox.y0 << " bx1 " << bBox.x1 << " by1 " - << bBox.y1 << " ix " << in_enlarge_tile.m_pos.x << " iy " - << in_enlarge_tile.m_pos.y << " iw " - << in_enlarge_tile.getRaster()->getLx() << " ih " - << in_enlarge_tile.getRaster()->getLy(); - if (reference_sw) { - os << " rx " << reference_tile.m_pos.x << " ry " - << reference_tile.m_pos.y << " rw " - << reference_tile.getRaster()->getLx() << " rh " - << reference_tile.getRaster()->getLy(); + << bBox.y1 << " ix " << enlarge_tile.m_pos.x << " iy " + << enlarge_tile.m_pos.y << " iw " << enlarge_tile.getRaster()->getLx() + << " ih " << enlarge_tile.getRaster()->getLy(); + if (refer_sw) { + os << " rx " << refer_tile.m_pos.x << " ry " << refer_tile.m_pos.y + << " rw " << refer_tile.getRaster()->getLx() << " rh " + << refer_tile.getRaster()->getLy(); } os << " frame " << frame << " ri_aff_det " << ri.m_affine.det() << " shrink_x " << ri.m_shrinkX << " shrink_y " << ri.m_shrinkY; @@ -286,10 +288,14 @@ void ino_spin_blur::doCompute(TTile &tile, double frame, /* ------ fx処理 ------------------------------------------ */ try { tile.getRaster()->lock(); - fx_(in_enlarge_tile.getRaster(), margin + enlarge_tile.getRaster()->lock(); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->lock(); + } + fx_(enlarge_tile.getRaster(), margin , - (reference_sw ? reference_tile.getRaster() : nullptr), ref_mode + refer_tile.getRaster(), refer_mode , tile.getRaster() @@ -297,10 +303,18 @@ void ino_spin_blur::doCompute(TTile &tile, double frame, , render_center.x, render_center.y, type, blur, radius, alpha_rend_sw, anti_alias_sw); + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); } /* ------ error処理 --------------------------------------- */ catch (std::bad_alloc &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("std::bad_alloc <"); @@ -309,6 +323,10 @@ void ino_spin_blur::doCompute(TTile &tile, double frame, } throw; } catch (std::exception &e) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("exception <"); @@ -317,6 +335,10 @@ void ino_spin_blur::doCompute(TTile &tile, double frame, } throw; } catch (...) { + if (refer_tile.getRaster() != nullptr) { + refer_tile.getRaster()->unlock(); + } + enlarge_tile.getRaster()->unlock(); tile.getRaster()->unlock(); if (log_sw) { std::string str("other exception");