Add read/write AVIF raster driver
Requires libavif. Mostly intended to be used to read/write tiles (as a replacement of JPEG or PNG). No dedicated geospatial capabilities
gdalinfo --format AVIF
Short Name: AVIF
Long Name: AV1 Image File Format
Supports: Raster
Extension: avif
Mime Type: image/avif
Help Topic: drivers/raster/avif.html
Supports: Raster subdatasets
Supports: Open() - Open existing dataset.
Supports: CreateCopy() - Create dataset by copying another.
Supports: Virtual IO - eg. /vsimem/
Creation Datatypes: Byte UInt16
<CreationOptionList>
<Option name="CODEC" type="string-select" description="Compression CODEC" default="AUTO">
<Value>AUTO</Value>
<Value>AOM</Value>
</Option>
<Option name="QUALITY" type="int" description="Quality for non-alpha channels (0=worst, 100=best/lossless)" default="60" min="0" max="100" />
<Option name="QUALITY_ALPHA" type="int" description="Quality for alpha channel (0=worst, 100=best/lossless)" default="100" min="0" max="100" />
<Option name="SPEED" type="int" description="Encoder speed (0=slowest, 10=fastest)" default="6" min="0" max="10" />
<Option name="NUM_THREADS" type="string" description="Number of worker threads for compression. Can be set to ALL_CPUS" default="ALL_CPUS" />
<Option name="WRITE_EXIF_METADATA" type="boolean" description="Whether to write EXIF metadata" default="YES" />
<Option name="WRITE_XMP" type="boolean" description="Whether to write XMP metadata" default="YES" />
<Option name="SOURCE_ICC_PROFILE" type="string" description="ICC profile encoded in Base64" />
<Option name="NBITS" type="int" description="Bit depth. Valid values are 8, 10, 12." />
<Option name="YUV_SUBSAMPLING" type="string-select" description="Subsampling factor for YUV colorspace (for RGB or RGBA)" default="444">
<Value>444</Value>
<Value>422</Value>
<Value>420</Value>
</Option>
</CreationOptionList>
coverage: 69.357%. remained the same when pulling 272efa86409530611665c3f5810c7499d6fa0a8e on rouault:avif into cf671746a97a92dc481b061c963ce4bec0237ec0 on OSGeo:master.
CC @bradh
I tried this with an AVIF file I'd previously created with libheif.
gdalinfo ~/testbed20/silvereye/smalltiles_2024-06-29/complex_osm_tile_aom_q100.avif
Driver: AVIF/AV1 Image File Format
Files: /home/bradh/testbed20/silvereye/smalltiles_2024-06-29/complex_osm_tile_aom_q100.avif
Size is 256, 256
Image Structure Metadata:
YUV_SUBSAMPLING=420
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 256.0)
Upper Right ( 256.0, 0.0)
Lower Right ( 256.0, 256.0)
Center ( 128.0, 128.0)
Band 1 Block=256x1 Type=Byte, ColorInterp=Red
Band 2 Block=256x1 Type=Byte, ColorInterp=Green
Band 3 Block=256x1 Type=Byte, ColorInterp=Blue
However
bradh@audax:~/coding/gdal_rouault/build$ gdal_translate ~/testbed20/silvereye/smalltiles_2024-06-29/complex_osm_tile_aom_q100.avif out.png
Input file size is 256, 256
ERROR 1: avifDecoderNextImage() failed with: No codec available
ERROR 1: libpng: No IDATs written into file
bradh@audax:~/coding/gdal_rouault/build$ gdal_translate ~/testbed20/silvereye/smalltiles_2024-06-29/complex_osm_tile_aom_q100.avif out.tiff
Input file size is 256, 256
0ERROR 1: avifDecoderNextImage() failed with: No codec available
Sample data smalltiles_2024-06-29.zip
ERROR 1: avifDecoderNextImage() failed with: No codec available
@bradh I can successfully decode those 2 images with my build using libavif from Ubuntu 22.04. From the error message, I would assume that your libavif build has been done without any codec at all (aom, dav1d or libgav1), which is quite surprising that its build system would allow that. Can you check how it has been built ? For the write side, "gdalinfo --format AVIF" will show which encoding codecs are available. On my build:
<Option name="CODEC" type="string-select" description="Compression CODEC" default="AUTO">
<Value>AUTO</Value>
<Value>AOM</Value>
</Option>
From the error message, I would assume that your libavif build has been done without any codec at all (aom, dav1d or libgav1), which is quite surprising that its build system would allow that. Can you check how it has been built ?
Yes, this was the problem. I built from source, and the default is for the codecs to be disabled. I had assumed it would pick up the system versions.
With some configuration of the the cmake, it now gives me:
Format Details:
Short Name: AVIF
Long Name: AV1 Image File Format
Supports: Raster
Extension: avif
Mime Type: image/avif
Help Topic: drivers/raster/avif.html
Supports: Raster subdatasets
Supports: Open() - Open existing dataset.
Supports: CreateCopy() - Create dataset by copying another.
Supports: Virtual IO - eg. /vsimem/
Creation Datatypes: Byte UInt16
<CreationOptionList>
<Option name="CODEC" type="string-select" description="Compression CODEC" default="AUTO">
<Value>AUTO</Value>
<Value>AOM</Value>
<Value>RAV1E</Value>
<Value>SVT</Value>
</Option>
<Option name="QUALITY" type="int" description="Quality for non-alpha channels (0=worst, 100=best/lossless)" default="60" min="0" max="100" />
<Option name="QUALITY_ALPHA" type="int" description="Quality for alpha channel (0=worst, 100=best/lossless)" default="100" min="0" max="100" />
<Option name="SPEED" type="int" description="Encoder speed (0=slowest, 10=fastest)" default="6" min="0" max="10" />
<Option name="NUM_THREADS" type="string" description="Number of worker threads for compression. Can be set to ALL_CPUS" default="ALL_CPUS" />
<Option name="WRITE_EXIF_METADATA" type="boolean" description="Whether to write EXIF metadata" default="YES" />
<Option name="WRITE_XMP" type="boolean" description="Whether to write XMP metadata" default="YES" />
<Option name="SOURCE_ICC_PROFILE" type="string" description="ICC profile encoded in Base64" />
<Option name="NBITS" type="int" description="Bit depth. Valid values are 8, 10, 12." />
<Option name="YUV_SUBSAMPLING" type="string-select" description="Subsampling factor for YUV colorspace (for RGB or RGBA)" default="444">
<Value>444</Value>
<Value>422</Value>
<Value>420</Value>
</Option>
</CreationOptionList>
I did a conversion from TIFF to AVIF. It rendered fine, and I'm pretty confident that it was using the libavif implementation (rather than libheif) based on the file type compatible brands including MA1A.