/** * Apply one of the 14 predictor functions to four neighbouring pixels. * Each pixel is a packed ARGB Uint32. The return value is the *predicted* * pixel — the encoder subtracts it from the actual pixel to produce the * residual; the decoder adds it back. * * Implemented as a switch rather than a dispatch table because every * mode does different per-channel arithmetic, and the JIT inlines this * switch into a tight loop better than indirect calls. */ export declare function predict(mode: number, L: number, T: number, TL: number, TR: number): number; /** * Apply the inverse predictor transform: read the residual ARGB image * + the mode-per-block image, and produce the original ARGB pixels. * * `argb` is mutated in place. */ export declare function inversePredictorTransform(argb: Uint32Array, width: number, height: number, bits: number, modeImage: Uint32Array, modeWidth: number): void; /** * Apply the forward predictor transform: encode each pixel as * `pixel - predictor`, picking a single mode for all blocks (mode 11, * the select predictor) for now. Returns the mode image as an ARGB * `Uint32Array` whose green channel holds the mode value per block. * * Picking per-block modes adaptively is a small additional pass — * for each block, we'd try every mode on a representative interior * pixel and keep the one with the smallest residual entropy. Mode 11 * alone already wins most of the compression on natural images. * * `argb` is mutated in place to hold residuals. */ export declare function applyPredictorTransform(argb: Uint32Array, width: number, height: number, bits: number): { modeImage: Uint32Array, modeWidth: number, modeHeight: number }; /** * VP8L predictor transform. * * The predictor transform splits the image into `2^bits × 2^bits` blocks * and assigns each block one of 14 prediction modes. For each pixel * (except the very first row/column), the pixel value is replaced by * `pixel - predictor(neighbours)` (per channel, mod 256). The decoder * reverses by adding `predictor(neighbours)` back. * * Why this helps: after subtract-green, a smooth natural image has small * differences between neighbours. The predictor produces an even smaller * residual by using a *prediction* of each pixel based on its already- * decoded neighbours — when the prediction is good the residual is tiny, * which Huffman codes very efficiently. * * The 14 modes use the neighbours `L` (left), `T` (top), `TL` (top-left), * `TR` (top-right) — all already-decoded by the time we predict. Special * cases: * • the very first pixel uses an opaque-black predictor (`0xFF000000`) * • the rest of the first row uses `L` * • the rest of the first column uses `T` * • everything else uses `mode_table[block_mode]` * * The mode-per-block image is stored at the start of the bitstream as a * recursively-encoded sub-image whose pixels carry the mode in the green * channel. * * Reference: WebP Lossless Bitstream Specification §3.1. */ /** * Number of distinct modes (0..13). Spec reserves 14..15 but they're * undefined; we never emit them and reject them on decode. */ export declare const NUM_PREDICTORS: 14;