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

props: write out any properties set on the image #2510

Merged
merged 22 commits into from
Dec 30, 2024

Conversation

bradh
Copy link
Contributor

@bradh bradh commented Nov 27, 2024

This complements the opaque property reading done under #2420

There are a couple of issues I'd like guidance on:

  • the AV2 CI test failure
  • whether it is OK to carry over unsupported properties when writing out a new file

An example of the unsupported property might be a udes that applied to the original image, but might not be appropriate in a modified version of that image. I'm unsure of the best way to handle this.

Copy link
Collaborator

@y-guyon y-guyon left a comment

Choose a reason for hiding this comment

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

Thank you for the pull request and the tests.

the AV2 CI test failure

This is expected. AV2 is disabled by default and must be explicitly chosen as a codec through both the encoding and decoding API, even if enabled at libavif compile time. When only AV2 is available as a codec, encoding fails by default.
It can be solved by skipping the whole test file, example:

avifrangetest
avify4mtest
PROPERTIES DISABLED True

or just the test unit, example:

if (!testutil::Av1EncoderAvailable() || !testutil::Av1DecoderAvailable()) {
GTEST_SKIP() << "AV1 codec unavailable, skip test.";
}

whether it is OK to carry over unsupported properties when writing out a new file

From a libavif API point of view, the only way to have custom props in an avifImage is to manually add them or to decode an AVIF file (for now). On top of that, I guess it is quite rare for a user of libavif to encode to AVIF an avifImage that came from decoding an AVIF file, so carrying over custom props should not really happen in practice.

src/write.c Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
tests/gtest/avifpropertytest.cc Outdated Show resolved Hide resolved
tests/gtest/avifpropertytest.cc Outdated Show resolved Hide resolved
tests/gtest/avifpropertytest.cc Outdated Show resolved Hide resolved
tests/gtest/avifpropertytest.cc Show resolved Hide resolved
@bradh bradh force-pushed the prop_write_2024-11-27 branch 2 times, most recently from 07614a3 to 2f4fe06 Compare November 27, 2024 22:58
src/write.c Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
tests/gtest/avifpropertytest.cc Outdated Show resolved Hide resolved
tests/gtest/avifpropertytest.cc Show resolved Hide resolved
@bradh bradh force-pushed the prop_write_2024-11-27 branch from 7d366cf to f2cc919 Compare November 30, 2024 09:00
Copy link
Collaborator

@y-guyon y-guyon left a comment

Choose a reason for hiding this comment

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

Sorry for the churn. All these open questions are part of why I did not write the encoder part at the same time as the decoder part.

tests/gtest/avifpropinternaltest.cc Outdated Show resolved Hide resolved
tests/gtest/avifpropinternaltest.cc Outdated Show resolved Hide resolved
tests/gtest/avifpropinternaltest.cc Show resolved Hide resolved
src/write.c Show resolved Hide resolved
src/properties.c Show resolved Hide resolved
src/properties.c Show resolved Hide resolved
src/properties.c Outdated Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
Copy link
Collaborator

@wantehchang wantehchang left a comment

Choose a reason for hiding this comment

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

Brad: Please consider my review as supplemental. Yannis is the primary reviewer of this pull request.

include/avif/avif.h Outdated Show resolved Hide resolved
src/properties.c Show resolved Hide resolved
src/properties.c Outdated Show resolved Hide resolved
src/properties.c Outdated Show resolved Hide resolved

static const size_t numKnownProperties = sizeof(avifKnownProperties) / sizeof(avifKnownProperties[0]);

static const size_t FOURCC_BYTES = 4;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional: The integer literal 4 is already used in several places (e.g., line 9 and line 34) in the pull request, so it doesn't seem necessary to define this constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it made the code a little easier to read.

The other usages were in array bounds, which is only supported by GCC as an extension.

I can change it to be a #define if that would be preferred.

src/write.c Outdated Show resolved Hide resolved
src/write.c Outdated Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
include/avif/avif.h Show resolved Hide resolved
@bradh bradh force-pushed the prop_write_2024-11-27 branch from 6eb30b1 to d0b6725 Compare December 14, 2024 06:10
@bradh
Copy link
Contributor Author

bradh commented Dec 17, 2024

I believe I have addressed all the comments.

I'd particularly like review on the fuzzer and the gain map related code.

I'd like feedback on the ordering issue, see #2510 (comment)

@bradh bradh marked this pull request as ready for review December 17, 2024 06:14
Copy link
Collaborator

@y-guyon y-guyon left a comment

Choose a reason for hiding this comment

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

Thank you for adding the gainmap test and fuzz test! The PR looks good, just a few nits.

include/avif/avif.h Outdated Show resolved Hide resolved
tests/gtest/avif_fuzztest_properties.cc Outdated Show resolved Hide resolved
tests/gtest/avif_fuzztest_properties.cc Outdated Show resolved Hide resolved
src/read.c Outdated Show resolved Hide resolved
tests/gtest/avifpropertytest.cc Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
@bradh bradh force-pushed the prop_write_2024-11-27 branch from c474849 to 593ad22 Compare December 21, 2024 08:45
@y-guyon y-guyon merged commit 3a25ba1 into AOMediaCodec:main Dec 30, 2024
34 checks passed
@bradh
Copy link
Contributor Author

bradh commented Dec 30, 2024

@y-guyon Thanks for all the help on this one - much appreciated.

@bradh bradh deleted the prop_write_2024-11-27 branch December 30, 2024 08:48
@y-guyon
Copy link
Collaborator

y-guyon commented Dec 30, 2024

@y-guyon Thanks for all the help on this one - much appreciated.

At least as many thanks to you then!

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.

3 participants