SpawnDev.Codecs

Image, video and audio codecs in C# that run on any GPU.

License: MITnet10.0

SpawnDev.Codecs is a codec library for .NET where the codec work itself, from colour conversion to the entropy coder, runs as C# kernels compiled by SpawnDev.ILGPU on the accelerator you provide. The host only uploads input, launches kernels and reads back results. It targets the browser (WebGPU, WebGL, Wasm) and desktop (CUDA, OpenCL, CPU) and covers patent-clean formats only.

Runs on

WebGPUWebGL (partial: no serial frame coders)WasmCUDAOpenCLVelocity (SIMD CPU)CPU

Highlights

  • Image codecs: PNG (APNG, Adam7, 16-bit), JPEG (baseline and progressive), WebP (lossless, lossy, alpha, animation), GIF and BMP, encode and decode, plus ImageDecoderGpu that recognizes the format.
  • WebP lossy encode matches libwebp 1.6.0 and JPEG encode matches libjpeg-turbo file for file; WebP and JPEG decode match the reference libraries pixel for pixel.
  • Video: VP8, VP9 and AV1 keyframe encoders and decoders; the VP8 keyframe decoder matches ffmpeg pixel for pixel on 182 real files.
  • Audio: Opus decoder (SILK, CELT, hybrid) and CELT-only Opus encoder byte-identical with libopus 1.5.2, Vorbis decoders and FLAC.
  • Every entry point has three overloads: accelerator memory (ArrayView1D), a JS typed array in the browser, and managed byte[].
  • Serial stages are resumable chains of short launches so no kernel holds the GPU long enough to trip the OS watchdog.
Program.cs
using SpawnDev.Codecs.Images;

using var images = new ImageDecoderGpu(accelerator);
DecodedImage picture = await images.DecodeAsync(File.ReadAllBytes("photo.jpg"));
// picture.Info: Format, Width, Height, HasAlpha, BitDepth, FrameCount, Orientation
// picture.Pixels: Width x Height x 4 bytes of RGBA8

Install

dotnet add package SpawnDev.Codecs
dotnet add package SpawnDev.Codecs.References

Building on SpawnDev.Codecs?

Private tickets, response targets and a direct line to the engineer who wrote it.

See support plans
An unhandled error has occurred. Reload x