gpu library

GPU (minigpu) video utilities for miniav_tools_codecs — WEB-SAFE.

A separate entry point (not the main miniav_tools_codecs.dart barrel, which pulls the native dart:ffi codec bindings) so a consumer — including one compiled for web, or a non-Flutter tool — can use the GPU converters without dragging in the native asset. Depends only on minigpu (web-capable) and the pure-Dart platform interface.

Classes

GpuPlanarYuvToRgbaConverter
Reusable converter: shader + params + slotCount independent (yuv upload, rgba output) buffer pairs so a presenter can ping-pong slots while the display samples the previous frame. Buffers are sized per resolution+layout and rebuilt on change. Not thread-safe — drive from one serialized path.
GpuRgbaToYuv420Converter
Reusable GPU RGBA→YUV420 converter. One per output resolution; the shader and plane buffers are reused across frames. Not thread-safe — drive it from a single serialized encode path.
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

Constants

kPlanarYuvToRgbaBt601Wgsl → const String
The unified kernel. >> on i32 is arithmetic in WGSL (matching Dart), so the rounding of negative intermediates is identical to the CPU reference.
kRgbaToYuv420Wgsl → const String