libheif icon indicating copy to clipboard operation
libheif copied to clipboard

Add experimental gain map support

Open DichenZhang1 opened this issue 1 year ago • 7 comments

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 avatar Feb 02 '24 00:02 DichenZhang1

Hi there!

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

Thank you!

DichenZhang1 avatar Mar 13 '24 00:03 DichenZhang1

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 avatar Apr 01 '24 14:04 DichenZhang1

Friendly bumping up again. Thank you!

DichenZhang1 avatar Apr 12 '24 18:04 DichenZhang1

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 avatar Apr 16 '24 07:04 farindk

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?

farindk avatar Apr 16 '24 07:04 farindk

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!

DichenZhang1 avatar Apr 18 '24 22:04 DichenZhang1

@DichenZhang1 I tested this code, heif-enc 01_with_gain_map.jpg gm_01.heic, but when open the gm_01.heic file in Mac, it seems not hava HDR effect as 01_with_gain_map.jpg. 01_with_gain_map.jpg.zip Sincerely waiting for your reply @DichenZhang1

xutch avatar May 30 '25 07:05 xutch