Merged master into rgbcurvesspeedup.
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
#include <cmath>
|
||||
#include <glib.h>
|
||||
#include <glibmm.h>
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#include "rtengine.h"
|
||||
#include "improcfun.h"
|
||||
@@ -39,9 +42,6 @@
|
||||
#include "ciecam02.h"
|
||||
#define BENCHMARK
|
||||
#include "StopWatch.h"
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
#undef CLIPD
|
||||
#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f)
|
||||
|
||||
@@ -3081,25 +3081,42 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
||||
}
|
||||
}
|
||||
|
||||
ClutPtr colorLUT;
|
||||
std::shared_ptr<HaldCLUT> hald_clut;
|
||||
bool clutAndWorkingProfilesAreSame = false;
|
||||
TMatrix xyz2clut, clut2xyz;
|
||||
#ifdef __SSE2__
|
||||
vfloat v_work2xyz[3][3] ALIGNED16;
|
||||
vfloat v_xyz2clut[3][3] ALIGNED16;
|
||||
vfloat v_clut2xyz[3][3] ALIGNED16;
|
||||
vfloat v_xyz2work[3][3] ALIGNED16;
|
||||
#endif
|
||||
|
||||
if ( params->filmSimulation.enabled && !params->filmSimulation.clutFilename.empty() ) {
|
||||
colorLUT.set( clutStore.getClut( params->filmSimulation.clutFilename ) );
|
||||
hald_clut = CLUTStore::getInstance().getClut( params->filmSimulation.clutFilename );
|
||||
|
||||
if ( colorLUT ) {
|
||||
clutAndWorkingProfilesAreSame = colorLUT->profile() == params->icm.working;
|
||||
if ( hald_clut ) {
|
||||
clutAndWorkingProfilesAreSame = hald_clut->getProfile() == params->icm.working;
|
||||
|
||||
if ( !clutAndWorkingProfilesAreSame ) {
|
||||
xyz2clut = iccStore->workingSpaceInverseMatrix( colorLUT->profile() );
|
||||
clut2xyz = iccStore->workingSpaceMatrix( colorLUT->profile() );
|
||||
xyz2clut = iccStore->workingSpaceInverseMatrix( hald_clut->getProfile() );
|
||||
clut2xyz = iccStore->workingSpaceMatrix( hald_clut->getProfile() );
|
||||
|
||||
#ifdef __SSE2__
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
v_work2xyz[i][j] = F2V(wprof[i][j]);
|
||||
v_xyz2clut[i][j] = F2V(xyz2clut[i][j]);
|
||||
v_xyz2work[i][j] = F2V(wiprof[i][j]);
|
||||
v_clut2xyz[i][j] = F2V(clut2xyz[i][j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double filmSimCorrectedStrength = double(params->filmSimulation.strength) / 100.;
|
||||
double filmSimSourceStrength = double(100 - params->filmSimulation.strength) / 100.;
|
||||
const float film_simulation_strength = static_cast<float>(params->filmSimulation.strength) / 100.0f;
|
||||
|
||||
const float exp_scale = pow (2.0, expcomp);
|
||||
const float comp = (max(0.0, expcomp) + 1.0) * hlcompr / 100.0;
|
||||
@@ -3295,6 +3312,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
||||
editWhateverTmp = (float(*))data;
|
||||
}
|
||||
|
||||
float out_rgbx[4 * TS] ALIGNED16; // Line buffer for CLUT
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for schedule(dynamic) collapse(2)
|
||||
@@ -4193,50 +4211,114 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
|
||||
}
|
||||
|
||||
|
||||
//Film Simulations
|
||||
if ( colorLUT ) {
|
||||
// Film Simulations
|
||||
if (hald_clut) {
|
||||
|
||||
for (int i = istart, ti = 0; i < tH; i++, ti++) {
|
||||
if (!clutAndWorkingProfilesAreSame) {
|
||||
// Convert from working to clut profile
|
||||
int j = jstart;
|
||||
int tj = 0;
|
||||
|
||||
#ifdef __SSE2__
|
||||
for (; j < tW - 3; j += 4, tj += 4) {
|
||||
vfloat sourceR = LVF(rtemp[ti * TS + tj]);
|
||||
vfloat sourceG = LVF(gtemp[ti * TS + tj]);
|
||||
vfloat sourceB = LVF(btemp[ti * TS + tj]);
|
||||
|
||||
vfloat x;
|
||||
vfloat y;
|
||||
vfloat z;
|
||||
Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_work2xyz);
|
||||
Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2clut);
|
||||
|
||||
STVF(rtemp[ti * TS + tj], sourceR);
|
||||
STVF(gtemp[ti * TS + tj], sourceG);
|
||||
STVF(btemp[ti * TS + tj], sourceB);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (; j < tW; j++, tj++) {
|
||||
float &sourceR = rtemp[ti * TS + tj];
|
||||
float &sourceG = gtemp[ti * TS + tj];
|
||||
float &sourceB = btemp[ti * TS + tj];
|
||||
|
||||
float x, y, z;
|
||||
Color::rgbxyz( sourceR, sourceG, sourceB, x, y, z, wprof );
|
||||
Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, xyz2clut);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
||||
float &sourceR = rtemp[ti * TS + tj];
|
||||
float &sourceG = gtemp[ti * TS + tj];
|
||||
float &sourceB = btemp[ti * TS + tj];
|
||||
|
||||
if (!clutAndWorkingProfilesAreSame) {
|
||||
//convert from working to clut profile
|
||||
float x, y, z;
|
||||
Color::rgbxyz( sourceR, sourceG, sourceB, x, y, z, wprof );
|
||||
Color::xyz2rgb( x, y, z, sourceR, sourceG, sourceB, xyz2clut );
|
||||
// Apply gamma sRGB (default RT)
|
||||
sourceR = Color::gamma_srgbclipped(sourceR);
|
||||
sourceG = Color::gamma_srgbclipped(sourceG);
|
||||
sourceB = Color::gamma_srgbclipped(sourceB);
|
||||
}
|
||||
|
||||
const std::size_t line_offset = ti * TS;
|
||||
hald_clut->getRGB(
|
||||
film_simulation_strength,
|
||||
std::min(TS, tW - jstart),
|
||||
rtemp + line_offset,
|
||||
gtemp + line_offset,
|
||||
btemp + line_offset,
|
||||
out_rgbx
|
||||
);
|
||||
|
||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
||||
float &sourceR = rtemp[ti * TS + tj];
|
||||
float &sourceG = gtemp[ti * TS + tj];
|
||||
float &sourceB = btemp[ti * TS + tj];
|
||||
|
||||
// Apply inverse gamma sRGB
|
||||
sourceR = Color::igamma_srgb(out_rgbx[tj * 4 + 0]);
|
||||
sourceG = Color::igamma_srgb(out_rgbx[tj * 4 + 1]);
|
||||
sourceB = Color::igamma_srgb(out_rgbx[tj * 4 + 2]);
|
||||
}
|
||||
|
||||
if (!clutAndWorkingProfilesAreSame) {
|
||||
// Convert from clut to working profile
|
||||
int j = jstart;
|
||||
int tj = 0;
|
||||
|
||||
#ifdef __SSE2__
|
||||
for (; j < tW - 3; j += 4, tj += 4) {
|
||||
vfloat sourceR = LVF(rtemp[ti * TS + tj]);
|
||||
vfloat sourceG = LVF(gtemp[ti * TS + tj]);
|
||||
vfloat sourceB = LVF(btemp[ti * TS + tj]);
|
||||
|
||||
vfloat x;
|
||||
vfloat y;
|
||||
vfloat z;
|
||||
Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_clut2xyz);
|
||||
Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2work);
|
||||
|
||||
STVF(rtemp[ti * TS + tj], sourceR);
|
||||
STVF(gtemp[ti * TS + tj], sourceG);
|
||||
STVF(btemp[ti * TS + tj], sourceB);
|
||||
}
|
||||
#endif
|
||||
|
||||
//appply gamma sRGB (default RT)
|
||||
sourceR = CLIP<float>( Color::gamma_srgb( sourceR ) );
|
||||
sourceG = CLIP<float>( Color::gamma_srgb( sourceG ) );
|
||||
sourceB = CLIP<float>( Color::gamma_srgb( sourceB ) );
|
||||
for (; j < tW; j++, tj++) {
|
||||
float &sourceR = rtemp[ti * TS + tj];
|
||||
float &sourceG = gtemp[ti * TS + tj];
|
||||
float &sourceB = btemp[ti * TS + tj];
|
||||
|
||||
float r, g, b;
|
||||
colorLUT->getRGB( sourceR, sourceG, sourceB, r, g, b );
|
||||
// apply strength
|
||||
sourceR = r * filmSimCorrectedStrength + sourceR * filmSimSourceStrength;
|
||||
sourceG = g * filmSimCorrectedStrength + sourceG * filmSimSourceStrength;
|
||||
sourceB = b * filmSimCorrectedStrength + sourceB * filmSimSourceStrength;
|
||||
// apply inverse gamma sRGB
|
||||
sourceR = Color::igamma_srgb( sourceR );
|
||||
sourceG = Color::igamma_srgb( sourceG );
|
||||
sourceB = Color::igamma_srgb( sourceB );
|
||||
|
||||
if (!clutAndWorkingProfilesAreSame) {
|
||||
//convert from clut to working profile
|
||||
float x, y, z;
|
||||
Color::rgbxyz( sourceR, sourceG, sourceB, x, y, z, clut2xyz );
|
||||
Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, clut2xyz);
|
||||
Color::xyz2rgb( x, y, z, sourceR, sourceG, sourceB, wiprof );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!blackwhite) {
|
||||
if (!blackwhite) {
|
||||
// ready, fill lab
|
||||
for (int i = istart, ti = 0; i < tH; i++, ti++) {
|
||||
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
|
||||
|
||||
Reference in New Issue
Block a user