Coder Social home page Coder Social logo

Comments (8)

y-guyon avatar y-guyon commented on July 24, 2024 1

Thank you for the bug report. See #1421 for an open entry about the issue: avifdec now writes CICP metadata (here 9/16/9) to PNG as a cHRM chunk, but JPEG does not support that.

The AVIF file has no ICC color profile by the way but I tried stuffing ITUR_2100_PQ_FULL.ICC into the output JPG using avifdec input.avif --icc colorprofile.icc output.jpg (requires #2042):

20140606_102418_IMGP0297_hdr_rec2020_pq_yuv444_full_cq10

It does not seem to be the correct ICC but it could be a working approach.

from libavif.

y-guyon avatar y-guyon commented on July 24, 2024 1

Btw, if -d is not specified, will avifdec correctly choose PNG bit depth depending on input?

Yes.

from libavif.

o-l-a-v avatar o-l-a-v commented on July 24, 2024

Even if --icc is not specified I still expect avifdec.exe input.avif output.jpg to create an SDR JPG image looking close to the original.

One more alternative approach/idea: If input is HDR => Use JPEG XL jpegli to encode to JPEG with XYB colorspace, which supports HDR.

from libavif.

y-guyon avatar y-guyon commented on July 24, 2024

Even if --icc is not specified I still expect avifdec.exe input.avif output.jpg to create an SDR JPG image looking close to the original.

Unfortunately libavif cannot handle all format and color space combinations, with workarounds for every situation. Detecting special cases such as common CICP combinations and outputting a matching ICC profile in JPG seems doable though.
If this is impossible for various reasons, or in the meantime, would an error or warning in avifdec console output be better?

Have you tried other conversion tools than avifdec for going from AVIF to JPG? Maybe there is some acceptable behavior we could match.

One more alternative approach/idea: If input is HDR => Use JPEG XL jpegli to encode to JPEG with XYB colorspace, which supports HDR.

So the input AVIF file would be in XYB colorspace?
If so, why not directly embed an HDR PQ ICC profile in the input AVIF file? It would be forwarded to the output JPG by avifdec.

from libavif.

o-l-a-v avatar o-l-a-v commented on July 24, 2024

Error if input has CICP and output is set to JPG until this might get fixed in the future makes sense.

I'm no image expert, I might've gotten the XYB part of jpegli wrong.

I don't know of other tools that handle this scenario, no.

from libavif.

kmilos avatar kmilos commented on July 24, 2024

If so, why not directly embed an HDR PQ ICC profile in the input AVIF file? It would be forwarded to the output JPG by avifdec.

This not a good idea for 8-bit encoding like JPEG (I guess until, and if avifdec decides to support 12-bit JPEG as well).

IMHO, I think it should be enough detect anything other than sRGB/Rec709 (as either CICP or ICC), and throw a warning in the console that the image cannot really be preserved in a JPEG (or any other 8-bit container), unless the input was 8-bit to begin with of course.

I still expect avifdec.exe input.avif output.jpg to create an SDR JPG image looking close to the original.

Gamut and tone mapping should be left to a different abstraction level/library, as there are a few compromises and creative choices to be made there, it's not really a job of the codec library IMHO.

from libavif.

kmilos avatar kmilos commented on July 24, 2024

Btw, if -d is not specified, will avifdec correctly choose PNG bit depth depending on input?

from libavif.

leo-barnes avatar leo-barnes commented on July 24, 2024

Gamut and tone mapping should be left to a different abstraction level/library, as there are a few compromises and creative choices to be made there, it's not really a job of the codec library IMHO.

Completely agree. libavif could add the ITU-R recommended way of tone mapping from HDR to SDR as a convenience, but it doesn't necessarily produce great results.

from libavif.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.