TypeScript API 参考
@quajs/qualix、@quajs/qualix/header、@quajs/qualix/web、@quajs/qualix/quack 与 @quajs/qualix/cocos 全部导出函数与接口。
@quajs/qualix/header(零 WASM 纯 JS)
isQuaLix(input: ArrayBufferView | ArrayBuffer): boolean— 检验 4 字节 QLX 签名(51 4C 58 07)。inspectQuaLix(input: ArrayBufferView | ArrayBuffer): QuaLixHeaderInfo— 解析完整 32 字节小端文件头;签名不匹配或字段无效时抛出错误。colorCodeToProfile(code: number)/colorProfileToCode(color)— 在1/2/3与'srgb8' | 'pq10' | 'hlg10'间转换。- 常量:
QLX_MAGIC、QLX_FORMAT_VERSION、QLX_HEADER_SIZE = 32、QLX_MIME_TYPE = 'video/x-qualix'、QLX_DEFAULT_BUDGET、QLX_ADAPTIVE_QUANTIZATION = 255。
@quajs/qualix(内联 WASM 解码器)
loadQuaLixRuntime(): Promise<QuaLixRuntime>— 异步编译并缓存内嵌的qualix_decoder.wasm,返回支持.open(bytes, budget?)与.openReader(size, readAt, budget?)的运行时。getQuaLixRuntimeSync(): QuaLixRuntime— 在 Node / Worker 环境同步实例化并返回运行时。openQuaLix(bytes: Uint8Array, budget?: number): Promise<QuaLixClipHandle>— 校验头部并在 WASM 内打开整片剪辑。decodeQuaLixFrame(bytes: Uint8Array, frameIndex?: number, budget?: number)— 解码单帧并返回{ info, frameIndex, rgba8 },用毕自动释放句柄。unpackRgb10A2ToRgba8(src: Uint8Array, pixelCount: number, dst?: Uint8ClampedArray)— 将 10-bitpq10/hlg10像素解包为 8-bitRGBA8供普通画布预览。
TypeScriptexport interface QuaLixDecodedFrame { index: number width: number height: number color: 'srgb8' | 'pq10' | 'hlg10' pixels: Uint8Array // WASM 内存只读视图;在下一次 decode()/close() 前有效 firstRow: number endRow: number toRgba8: (target?: Uint8ClampedArray) => Uint8ClampedArray}
@quajs/qualix/web(浏览器播放与 <video> 桥接)
QuaLixCanvasPlayer.create(canvas, bytes, options?)— 驱动HTMLCanvasElement逐帧解码与脏行上传,支持play()、pause()、seekSeconds(t)、step(dt)、dispose(),并按IntersectionObserver/visibilitychange自动休眠。attachQuaLixToVideoElement(video, bytes, options?)— 把 QLX 播放状态绑定到现有<video>节点(captureStream()+__quaQualixCanvas),同步支持duration、currentTime、videoWidth、videoHeight、loop、playbackRate与ended/error事件。blitQuaLixFrameToCanvas(ctx, frame, scratch, fullBlit?)— 按脏行区间[firstRow, endRow)增量执行ctx.putImageData。
@quajs/qualix/quack 与 @quajs/qualix/cocos
transcodeVideoBufferToQlx(input, ext?, options?)/packVideoAssetsWithQuaLix(assets, options?)/QuaLixPlugin— Node.js 构建侧视频转码与 Quack 插件(默认保留逻辑文件名,混流音视频自动直通)。createQuaLixSpriteTexture(clip, createTexture, rgba8888FormatCode)— Cocos CreatorTexture2D.uploadData逐帧更新封装。