Skip to content

Commit 3977cd3

Browse files
committed
Fix side effect of transition point limits
1 parent e624779 commit 3977cd3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/iop/agx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,12 @@ static tone_mapping_params_t _calculate_tone_mapping_params(const dt_iop_agx_use
777777

778778
const float remaining_y_below_pivot = tone_mapping_params.pivot_y - tone_mapping_params.target_black;
779779
const float toe_length_y = remaining_y_below_pivot * user_params->curve_linear_percent_below_pivot / 100.0f;
780-
const float dx_linear_below_pivot = toe_length_y / tone_mapping_params.slope;
780+
float dx_linear_below_pivot = toe_length_y / tone_mapping_params.slope;
781781
// ...and subtract it from pivot_x to get the x coordinate where the linear section joins the toe
782782
// ... but keep the transition point above x = 0
783783
tone_mapping_params.toe_transition_x = fmaxf(_epsilon, tone_mapping_params.pivot_x - dx_linear_below_pivot);
784+
// fix up in case the limitation kicked in
785+
dx_linear_below_pivot = tone_mapping_params.pivot_x - tone_mapping_params.toe_transition_x;
784786

785787
// from the 'run' pivot_x->toe_transition_x, we calculate the 'rise'
786788
const float toe_y_below_pivot_y = tone_mapping_params.slope * dx_linear_below_pivot;
@@ -818,10 +820,11 @@ static tone_mapping_params_t _calculate_tone_mapping_params(const dt_iop_agx_use
818820
tone_mapping_params.target_white = powf(user_params->curve_target_display_white_percent / 100.0, 1.0f / tone_mapping_params.curve_gamma);
819821
const float remaining_y_above_pivot = tone_mapping_params.target_white - tone_mapping_params.pivot_y;
820822
const float shoulder_length_y = remaining_y_above_pivot * user_params->curve_linear_percent_above_pivot / 100.0f;
821-
const float dx_linear_above_pivot = shoulder_length_y / tone_mapping_params.slope;
823+
float dx_linear_above_pivot = shoulder_length_y / tone_mapping_params.slope;
822824

823825
// don't allow shoulder_transition_x to reach 1
824826
tone_mapping_params.shoulder_transition_x = fminf(1 - _epsilon, tone_mapping_params.pivot_x + dx_linear_above_pivot);
827+
dx_linear_above_pivot = tone_mapping_params.pivot_x - tone_mapping_params.shoulder_transition_x;
825828
tone_mapping_params.shoulder_transition_y = tone_mapping_params.pivot_y + shoulder_length_y;
826829
tone_mapping_params.shoulder_power = user_params->curve_shoulder_power;
827830

0 commit comments

Comments
 (0)