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

Improvements to grain synth gamma handling #622

Merged
merged 1 commit into from
Apr 26, 2022

Conversation

shssoichiro
Copy link
Collaborator

  • Fixes BT.1886 to use the more correct formula and gamma
  • Simplify the mid_tone function
  • Add quickcheck tests around to_linear/from_linear

TransferFunction::SMPTE2084 => {
if x == 0.0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Floating point comparisons to 0 should probably be done against an epsilon, like x.abs() < f32::EPSILON

TransferFunction::BT1886 => 0.18,
TransferFunction::SMPTE2084 => 26. / 10000.,
}
self.to_linear(0.5)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it should call from_linear (since from_linear takes a value between 0 and 1), but I'm not sure. Could you explain why to_linear is called here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The midtone we're seeking here is the perceptual gray midtone according to the transfer function, i.e. based on this transfer function, what value with the transfer function applied appears to be "half brightness". This is calculated by doing the transfer calculation on a mathematically half luma value, i.e. to_linear(0.5), and for e.g. a flat gamma curve of 2.4, results in a midtone of about 0.189 (approximately the previous constant value).

- Fixes BT.1886 to use the more correct formula and gamma
- Simplify the `mid_tone` function
- Add quickcheck tests around `to_linear`/`from_linear`
@mergify mergify bot merged commit ec93312 into master-of-zen:master Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants