convert library

Platform-neutral colour conversion — importable from ANY Dart target (web, native, pure-Dart CLIs) with no FFI, no dart:io, no minigpu.

This is the boundary for consumers that only want the conversion math (coefficient tables + pure-Dart YUV420<->RGBA loops) without pulling in the codec backends: import 'package:miniav_tools_codecs/convert.dart';

The native-accelerated twin (CpuFrameConverter, C loops, ~10-20x faster) and the GPU converters live in the main miniav_tools_codecs.dart barrel; all three implementations are byte-identical per matrix/range.

Classes

RgbaYuvCoeffs
Canonical ×256 fixed-point RGB→YCbCr coefficients — the inverse direction, same single-source-of-truth contract as YuvRgbCoeffs. Shared by the native C converter (frame_convert.c miniav_rgba_to_i420), the pure-Dart converter (rgba_yuv_dart.dart, the web / no-FFI path), and the GPU WGSL converter — all byte-identical.
YuvRgbCoeffs

Enums

DecodedPixelLayout
Planar layout + bit depth of a CPU-resident decoded frame's tightly-packed bytes (from DecodedFrame.readBytes). The presenter routes to the matching YUV→RGBA converter; combined with DecodedFrame.isFullRange it fully determines the colour conversion. GPU/browser frames ignore this (they route by DecodedFrame.outputKind / DecodedFrame.webVideoFrame).
YuvColorMatrix
YCbCr→RGB matrix of a CPU-resident decoded frame. Combined with DecodedFrame.isFullRange it selects the converter's coefficient set.

Functions

dartI420ToRgba(Uint8List y, Uint8List u, Uint8List v, int width, int height, {bool fullRange = false, YuvColorMatrix matrix = YuvColorMatrix.bt601, bool bgra = false, int strideY = 0, int strideU = 0, int strideV = 0, Uint8List? out}) Uint8List
Convert I420 planes -> packed RGBA8888 (alpha 255), or BGRA8888 with bgra. Plane strides are in bytes (<=0 = tightly packed). Writes into out when provided (must hold width*height*4); otherwise allocates. Byte-identical to the C miniav_i420_to_rgba for every matrix/range.
dartI420ToRgbaAsync(Uint8List y, Uint8List u, Uint8List v, int width, int height, {bool fullRange = false, YuvColorMatrix matrix = YuvColorMatrix.bt601, bool bgra = false, Uint8List? out, int chunkRows = 32}) Future<Uint8List>
dartI420ToRgba that yields to the event loop every chunkRows rows.
dartI422ToRgba(Uint8List y, Uint8List u, Uint8List v, int width, int height, {bool fullRange = false, YuvColorMatrix matrix = YuvColorMatrix.bt601, bool bgra = false, int strideY = 0, int strideU = 0, int strideV = 0, Uint8List? out}) Uint8List
Convert I422 planes (chroma half-width, FULL height — e.g. deinterleaved YUY2) -> packed RGBA8888/BGRA8888. Same contract as dartI420ToRgba; byte-identical to the C miniav_i422_to_rgba.
dartRgbaToI420(Uint8List rgba, int width, int height, {bool fullRange = false, YuvColorMatrix matrix = YuvColorMatrix.bt601, bool bgra = false, int srcStrideBytes = 0, Uint8List? outY, Uint8List? outU, Uint8List? outV}) I420Planes
Convert packed RGBA8888 (or BGRA8888 with bgra) -> tightly-packed I420 planes. srcStrideBytes is the source row stride (<=0 = tight, 4*width) — capture APIs (DXGI, V4L2) often pad rows.
dartRgbaToI420Async(Uint8List rgba, int width, int height, {bool fullRange = false, YuvColorMatrix matrix = YuvColorMatrix.bt601, bool bgra = false, int srcStrideBytes = 0, Uint8List? outY, Uint8List? outU, Uint8List? outV, int chunkRows = 32}) Future<I420Planes>
dartRgbaToI420 that yields to the event loop every chunkRows luma rows.

Typedefs

I420Planes = ({Uint8List u, Uint8List v, Uint8List y})
Tightly-packed I420 planes (chroma dims (w+1)~/2 x (h+1)~/2).