From c819cb63a253b7ee1e884c43063537317e610b42 Mon Sep 17 00:00:00 2001 From: rom9 <4711834+rom9@users.noreply.github.com> Date: Wed, 12 Jun 2019 22:11:34 +0200 Subject: [PATCH 1/2] Speed boost in the median vectors fill via loop unrolling --- rtengine/filmnegativeproc.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/rtengine/filmnegativeproc.cc b/rtengine/filmnegativeproc.cc index db98fdf02..7c7103dc6 100644 --- a/rtengine/filmnegativeproc.cc +++ b/rtengine/filmnegativeproc.cc @@ -150,16 +150,28 @@ void RawImageSource::filmNegativeProcess(const procparams::FilmNegativeParams &p // Chose an odd step, not multiple of the CFA size, to get a chance to visit each channel. if(ri->getSensorType() == ST_BAYER) { for (int row = 0; row < H; row+=5) { - for (int col = 0; col < W; col+=5) { - int c = FC(row, col); // three colors, 0=R, 1=G, 2=B - cvs[c].push_back(rawData[row][col]); + int col = 0; + int c0 = FC(row, col); + int c1 = FC(row, col + 5); + for (; col < W - 5; col+=10) { + cvs[c0].push_back(rawData[row][col]); + cvs[c1].push_back(rawData[row][col + 5]); + } + if (col < W) { + cvs[c0].push_back(rawData[row][col]); } } } else if(ri->getSensorType() == ST_FUJI_XTRANS) { for (int row = 0; row < H; row+=5) { - for (int col = 0; col < W; col+=5) { - int c = ri->XTRANSFC(row, col); // three colors, 0=R, 1=G, 2=B - cvs[c].push_back(rawData[row][col]); + int col = 0; + const unsigned int cs[6] = {ri->XTRANSFC(row, 0), ri->XTRANSFC(row, 5), ri->XTRANSFC(row, 10), ri->XTRANSFC(row, 15), ri->XTRANSFC(row, 20), ri->XTRANSFC(row, 25)}; + for (; col < W - 25; col += 30) { + for (int c = 0; c < 6; ++c) { + cvs[cs[c]].push_back(rawData[row][col + c * 5]); + } + } + for (int c = 0; col < W; col += 5, ++c) { + cvs[cs[c]].push_back(rawData[row][col]); } } } From d01f78864c9052963d354a9c0b3cdb60f82e38be Mon Sep 17 00:00:00 2001 From: rom9 <4711834+rom9@users.noreply.github.com> Date: Fri, 14 Jun 2019 22:14:24 +0200 Subject: [PATCH 2/2] Locked red and blue exponents by default in the GUI, added CheckButton to unlock them. --- rtdata/languages/default | 4 +++- rtgui/filmnegative.cc | 33 +++++++++++++++++++++++++++------ rtgui/filmnegative.h | 4 ++++ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 1c6a1acba..36e441015 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1639,9 +1639,11 @@ TP_EXPOSURE_TCMODE_WEIGHTEDSTD;Weighted Standard TP_EXPOS_BLACKPOINT_LABEL;Raw Black Points TP_EXPOS_WHITEPOINT_LABEL;Raw White Points TP_FILMNEGATIVE_BLUE;Blue exponent -TP_FILMNEGATIVE_GREEN;Green exponent +TP_FILMNEGATIVE_GREEN;Green exponent (lead) TP_FILMNEGATIVE_GUESS_TOOLTIP;Calculate exponents by picking 2 neutral reference spots in the image; one white (light gray) and one black (dark gray).\nThe order does not matter. The exponents will be updated after the second spot is picked. TP_FILMNEGATIVE_LABEL;Film Negative +TP_FILMNEGATIVE_LOCKCHANNELS;Lock exponent ratios +TP_FILMNEGATIVE_LOCKCHANNELS_TOOLTIP;Unlock to adjust channel exponents independently. This allows to adapt to the color characteristics of different film types. TP_FILMNEGATIVE_PICK;Pick white and black spots TP_FILMNEGATIVE_RED;Red exponent TP_FILMNEGATIVE_REF_SPOTS;Film negative reference spots diff --git a/rtgui/filmnegative.cc b/rtgui/filmnegative.cc index 8f1fb5610..72307946b 100644 --- a/rtgui/filmnegative.cc +++ b/rtgui/filmnegative.cc @@ -49,6 +49,9 @@ FilmNegative::FilmNegative () : FoldableToolPanel(this, "filmnegative", M("TP_FI greenExp = mkExponentAdjuster(M("TP_FILMNEGATIVE_GREEN"), 2.0); blueExp = mkExponentAdjuster(M("TP_FILMNEGATIVE_BLUE"), 1.72); + redExp->set_sensitive(false); + blueExp->set_sensitive(false); + redRatio = redExp->getValue() / greenExp->getValue(); blueRatio = blueExp->getValue() / greenExp->getValue(); @@ -56,6 +59,10 @@ FilmNegative::FilmNegative () : FoldableToolPanel(this, "filmnegative", M("TP_FI EvFilmNegativeEnabled = m->newEvent(FIRST, "HISTORY_MSG_FILMNEGATIVE_ENABLED"); EvFilmNegativeExponents = m->newEvent(FIRST, "HISTORY_MSG_FILMNEGATIVE_EXPONENTS"); + lockChannels = Gtk::manage (new Gtk::CheckButton (M("TP_FILMNEGATIVE_LOCKCHANNELS"))); + lockChannels->set_tooltip_text(M("TP_FILMNEGATIVE_LOCKCHANNELS_TOOLTIP")); + lockChannels->set_active (true); + spotgrid = Gtk::manage(new Gtk::Grid()); spotgrid->get_style_context()->add_class("grid-spacing"); @@ -86,11 +93,13 @@ FilmNegative::FilmNegative () : FoldableToolPanel(this, "filmnegative", M("TP_FI // spotgrid->attach (*slab, 1, 0, 1, 1); // spotgrid->attach (*wbsizehelper, 2, 0, 1, 1); + pack_start (*lockChannels, Gtk::PACK_SHRINK, 0); pack_start (*redExp, Gtk::PACK_SHRINK, 0); pack_start (*greenExp, Gtk::PACK_SHRINK, 0); pack_start (*blueExp, Gtk::PACK_SHRINK, 0); pack_start (*spotgrid, Gtk::PACK_SHRINK, 0 ); + lockChannels->signal_toggled().connect( sigc::mem_fun(*this, &FilmNegative::lockChannelsToggled) ); spotbutton->signal_toggled().connect( sigc::mem_fun(*this, &FilmNegative::editToggled) ); // spotsize->signal_changed().connect( sigc::mem_fun(*this, &WhiteBalance::spotSizeChanged) ); @@ -191,6 +200,12 @@ void FilmNegative::editToggled () } } +void FilmNegative::lockChannelsToggled () +{ + bool unlocked = !lockChannels->get_active(); + redExp->set_sensitive(unlocked); + blueExp->set_sensitive(unlocked); +} void FilmNegative::read (const ProcParams* pp, const ParamsEdited* pedited) { @@ -245,12 +260,18 @@ void FilmNegative::setDefaults (const ProcParams* defParams, const ParamsEdited* void FilmNegative::setBatchMode (bool batchMode) { - spotConn.disconnect(); - removeIfThere(this, spotgrid, false); - ToolPanel::setBatchMode (batchMode); - redExp->showEditedCB (); - greenExp->showEditedCB (); - blueExp->showEditedCB (); + if(batchMode) { + spotConn.disconnect(); + lockChannelsConn.disconnect(); + removeIfThere(this, spotgrid, false); + removeIfThere(this, lockChannels, false); + redExp->set_sensitive(true); + blueExp->set_sensitive(true); + ToolPanel::setBatchMode (batchMode); + redExp->showEditedCB (); + greenExp->showEditedCB (); + blueExp->showEditedCB (); + } } bool FilmNegative::mouseOver(int modifierKey) diff --git a/rtgui/filmnegative.h b/rtgui/filmnegative.h index 5d6c8ce03..1a2262aec 100644 --- a/rtgui/filmnegative.h +++ b/rtgui/filmnegative.h @@ -50,6 +50,9 @@ private: Adjuster* greenExp; Adjuster* blueExp; + Gtk::CheckButton* lockChannels; + sigc::connection lockChannelsConn; + Gtk::Grid* spotgrid; Gtk::ToggleButton* spotbutton; sigc::connection spotConn; @@ -57,6 +60,7 @@ private: double redRatio, blueRatio; void editToggled (); + void lockChannelsToggled (); public: