From 39f4db609a7c589043d84ef7e9a3ce13eb8aa972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Sun, 1 May 2016 11:10:11 +0200 Subject: [PATCH] Final code cleanup - Corrected whitespace and comments - Replaced `VECTLENSP` with `__SSE2__` and `4` - Removed redundant `inline` (see: http://programmers.stackexchange.com/a/35436 and http://stackoverflow.com/a/5971755) --- rtengine/clutstore.cc | 4 ++-- rtengine/improcfun.cc | 52 +++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/rtengine/clutstore.cc b/rtengine/clutstore.cc index b5f07c121..5e96046ae 100644 --- a/rtengine/clutstore.cc +++ b/rtengine/clutstore.cc @@ -75,7 +75,7 @@ bool loadFile( } #ifdef __SSE2__ -inline vfloat getClutValue(const AlignedBuffer& clut_image, size_t index) +vfloat getClutValue(const AlignedBuffer& clut_image, size_t index) { #ifdef __SSE4_1__ return _mm_cvtepi32_ps(_mm_cvtepu16_epi32(*reinterpret_cast(clut_image.data + index))); @@ -260,7 +260,7 @@ void rtengine::HaldCLUT::splitClutFilename( profile_name = "sRGB"; for (const auto& working_profile : rtengine::getWorkingProfiles()) { - if ( std::search( name.rbegin(), name.rend(), working_profile.rbegin(), working_profile.rend() ) == name.rbegin() ) { + if (std::search(name.rbegin(), name.rend(), working_profile.rbegin(), working_profile.rend()) == name.rbegin()) { profile_name = working_profile; name.erase(name.size() - working_profile.size()); break; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 4660ed6cb..c1079c8b1 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -3208,7 +3208,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer std::shared_ptr hald_clut; bool clutAndWorkingProfilesAreSame = false; TMatrix work2xyz, xyz2clut, clut2xyz, xyz2work; -#ifdef VECTLENSP +#ifdef __SSE2__ vfloat v_work2xyz[3][3]; vfloat v_xyz2clut[3][3]; vfloat v_clut2xyz[3][3]; @@ -3226,7 +3226,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer xyz2clut = iccStore->workingSpaceInverseMatrix( hald_clut->getProfile() ); xyz2work = iccStore->workingSpaceInverseMatrix( params->icm.working ); clut2xyz = iccStore->workingSpaceMatrix( hald_clut->getProfile() ); -#ifdef VECTLENSP +#ifdef __SSE2__ for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { v_work2xyz[i][j] = F2V(work2xyz[i][j]); @@ -4350,25 +4350,25 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } - //Film Simulations + // Film Simulations if (hald_clut) { float out_rgbx[4 * TS] ALIGNED16; for (int i = istart, ti = 0; i < tH; i++, ti++) { if (!clutAndWorkingProfilesAreSame) { -#ifdef VECTLENSP - if (!(std::min(TS, tW - jstart) & ~(VECTLENSP - 1))) { - for (int j = jstart, tj = 0; j < tW; j += VECTLENSP, tj += VECTLENSP) { + // Convert from working to clut profile +#ifdef __SSE2__ + if (!(std::min(TS, tW - jstart) & ~3)) { + for (int j = jstart, tj = 0; j < tW; 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]); - //convert from working to clut profile 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 ); + 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); @@ -4383,10 +4383,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceG = gtemp[ti * TS + tj]; float &sourceB = btemp[ti * TS + tj]; - //convert from working to clut profile float x, y, z; - Color::rgbxyz( sourceR, sourceG, sourceB, x, y, z, work2xyz ); - Color::xyz2rgb( x, y, z, sourceR, sourceG, sourceB, xyz2clut ); + Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, work2xyz); + Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, xyz2clut); } } } @@ -4396,10 +4395,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceG = gtemp[ti * TS + tj]; float &sourceB = btemp[ti * TS + tj]; - //apply gamma sRGB (default RT) - sourceR = Color::gamma_srgbclipped( sourceR ); - sourceG = Color::gamma_srgbclipped( sourceG ); - sourceB = Color::gamma_srgbclipped( sourceB ); + // 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; @@ -4417,26 +4416,26 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceG = gtemp[ti * TS + tj]; float &sourceB = btemp[ti * TS + tj]; - // apply inverse gamma sRGB + // 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) { -#ifdef VECTLENSP - if (!(std::min(TS, tW - jstart) & ~(VECTLENSP - 1))) { - for (int j = jstart, tj = 0; j < tW; j += VECTLENSP, tj += VECTLENSP) { + // Convert from clut to working profile +#ifdef __SSE2__ + if (!(std::min(TS, tW - jstart) & ~3)) { + for (int j = jstart, tj = 0; j < tW; 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]); - //convert from clut to working profile 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 ); + 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); @@ -4451,10 +4450,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float &sourceG = gtemp[ti * TS + tj]; float &sourceB = btemp[ti * TS + tj]; - //convert from clut to working profile float x, y, z; - Color::rgbxyz( sourceR, sourceG, sourceB, x, y, z, clut2xyz ); - Color::xyz2rgb( x, y, z, sourceR, sourceG, sourceB, xyz2work ); + Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, clut2xyz); + Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, xyz2work); } } } @@ -4462,7 +4460,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer } - 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++) {