HeifEncodeOptions

class HeifEncodeOptions(val quality: Int = 50, val lossless: Boolean = false, val chroma: HeifChroma = HeifChroma.Yuv420, val bitDepth: Int? = null, val effort: Int = 2, val tileSize: Int? = 512, val thumbnailSize: Int? = null, val orientation: Orientation = Orientation.Normal, val keyFrameInterval: Int = 0)(source)

The settings of a HEIF encode (#174), for ImageKodec.encodeHeic, ImageKodec.encodeHeic16, ImageKodec.encodeAvif and ImageKodec.encodeAvif16 (#176). Every parameter has a default, so name only the ones to change:

val heic = ImageKodec.encodeHeic(bitmap, HeifEncodeOptions(quality = 80, chroma = HeifChroma.Yuv444))

Throws

when a value is out of its range

Constructors

Link copied to clipboard
constructor(quality: Int = 50, lossless: Boolean = false, chroma: HeifChroma = HeifChroma.Yuv420, bitDepth: Int? = null, effort: Int = 2, tileSize: Int? = 512, thumbnailSize: Int? = null, orientation: Orientation = Orientation.Normal, keyFrameInterval: Int = 0)

Properties

Link copied to clipboard

the bits of each coded sample: 8, 10 or 12, or null for 8 from a KiteBitmap and for 10 lossy or 12 lossless from a KiteBitmap16.

Link copied to clipboard

the chroma subsampling of a lossy colour picture. The default, 4:2:0, averages each 2 by 2 block of chroma, centred where the decoder's upsampling expects it.

Link copied to clipboard
val effort: Int

1 (fast) to 3 (thorough). 1 tests few intra modes and no transform skip, 2 adds 64 by 64 coding units, one level of transform split and rate-distortion optimised quantization, and 3 tests every mode and two levels of transform split with no early stops. In AV1, 1 tries one mode a block, square partitions down to 8 by 8 and two transform types; 2 adds filter intra, a transform split, 4 by 4 blocks, more transform types, a level search, loop restoration and, on screen content, intra block copy; 3 adds a second mode, angle deltas, rectangular partitions, a second split and every transform type throughout. In the inter frames of an AV1 sequence (#177), 1 predicts from the frame before alone, in a narrow motion search; 2 adds the frame before that, the two averaged, and a wider search; 3 searches wider still and codes more candidates.

Link copied to clipboard

for an animation (#177): above 0, a picture coded on its own, which a player can start from, at least every that many frames; 0, the default, codes the first frame alone that way and every later one from those before it, which is smallest. Still pictures ignore it.

Link copied to clipboard

codes the picture so that it decodes to exactly the input: RGB through the identity matrix of ITU-T H.273 in 4:4:4, or gray in 4:0:0, with quality and chroma ignored. A 16-bit input keeps exactly the samples a picture of bitDepth bits can give back through ImageKodec.decode16; other values move to the nearest of those.

Link copied to clipboard

how to show the stored pixels, as irot and imir properties: a reader that applies them, as ImageKodec.decode with applyOrientation does, shows bitmap.oriented(orientation). An EXIF block written with the image takes the same orientation, so the two never disagree.

Link copied to clipboard

0 to 100, higher is better and larger. The HEVC encoder codes at a QP of 46 less half the quality, rounded up, and at least 1 (46 at 0, 21 at 50, 6 at 80, 1 from 90 on), so that a quality gives about the SSIMULACRA 2 score of libheif's heif-enc -q at the same number. The AV1 encoder codes at a base_q_idx of 240 at 0, 117 at 50, 43 at 80 and 1 from 97 on, straight between, so that 50 and 80 give about the SSIMULACRA 2 score of libavif's avifenc -q 50 and -q 80.

Link copied to clipboard

the longest side of a thumbnail item to write beside the image, scaled down from it, or null for none. A picture no larger than this gets no thumbnail.

Link copied to clipboard

the side of the square tiles of a grid, a multiple of 8 from 64 to 8192: a picture wider or taller than this is written as a grid of tiles of this size, which the tile runner of ImageKodec.setTileRunner encodes, and the edge tiles are padded by repeating the last row and column. 512 is what phones write. Null writes one coded picture of any size the codec's levels hold.

Functions

Link copied to clipboard
open override fun toString(): String