AOMediaCodec / libavif

libavif - Library for encoding and decoding .avif files
Other
1.53k stars 195 forks source link

Safari on iPhone8 with iOS 16.5 doesn't show avifenc encoded AVIF #1441

Closed novomesk closed 1 year ago

novomesk commented 1 year ago

Hello,

@leo-barnes FYI,

I have a problem.avif which doesn't show in Safari browser for some reason. I'd like to know if there is something wrong with the file or it is something on Apple's side. It would be useful for me to know, what to do (or what to avoid) so that the AVIF images work in Safari.

problem.zip

File was created by encoding JPG image via avifenc 0.11.1, I believe libaom v3.6.1 was used.

Image works in Firefox and Chrome.

avifdec -i problem.avif
Image decoded: problem.avif
 * Resolution     : 5616x3744
 * Bit Depth      : 8
 * Format         : YUV444
 * Alpha          : Absent
 * Range          : Full
 * Color Primaries: 1
 * Transfer Char. : 13
 * Matrix Coeffs. : 5
 * ICC Profile    : Present (3144 bytes)
 * XMP Metadata   : Present (8762 bytes)
 * Exif Metadata  : Present (23122 bytes)
 * Transformations: None
 * Progressive    : Unavailable
 * 1 timescales per second, 1.00 seconds (1 timescales), 1 frame
 * Frame:
   * Decoded frame [0] [pts 0.00 (0 timescales)] [duration 1.00 (1 timescales)] [5616x3744]
heif-info problem.avif
MIME type: image/avif
main brand: avif
compatible brands: avif, mif1, miaf, MA1A

image: 5616x3744 (id=1), primary
  color profile: prof
  alpha channel: no
  depth channel: no
metadata:
  Exif: 23126 bytes
  XMP: 8762 bytes

Uploading to https://gpac.github.io/ComplianceWarden-wasm/avif.html shows:

Compliance Warden, version v31-master-rev0-gb1ce523.
+--------------------------------------+
| avif validation |
+--------------------------------------+

Specification description: AVIF v1.0.0, 19 February 2019
https://aomediacodec.github.io/av1-avif/

========================================
[avif] No errors.
========================================

+--------------------------------------+
| miaf validation |
+--------------------------------------+

Specification description: MIAF (Multi-Image Application Format)
MPEG-A part 22 - ISO/IEC 23000-22 - w18260 FDIS - Jan 2019

[miaf][Rule #26] Error: Found 1 (ItemIds={1}) 'pixi' associated for 3 displayable (not hidden) images (ItemIds={1,2,3})

========================================
[miaf] 1 error(s), 0 warning(s).
========================================

===== Involved rules descriptions:

[miaf][Rule #26] Section 7.3.6.6
The pixel information property shall be associated with every image that is
displayable (not hidden)

+--------------------------------------+
| heif validation |
+--------------------------------------+

Specification description: HEIF - ISO/IEC 23008-12 - 2nd Edition N18310

========================================
[heif] No errors.
========================================

+--------------------------------------+
| isobmff validation |
+--------------------------------------+

Specification description: ISO Base Media File Format
MPEG-4 part 12 - ISO/IEC 14496-12 - m17277 (6th+FDAM1+FDAM2+COR1-R4)

========================================
[isobmff] No errors.
========================================
jzern commented 1 year ago

cc @podborski

novomesk commented 1 year ago

If I change matrix coefficient from 5 to 6 via binary editor, Safari shows the file.

wantehchang commented 1 year ago

Daniel: Thanks for the info. Matrix coefficients 5 and 6 are functionally identical.

kmilos commented 1 year ago

Matrix coefficients 5 and 6 are functionally identical.

Yes, but MatrixCoefficients 5 should be the preferred, if not the only strictly legal option (in addition to 0) to go w/ ColourPrimaries 1 and TransferCharacteristics 13, if you read the H.273 spec carefully...

wantehchang commented 1 year ago

Hi Miloš,

Thank you for your comment. H.273 says IEC 61966-2-1 sYCC is ColourPrimaries=1, TransferCharacteristics=13, MatrixCoefficients=5, but it also says in Table 4 that MatrixCoefficients values 5 and 6 are functionally the same, with the following note:

NOTE 8 – In a previous version of this Specification, the IEC 61966-2-1 sYCC representation was identified as corresponding to MatrixCoefficients equal to 1. Closer study later determined that this representation should correspond to MatrixCoefficients equal to 5 instead (which is functionally the same as the value 6). This Specification was therefore revised to correct the error.

So I cannot conclude from H.273 that 1/13/5 is preferred over 1/13/6 unless we want to refer to it as IEC 61966-2-1 sYCC.

kmilos commented 1 year ago

So I cannot conclude from H.273 that 1/13/5 is preferred over 1/13/6 unless we want to refer to it as IEC 61966-2-1 sYCC.

This.

There will of course always be some wiggle room when interpreting specs. The way I read it, once you're in the TransferCharacteristics=13 case, there is (at least in my mind) clear intention that IEC 61966-2-1 is being used, meaning either sRGB (1/13/0) or sYCC (1/13/5).

leo-barnes commented 1 year ago

@novomesk Matrix 5 support is unfortunately not there in all code-paths. It tends to be pretty uncommon in HEIF/AVIF though, with the MIAF defaults for NCLX being 1/13/6 IIRC. The feeling I have gotten in discussions over the years is that 6 is preferred over 5.

I have filed an internal bug report about it and routed it to the appropriate team. Since this is not a libavif issue, I guess this issue should be closed and a new issue should be filed with WebKit so that there is an externally visible issue tracking it.

As a workaround, using matrix 6 should work everywhere.