qt-heif-image-plugin icon indicating copy to clipboard operation
qt-heif-image-plugin copied to clipboard

HEIF vs AVIF detection

Open novomesk opened this issue 4 years ago • 3 comments

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.

novomesk avatar May 19 '20 16:05 novomesk

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.

jakar avatar May 19 '20 18:05 jakar

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.

novomesk avatar May 22 '20 09:05 novomesk

Just added a pull request #22 to add complete support for AVIF to this plug-in. I hope this resolves this issue.

salehqt avatar Jun 18 '21 00:06 salehqt