| Crates.io | styx-codec |
| lib.rs | styx-codec |
| version | 0.1.0 |
| created_at | 2026-01-19 11:58:54.996679+00 |
| updated_at | 2026-01-19 11:58:54.996679+00 |
| description | Codec registry and MJPEG/raw codecs for the Styx media stack. |
| homepage | https://github.com/sozo/Styx |
| repository | https://github.com/sozo/Styx |
| max_upload_size | |
| id | 2054422 |
| size | 372,737 |
Unified codec trait plus a registry for pluggable encoders/decoders. Includes MJPEG decoding and raw color converters; optional features enable FFmpeg and alternate JPEG implementations.
[dependencies]
styx-codec = "0.1.0"
use styx_codec::prelude::*;
pub struct Passthrough {
desc: CodecDescriptor,
}
impl Codec for Passthrough {
fn descriptor(&self) -> &CodecDescriptor { &self.desc }
fn process(&self, input: FrameLease) -> Result<FrameLease, CodecError> {
if input.meta().format.code != self.desc.input {
return Err(CodecError::FormatMismatch { expected: self.desc.input, actual: input.meta().format.code });
}
Ok(input)
}
}
CodecDescriptor describes the kind (encoder/decoder), input/output FourCc, algorithm family, and implementation name.
CodecRegistry installs codecs and returns a CodecRegistryHandle for lookups:
use styx_codec::prelude::*;
use std::sync::Arc;
let registry = CodecRegistry::new();
let handle = registry.handle();
registry.register(FourCc::new(*b"MJPG"), Arc::new(MjpegDecoder::new(FourCc::new(*b"RG24"))));
let frame = /* FrameLease carrying MJPG data */;
let decoded = handle.process(FourCc::new(*b"MJPG"), frame)?;
Selection can be influenced via:
set_policy(CodecPolicy): ordered impls, priorities, and hardware bias per FourCc.set_impl_priority / enable_only / disable_impl: granular control over implementations.lookup_preferred / process_preferred: choose by ordered impl names and hardware bias.CodecStats tracks processed/errors/backpressure counters via the handle.
codec-ffmpeg): H264/H265/MJPEG encoders/decoders.codec-mozjpeg, codec-turbojpeg, codec-zune): alternate MJPEG backends.image feature: ImageAnyDecoder and helpers for DynamicImage conversions.See crates/styx/examples/mjpeg_decode.rs for an end-to-end registry/decode usage example.