mozilla / mp4parse-rust

Parser for ISO Base Media Format aka video/mp4 written in Rust.
Mozilla Public License 2.0
405 stars 62 forks source link

Should not reject AVIF images with `a1lx` property #343

Closed tongyuantongyu closed 2 years ago

tongyuantongyu commented 2 years ago

The current code rejects AVIF images with al1x property: https://github.com/mozilla/mp4parse-rust/blob/72eb355ddeada541d7e57dbe5fb60eb5124dea0d/mp4parse/src/lib.rs#L2726-L2730

And consequently prevents Firefox from displaying multilayer images like this one: https://github.com/AOMediaCodec/av1-avif/blob/master/testFiles/Apple/multilayer_examples/animals_00_multilayer_a1lx.avif

From AVIF specification: https://aomediacodec.github.io/av1-avif/#layered-image-indexing-property-description

The AV1LayeredImageIndexingProperty ... If associated, it shall not be marked as essential.

https://aomediacodec.github.io/av1-avif/#layered-items-overview

In the absence of a lsel property associated with an AV1 Image Item, the renderer is free to render either: only the output image of the highest spatial layer, or to render all output images of all the intermediate layers, resulting in a form of progressive decoding.

The a1lx property is not mean to be essential, and is allowed to be treated as if it's not present.

Also reasonably, it's totally fine if a progressive image is not rendered progressively, so before implementing support for progressive decoding, we should simply ignore a1lx property and render the image.

baumanj commented 2 years ago

Thanks for the report! I think you're exactly right and I'll look at a fix soon.