iipsrv 1.3
iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images
AVIFCompressor Class Reference

Wrapper class to AVIF library: Handles 8 bit and alpha channels. More...

#include <AVIFCompressor.h>

Inheritance diagram for AVIFCompressor:
Compressor

Public Member Functions

 AVIFCompressor (int quality)
 Constructor.
 
 ~AVIFCompressor ()
 Destructor.
 
void InitCompression (const RawTile &rawtile, unsigned int strip_height)
 Initialize strip based compression.
 
unsigned int CompressStrip (unsigned char *source, unsigned char *output, unsigned int tile_height)
 Compress a strip of image data.
 
unsigned int Finish (unsigned char *output)
 Finish the strip based compression and free memory.
 
unsigned int Compress (RawTile &t)
 Compress an entire buffer of image data at once in one command.
 
unsigned int getHeaderSize () const
 Return the WebP header size.
 
unsigned char * getHeader ()
 Return a pointer to the header itself.
 
const char * getMimeType () const
 Return the WebP mime type.
 
const char * getSuffix () const
 Return the image filename suffix.
 
ImageEncoding getImageEncoding () const
 Get compression type.
 
int getQuality () const
 Get the current compression level.
 
void setQuality (int quality)
 Set the compression level.
 
void setCodec (unsigned int codec)
 Set codec for use during encoding - note that not all may be enabled in libavif.
 
- Public Member Functions inherited from Compressor
 Compressor (int compressionLevel)
 Constructor.
 
unsigned int getHeaderSize () const
 Return the image header size.
 
unsigned char * getHeader ()
 Return a pointer to the image header itself.
 
int getQuality () const
 Get the current quality level.
 
bool defaultQuality () const
 Check whether we are using the default or whether user has requested a specific quality level.
 
void setResolution (float x, float y, int units)
 Set the physical output resolution.
 
void embedICCProfile (const bool embed)
 Embed ICC profile.
 
void embedXMPMetadata (const bool embed)
 Embed XMP metadata.
 
void embedExifMetadata (const bool embed)
 Embed EXIF metadata.
 
void setMetadata (const std::map< const std::string, const std::string > &metadata)
 Set general metadata.
 
virtual void injectMetadata (RawTile &t)
 Inject metadata into raw bitstream.
 

Static Public Member Functions

static avifCodecChoice getCodecChoice (unsigned int codec)
 Static function: Convert from our option native system to libavif's codec choices.
 
static const char * getCodecName (unsigned int codec)
 Static function: Get codec name from IIPImage codec option code.
 

Additional Inherited Members

- Protected Member Functions inherited from Compressor
virtual void writeMetadata ()
 Write metadata.
 
virtual void writeResolution ()
 Write DPI.
 
- Protected Attributes inherited from Compressor
int Q
 Quality or compression level for all image types.
 
bool default_quality
 Whether compression level is default or has been set manually.
 
unsigned char * header
 Pointer to the header data for the output image.
 
unsigned int header_size
 Size of the header data.
 
int dpi_units
 Physical resolution units: 0 for unknown, 1 for dots/inch or 2 for dots/cm.
 
float dpi_x
 Physical resolution (pixels per physical unit) for X direction.
 
float dpi_y
 Physical resolution (pixels per phyisical unit) in Y direction.
 
std::map< const std::string, const std::string > metadata
 Metadata.
 
std::string icc
 ICC Profile.
 
bool embedICC
 Whether ICC profile should be embedded.
 
std::string xmp
 XMP metadata.
 
bool embedXMP
 Whether XMP metadata should be embedded.
 
std::string exif
 EXIF metadata.
 
bool embedEXIF
 Whether EXIF metadata should be embedded.
 

Detailed Description

Wrapper class to AVIF library: Handles 8 bit and alpha channels.

Constructor & Destructor Documentation

◆ AVIFCompressor()

AVIFCompressor::AVIFCompressor ( int  quality)
inline

Constructor.

Parameters
qualityWebP compression level (range 0-100)

Member Function Documentation

