-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add properties to avifImage #2420
Conversation
This is an API design proposition for exposing the primary image item properties that are not used by libavif to the user. Context: #2395 |
I think the API is probably fine. I cannot make the implementation work though - it looks like only supported properties get associated with the image item. I think I got over that, and then hit a double free() on the box contents. Will send a PR for further review. |
Thank you for trying it out.
I wanted to make sure the API design is accepted by the other maintainers before turning this draft into a proper tested PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yannis: The current API looks fine. My only suggestion is to anticipate future feature requests (such as image sequence and encoding support) and make sure the API can be extended to support the new features. It would also be good to verify that Mr. Brad Hards is committed to using the new API.
As for the API itself, an alternative would be new functions to iterate over the opaque image item properties of the current image of the decoder (i.e., decoder->image
), or a function to look up a given image item property of decoder->image
. I am not sure if these alternatives would be better though.
I am not sure what commitment looks like, but I am definitely planning to use the API (in whatever form it ends up taking). Right now I have this branch: https://github.com/bradh/gdal/tree/heif_meta_2024-09-22 which allows GDAL (which is already using libavif) to extract geospatial data.
The sample file: The spatial extensions are not yet finalised (depends on OGC standards process), but the Content ID (which uses |
Note that the branch is still WIP, and I'll generalise the implementation to share the parsing code with the equivalent functionality in libheif. |
1722ae7
to
0271672
Compare
Add circle_custom_properties.avif. Adapt avifParseItemPropertyAssociation().
circle_custom_properties.avif generation snippetCode added to avifItemPropertyDedupStart(dedup);
avifBoxMarker custom1234;
AVIF_CHECKRES(avifRWStreamWriteFullBox(&dedup->s, "1234", AVIF_BOX_SIZE_TBD, 0, 0, &custom1234));
AVIF_CHECKRES(avifRWStreamWriteU8(&dedup->s, 1));
AVIF_CHECKRES(avifRWStreamWriteU8(&dedup->s, 2));
AVIF_CHECKRES(avifRWStreamWriteU8(&dedup->s, 3));
AVIF_CHECKRES(avifRWStreamWriteU8(&dedup->s, 4));
avifRWStreamFinishBox(&dedup->s, custom1234);
AVIF_CHECKRES(avifItemPropertyDedupFinish(dedup, s, &item->ipma, AVIF_FALSE));
avifItemPropertyDedupStart(dedup);
avifBoxMarker customabcd;
AVIF_CHECKRES(avifRWStreamWriteBox(&dedup->s, "abcd", AVIF_BOX_SIZE_TBD, &customabcd));
AVIF_CHECKRES(avifRWStreamWriteChars(&dedup->s, "abcd", 5));
avifRWStreamFinishBox(&dedup->s, customabcd);
AVIF_CHECKRES(avifItemPropertyDedupFinish(dedup, s, &item->ipma, AVIF_FALSE));
avifItemPropertyDedupStart(dedup);
avifBoxMarker customuuid;
AVIF_CHECKRES(avifRWStreamWriteBox(&dedup->s, "uuid", AVIF_BOX_SIZE_TBD, &customuuid));
AVIF_CHECKRES(avifRWStreamWriteChars(&dedup->s, "extended_type 16", 16));
avifRWStreamFinishBox(&dedup->s, customuuid);
AVIF_CHECKRES(avifItemPropertyDedupFinish(dedup, s, &item->ipma, AVIF_FALSE)); |
Potential future features:
These would be on top of the currently suggested API, right? Then I am also not sure if it is better. Alternatives considered:
Remaining questions:
|
I'm not sure what is required to move this forward (beyond the inevitable "more time in the day"), but I can say that the proposed API meets my needs. It would be useful if there was encoding support. I can potentially add that if it would help with the hours in the day problem. Image sequence support might be useful, but I don't need that yet. I don't need custom props on the alpha, gainmap, In terms of the alternatives, I like the properties as part of the image (rather than the decoder). That also probably makes the encoding support simpler too. Similar considerations on just having the bitstream location. I could adapt to any of the alternatives though - its a weak preference. I'm neutral on whether there is a flag to turn off the decoding. I do not see an issue to add one function call to the process. I can possibly implement that too if it would help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, mostly nits on comments
Use a stronger check in avifImagePushProperty().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yannis: I only reviewed the public header avif.h. (No need to wait for my full review with Maryla's approval.) The changes to avif.h look good. Please add an entry to the changelog. Thanks!
[skip ci]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks! You can ignore the suggestions marked as optional.
No description provided.