Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

EffectCraft #293: finish ProRes alpha runs (#2991)

skylar taylor-barrickd5ead4ba1ee2
diff --git a/ROADMAP.md b/ROADMAP.md
index c77769f82..a93ae8ae0 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -5,7 +5,7 @@
**Stage: alpha** · next: beta, ~19 points of ready-for-real-work and ~400–700 h away, plus opening Premiere's `.prproj` ([why](docs/target-app-parity.md#stage); passes the [core-workflow gate](docs/roadmap.md#alpha-gate))
-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (language table: German covers the whole interface) · **Target:** Adobe Premiere Pro 2026 (26.5.2)
+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (ProRes alpha final-run conformance and native macOS validation) · **Target:** Adobe Premiere Pro 2026 (26.5.2)
Progress toward parity with Adobe Premiere Pro. This page is the summary; the detail is in
[docs/target-app-parity.md](docs/target-app-parity.md) (assessment, methodology, calibration),
@@ -107,6 +107,8 @@ Ranked; detail and "done when" in [docs/roadmap.md](docs/roadmap.md) and [docs/g
## Progress log
+- **2026-10-22:** ProRes 4444 / XQ alpha slices include the final singleton run code required by RDD 36:2022. Six HD fixtures rejected by native macOS decoding now pass; syntax regression tests cover final runs and slice widths ([details](crates/prores/README.md#alpha-bitstream-conformance), EffectCraft #293).
+
- **2026-10-12:** Transform's motion-blur shutter on adjustment layers uses the sequence frame rate instead of 24 fps, so a 360° shutter in a 60 fps sequence spans one frame, not 2.5 (#1088)
- **2026-10-10 (changed media):** Settings ▸ Media ▸ Automatically refresh growing files works: media files that change on disk while the project is open (a recording still being written, a render written over the file a clip uses) are read again every *Refresh growing files every* seconds and as soon as the window comes back to the front: the new length, picture and identity, without an undo step (`media.refreshChanged`, `media_watch`).
- **2026-10-10 (re-measure):** full parity re-measure against Premiere Pro 26.5.2: menu label diff 338 / 366 (92%), installed bundle listings (10 UI languages, exporter and codec frameworks), 188 open issues. Breadth ~86% (file formats now counted), ready ~55%, stage **alpha**; progress docs reorganized per the craftrules standard ([target-app-parity](docs/target-app-parity.md), [gaps](docs/gaps.md), [roadmap](docs/roadmap.md), [codec](docs/codec-parity.md), [file-format](docs/file-format-parity.md), [hardware](docs/hardware-parity.md), [UI](docs/ui-parity.md), [localization](docs/localization-parity.md)).
@@ -166,6 +168,7 @@ Ranked; detail and "done when" in [docs/roadmap.md](docs/roadmap.md) and [docs/g
| Date | Change | Summary |
|---|---|---|
+| 2026-10-22 | minor | ProRes alpha: write the final singleton run code; 4444/XQ HD clips that failed native macOS decoding now decode, with syntax regression tests (EffectCraft #293) |
| 2026-10-13 | minor | Language table: German covers the whole interface (~100%) |
| 2026-10-12 | trivial | Progress log: Transform shutter on adjustment layers (#1088) |
| 2026-10-11 | minor | Language table: German ships the menus (#630, 10.6%) |
diff --git a/crates/prores/README.md b/crates/prores/README.md
index 3659d1a0f..c852fa332 100644
--- a/crates/prores/README.md
+++ b/crates/prores/README.md
@@ -1,6 +1,6 @@
# filmcraft-prores
-Clean-room Apple ProRes decoder and encoder in pure Rust, written from the public SMPTE RDD 36
+Clean-room Apple ProRes decoder and encoder in pure Rust, written from the public [SMPTE RDD 36:2022](https://pub.smpte.org/doc/rdd36/20220909-pub/rdd36-2022.pdf)
bitstream description. Layer L0: depends only on `filmcraft-bitstream`, `thiserror` and (optional,
feature `threads`, default on) `rayon`. Builds for `wasm32-unknown-unknown`; no `unsafe`.
@@ -95,6 +95,35 @@ decodes them with `-xerror`, with no errors, and agrees with this decoder within
69.9/69.2 dB (Y/C) on mandelbrot at 100% of the target rate. Busy content lands at 99.9–100.4%
of the target.
+## Alpha bitstream conformance
+
+Every alpha difference is followed by a run code, including a final singleton
+(RDD 36:2022 §5.3.3, Tables 12–14). Omitting the final run produces a truncated
+alpha payload: FFmpeg may accept it, while macOS native HD decoding fails with AVFoundation `-11821` / underlying `-12137`. This affected
+both 4444 and 4444 XQ exports, including EffectCraft's alpha output
+([effectcraft#293](https://github.com/storytold/effectcraft/issues/293)).
+
+The encoder tests check exact singleton codewords at 8 and 16 bits, run-length
+boundaries through 2048 and split runs, final-value bit alignments, and complete
+encoded slices for both profiles and all four slice widths. A separate,
+bounds-checked parser follows the published syntax and requires every run and
+zero alignment bit; round-tripping through a permissive decoder alone cannot
+catch this defect.
+
+Native validation on Apple M5 / macOS 27.0.1 used 14 synthetic 1920×1080 clips:
+opaque, transparent, gradient, changing last pixel, moving block, noisy alpha,
+and RGB-only, for each 4444 profile. Before the fix, the gradient, last-pixel and
+noise cases failed in AVAssetReader (six clips); afterwards all 14 decoded all
+six frames. FFmpeg's decoded frame hashes are unchanged by the fix. Small
+128×32 clips passed even before the fix. Resolve itself and the reporter's
+M1 Pro / macOS 15.8 environment were not available for this check.
+
+EffectCraft 0.16.0's complete export pipeline was also tested using an animated
+synthetic PNG with varying alpha: 4444 / XQ × straight / premultiplied × motion
+blur off / on (eight six-frame HD movies). All eight failed native decoding with
+the pinned encoder, and all eight passed with this codec patched in. FFmpeg's
+decoded frame hashes remained identical for every before/after pair.
+
## Performance
Measured with `cargo test --release -p filmcraft-prores --test it perf:: -- --ignored --nocapture` on
diff --git a/crates/prores/src/encode.rs b/crates/prores/src/encode.rs
index 06d8cb655..24c925393 100644
--- a/crates/prores/src/encode.rs
+++ b/crates/prores/src/encode.rs
@@ -472,9 +472,9 @@ pub(crate) fn encode_alpha(w: &mut Writer, vals: &[u32], bits: u32) {
}
prev = v;
idx += 1;
- if idx >= n {
- break;
- }
+ // RDD 36:2022 §5.3.3 requires a run after every alpha difference,
+ // including a singleton at the end of the slice. Do not replace that
+ // final `1` with byte-alignment zeros: native decoders reject it.
let mut run = 0;
while idx + run < n && vals[idx + run] == prev && run < 2047 {
run += 1;
@@ -493,3 +493,118 @@ pub(crate) fn encode_alpha(w: &mut Writer, vals: &[u32], bits: u32) {
idx += run;
}
}
+
+#[cfg(test)]
+mod alpha_tests {
+ use super::*;
+
+ #[test]
+ fn alpha_final_singleton_has_a_run_code() {
+ // RDD 36:2022 §5.3.3: every difference is followed by a run, including
+ // the final one. Tables 13/14 encode -1; Table 12 encodes run 1 as `1`.
+ // With 16-bit alpha the difference occupies exactly one byte, so the
+ // required final run must start another byte, followed by zero padding.
+ for (bits, expected) in [(16, vec![0x01, 0x80]), (8, vec![0x0c])] {
+ let mut w = Writer::new();
+ encode_alpha(&mut w, &[(1 << bits) - 2], bits);
+ assert_eq!(w.finish(), expected, "{bits}-bit final singleton");
+ }
+ }
+}
+
+#[cfg(test)]
+mod alpha_conformance_tests {
+ use super::*;
+ use filmcraft_bitstream::BitReader;
+
+ /// RDD 36:2022 §5.3.3 and Tables 12–14, using a bounds-checked reader.
+ /// Unlike the production decoder's zero-padded hot path, this checks every
+ /// final run and all alignment bits, so a truncated run cannot be accepted.
+ fn read_alpha(data: &[u8], bits: u32, count: usize) -> Vec<u32> {
+ let mut r = BitReader::new(data);
+ let mask = (1u32 << bits) - 1;
+ let mut prev = mask;
+ let mut out = Vec::new();
+ while out.len() < count {
+ let diff = if r.read_bits(1).unwrap() == 1 {
+ r.read_bits(bits).unwrap()
+ } else {
+ let code = r.read_bits(if bits == 16 { 7 } else { 4 }).unwrap();
+ let magnitude = (code >> 1) + 1;
+ if code & 1 == 0 { magnitude } else { magnitude.wrapping_neg() }
+ };
+ prev = prev.wrapping_add(diff) & mask;
+ let run = if r.read_bits(1).unwrap() == 1 {
+ 1
+ } else {
+ let short = r.read_bits(4).unwrap();
+ if short == 0 { r.read_bits(11).unwrap() + 1 } else { short + 1 }
+ } as usize;
+ assert!(run <= count - out.len(), "alpha run exceeds the slice");
+ out.extend(std::iter::repeat_n(prev, run));
+ }
+ assert!(r.bits_left() < 8, "only byte-alignment padding may remain");
+ while r.bits_left() > 0 {
+ assert_eq!(r.read_bits(1).unwrap(), 0, "alignment padding must be zero");
+ }
+ out
+ }
+
+ #[test]
+ fn alpha_runs_cover_boundaries_and_final_values() {
+ for bits in [8, 16] {
+ let mask = (1 << bits) - 1;
+ for run in [1, 2, 15, 16, 17, 2047, 2048, 2049, 4096] {
+ for tail in 0..=8 {
+ let mut values = vec![mask - 1; run];
+ // Short negative/positive deltas, modulo transitions and
+ // escaped full-width deltas, ending on every bit alignment.
+ values.extend([0, mask, 1, 7, 8, 64, 65, mask / 2].into_iter().take(tail));
+ let mut w = Writer::new();
+ encode_alpha(&mut w, &values, bits);
+ assert_eq!(read_alpha(&w.finish(), bits, values.len()), values, "bits={bits}, run={run}, tail={tail}");
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn encoded_alpha_slices_have_complete_final_runs() {
+ for profile in [Profile::P4444, Profile::P4444Xq] {
+ for log2_slice_mbs in 0..=3 {
+ let (width, height) = (128, 32);
+ let mut frame = Frame::new(width, height, ChromaFormat::Yuv444, 16, true);
+ frame.y.fill(32768);
+ frame.cb.fill(32768);
+ frame.cr.fill(32768);
+ let alpha = frame.alpha.as_mut().unwrap();
+ for (i, a) in alpha.iter_mut().enumerate() {
+ *a = (i as u16).wrapping_mul(257);
+ }
+ let mut cfg = EncoderConfig::new(profile, width, height);
+ cfg.log2_slice_mbs = log2_slice_mbs;
+ let bytes = Encoder::with_config(cfg).encode(&frame).unwrap();
+ let (_, start, _) = FrameHeader::parse(&bytes).unwrap();
+ let picture = &bytes[start..];
+ let header = PictureHeader::parse(picture).unwrap();
+ let table = &picture[header.header_size..][..2 * header.num_slices];
+ let mut offset = header.header_size + table.len();
+ let sw = 16 << log2_slice_mbs;
+ for (i, size) in table.as_chunks::<2>().0.iter().enumerate() {
+ let size = u16::from_be_bytes([size[0], size[1]]) as usize;
+ let slice = &picture[offset..offset + size];
+ offset += size;
+ let color_bytes: usize = slice[2..8].as_chunks::<2>().0.iter().map(|b| u16::from_be_bytes([b[0], b[1]]) as usize).sum();
+ let payload = &slice[(slice[0] >> 3) as usize + color_bytes..];
+ let actual = read_alpha(payload, 16, sw * 16);
+ let x0 = i % (width as usize / sw) * sw;
+ let y0 = i / (width as usize / sw) * 16;
+ let alpha = frame.alpha.as_ref().unwrap();
+ let expected: Vec<u32> = (y0..y0 + 16).flat_map(|y| (x0..x0 + sw).map(move |x| alpha[y * width as usize + x] as u32)).collect();
+ assert_eq!(actual, expected, "{profile:?}, slice {i}, log2={log2_slice_mbs}");
+ }
+ assert_eq!(offset, picture.len());
+ }
+ }
+ }
+}
diff --git a/docs/codec-parity.md b/docs/codec-parity.md
index f1ae5245c..d3a79679d 100644
--- a/docs/codec-parity.md
+++ b/docs/codec-parity.md
@@ -1,6 +1,6 @@
# Codec parity
-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** major (new file: every codec Premiere Pro 26.5.2 decodes or encodes, against ours) · **Target:** Adobe Premiere Pro 2026 (26.5.2) and Media Encoder 2026
+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (ProRes alpha final-run conformance and native macOS validation) · **Target:** Adobe Premiere Pro 2026 (26.5.2) and Media Encoder 2026
Video and audio codecs, decode and encode, with fidelity and how each is tested. Containers,
project and interchange files are in [file-format-parity.md](file-format-parity.md); hardware
@@ -17,7 +17,7 @@ contents). Percent is ready-for-real-work for that codec: depth, profiles, speed
|---|---|---|---|---|---|---|
| H.264 / AVC | decode all common profiles incl. High 10, 4:2:2 (XAVC S-I, AVC-Intra); encode 8/10-bit | own decoder, **8-bit 4:2:0 only** (Baseline / Main / High, CABAC / CAVLC); no High 10 / 4:2:2 / 4:4:4, interlaced field / MBAFF, lossless | own encoder (High / Main / Baseline, B-frames, CBR / VBR / 2-pass); 8-bit 4:2:0 only; hardware VideoToolbox / NVENC | decode bit-exact on 37+ conformance streams, 500–600 fps 1080p; encode ffprobe-checked, byte-identical across machines | 65% | 20–35 h |
| HEVC / H.265 | decode Main, Main 10, 4:2:2 10 (XAVC HS); encode 8/10-bit, HDR | own decoder Main / Main 10 / Main Still Picture, bit-exact on 41 fixtures, ~225 fps 1080p; **no 4:2:2 / RExt** | **hardware only** (VideoToolbox 8-bit; NVENC 8-bit and Main 10 HDR on Windows); no software encoder | NVENC round trip 48.9 dB (8-bit), 71.1 dB (10-bit); ffprobe | 60% | 30–60 h |
-| ProRes 422 family / 4444 / XQ | decode + encode all | own decode + encode, all six profiles, alpha | yes (export UI exposes 422 flavours; 4444 / XQ request #342) | ±1 LSB, 318 fps | 85% | 3–6 h |
+| ProRes 422 family / 4444 / XQ | decode + encode all | own decode + encode, all six profiles, alpha | yes (export UI exposes 422 flavours; 4444 / XQ request #342) | ±1 LSB, 318 fps; alpha final-run conformance and native macOS HD decode checked ([details](../crates/prores/README.md#alpha-bitstream-conformance)) | 85% | 3–6 h |
| ProRes RAW | decode | none (#345) | — | — | 0% | 30–50 h (spec availability uncertain) |
| DNxHD / DNxHR | decode + encode, MXF / MOV | own decode (all SMPTE ST 2019-1 CIDs, 8/10/12-bit, 4:2:2 / 4:4:4, interlaced, alpha) and encode LB / SQ / HQ / HQX / 444 | yes, MOV + MXF | within IDCT precision of ffmpeg on 22 fixtures | 90% | 2–4 h |
| AV1 | decode (hardware on Windows); export through Media Encoder plug-ins / recent versions | own decoder Main 8/10-bit, all tools, film grain, bit-exact vs libdav1d on 41 vectors; hardware on Windows | none | slow in software (~4 fps 1080p single-thread) | 55% | 30–50 h (encoder + speed) |
@@ -61,5 +61,6 @@ contents). Percent is ready-for-real-work for that codec: depth, profiles, speed
| Date | Change | Summary |
|---|---|---|
+| 2026-10-22 | minor | ProRes alpha final-run syntax regression tests and native macOS HD decode validation |
| 2026-10-11 | minor | CinemaDNG / DNG decode (#1065) |
| 2026-10-10 | major | Created: codec-by-codec comparison with Premiere 26.5.2 from the codec crates' READMEs, the export format registry and the installed bundle's listings |