Skip to content
QuaLix
On this page

TypeScript API

Complete API reference for @quajs/qualix, @quajs/qualix/header, @quajs/qualix/web, @quajs/qualix/quack, and @quajs/qualix/cocos.

@quajs/qualix/header (Zero-WASM pure JS)

  • isQuaLix(input: ArrayBufferView | ArrayBuffer): boolean — Validates the 4-byte QLX signature (51 4C 58 07).
  • inspectQuaLix(input: ArrayBufferView | ArrayBuffer): QuaLixHeaderInfo — Parses the 32-byte header without WASM; throws on an invalid signature or header field.
  • colorCodeToProfile(code) / colorProfileToCode(color) — Converts wire byte codes 1..3 to 'srgb8' | 'pq10' | 'hlg10'.
  • Constants: QLX_MAGIC, QLX_FORMAT_VERSION, QLX_HEADER_SIZE = 32, QLX_MIME_TYPE = 'video/x-qualix', QLX_DEFAULT_BUDGET, QLX_ADAPTIVE_QUANTIZATION = 255.

@quajs/qualix (Inline WASM decoder)

  • loadQuaLixRuntime(): Promise<QuaLixRuntime> — Instantiates and caches the inline qualix_decoder.wasm module (open and streaming openReader).
  • getQuaLixRuntimeSync(): QuaLixRuntime — Synchronous WASM instantiation for Node.js and Worker threads.
  • openQuaLix(bytes: Uint8Array, budget?: number): Promise<QuaLixClipHandle> — Validates header and opens an in-memory QLX clip.
  • decodeQuaLixFrame(bytes: Uint8Array, frameIndex?: number, budget?: number) — Decodes a single frame into an owned Uint8ClampedArray and closes immediately.
  • unpackRgb10A2ToRgba8(src, pixelCount, dst?) — Converts 10-bit R10G10B10A2 pixels into 8-bit RGBA8 for SDR canvas display.
TypeScript
export interface QuaLixDecodedFrame { index: number width: number height: number color: 'srgb8' | 'pq10' | 'hlg10' pixels: Uint8Array // Borrowed view valid until next decode() or close() firstRow: number endRow: number toRgba8: (target?: Uint8ClampedArray) => Uint8ClampedArray}

@quajs/qualix/web (Browser playback & <video> adapter)

  • QuaLixCanvasPlayer.create(canvas, bytes, options?) — Binds WASM decoding to an HTMLCanvasElement with dirty-row uploads, seek/loop/rate controls, and offscreen/hidden RAF pausing.
  • attachQuaLixToVideoElement(video, bytes, options?) — Mounts .qlx playback onto an existing <video> element (captureStream() + __quaQualixCanvas canvas snapshot support) with standard media properties and events.
  • blitQuaLixFrameToCanvas(ctx, frame, scratch, fullBlit?) — Uploads [firstRow, endRow) incrementally with ctx.putImageData.

@quajs/qualix/quack & @quajs/qualix/cocos

  • transcodeVideoBufferToQlx(input, ext?, options?), packVideoAssetsWithQuaLix(assets, options?), QuaLixPlugin — Node.js build-time transcoders and Quack plugin (preserves logical asset names and passes through muxed A/V containers unless stripAudio is set).
  • createQuaLixSpriteTexture(clip, createTexture, rgba8888FormatCode) — Incremental Texture2D frame uploader for Cocos Creator Web.