HeifEncoder

interface HeifEncoder(source)

The encoder of one coded item type of HEIF, such as hvc1 for HEVC (#174). The core writes the container: it converts RGB to planes, cuts a large picture into the tiles of a grid, and writes the items, their properties and their references. An encoder only turns the planes of one picture into the payload of its configuration property and the coded data of its item.

Register an encoder with ImageKodec.registerHeifEncoder.

Properties

Link copied to clipboard
abstract val alphaUrn: String

The URN of the auxC property of an alpha plane coded by this encoder, as the readers of the codec expect it: urn:mpeg:hevc:2015:auxid:1 for HEVC, urn:mpeg:mpegB:cicp:systems:auxiliary:alpha for AV1.

Link copied to clipboard

The four-character type of the item property that configures the codec, such as hvcC.

Link copied to clipboard
abstract val itemType: String

The four-character item type this encoder writes, such as hvc1.

Functions

Link copied to clipboard
abstract fun encode(planes: HeifPlanes, parameters: HeifEncodeParameters, cancellationCheck: () -> Unit?): HeifCodedPicture

Codes planes, one picture, as parameters ask. Luma has 1 sample or more on each side, and in subsampled chroma an even number, so the picture needs no rounding up. Call cancellationCheck at a coarse step, such as once a row of coding blocks, and let what it throws pass through. Throw IllegalArgumentException for a picture the codec cannot hold.

Link copied to clipboard
open fun openSequence(parameters: HeifEncodeParameters, keyFrameInterval: Int): HeifSequenceEncoder?

Opens an encoder of one image sequence (#177), the pictures of one track of a HEIF file, coded as parameters ask, or returns null when this encoder codes still pictures only, as the default does. The core calls it for ImageKodec.encodeAvif and ImageKodec.encodeHeic with an animation, once for the colour track and once more for an alpha track. keyFrameInterval above 0 asks for a picture that needs no earlier one (a sync sample) at least every that many pictures; 0 asks for the first alone.