qt-heif-image-plugin
qt-heif-image-plugin copied to clipboard
HEIF vs AVIF detection
There is following code in qheifhandler.cpp
if (w1 != "ftyp") {
// not an ftyp box
return Format::None;
}
// brand follows box name, determines format
if (w2 == "mif1") {
return Format::Heif;
Unfortunately ftyp+mif1 is used by AVIF too (examples here: http://download.opencontent.netflix.com/?prefix=AV1/Chimera/AVIF/ ) but qt-heif-image-plugin with older libheif are not able to load AVIF.
I saw situation when qt-heif-image-plugin is installed together with my qt-avif-image-plugin. qt-heif-image-plugin indicated that it can read the AVIF file (and as consequence the file was not opened via qt-avif-image-plugin) but qt-heif-image-plugin did not open it so the AVIF image was not displayed at all.
I think both qt-heif-image-plugin and qt-avif-image-plugin should read more than 12 bytes from beginning to determine file format, so we properly detect whether we have HEIF with HEVC compression or AVIF with AV1 compression.
Thanks for reporting this. This is clearly a bug.
It was commented here that maybe it would be better to use libheif to check this header info, but I haven't had a chance to look into that yet.
Just a note: Future versions of libheif will support AVIF, so you will be able to load AVIF files via qt-heif-image-plugin too. But some distributions keep old versions of libraries. Letting libheif to auto-detect by itself what it is able to open is a good idea.
Just added a pull request #22 to add complete support for AVIF to this plug-in. I hope this resolves this issue.