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

Better avif support #1504

Open
rkfox opened this issue Jul 4, 2021 · 6 comments
Open

Better avif support #1504

rkfox opened this issue Jul 4, 2021 · 6 comments

Comments

@rkfox
Copy link

rkfox commented Jul 4, 2021

I would like to be able to decode 10-bit avif images. It appears that cavif-rs outputs 10-bit avif images that cannot be decoded using image-rs.

@rkfox
Copy link
Author

rkfox commented Jul 4, 2021

I looked through cavif-rs and it appears to only output 8-bit avif files so I'm not sure what is going on here since image-rs lists decode support for 8-bit avif files. The image loads fine in Chromium, but image-rs cannot decode it.

The image was encoded like this:
cavif --speed 1 --quality 60 sample.jpg

Github does not support attaching .avif files or I would include a test file.

@rkfox rkfox changed the title 10-bit avif support Better avif support Jul 4, 2021
@fintelia
Copy link
Contributor

fintelia commented Jul 6, 2021

Are you able to upload a zipped version of the file?

@baumanj
Copy link

baumanj commented Jul 6, 2021

@rkfox: you can check the file with https://gpac.github.io/ComplianceWarden-wasm/avif.html to see if it was invalidly encoded

@rkfox
Copy link
Author

rkfox commented Jul 12, 2021

It did not pass validation. Strange that they appear fine in the browser though.

Result:
Compliance Warden, version v28-master-rev0-g29d5bb7.
+--------------------------------------+
| avif validation |
+--------------------------------------+

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

[avif][Rule #7] Error: The values of the AV1CodecConfigurationBox shall match
the Sequence Header OBU in the AV1 Image Item Data:
AV1CodecConfigurationBox:
seq_profile=0
seq_level_idx_0=0
seq_tier_0=0
high_bitdepth=0
twelve_bit=0
mono_chrome=0
chroma_subsampling_x=0
chroma_subsampling_y=0
chroma_sample_position=0
Sequence Header OBU in the AV1 Image Item Data:
seq_profile=1
seq_level_idx_0=31
seq_tier_0=0
high_bitdepth=0
twelve_bit=0
mono_chrome=0
chroma_subsampling_x=0
chroma_subsampling_y=0
chroma_sample_position=0

[avif][Rule #9] Error: Transformative property "av1C" shall be marked as essential (item_ID=1)

========================================
[avif] 2 error(s), 0 warning(s).
========================================

===== Involved rules descriptions:

[avif][Rule #7] Section 2.2.1
The values of the fields in the AV1CodecConfigurationBox shall match those of the
Sequence Header OBU in the AV1 Image Item Data.

[avif][Rule #9] Section 2.2.1
AV1 Item Configuration Property [...] shall be marked as essential.

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

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

[miaf][Rule #2] Error: compatible_brands list shall contain 'miaf' (not found) and 'mif1' (found)

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

===== Involved rules descriptions:

[miaf][Rule #2] Section 7.2.1.2
The FileTypeBox shall contain, in the compatible_brands list,
the following (in any order): 'mif1' (specified in ISO/IEC 23008-12)
[...]
Files conforming to the general restrictions in clause 7 shall include
the brand 'miaf' in the compatible_brands in the FileTypeBox.

+--------------------------------------+
| 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.
========================================

SampleJPGImage_500kbmb.zip

@baumanj
Copy link

baumanj commented Jul 12, 2021

Here's an AVIF version of your JPEG encoded with libavif which does pass validation. I believe there are some compliance issues with cavif-rs (or more precisely avif-serialize).

The reason the cavif-rs-encoded file appears fine in the browser (at least in Firefox; chromium uses a different library for parsing) is that it's using a newer version of mp4parse that hasn't been published on crates.io. There's been significant updates to the compliance-related functionality since the last time I published to crates.io. If the newer version would be helpful (this can be tested by changing the dependency on mp4parse in Cargo.toml to mp4parse = { git = "https://github.com/mozilla/mp4parse-rust" }), then I'd be happy to set aside some time to publish a newer version.

@ghost
Copy link

ghost commented May 14, 2022

Just an update on this. image cannot decode images encoded by libavif 0.9.0 with libaom.

Output:

[2022-05-14T18:08:01Z DEBUG mp4parse] read_avif(strictness: Normal)
[2022-05-14T18:08:01Z DEBUG mp4parse] infe ItemId(1) item_type: av01
[2022-05-14T18:08:01Z DEBUG mp4parse] remain 6 (skipped) in BoxHeader { name: infe, size: 26, offset: 8, uuid: None }
[2022-05-14T18:08:01Z DEBUG mp4parse] infe ItemId(2) item_type: av01
[2022-05-14T18:08:01Z DEBUG mp4parse] remain 6 (skipped) in BoxHeader { name: infe, size: 26, offset: 8, uuid: None }
[2022-05-14T18:08:01Z DEBUG mp4parse] primary_item_id type: av01
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Decoding(DecodingError { format: Exact(Avif), underlying: Some(InvalidOperation) })', src/main.rs:2:31

Encoded to AVIF using this command:
avifenc --codec aom image.png image.avif

Output from AVIF validator (no errors):

Result:
Compliance Warden, version v29-master-rev3-gc808d21.
+--------------------------------------+
| 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] No errors.
========================================

+--------------------------------------+
| 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.
========================================


Tool errors:

image.zip

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

No branches or pull requests

3 participants