/* * This file is part of RawTherapee. * * Copyright (c) 2004-2010 Gabor Horvath * * RawTherapee is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RawTherapee is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ #include #include #include #include #undef THREAD_PRIORITY_NORMAL #define MAXVAL 0xffff #define CLIP(a) ((a)>0?((a)r[i][j] + lumi[1]*img->g[i][j] + lumi[2]*img->b[i][j]; map[i][j] = CLIP(val); } //MyTime t1,t2; //t1.set (); if (!hq) { AlignedBuffer* buffer1 = new AlignedBuffer (MAX(W,H)*5); AlignedBuffer* buffer2 = new AlignedBuffer (MAX(W,H)*5); // blur if (settings->dualThreadEnabled) { Glib::Thread *thread1 = Glib::Thread::create(sigc::bind(sigc::ptr_fun(gaussHorizontal_unsigned), map, map, buffer1, W, 0, H/2, radius), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); Glib::Thread *thread2 = Glib::Thread::create(sigc::bind(sigc::ptr_fun(gaussHorizontal_unsigned), map, map, buffer2, W, H/2, H, radius), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); thread1->join (); thread2->join (); thread1 = Glib::Thread::create(sigc::bind(sigc::ptr_fun(gaussVertical_unsigned), map, map, buffer1, H, 0, W/2, radius), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); thread2 = Glib::Thread::create(sigc::bind(sigc::ptr_fun(gaussVertical_unsigned), map, map, buffer2, H, W/2, W, radius), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); thread1->join (); thread2->join (); } else { gaussHorizontal_unsigned (map, map, buffer1, W, 0, H, radius); gaussVertical_unsigned (map, map, buffer1, H, 0, W, radius); } delete buffer1; delete buffer2; } else { if (settings->dualThreadEnabled) { bilateralparams r1, r2; r1.row_from = 0; r1.row_to = H/2; r2.row_from = H/2; r2.row_to = H; Glib::Thread *thread1 = Glib::Thread::create(sigc::bind(sigc::ptr_fun(bilateral_box_unsigned), map, buffer, W, H, 8000, radius, r1), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); Glib::Thread *thread2 = Glib::Thread::create(sigc::bind(sigc::ptr_fun(bilateral_box_unsigned), map, buffer, W, H, 8000, radius, r2), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); thread1->join (); thread2->join (); } else { bilateralparams r1; r1.row_from = 0; r1.row_to = H; bilateral_box_unsigned (map, buffer, W, H, 8000, radius, r1); } for (int i=0; i0 && j>0 && i max) max = val; _avg = 1.0/n * val + (1.0 - 1.0/n) * _avg; n++; } avg = (int) _avg; } void SHMap::forceStat (unsigned short max_, unsigned short min_, unsigned short avg_) { max = max_; min = min_; avg = avg_; } }