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

Add experimental gain map support #1121

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

DichenZhang1
Copy link
Contributor

This feature is hidden behind the WITH_EXPERIMENTAL_GAIN_MAP compile flag.

See https://helpx.adobe.com/camera-raw/using/gain-map.html for an introduction
to gain maps. Note that in this change, gain maps are not stored as auxiliary
items as proposed by Adobe, but as a hidden input to a new 'tmap' (tone mapped)
derived item.

An 'altr' (alternatives group) box is also added to tell the decoder that it
may show the tone mapped image (preferrably) or the base image as a fall back.
The primary item id still points to the base image for backward compatibility.

DichenZhang1 and others added 3 commits February 2, 2024 00:22
    This feature is hidden behind the WITH_EXPERIMENTAL_GAIN_MAP compile flag.

    See https://helpx.adobe.com/camera-raw/using/gain-map.html for an introduction
    to gain maps. Note that in this change, gain maps are not stored as auxiliary
    items as proposed by Adobe, but as a hidden input to a new 'tmap' (tone mapped)
    derived item.

    An 'altr' (alternatives group) box is also added to tell the decoder that it
    may show the tone mapped image (preferrably) or the base image as a fall back.
    The primary item id still points to the base image for backward compatibility.
    This feature is hidden behind the WITH_EXPERIMENTAL_GAIN_MAP compile flag.

    See https://helpx.adobe.com/camera-raw/using/gain-map.html for an introduction
    to gain maps. Note that in this change, gain maps are not stored as auxiliary
    items as proposed by Adobe, but as a hidden input to a new 'tmap' (tone mapped)
    derived item.

    An 'altr' (alternatives group) box is also added to tell the decoder that it
    may show the tone mapped image (preferrably) or the base image as a fall back.
    The primary item id still points to the base image for backward compatibility.
@DichenZhang1
Copy link
Contributor Author

Hi there!

Can someone help to review this pull request? This is adding gain map support for HEIC and AVIF images.

Thank you!

@DichenZhang1
Copy link
Contributor Author

Hi there!

This change is adding support for encoding and decoding HEIC and AVIF with gain map images. Could anyone help to take a look and provide feedback?

Thank you!

@DichenZhang1
Copy link
Contributor Author

Friendly bumping up again. Thank you!

@farindk
Copy link
Contributor

farindk commented Apr 16, 2024

Thank you for the contribution. It generally looks good.

The GainMapMetadata is currently a private data class, but also exposed in the API.
I guess that this data should also be public.
In that case, we should rename this to follow the usual naming scheme (like heif_gain_map_metadata), make it a POD struct and move it to a public header. We can add a new header file (e.g. heif_hdr.h) where we collect HDR related things so that heif.h is not getting too long.

@farindk
Copy link
Contributor

farindk commented Apr 16, 2024

Is this standardized anywhere? Could you point me to the specification?

The Adobe document says:

Gain Maps are currently undergoing standardization in ISO/TC 42 Photography. Furthermore, various
technical committees have ongoing efforts to standardize Gain Map storage in different file formats.
Consequently, the original Gain Map storage proposals have been removed from this document to avoid
confusion and conflicting information.

Does that mean that there is no final spec yet? We can include it as "experimental" anyway, but have to make it very clear that the spec is not finalized yet.

Do you have any kind of test program? Maybe a patched heif_convert that I could use to test this?

@DichenZhang1
Copy link
Contributor Author

Hi Dirk,

Thank you for looking into this!

I've changed the GainMapMetadata name to heif_gain_map_metadata and made it public. The spec is not finalized yet, and I'll keep monitoring the updates. For verification, I've added some code in heif_enc and heif_info and they can be a closed loop for encoding and decoding. But we only have a pseudo gain map metadata (all values are zeros) and ideally this should be an input from user.

Thank you!

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