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

Add .avif (AV1 Image File Format) support #292

Closed
EwoutH opened this issue Dec 18, 2018 · 29 comments
Closed

Add .avif (AV1 Image File Format) support #292

EwoutH opened this issue Dec 18, 2018 · 29 comments
Labels
image format support for a new image format
Milestone

Comments

@EwoutH
Copy link
Contributor

EwoutH commented Dec 18, 2018

The AV1 Image File Format (AVIF) is a new image format based on the AV1 video codec. It would be great if support for this format could be added.

The AVIF spec can be found here: https://aomediacodec.github.io/av1-avif/
Netflix published a bunch of test images: http://download.opencontent.netflix.com/?prefix=AV1/Chimera/AVIF/

@diemmarkus diemmarkus added the image format support for a new image format label Dec 19, 2018
@diemmarkus
Copy link
Member

I'll have a look at it - thanks!

@EwoutH
Copy link
Contributor Author

EwoutH commented Dec 20, 2018

Great! Here are some more samples if you need them: https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft

Especially the tiled one (Summer_in_Tomsk_720p_5x4_grid.avif) is tricky.

@EwoutH
Copy link
Contributor Author

EwoutH commented May 9, 2019

libavif tagged a new release, 0.1.3. See Colorist for an example implementation.

@novomesk
Copy link
Collaborator

I just installed nomacs and I observed that it opens AVIF and AVIFS files.
I develop a Qt Image Plugin with AVIF support and I think that maybe nomacs loaded the *.AVIF files because it is a QT application.
nomacs

@diemmarkus
Copy link
Member

I develop a Qt Image Plugin with AVIF support and I think that maybe nomacs loaded the *.AVIF files because it is a QT application

for sure - nomacs uses any qt image plugins that are available on the system. is your image plugin open source? if yes, I will add it to the default installer on windows.

@novomesk
Copy link
Collaborator

Yes, my plug-in is free.
I am preparing a new improved version but it is not public yet.
So far you can see how the old version of my plug-in looks like, I shared sources here:
https://bugs.kde.org/show_bug.cgi?id=416941
The old version of my plug-in works with libavif 0.5.7 but doesn't work with 0.6.x (New version will work with 0.6.x).
I can notify you when the new version is ready.
You will need to prepare two libraries: libaom and libavif. cmake is needed in the configuration process. Libaom needs to be not very old, at least v1.0.0-errata1-avif.

@diemmarkus
Copy link
Member

I can notify you when the new version is ready.

yes please!

@novomesk
Copy link
Collaborator

novomesk commented Mar 20, 2020

The new version of my plug-in:
http://188.121.162.14/avif/qt_avif_image_plugin_2020-03-20.zip

I started to host it on github too: https://github.com/novomesk/qt-avif-image-plugin

@diemmarkus
Copy link
Member

is it already ready to use? If so, I'll test it on my system...

@novomesk
Copy link
Collaborator

Yes, I believe it is ready. It works on Linux, I tried Gentoo and Ubuntu, other people used it on Arch. I haven't tried with Windows yet.
The plug-in itself is simple. Just to build libavif with recently new libaom.

@novomesk
Copy link
Collaborator

@diemmarkus
Did you have success to build my plug-in on Windows?
In the past I used only MSYS2,
but today I tried to build libaom and libavif using Visual Studio 2019 and when these 2 libs were ready, Qt Creator built qavif.dll (my plug-in).
I plan to create Windows instructions in the near future anyway.

@diemmarkus
Copy link
Member

no : )
-> I stopped when I saw that there are a few additional dependencies. I am currently making things ready for appveyor (#488). I will add avif there if time permits (of course you are very welcome to support me in this process : )

@EwoutH
Copy link
Contributor Author

EwoutH commented Jun 2, 2020

@diemmarkus I contributed to the libavif AppVeyor configuration. Please let me know if you need any help building libavif!

@diemmarkus
Copy link
Member

@EwoutH I am pretty sure you can help here : )
Since I am new to AppVeyor, I have a few starter questions:
what is the best way for me to make use of compiled libavif packages?

  • should I download the latest static lib zip in my appveyor script (and hope compilers did not change)?
  • or is there a mechanism that allows me to use your appveyor config?

@novomesk
Copy link
Collaborator

novomesk commented Jun 4, 2020

