Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Fix #17178 JzCzhz color picker #17209

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading