Skip to content

Commit

Permalink
shaders/colorspace: simplify iir_coeff math
Browse files Browse the repository at this point in the history
The old trigonometric expression was needlessly complicated when the
math here is just equivalent to a normal exponential decay.

As a side note, handle the case of rate = 0 ("infinite" cutoff
frequench) correctly.
  • Loading branch information
haasn committed Aug 18, 2023
1 parent 14c273a commit 1c464ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/shaders/colorspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,9 @@ static void sh_color_map_uninit(pl_gpu gpu, void *ptr)

static inline float iir_coeff(float rate)
{
float a = 1.0 - cos(1.0 / rate);
return sqrt(a*a + 2*a) - a;
if (!rate)
return 1.0f;
return 1.0f - expf(-1.0f / rate);
}

static float measure_peak(const struct peak_buf_data *data, float percentile)
Expand Down

0 comments on commit 1c464ba

Please sign in to comment.