◆ Compress()

unsigned int AVIFCompressor::Compress ( RawTile t)
virtual

Compress an entire buffer of image data at once in one command.

Compress a single tile of data.

Parameters
ttile of image data
Returns
size of compressed data

Reimplemented from Compressor.

References RawTile::bpc, RawTile::capacity, RawTile::channels, RawTile::compressionType, RawTile::data, RawTile::dataLength, RawTile::height, RawTile::memoryManaged, Compressor::Q, RawTile::quality, RawTile::triplicate(), and RawTile::width.

Referenced by InitCompression().

◆ CompressStrip()

unsigned int AVIFCompressor::CompressStrip ( unsigned char *  source,
unsigned char *  output,
unsigned int  tile_height 
)
virtual

Compress a strip of image data.

libwebp cannot handle line or region-based encoding, so simulate strip-based output using byte chunks

Parameters
sourcesource image data
tile_heightpixel height of the tile we are compressing
outputoutput_buffer
Returns
size of compressed strip

Reimplemented from Compressor.

References RawTile::data, RawTile::dataLength, and RawTile::height.

◆ Finish()

unsigned int AVIFCompressor::Finish ( unsigned char *  output)
virtual

Finish the strip based compression and free memory.

Parameters
outputOutput buffer
Returns
size of output generated

Reimplemented from Compressor.

References RawTile::data, and RawTile::dataLength.

◆ getCodecChoice()

static avifCodecChoice AVIFCompressor::getCodecChoice ( unsigned int  codec)
inlinestatic

Static function: Convert from our option native system to libavif's codec choices.

Parameters
codecIIPImage's codec option code (0=auto,1=aom,2=rav1e,3=svt)
Returns
libavif codec choice enum

Referenced by getCodecName(), and setCodec().

◆ getCodecName()

static const char * AVIFCompressor::getCodecName ( unsigned int  codec)
inlinestatic

Static function: Get codec name from IIPImage codec option code.

Parameters
codecIIPImage's codec option code (0=auto,1=aom,2=rav1e,3=svt)
Returns
code name

References getCodecChoice().

◆ getImageEncoding()

ImageEncoding AVIFCompressor::getImageEncoding ( ) const
inlinevirtual

Get compression type.

Reimplemented from Compressor.

◆ getMimeType()

const char * AVIFCompressor::getMimeType ( ) const
inlinevirtual

Return the WebP mime type.

Reimplemented from Compressor.

◆ getQuality()

int AVIFCompressor::getQuality ( ) const
inline

Get the current compression level.

Returns
compresson level

References Compressor::Q.

◆ getSuffix()

const char * AVIFCompressor::getSuffix ( ) const
inlinevirtual

Return the image filename suffix.

Reimplemented from Compressor.

◆ InitCompression()

void AVIFCompressor::InitCompression ( const RawTile rawtile,
unsigned int  strip_height 
)
virtual

Initialize strip based compression.

Initialize chunk-based encoding for the CVT handler.

For strip based encoding, we need to first initialize with InitCompression, then compress a single strip at a time using CompressStrip and finally clean up using Finish

Parameters
rawtileRawTile object containing the image to be compressed
strip_heightheight in pixels of the strip we want to compress

Reimplemented from Compressor.

References RawTile::bpc, RawTile::capacity, RawTile::channels, Compress(), RawTile::data, RawTile::dataLength, RawTile::height, RawTile::memoryManaged, and RawTile::width.

◆ setCodec()

void AVIFCompressor::setCodec ( unsigned int  codec)
inline

Set codec for use during encoding - note that not all may be enabled in libavif.

Parameters
codecIIPImage's codec option code (0=auto,1=aom,2=rav1e,3=svt)

References getCodecChoice().

◆ setQuality()

void AVIFCompressor::setQuality ( int  quality)
inlinevirtual

Set the compression level.

Parameters
qualitycompression level: 0-100 with (0 = highest compression). -1 = lossless

Reimplemented from Compressor.

References Compressor::Q.


The documentation for this class was generated from the following files: