Skip to content

Latest commit

 

History

History
56 lines (52 loc) · 21.9 KB

codecs.md

File metadata and controls

56 lines (52 loc) · 21.9 KB

Codecs and formats

The full per-codec and per-container detail behind the summary table in the README: what each backend covers, how it was verified, and how it was measured. Every codec backend is 100% Rust (no C/C++ FFI) and permissively licensed; container (de)muxers are our own code.

Codec Backing crate License Pure Rust
AV1 encode (avif) rusty_av1e BSD-2-Clause ✅ (our rav1e fork; pure-Rust, no asm)
AV1 decode (avif) rusty_av1d BSD-2-Clause ✅ (our rav1d fork; Rust port of dav1d)
AV2 decode in-house (rusty_av2d) BSD-2-Clause ✅ (byte-identical vs AVM across a 45-clip corpus; standalone crate)
H.264 decode/encode rusty_h264 BSD-2-Clause ✅ (portable Rust SIMD, no C, no assembler)
HEVC decode in-house (rusty_h265) Apache-2.0 ✅ (147/147 JCT-VC conformance streams bit-exact; 0.80× to 1.37× FFmpeg's single-thread speed; forbid(unsafe_code) core; standalone crate)
VP9 decode/encode in-house (rusty_vp9) Apache-2.0 ✅ (bit-exact vs all 315 libvpx vectors; 0.2 encodes 1.5–2.0× and decodes 1.1–1.2× faster than 0.1; standalone crate)
AAC decode/encode in-house (rusty_aac) Apache-2.0 ✅ (decode: LC, Main, LTP, HE-AAC v1/v2, ER LD/ELD; encode: AAC-LC; standalone crate)
MP3 decode/encode in-house (rusty_mp3) Apache-2.0 ✅ (decoder bit-exact vs FFmpeg; standalone crate)
PNG encode/decode in-house (rusty_png) MIT OR Apache-2.0 ✅ (performance fork of image-rs/image-png; pure-Rust zlib-rs DEFLATE, parallel encode; standalone crate)
JPEG decode/encode in-house (rusty_jpeg) (MIT OR Apache-2.0) AND IJG ✅ (vendored merge of jpeg-decoder + jpeg-encoder; baseline + progressive; standalone crate)
GIF encode/decode gif MIT/Apache-2.0 ✅
WebP encode/decode in-house (rusty_webp) MIT OR Apache-2.0 ✅ (performance/feature fork of image-rs/image-webp; 0.2 decodes 1.1–1.5× and encodes 1.3–2.2× faster than 0.1 with identical output; standalone crate)
Opus encode/decode rusty-opus (our opus-rs fork) BSD-3-Clause ✅ (AVX2 SILK + frame-parallel; pure Rust, no C/FFI)
Vorbis encode + decode in-house (rusty_vorbis) Apache-2.0 ✅ (first permissive Rust Vorbis encoder; decoder matches FFmpeg 8.1 — same frame counts, max abs diff ~2e-7 — and is ~1.5x faster than symphonia; the CLI decodes Vorbis with it)
FLAC decode/encode in-house (rusty_flac) Apache-2.0 ✅ (lossless both directions; claxon kept as the independent decode oracle in tests; standalone crate)
JPEG XL decode jxl-oxide MIT/Apache-2.0 ✅

Codec backends — every one is 100% Rust (no C/C++ FFI) and permissively licensed. Container (de)muxers are our own code.

Kind Supported Status
Video codec vp9 (VP9) decode + encode — in-house pure-Rust (rusty_vp9, also usable standalone). Decoder bit-exact against all 315 official libvpx conformance vectors (profiles 0–3, 8/10/12-bit, AVX2 + NEON). Encoder: RDO partition/mode, rate control (CBR + two-pass), golden/ALT-REF + temporal filtering, compound (bi-directional) prediction, validated pixel-exact vs libvpx & ffmpeg. Read at a matched operating point — both encoders in constant-quality mode at the same cq ladder, speed preset and lookahead, compared at equal PSNR — it needs ~+36% bitrate and runs ~3× slower than libvpx on the Derf CIF set (measured on 0.1; 0.2 encodes 1.5–2.0× faster than 0.1 with a byte-identical bitstream, so the speed gap has narrowed but has not been re-measured against libvpx). (Keyframe-only BD-rate is ~+0.9%: the gap is the inter path, not residual coding.) Younger than libvpx, actively optimizing
Video codec h264 (H.264 / AVC) decode + encode — in-house pure-Rust (rusty_h264, also usable standalone), default. Codec core is #![forbid(unsafe_code)]; unsafe/asm is confined to one acceleration crate. Decoder bit-exact vs Cisco's h264dec across openh264's conformance corpus (35/35 clean streams) and pixel-exact vs FFmpeg on the CABAC paths; encoder decodes bit-exactly under FFmpeg across QP 0–51. Decode speed measured on x264-encoded 720p (our own encoder's output understates decode cost — its fast preset emits no sub-pel motion, skipping the whole interpolation path), one pinned core, CPU time, ABBA-alternated, 9 pairs, 9/9 with z = 3.00: 1.98× / 2.16× / 2.06× behind FFmpeg's native h264 at x264 veryfast (baseline/CAVLC) / medium (main/CABAC) / slower (high) — i.e. 213 / 146 / 125 Mpx/s vs 412 / 294 / 255. Younger than FFmpeg's h264, actively optimizing
Video codec AV1 (AV1) decode + encode — the royalty-free next-gen codec, 100% pure Rust, no C/FFI. Our rusty-av1-toolkit (rusty_av1d / rusty_av1e, BSD-2) forks rav1d (Rust port of VideoLAN's dav1d, the world's fastest AV1 decoder) + rav1e (the reference pure-Rust AV1 encoder), with a no-nasm, no-asm pure-Rust build path. Our encoder fork runs ~1.10× faster than stock rav1e at byte-identical output, or up to ~1.69× faster in opt-in --racecar mode
Video codec av2 (AV2) decode — AOMedia's successor to AV1, 100% pure Rust, no C/FFI (rusty_av2d, also usable standalone). The first independent AV2 decoder: every clip in a 47-clip conformance corpus decodes byte-identical to AOM's avmdec, alongside 112 unit/integration tests — a single differing byte fails the gate. Coverage spans all intra modes, compound prediction and B-pyramids, TIP (including TIP-as-output), the warp family, wedge compound, all five in-loop filters, delta-Q, loop restoration, TX partitioning, 64px and 128px superblocks, the full {8,10-bit} × {4:2:0, 4:2:2, 4:4:4} matrix, film grain, S-frames, palette/screen content, quantization matrices, multi-tile streams, and non-superblock-aligned frame dimensions; eleven clips are single-tool-disabled controls verifying each sequence-header gate in both directions. Forked from rav1d and retargeted AV1→AV2 by inverting the AVM reference decoder's parse against a symbol-level oracle. Research preview — AV2 is not a finalized standard (no official vectors exist; the bitstream may still change), performance is unoptimized and unmeasured, and there is no AV2 encoder. Reads .ivf (fourcc AV02)
Image codec avif (AV1 still image) decode + encode, 8- & 10-bit (rusty_av1d / rusty_av1e)
Image codec png decode + encode — in-house pure-Rust (rusty_png, also usable standalone). A performance fork of image-rs/image-png, carried forward in-tree, gated against upstream on 330 comparisons (11 images × 30 configurations): upstream's decoder reads our output back to the source pixels 330/330, and encode bytes match upstream 190/330 — the 140 that differ are Default/Best streaming a run of 256 KiB IDATs where upstream writes one giant chunk, which leaves the DEFLATE payload byte-for-byte identical and costs +0.0045% file size. Full colour-type and bit-depth coverage, APNG, interlacing. DEFLATE via zlib-rs — flate2's pure-Rust zlib rewrite, so no C enters the tree — which measured 1.68–2.72× faster than the stock miniz_oxide backend at size parity. Multi-threaded DEFLATE for a single image (pigz-style block splitting; ffmpeg's PNG encoder is single-threaded per image): 2.11–3.06× faster end-to-end at 0.1–0.2% smaller, with blocks sized not counted so an image too small to split stays serial and pays +0.00%. Encoder settings dispatch on content — a measured repeated-pixel signal that separates photographs (0.0366–0.2037) from graphics (0.5312–0.9790) with nothing between — plus automatic gray/palette narrowing, together taking nine real screenshots/charts/diagrams from +115.6% to −6.1% against ffmpeg's default while leaving photographs byte-identical. 16-bit input reduces to 8-bit matching ffmpeg exactly (100.00% agreement over 6.2 M samples, against 66.01% for the truncation it replaced). IDAT is streamed, not accumulated — the encoder used to build the entire compressed stream in one buffer and copy all of it into the writer, because a chunk carries its length ahead of its payload; emitting fixed 256 KiB chunks removes the need to know the total at all. The parallel path streams too — it had been making three full-size copies (each worker's block, a buffer concatenating them, then a third to prepend two header bytes), and its IDAT payload is byte-identical at 2, 4 and 8 threads. With a matching fix to a redundant whole-frame clone in the codec glue, peak memory falls 24–40% measured same-config at both ends: level 6 single-thread 39–40% (park_joy 94.9 → 57.6 MB), level 6 -threads 8 27–29% (118.7 → 85.1 MB), default Fast 24–26% (101.1 → 77.3 MB). These are memory results only: every accompanying speed measurement landed inside the noise floor and none is claimed. -compression_level, -pred, -threads. Measured on the public CLIC professional validation set (native-RGB photography — citable, reproducible) alongside the Derf/xiph frames, one instrument, each direction measured alone: decode-only 2.55–2.89× faster than ffmpeg (median 2.60×, z = 3); encode-only from raw, at matched filter and matched size, 0.94–1.05× on CLIC photographs (median 0.97×) and 0.86–0.91× on video frames, at 0.2–0.3% smaller. That split is real and reported as two ranges rather than averaged. Whatever residue remains is zlib-rs vs zlib, not PNG, since the profiler puts DEFLATE at 94–99.5% of encode. 175/175 pngsuite files and 2,100 randomly-mutated inputs: zero panics
Image codec mjpeg (JPEG/MJPEG) decode + encode — in-house pure-Rust (rusty_jpeg, also usable standalone). Baseline and progressive DCT, planar YUV in/out, -q:v / -sampling / -progressive / -optimize_huffman / -trellis / -restart_interval. At parity with FFmpeg 8.1.2 on both halves at matched output size (encode median 0.96×, N=41; decode 1.02×, N=31 — paired, interleaved, pinned CPU time). Box-averaged chroma downsampling is worth −17.12% BD-rate on chroma-detailed content vs the point-sampling it replaced. -optimize_huffman 1 gives −7.4% file size, losslessly, for ~2× encode. AVX2/SSE4.1 kernels on x86 and NEON on aarch64, each with a scalar twin asserted bit-exact in CI; ARM kernels verified on real ARM hardware. Fuzzed, and validated against a foreign-encoder corpus — 117,120 mutated decodes, zero panics
Image codec gif decode + encode (pure-Rust gif; first frame)
Image codec webp (VP8/VP8L) decode + lossless encode — in-house pure-Rust (rusty_webp, our fork of image-rs/image-webp 0.2.4, also usable standalone). Decode: VP8 (lossy), VP8L (lossless), and animated WebP — all frames, composited, with per-frame durations (FFmpeg's native webp decoder errors on animated files). Still lossy images decode straight to their native YUV 4:2:0 planes — no RGB round-trip — and the output is bit-exact with FFmpeg's decoder on every corpus image. Measured (pinned CPU time, ABBA-interleaved, N=31, null-arm ≤5%, 8K real-content corpus): lossy decode 1.24–1.29× faster than FFmpeg (batched branch-free loop-filter kernels ~6× on a stage that was 49% of decode, a block-scoped fast session in the boolean decoder, and a DC-only IDCT path — each bit-exact-gated against in-tree scalar oracles), lossless decode ~2.15× faster. Those ratios were measured on 0.1; 0.2 is faster again with identical pixels (0.1 → 0.2, pinned interleaved pairs: lossy decode 1.31–1.41×, lossless decode 1.12–1.16×, animations 1.5×, after an instruction-count campaign that removed 36–45% of lossy-decode instructions; stills gated bit-exact against libwebp 1.5.0), and it fixes animated frames whose opaque pixels decoded one level too dark. Encode (lossless VP8L): greedy hash-chain LZ77 backward references, color cache (size picked per image by entropy estimate), and per-tile predictor selection (14 modes, 16-px tiles) behind a run-rate content dispatch — 1.6–2.8× faster than libwebp's default effort (m4) at +4–13% size on photos (smaller than libwebp's fastest mode m0 on every corpus image) and up to 39% smaller than m4 on screen/repeated content. Those encode figures are from 0.1 as well: 0.2 encodes 1.3–2.2× faster than 0.1 and writes byte-identical files. Lossy (VP8) encoding not yet implemented
Image codec jpegxl (JPEG XL) decode (pure-Rust jxl-oxide; no Rust encoder yet)
Audio codec aac in-house rusty_aac (also usable standalone) — decoder for the MPEG-4 AAC family short of USAC: AAC-LC, Main, LTP, HE-AAC v1/v2 (SBR, PS), ER AAC-LC/LTP, AAC-LD, AAC-ELD, 960-sample frames, PCE layouts, LATM; all 83 non-USAC ISO/IEC 14496-26 conformance streams within 1 LSB of FFmpeg. Encoder (AAC-LC, mono–5.1): psychoacoustic model, block switching, M/S and joint stereo rate control, MP4 esds — 3–8× faster than FFmpeg's native AAC encoder (frame-parallel)
Audio codec mp3 (MPEG-1/2 Layer III), mp2 / mp1 (Layer II / I, decode) in-house decoder + encoder (rusty_mp3, also usable standalone). Layer I and II decode too, MPEG-2 low rates and free format included, within 1 LSB of the ISO vectors and within 0.05 s16 of symphonia — decoder bit-exact vs FFmpeg and faster than it at matched CPU — decode-and-discard on the same physical cores, 27.5-min stream, 15 pairs: 1.24× faster on 1 core (1,952 vs 2,431 ms, 15/15, z = −3.87) and 1.39× on 2 (1,017 vs 1,455 ms) via a two-stage pipeline, at lower total CPU (1,875 vs 2,125 ms). Five bit-identical decode bricks got there (word-load bit reader, circular synthesis FIFO, exact-symmetry + AVX IMDCT, AVX matrixing/window, division-free Huffman); the pipeline splits entropy from transform along a state boundary, so output stays bit-identical. encoder MPEG-1/2/2.5, CBR + VBR, joint stereo, block switching, bit reservoir. 0.4.0 caches the psychoacoustic model's FFT twiddle factors (rebuilt on every call before, for ten distinct values) and reuses the mid/side scratch across frames: 1.045× faster encode (pinned CPU, 33/41 pairs, z = 3.90) at 34% fewer allocations per frame. 0.4.1 makes decode 1.185× faster (39/41 pairs, z = 5.78) via an O(1) word-load bit reader, a circular synthesis FIFO with a contiguous window loop, and a half-work IMDCT that exploits an exact kernel symmetry. Every one of these is byte-identical, verified over a 15-stream corpus (all channel modes, MPEG-1/2/2.5, 128–320k + VBR, four content classes). Quality, PEAQ ODG at matched actual bitrate vs LAME, three-clip corpus: CBR 192k mean gap 0.72 ODG (guitar 0.29 · piano 0.48 · clicks 1.39); CBR 128k mean gap 1.08 (0.37 · 1.13 · 1.75). Content-dependent — close on tonal material, 1.4–1.8 behind on transients, where the per-band distortion loop is inert and the psymodel has no short-block thresholds. 0.6.0 rebuilt VBR after PEAQ caught it 3.51 ODG adrift (−3.50 vs +0.01 at ~200 kbps): -q:a is now a target bitrate driving the same two-loop quantizer CBR uses, instead of a separate unanchored noise-to-mask search
Audio codec opus decode + encode — our own rusty-opus (BSD-3 performance fork of the pure-Rust opus-rs). Quality at parity with libopus (mean −0.015 BD-ODG over 18 content classes × 5 rates, matched actual bitrate) and 18/18 classes ahead of FFmpeg's own native Opus encoder (+1.5 ODG). Three byte-identical AVX2 SILK kernels + an O(n²)-copy fix in the encode wrapper make rff -c:a opus 1.50× faster than libopus on CELT speech and 1.60× on stereo music per core (3.0× FFmpeg's native encoder on music), and within 4% on the SILK path (pinned CPU, slope-corrected, N=41, coding path verified from TOC bytes); frame-parallel encoding (chunked + state-primed, PEAQ-neutral ΔODG ≤ 0.03) adds wall-clock on top, since libopus is single-threaded per stream — ffmpeg decodes our output at unity. Knobs: -b:a, -compression_level, -opus_parallel
Audio codec vorbis decode + encode — decode via the in-house decoder (FFmpeg-matched, float output in FFmpeg channel order, granule end-trim); in-house encoder (rusty_vorbis, also usable standalone) — the first permissively-licensed Vorbis encoder in Rust (none existed before). Window → N/4-FFT MDCT → Bark-scale masking floor → channel coupling + point stereo → rate-distortion residue VQ, emitting an embedded libvorbis setup header; -q:a 0–9. ffmpeg decodes our output, validated packet-exact against lewton + libvorbis. ~5.3× faster than libvorbis wall-clock (stereo music, 24 cores) via frame-parallel encoding (libvorbis is single-threaded) over a structure-of-arrays + AVX2 residue-VQ search and an energy-bucket class shortlist (PEAQ-validated perceptually neutral, ΔODG ≤ 0.03); per-thread ~1.4× behind libvorbis (was 4.7×)
Audio codec flac decode + encode — in-house rusty_flac (also usable standalone): lossless encoder (LPC + stereo decorrelation + partitioned Rice + MD5) and decoder, with frame resync after damage; claxon is kept as the independent decode oracle for the encoder's lossless gate
Audio codec pcm (s16le / f32le) decode + encode (in-house); also decodes u8, s24, s32 and f64
Audio codec alac (Apple Lossless) decode (in-house) — 16/20/24/32-bit, 1–8 channels, from MP4, CAF and Matroska; FFmpeg's arithmetic and channel order. Lossless on every test stream (decoded output equals the source PCM at 16/24/32 bits, 1–8 channels) and sample-exact against symphonia. 0.6.3 decodes 1.9–2.0× faster than 0.6.2 (register-resident fixed-order predictor, 64-bit bit reader, sign-split coefficient adaptation), 1.24–1.25× faster than symphonia 0.5.5 on 16-bit stereo, with byte-identical output on all 30 fixtures
Audio codec pcm_alaw / pcm_mulaw (G.711), adpcm_ms, adpcm_ima_wav, adpcm_ima_qt (ima4) decode (in-house) to s16, with FFmpeg's arithmetic. Sample-exact against symphonia on sox-encoded WAVs (mono, stereo, 8 kHz)
Container avif (AV1 Image File Format) demux + mux (reads foreign AVIFs too)
Container av2f (AV2 still image) demux + mux — ⚠️ EXPERIMENTAL, not an AOM standard. One AV2 picture in an ISOBMFF/HEIF file, in AVIF's shape (rusty_av2f, also usable standalone). AVIF's brand / item type / config record are fixed by a published AOM specification; no equivalent document exists for AV2, so ours (av2f / av02 / av2C) are chosen, not specified — isolated in one source file so adopting a real spec is a one-file edit. Files written here are readable here and nowhere else, with no compatibility promise. Gated end to end: a committed .av2f fixture decodes byte-identical to AOM's avmdec, and re-muxing reproduces the file byte for byte. Writes only the full still-picture header (the compact single_picture_header_flag form is refused until rusty_av2d parses it bit-exactly)
Container png / jpeg / gif / webp / jpegxl demux + mux
Container wav (RIFF/WAVE) / ogg (Opus/Vorbis) / flac demux + mux. WAV also reads RF64/BW64, WAVE_FORMAT_EXTENSIBLE (the whole SubFormat GUID checked), s32/f64, G.711 and MS/IMA ADPCM; Ogg also reads FLAC (.oga)
Container aiff (AIFF / AIFF-C) / caf (Core Audio Format) demux — AIFF: NONE/twos/sowt PCM, in24/in32 and their little-endian 23ni/42ni, fl32/fl64, alaw/ulaw, ima4, with compression types matched regardless of case. CAF: lpcm, ALAC, AAC, MPEG audio (.mp1/.mp2/.mp3), FLAC (STREAMINFO from the cookie), ima4, alaw/ulaw, with the packet table. Sample-exact against symphonia
Container avi (Audio Video Interleaved) demux + mux (RIFF/hdrl/movi/idx1)
Container mp4 / mov (ISOBMFF) demux + mux, separate ISO (mp4) and QuickTime (mov) muxers, fragmented MP4 read — H.264, HEVC (demux), AV1, VP9 (vpcC), APV, and in MOV ProRes (all six profiles) and DNxHD/HR; AAC (esds), Opus, FLAC (dfLa), ALAC, AC-3/E-AC-3, and PCM in MOV (sowt twos in24 in32 fl32 fl64 lpcm, sound description v0/v1/v2); colr/pasp/clap/mdcv/clli and the QuickTime timecode track, read and written
Container matroska / webm (EBML) demux + mux — Cluster/(Simple)Block packets with lacing; AV1/H.264/HEVC/VP9/VP8 video + Opus/Vorbis/AAC/FLAC/MP3/AC-3/E-AC-3/ALAC/PCM audio, subtitles; Colour + HDR mastering, WebM alpha (BlockAdditions), CodecDelay/SeekPreRoll, header-stripping and zlib ContentEncodings (demux)