Today I tried AppVeyor, I reused some portions of the configuration made by EwoutH.
https://ci.appveyor.com/project/novomesk/qt-avif-image-plugin
Result is qavif.dll
I combined it with your files from nomacs-portable.zip and I was able to open AVIF files.

@novomesk
Copy link
Collaborator

novomesk commented Jun 8, 2020

Marcus,
can you add something like this into DkSettings.cpp please?
if (qtFormats.contains("avif")) app_p.saveFilters.append("AV1 Image File Format (*.avif)");
so we can save AVIF via nomacs too.

@diemmarkus
Copy link
Member

can you add something like this into DkSettings.cpp please?

sure.... if like, you can added & create a pull request (then it's your contribution). does avif save need parameters?

@novomesk
Copy link
Collaborator

You can modify AVIF output quality via QImageWriter::setQuality(int quality)
range 0-100
0 - small file
100 - almost lossless
I use default value 52 - slightly above the middle.

@novomesk
Copy link
Collaborator

Can I contribute to the DkCompressDialog so user can adjust the quality/compression?
We would need new string to translate:
setWindowTitle(tr("AVIF Settings"));
However these values are not suitable for AVIF compression:

mCompressionCombo->addItem(tr("Best Quality"), 100);
mCompressionCombo->addItem(tr("High Quality"), 97);
mCompressionCombo->addItem(tr("Medium Quality"), 90);
mCompressionCombo->addItem(tr("Low Quality"), 80);
mCompressionCombo->addItem(tr("Bad Quality"), 60);

because at quality==80, AVIF is saved with subjectively high quality.
60 could be called Medium
40 - low
20 -bad
How to solve it? Another QComboBox* mCompressionAVIFCombo?

@diemmarkus
Copy link
Member

diemmarkus commented Jun 15, 2020

I set up a branch to add these features. There you can change compression values in DkSaveDialog.cpp#106 and apply them in the init() function (see line 174).

@novomesk
Copy link
Collaborator

OK, I started to work on that. I will let you know when I finish.
nomacs_avif_settings

@diemmarkus
Copy link
Member

@novomesk there is one last wish (as always : ): can you attach the appveyor's artifact to the github release? this way I can use the latest stable in nomacs rather than the latest nightly.

@novomesk
Copy link
Collaborator

I will do it for future releases.
I would like to do it after next release of libavif. There were some breaking changes/big refactor/important improvements. So I wait for the right time. I hope it is a matter of few more days.

@diemmarkus
Copy link
Member

I just realized, that libheif now also supports avif. since I have the feeling, that you guys know much more about the codec than I do: is there any advantage of choosing libavif over libheif for loading? from my point of view: libheif is LGPL, libavif has a license which I don't know (but should do for us).

@novomesk
Copy link
Collaborator

libavif and libaom use the BSD 2-Clause License which says, "as is", "no warranty", "no liability" - it is even more free than LGPL.
new libheif (1.7.0) also uses libaom to encode/decode AV1-codec compressed data like libavif.
I started to use libheif recently and I have to say that libavif is best for AVIF so far.
When I tested libheif 1.7.0 I encontered few issues and reported them (you can check what I reported there). Some of them are resolved already. There are still some things to verify and to implement in libheif. I keep following the progress in libheif and to provide feedback there.

@diemmarkus
Copy link
Member

thanks for the fast feedback. updating to libheif 1.7.0 just broke everything on my side : )

@novomesk
Copy link
Collaborator

I attached DLL to the
https://github.com/novomesk/qt-avif-image-plugin/releases/tag/v0.2.0
Will you merge the 292-save-avif branch later? Just curious.

@novomesk
Copy link
Collaborator

I observed that in order to play AVIFS animation, it is enough to do modify DkImageContainer.cpp
Original in DkImageContainer::hasMovie():
return newSuffix.contains(QRegExp("(gif|mng|webp)", Qt::CaseInsensitive)) != 0;
AVIFS added:
return newSuffix.contains(QRegExp("(avifs|gif|mng|webp)", Qt::CaseInsensitive)) != 0;
Can you add it?

@diemmarkus
Copy link
Member

Will you merge the 292-save-avif branch later? Just curious.

292-save-avif is on top of appveyor that currently causes troubles with the updated libheif : ) -> I will merge it after appveyor is merged

Can you add it?

sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
image format support for a new image format
Projects
None yet
Development

No branches or pull requests

3 participants