class

Hwaro::Content::Processors::WebpEncoder::VP8

Inherits Reference < Object

Constants

BIAS_UV = {110, 115}
BIAS_Y1 = {96, 110}

Quantizer bias (1/256 of a step) for [dc, ac] of luma, the Y2 block (the luma DCs of an intra 16x16 macroblock) and chroma.

BIAS_Y2 = {96, 108}
BPS = 32

Work-buffer stride and the index of a macroblock's top-left pixel in it: one row above and room on the left for the edge samples, the layout the libwebp decoder predicts in.

I4_CANDIDATES = 3

Sub-block modes fully evaluated per 4x4 block (of 10).

I4_MODE_COSTS = Slice(Int64).new(1000) do |idx| ctx = idx // 10 cost = 0_i64 i4_mode_bits(idx % 10, ctx * 9) do |bit, prob| cost = cost + (bit ? COST[256 - prob] : COST[prob]) end cost end

Rate of each sub-block mode in each (above, left) context, plus the shared cost of nothing else: [(above * 10 + left) * 10 + mode].

LAMBDA_K = 0.023

Rate-distortion weight: lambda = K * (AC step)^2, distortion in squared error, rate in bits.

LAMBDA_UV_K = 0.047
LEVELS_PER_MB = 25 * 16

Per macroblock: block 0 = Y2, 1-16 = Y, 17-20 = U, 21-24 = V.

MAX_PARTITION0 = (1 << 19) - 1

Partition 0 length is a 19-bit field of the frame tag.

TYPE_I16_AC = 0

Coefficient table types.

TYPE_I4 = 3
TYPE_UV = 2
TYPE_Y2 = 1
UV_DC_DELTA = -2

Chroma DC quantizer offset libwebp writes at its default settings.

Y_OFF = BPS + 8

Constructors

new(pixels : Bytes, width : Int32, height : Int32, channels : Int32, quality : Int32)
Source

Class methods

i4_mode_bits(mode : Int32, probs : Int32, &) : Nil

Sub-block mode tree (libwebp PutI4Mode) under probs (an offset into BMODE_PROBS).

Source

Instance methods

encode

The VP8 frame (the "VP8 " chunk payload), or nil when partition 0 outgrows its size field.

Source