Skip to content

Add custom codec callback in avifEncoder - #2381

Draft
y-guyon wants to merge 2 commits into
AOMediaCodec:mainfrom
y-guyon:custom
Draft

Add custom codec callback in avifEncoder#2381
y-guyon wants to merge 2 commits into
AOMediaCodec:mainfrom
y-guyon:custom

Conversation

@y-guyon

@y-guyon y-guyon commented Aug 9, 2024

Copy link
Copy Markdown
Contributor

No description provided.

@wantehchang wantehchang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yannis: I only took a cursory look at this pull request. The commit message has the subject line "Add custom codec callback in avifEncoder". That is confusing, because these callbacks do not seem to provide access to a custom AV1 codec. Should we change "custom codec" to "custom encode data"?

Comment thread include/avif/avif.h Outdated
@y-guyon

y-guyon commented Sep 17, 2024

Copy link
Copy Markdown
Contributor Author

Yannis: I only took a cursory look at this pull request.

Thank you. This PR is a proof-of-concept to kickstart a discussion, not a request to merge code.

The commit message has the subject line "Add custom codec callback in avifEncoder". That is confusing, because these callbacks do not seem to provide access to a custom AV1 codec.

I did not mention AV1. This could be used for any kind of coded samples (AV2?) but to be compliant with the AVIF specification it would have to be AV1 samples indeed.

Should we change "custom codec" to "custom encode data"?

To me the piece of software that generates encoded data is a codec, so "custom codec callback" is accurate. Whether that is used to feed already compressed samples or to actually encode pixels on the spot, it is opaque to the libavif API.

@y-guyon

y-guyon commented Oct 8, 2024

Copy link
Copy Markdown
Contributor Author

Note that avifCodecEncodeImageFunc can use avifEncoderCustomEncodeImageArgs too. It can be implemented in another PR to simplify the review of this PR.

@y-guyon

y-guyon commented Oct 8, 2024

Copy link
Copy Markdown
Contributor Author

I tagged the new avifEncoder fields as "Experimental feature" as there may be overlooked edge cases. I do not think introducing a new EXPERIMENTAL CMake flag is worth it.

The new API can be fuzzed in another PR once the design is settled.

Comment thread include/avif/avif.h Outdated
Comment thread include/avif/avif.h Outdated
Comment thread include/avif/avif.h Outdated
@y-guyon

y-guyon commented Oct 9, 2024

Copy link
Copy Markdown
Contributor Author

I had another go at it to answer Maryla's comments but the added API starts to be large. I wonder if this is still worth it. Thoughts?

@s1ddok

s1ddok commented Jun 2, 2026

Copy link
Copy Markdown

@y-guyon do you think this PR leads us to be able to demux AVIFs? I'm looking for a way to access raw av1 encoded packets to decode on them on GPU. previously you pointed to this PR as the one that can potentially enable it. do you think it is feasible?

@y-guyon

y-guyon commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

do you think this PR leads us to be able to demux AVIFs?

No, this PR only allows already encoded AV1 OBU sequences to be passed to libavif at encoding. I believe you would need something similar but on the decoding side.

@maryla-uc

Copy link
Copy Markdown
Contributor

Other libraries should be able to do that. FFmpeg's libavformat, or gpac's libgpac?

Note that if the image is a grid, you will have to get each grid cell item data and stitch up the image yourself. Same thing if there is alpha, that will be a different item. Not sure libavformat can get you the different item data, but libgpac should be able to, although I haven't actually tried either.

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

Successfully merging this pull request may close these issues.

4 participants