[Mesa-dev] [PATCH 18/29] util/srgb: Add a float sRGB -> linear helper
Pohjolainen, Topi
topi.pohjolainen at gmail.com
Tue Mar 6 08:39:47 UTC 2018
On Fri, Jan 26, 2018 at 05:59:47PM -0800, Jason Ekstrand wrote:
> ---
> src/util/format_srgb.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/src/util/format_srgb.h b/src/util/format_srgb.h
> index 34b50af..596af56 100644
> --- a/src/util/format_srgb.h
> +++ b/src/util/format_srgb.h
> @@ -55,6 +55,20 @@ util_format_linear_to_srgb_helper_table[104];
>
>
> static inline float
> +util_format_srgb_to_linear_float(float cs)
> +{
> + if (cs <= 0.0f)
> + return 0.0f;
> + else if (cs <= 0.04045f)
In patch 8 you used open-ended: "cs < 0.04045f". As I mentioned in my reply
there, I don't know what is the correct form. But we should probably be
consistent between these two.
Looking the already existing util_format_linear_to_srgb_float() I see that it
uses equivalent open-ended "cl < 0.0031308f" as you did in patch 8.
The first search hit for me for the subject was:
http://entropymine.com/imageworsener/srgbformula/
which starts by close-ended "cs <= 0.04045f" but argues later on that
cs <= 0.0404482362771082 might be more accurate.
> + return cs / 12.92f;
> + else if (cs < 1.0f)
> + return powf((cs + 0.055) / 1.055f, 2.4f);
> + else
> + return 1.0f;
> +}
> +
> +
> +static inline float
> util_format_linear_to_srgb_float(float cl)
> {
> if (cl <= 0.0f)
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list