Closed Bug 1654462 Opened 4 years ago Closed 3 years ago

AVIF files should support alpha/transparency

Categories

(Core :: Graphics: ImageLib, defect, P1)

defect

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: TD-Linux, Assigned: chunmin)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

Attached image dst_lossless.avif

The attached AVIF should be transparent in the same places as the attached PNG.

Attached image src.png
Severity: -- → S3
Assignee: nobody → cchang
Priority: -- → P1

To-do tasks for prototype:

  • [x] Expose alpha_item and premultiplied_alpha
    • mp4parse-rust draft here
    • gecko patch here
    • manual for vendoring mp4parse-rust
  • [x] Decode alpha plane with Dav1d (draft here)
  • [x] Decode alpha plane with AOM
    • We plan to delete the AOM decoder in the future so no worry to implement this.
  • [x] Decode the primary item with the alpha item
  • [ ] Create/Update test page

This imports the change of https://github.com/mozilla/mp4parse-rust/pull/258

Once the above PR is merged in the upstream, it will be landed in the
gecko in a different bug maybe.

This patch implements the transparency support for AVIF image files, if
the decoder preference is Dav1d. We have a plan to drop AOM decoder in
the future so this patch doesn't implement the alpha support for AOM
decoder. An side-benefit is that we can flip the decoder preference to
see the images before and after blending the alpha data.

This patch creates a function to convert the decoded YCbCr and Alpha
data to RGBA by using the existing ConvertYCbCrToRGB function to convert
the YCbCr data into RGB data first and then insert the Alpha data to the
RGBA buffer, if the layout of the decode YCbCr data is not I420. If the
layout is I420, the YCbCr and Alpha data can be converted by using the
libyuv::I420AlphaToARGB directly. (To see the image that calls the
ConvertYCbCrToRGB only, you can set the decoder to AOM.)

On the other hand, this patch refactors the nsAVIFDecoder a bit to make
the lifetime of the parsed data and decoded image data clearer. They
won't live longer than Parser object and {Dav1d, AOM}Decoder object.
This should improve the code readability.

Depends on D98950

Comment on attachment 9191691 [details]
Bug 1654462 - Import mp4parse c api to get alpha item

Revision D98950 was moved to bug 1681811. Setting attachment 9191691 [details] to obsolete.

Attachment #9191691 - Attachment is obsolete: true
Depends on: 1681811
Depends on: 1682677
Pushed by cchang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c1478d03a451
Add alpha support in nsAVIFDecoder r=jbauman
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
No longer depends on: 1682677
Regressions: 1683108
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: