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

Experimental reduced HEIF header #1432

Merged
merged 23 commits into from
Sep 1, 2023
Merged

Conversation

y-guyon
Copy link
Collaborator

@y-guyon y-guyon commented Jun 13, 2023

Remove a few hundred bytes of container boilerplate for simple images. This prototype uses a small box that expands in meaning to a full meta box with all defined items and properties.

Warning: This feature is experimental and forbidden by the current AVIF specification.

@y-guyon
Copy link
Collaborator Author

y-guyon commented Jun 13, 2023

I tried this patch on 889 random PNG images from the web.
avifenc -s 6 -q 75 gave files 7.7% smaller on average when the --minimize flag was used.

-s 6 -q 75 stats Regular AVIF file size Minimized AVIF file size Difference in bytes Ratio
Minimum 319 82 233 19.28%
Maximum 4,298,570 4,298,333 464 99.99%
Average 32, 279 32,013 266 92.30% (95.26% for s9)

On paris_icc_exif_xmp.png:

avifenc -s 6 -q 75 --ignore-icc --ignore-exif --ignore-xmp

generates headers of 282 bytes and 42 bytes without and with --minimize, respectively. This is without the 15,333 bytes of AV1 payload.

@y-guyon
Copy link
Collaborator Author

y-guyon commented Aug 11, 2023

avifROStreamReadBits() and avifRWStreamWriteBits() could be submitted separately and used in some parts of the existing parsing/writing code, such as avifParseCodecConfiguration() which reads individual bits.

Copy link
Collaborator

@maryla-uc maryla-uc left a comment

Choose a reason for hiding this comment

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

Just a few minor comments!

include/avif/internal.h Outdated Show resolved Hide resolved
src/read.c Outdated Show resolved Hide resolved
src/read.c Show resolved Hide resolved
src/read.c Outdated Show resolved Hide resolved
src/read.c Outdated Show resolved Hide resolved
src/stream.c Outdated Show resolved Hide resolved
src/write.c Outdated Show resolved Hide resolved
src/write.c Show resolved Hide resolved
include/avif/internal.h Outdated Show resolved Hide resolved
@y-guyon
Copy link
Collaborator Author

y-guyon commented Aug 18, 2023

Rebased to include #1506.

@y-guyon
Copy link
Collaborator Author

y-guyon commented Aug 19, 2023

Rebased because avifRWStreamWriteBox() and writeCodecConfig() signatures changed in #1498.

Copy link
Collaborator

@maryla-uc maryla-uc left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

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.

Yannis: I only reviewed the public header avif.h. I suggest a change in anticipation of the libavif 1.0.0 release.

include/avif/avif.h Outdated Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
include/avif/avif.h Outdated Show resolved Hide resolved
@wantehchang wantehchang self-requested a review August 22, 2023 20:22
@wantehchang wantehchang dismissed their stale review August 22, 2023 20:22

Requested change has been made

@wantehchang wantehchang removed their request for review August 22, 2023 20:23
Add AVIF_ENABLE_EXPERIMENTAL_AVIR flag.
Remove a few hundred bytes of container boilerplate for simple images.
This prototype uses a small box that expands in meaning to a full meta
box with all defined items and properties.

Warning: This feature is experimental and forbidden by the current
AVIF specification.
Split avifEncoderWriteFileTypeBoxAndCondensedImageBox() into
avifEncoderWriteCondensedImageBox() for simpler extendedMeta freeing.
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.

Yannis: I verified that the pull request is essentially a no-op if AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP is not defined. I didn't review the code inside #if defined(AVIF_ENABLE_EXPERIMENTAL_AVIR).

Just three more minor comments.

include/avif/internal.h Show resolved Hide resolved
src/write.c Outdated Show resolved Hide resolved
src/write.c Outdated Show resolved Hide resolved
@y-guyon y-guyon merged commit 73510a1 into AOMediaCodec:main Sep 1, 2023
14 checks passed
@y-guyon y-guyon deleted the reduced_header branch September 1, 2023 12:09
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