[FFmpeg-trac] #9673(undetermined:closed): ffmpeg not reading color information from JPEG ICC profile

FFmpeg trac at avcodec.org
Tue Sep 26 16:12:08 EEST 2023


#9673: ffmpeg not reading color information from JPEG ICC profile
-------------------------------------+-------------------------------------
             Reporter:  Cosmin       |                    Owner:  haasn
  Stejerean                          |
                 Type:  defect       |                   Status:  closed
             Priority:  normal       |                Component:
                                     |  undetermined
              Version:  unspecified  |               Resolution:  fixed
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Comment (by haasn):

 So, I did some extensive reverse engineering of the Apple DCI-P3 profile
 and came to the following conclusions:

 1. They (accidentally?) used the D65 Chromatic Adaptation matrix for this
 profile (as would be correct for Display-P3)
 2. They then used this Chromatic Adaptation matrix on the (correct) DCI-P3
 primaries, resulting in the "correct" R/G/B Matrix columns. But, for some
 reason, Little-CMS does not correctly read these back out, probably
 because of the white point issue.
 3. They then encoded the *unadapted* white point (D65) into the media
 white point tag, which violates spec as you're supposed to encode the
 *adapted* white point (D50) instead. (See sections 6.2.3 and 6.3.2)

 So, the tl;dr here is that Apple made a mistake when creating this
 profile, and I can prove it. (It violates ICCv4 spec)

 For further information/cross verification, notice that the Apple DCI-P3
 profile almost matches the "DCI-P3-D65.icc" profile from ICC/color.org:

 Connection Space Illuminant     : 0.9642 1 0.82491
 Chromatic Adaptation            : 1.04791 0.02293 -0.0502 0.0296 0.99046
 -0.01707 -0.00925 0.01506 0.75179
 Red Matrix Column               : 0.51512 0.2412 -0.00105
 Green Matrix Column             : 0.29198 0.69225 0.04189
 Blue Matrix Column              : 0.1571 0.06657 0.78407
 Media White Point               : 0.96419 1 0.82491

 Except that the media white point in the ICC profile is correct (D50),
 whereas the one in the Apple profile is incorrect (D65).

 This does, mean, however, that we could apply a simple work-around in
 principle: If the profile fails decoding, we can try a second time using
 the (incorrect) "mediaWhitePointTag" as the white point instead of the
 (correct) "chromaticAdaptationTag^-1 * mediaWhitePointTag". If that
 produces an exact match, return it.

 However, since this is a hack and a work-around for a broken profile, I'd
 rather hide it behind some sort of extra option or debug flag. I'll have
 to think about whether this is a preferred solution or not.

 Maybe you can work around it on your side instead, by detecting the
 profile e.g. by its "Profile Description" tag? What do you think?
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9673#comment:20>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list