Skip to content

Harden linear_to_gamma() function? #1202

@hollasch

Description

@hollasch

We currently have the following implementation:

inline double linear_to_gamma(double linear_component)
{
    return sqrt(linear_component);
}

This will barf on negative values, returning NaN. Should we harden this like so?

inline double linear_to_gamma(double linear_component)
{
    if (linear_component < 0)
        return 0;

    return sqrt(linear_component);
}

or

inline double linear_to_gamma(double linear_component)
{
    return sqrt(fmax(0, linear_component));
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions