Skip to main content

Crate oxideav_prores

Crate oxideav_prores 

Source
Expand description

Apple ProRes codec — pure-Rust decoder + encoder following SMPTE RDD 36:2022.

Scope: all six ProRes video profiles, dispatched by container FourCC:

  • 422 Proxy / LT / Standard / HQ for 4:2:2 Y’CbCr at 8-, 10-, 12-, or 16-bit depth (Yuv422P{,10Le,12Le,16Le}, fourccs apco/apcs/apcn/apch).
  • 4444 + 4444 XQ for 4:4:4 Y’CbCr at 8-/10-/12-/16-bit (Yuv444P{,10Le,12Le,16Le}, fourccs ap4h/ap4x). These profiles also carry an optional per-pixel alpha plane (RDD 36 §5.3.3) coded losslessly via the raster-scan run-length code from §7.1.2 (Tables 12-14). The decoded alpha lands as a 4th VideoPlane on the output VideoFrame; the encoder accepts the same shape on input through encoder::encode_frame_with_alpha.
  • Alpha-typed surfaces on both codec directions: request PixelFormat::Yuva4(2|4)4P{,10Le,12Le,16Le} in CodecParameters to make the 4-plane layout part of the format contract — the decoder then always emits 4 planes (coded alpha converted to the surface depth per §7.5.2, exact at the 16-bit surfaces; a no-alpha stream gets a synthesised opaque plane), and the encoder requires 4-plane input and codes alpha on every frame (bitstream version 1 per §6.4) — 16-bit coded alpha for the deep formats, so no input precision is dropped on the wire. See decoder::decode_packet_with_format.

§Bitstream

  • frame() { frame_size, 'icpf', frame_header(), picture()+ } per RDD 36 §5.1.
  • picture() { picture_header(), slice_table(), slice()+ } per §5.2.
  • slice() { slice_header(), Y' data, Cb data, Cr data, [A' data] } per §5.3, with each color component coded by §7.1.1’s run/level/ sign entropy coder and the optional alpha array coded by §7.1.2’s run-length / VLC code.

Bitstream syntax, entropy coder, slice + block scans, alpha entropy coder, and inverse quantization are bit-exact with the spec. The IDCT is a textbook float implementation (§7.4 allows fixed- or floating-point, subject to Annex A accuracy) — sufficient for visual fidelity.

§Interlaced (RDD 36 §5.1, §6.2, §7.5.3)

Interlaced frames carry two pictures (one per field) sharing one frame_header(). The encoder splits the source into top + bottom fields per §7.5.3 (top field = source rows 0, 2, 4, …; bottom field = rows 1, 3, 5, …) and emits them in the order indicated by interlace_mode (1 = top-field-first, 2 = bottom-field-first). Each picture uses the interlaced block scan (§7.2 Figure 5) instead of the progressive one (Figure 4). The decoder reverses the deinterleave on output. See encoder::encode_frame_interlaced.

§Module layout

  • bitstream — MSB-first bit reader/writer.
  • entropy — RDD 36 Golomb-Rice / exp-Golomb combination codes plus the adaptive run/level/sign coefficient coder.
  • alpha — Run-length + diff-VLC alpha entropy coder (Tables 12-14) + alpha pixel-sample mapping (§7.5.2).
  • dct — Textbook f32 8x8 forward/inverse DCT.
  • quant — Default quant matrices, qScale table, block scans.
  • [slice] — Per-slice pack/unpack: per-component encode + inverse slice scan into natural-order blocks.
  • frame — Frame / picture / slice header layouts.
  • decoderPacket -> VideoFrame (Yuv4(2|4)4P{,10Le,12Le,16Le} / Yuva4(2|4)4P{,10Le,12Le,16Le}, optional 4th alpha plane).
  • encoderVideoFrame -> Packet, with optional alpha.

Modules§

alpha
ProRes alpha channel entropy codec (SMPTE RDD 36 §5.3.3 + §7.1.2).
bitstream
Bit I/O primitives used by the SMPTE RDD 36 entropy coder.
dct
Textbook f32 8x8 forward/inverse DCT used by ProRes.
decoder
ProRes decoder following SMPTE RDD 36 §5 + §7.
encoder
ProRes encoder following SMPTE RDD 36 §5 + §7.
entropy
SMPTE RDD 36 entropy coding for ProRes scanned coefficients.
frame
ProRes frame, picture, and slice headers (SMPTE RDD 36 §5).
quant
Quantisation matrices and scan tables for SMPTE RDD 36 ProRes.
slice
ProRes slice encode / decode (SMPTE RDD 36 §5.3 + §7.1 + §7.2).

Constants§

CODEC_ID_STR
Public codec id.
PRORES_FOURCCS
All six MP4 / MOV VisualSampleEntry FourCCs that identify a ProRes bitstream. Canonical lower-case spelling as defined by Apple’s ProRes white paper (April 2022):
PRORES_RAW_FOURCCS
MP4 / MOV VisualSampleEntry FourCCs that identify an Apple ProRes RAW bitstream. ProRes RAW is a separate Apple format that wraps single-plane Bayer/CFA sensor data; it is NOT one of the six RDD 36 YUV/RGB profiles this crate decodes and uses an incompatible sample structure. It has no public bitstream specification: no SMPTE-registered document covers it, and Apple’s only published ProRes RAW document is a marketing white paper with no frame/slice syntax, entropy coding, transform, or quantisation description — there is no normative source a decoder could be implemented from. These FourCCs deliberately resolve to neither a CodecId nor a frame::Profile here — is_prores_raw_fourcc lets a caller tell “ProRes RAW, which we don’t decode” apart from “not ProRes at all”.

Functions§

codec_id_for_fourcc
Returns Some(CodecId::new("prores")) if fourcc (case-insensitive) is one of the six ProRes MP4/MOV VisualSampleEntry FourCCs.
fourcc_for_profile
Returns the canonical (lowercase) MP4/MOV VisualSampleEntry FourCC for a given frame::Profile — the exact inverse of profile_for_fourcc.
is_prores_raw_fourcc
Returns true if fourcc (case-insensitive) is an Apple ProRes RAW VisualSampleEntry FourCC (aprn / aprh).
profile_for_fourcc
Returns the matching frame::Profile for a given MP4/MOV FourCC.
register
Unified registration entry point: install the ProRes codec factories into the codec sub-registry of a RuntimeContext.
register_codecs
Register the ProRes decoder + encoder for all six profiles (422 Proxy/LT/Standard/HQ and 4444 / 4444 XQ).