/** * For decoding: given a prefix code 0..39 and the extra-bits *value* * already read, return the RAW distance value (the value before plane * remapping). The caller passes this through `planeCodeToDistance` to * recover the actual pixel distance. Splitting the two steps keeps the * Huffman/extra-bits decoding and the spatial mapping cleanly separable. */ export declare function distanceFromCode(code: number, extraBitsValue: number): number; /** * For encoding: convert a *raw* distance value (post-plane-remap) into * the prefix code + extra-bits payload. Returns `null` if the value is * out of range. Encoders that want to pick the most compact 2D offset * for a given linear distance should call `linearDistanceToRaw` first * to get a list of candidate raw values, score the prefix-encoded sizes, * and pass the winner here. */ export declare function distanceToCode(rawDistance: number): { code: number extraBits: number extraValue: number } | null; /** * Convert a raw distance value (1..MAX_DISTANCE) into the actual linear * pixel offset, using the plane-code mapping for raw values ≤ 120. The * `xsize` argument is the width of the pixel stream the backreference * lives in — the same width passed to `decodePixelStream`. */ export declare function planeCodeToDistance(xsize: number, rawDistance: number): number; /** * Convert a linear pixel distance into the *cheapest* raw distance value * — accounting for the plane-code shortcuts. For the same final distance * there can be (a) the linear-form `distance + 120`, and (b) zero or * more plane-code forms within ±7 columns of the current pixel. We * return the raw value with the shortest prefix code; ties broken by * smaller raw value (matches libwebp's preference order). */ export declare function linearDistanceToRaw(distance: number, xsize: number): number | null; /** * VP8L distance-code helpers. * * Distances in VP8L are LZ77 backreferences expressed as a single prefix * code 0..39 plus extra bits for codes ≥ 4. The code → distance mapping * is DEFLATE-style: each code represents a base distance with a fixed * number of extra bits to read. * * On TOP of that, the spec applies a 120-entry "plane code" remapping * (libwebp's `kCodeToPlane`): the first 120 raw distance values aren't * linear pixel distances at all but compact 2D `(xoffset, yoffset)` * tuples relative to the current pixel — so "the pixel directly above" * is a 1-2 bit code instead of `xsize`-bits. Raw values > 120 are linear * distances minus 120. The decoder converts via * xoffset = 8 - (kCodeToPlane[raw - 1] & 0x0F) * yoffset = kCodeToPlane[raw - 1] >> 4 * actual = max(1, yoffset * xsize + xoffset) * (matching libwebp's `PlaneCodeToDistance`). The encoder inverts this * by mapping the linear distance back into a plane code when one of the * 120 entries lands within ±7 of the current pixel. * * Reference: WebP Lossless Bitstream Specification §8.2. */ /** Number of distance prefix codes in the VP8L distance alphabet. */ export declare const NUM_DISTANCE_CODES: 40; /** * Per-spec extra-bit count for distance prefix codes 0..39. The first 4 * codes are direct (no extra bits); each pair afterwards doubles the * range covered. */ export declare const DISTANCE_EXTRA_BITS: Uint8Array; /** * Per-spec base distance for prefix codes 0..39. Code `c` covers * `[DISTANCE_OFFSET[c], DISTANCE_OFFSET[c] + (1 << DISTANCE_EXTRA_BITS[c]) - 1]`. */ export declare const DISTANCE_OFFSET: Uint32Array; /** * Largest distance representable in the alphabet. A backreference whose * linear distance exceeds this can't be encoded — the encoder must fall * back to literal-emit for that pixel. */ export declare const MAX_DISTANCE: unknown; /** * The 120-entry "plane code" table from the VP8L spec. Each byte encodes * a packed (yoffset, xoffset) pair — see `planeCodeToDistance` for the * unpacking. Order matches libwebp's `kCodeToPlane24` in `huffman_utils.h`. */ export declare const CODE_TO_PLANE_CODES: 120;