Skip to content

Commit

Permalink
First version, does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
kofa73 committed Aug 17, 2024
1 parent d5f30e3 commit abc23e9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
27 changes: 26 additions & 1 deletion src/common/color_picker.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ static inline void _color_picker_rgb_or_lab(dt_aligned_pixel_t acc,
_update_stats_by_ch(acc, low, high, k, pixels[i + k]);
}


static inline void _color_picker_Lab_2_JzCzhz(dt_aligned_pixel_t acc,
dt_aligned_pixel_t low,
dt_aligned_pixel_t high,
const float *const pixels,
const size_t width,
const void *const data)
{
for(size_t i = 0; i < width; i += 4)
{
dt_aligned_pixel_t pick;
dt_Lab_2_JzCzhz(pixels + i, pick);
// copied from _color_picker_jzczhz
// allow for determining sensible max/min values
// FIXME: the mean calculation of hue isn't always right, use circular mean calc instead?
pick[3] = pick[2] < 0.5f ? pick[2] + 0.5f : pick[2] - 0.5f;
_update_stats_4ch(acc, low, high, pick);
}
}


static inline void _color_picker_lch(dt_aligned_pixel_t acc,
dt_aligned_pixel_t low,
dt_aligned_pixel_t high,
Expand Down Expand Up @@ -227,7 +248,7 @@ static void _color_picker_work_4ch(const float *const pixel,
worker(acc, low, high, pixel + offset, stride, data);
}

// copy all four channels, as four some colorspaces there may be
// copy all four channels, as for some colorspaces there may be
// meaningful data in the fourth pixel
for_four_channels(c)
{
Expand Down Expand Up @@ -483,6 +504,10 @@ void dt_color_picker_helper(const dt_iop_buffer_dsc_t *dsc,
// scene-referred blending for RGB modules
_color_picker_work_4ch(source, roi, box, pick, profile, _color_picker_jzczhz, 10);
}
else if(effective_cst == IOP_CS_JZCZHZ && picker_cst == IOP_CS_LAB)
{
_color_picker_work_4ch(source, roi, box, pick, NULL, _color_picker_Lab_2_JzCzhz, 10);
}
else if(effective_cst == picker_cst)
{
// most iop pickers and the global picker
Expand Down
14 changes: 13 additions & 1 deletion src/common/colorspaces_inline_conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,6 @@ static inline void dt_Lab_2_LCH(const dt_aligned_pixel_t Lab, dt_aligned_pixel_t
LCH[2] = var_H;
}


DT_OMP_DECLARE_SIMD()
static inline void dt_LCH_2_Lab(const dt_aligned_pixel_t LCH, dt_aligned_pixel_t Lab)
{
Expand Down Expand Up @@ -890,6 +889,19 @@ static inline void dt_JzAzBz_2_JzCzhz(const dt_aligned_pixel_t JzAzBz, dt_aligne
JzCzhz[2] = var_H >= 0.0f ? var_H : 1.0f + var_H;
}

DT_OMP_DECLARE_SIMD()
static inline void dt_Lab_2_JzCzhz(const dt_aligned_pixel_t Lab, dt_aligned_pixel_t JzCzhz)
{
dt_aligned_pixel_t XYZ;
dt_Lab_to_XYZ(Lab, XYZ);

dt_aligned_pixel_t JzAzBz;
dt_XYZ_2_JzAzBz(XYZ, JzAzBz);

dt_JzAzBz_2_JzCzhz(JzAzBz, JzCzhz);
}


DT_OMP_DECLARE_SIMD(aligned(JzCzhz, JzAzBz: 16))
static inline void dt_JzCzhz_2_JzAzBz(const dt_aligned_pixel_t JzCzhz, dt_aligned_pixel_t JzAzBz)
{
Expand Down

0 comments on commit abc23e9

Please sign in to comment.