-
Notifications
You must be signed in to change notification settings - Fork 207
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
Refactor gain map API #2444
Refactor gain map API #2444
Conversation
Remote avifGainMapMetadata and avifGainMapMetadataDouble which were not extensible. Expose avifDoubleTo(Un)SignedFraction instead.
1448be6
to
641deb2
Compare
{ | ||
uint32_t positive_numerator; | ||
if (!avifDoubleToUnsignedFractionImpl(fabs(v), INT32_MAX, &positive_numerator, denominator)) { | ||
if (!avifDoubleToUnsignedFractionImpl(fabs(v), INT32_MAX, &positive_numerator, &fraction->d)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In avifDoubleToUnsignedFractionImpl()
, the variable maxD
is declared as uint64_t
, but it is only used in a comparison with newD
, which is a double
. So maxD
could be declared as double
. If maxD
should have an integer type, uint32_t
is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maryla: Please consider my review as supplemental. I only reviewed the changes to avif.h. They look good.
@vigneshvg FYI. @maryla-uc Maryla: Could you or Vignesh port the changes to the public header avif.h to CrabbyAvif? Thanks. |
avifGainMapMetadata and avifGainMapMetadataDouble were not future proof. Instead of adding Create()/Destroy() functions, simply inline avifGainMapMetadata inside avifGainMap and remove avifGainMapMetadataDouble.
Add avifSignedFraction (int32/uint32) and avifUnsignedFraction (uint32/uint32), in addition to the existing avifFraction (int32/int32). It's unfortunate that avifFraction uses a int32 denominator, but I don't think this can be changed now. This is not strictly necessary but makes the API a bit neater.
Expose avifDoubleToSignedFraction and avifDoubleToUnsignedFraction in avif.h
This is not strictly necessary either, since users should rarely have to fill in the fraction values themselves, and even if they do, they can use a naive method like setting the denominator to a large fixed value. But they are convenient and avifjpeg.c does use them right now. However, I'm open to removing them from the API, or putting them behind AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP (although this define should go away eventually).