Skip to content

Commit

Permalink
ryb vectorscope: add sRGB to linear sRGB into inline conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
phweyland committed Sep 4, 2021
1 parent 497feb9 commit 2c7723c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/common/colorspaces_inline_conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,23 @@ static inline void dt_Rec709_to_XYZ_D50(const dt_aligned_pixel_t sRGB, dt_aligne
}


#ifdef _OPENMP
#pragma omp declare simd aligned(sRGB, RGB)
#endif
static inline void dt_sRGB_to_linear_sRGB(const dt_aligned_pixel_t sRGB, dt_aligned_pixel_t RGB)
{
// gamma corrected sRGB -> linear sRGB
for(int c = 0; c < 3; c++)
RGB[c] = sRGB[c] <= 0.04045f ? sRGB[c] / 12.92f : powf((sRGB[c] + 0.055f) / (1.0f + 0.055f), 2.4f);
}

#ifdef _OPENMP
#pragma omp declare simd aligned(sRGB, XYZ)
#endif
static inline void dt_sRGB_to_XYZ(const dt_aligned_pixel_t sRGB, dt_aligned_pixel_t XYZ)
{
dt_aligned_pixel_t rgb = { 0 };
// gamma corrected sRGB -> linear sRGB
for(int c = 0; c < 3; c++)
rgb[c] = sRGB[c] <= 0.04045f ? sRGB[c] / 12.92f : powf((sRGB[c] + 0.055f) / (1.0f + 0.055f), 2.4f);
dt_sRGB_to_linear_sRGB(sRGB, rgb);
// linear sRGB -> XYZ
dt_Rec709_to_XYZ_D50(rgb, XYZ);
}
Expand Down
4 changes: 1 addition & 3 deletions src/libs/histogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,7 @@ static void _get_chromaticity(const dt_aligned_pixel_t RGB, dt_aligned_pixel_t
else
{
dt_aligned_pixel_t RYB, rgb, HCV;
// gamma corrected sRGB -> linear sRGB
for_each_channel(ch, aligned(rgb, RGB:16))
rgb[ch] = RGB[ch] <= 0.04045f ? RGB[ch] / 12.92f : powf((RGB[ch] + 0.055f) / (1.0f + 0.055f), 2.4f);
dt_sRGB_to_linear_sRGB(RGB, rgb);
_rgb2ryb(rgb, RYB, rgb2ryb_ypp);
dt_RGB_2_HCV(RYB, HCV);
const float alpha = 2.0 * M_PI * HCV[0];
Expand Down

0 comments on commit 2c7723c

Please sign in to comment.