Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Follow-up to #2804: ProRes frame headers carry the colr atom's colour codes

Brandon Thomas35ce2186a4bf
diff --git a/crates/export/src/encode.rs b/crates/export/src/encode.rs
index 175c9063d..c9888a035 100644
--- a/crates/export/src/encode.rs
+++ b/crates/export/src/encode.rs
@@ -208,6 +208,12 @@ impl ProRes {
let alpha = channels == Channels::Rgba;
let mut cfg = filmcraft_prores::EncoderConfig::new(profile, w, h);
cfg.encode_alpha = alpha;
+ // The frame header carries the same H.273 codes as the `colr` atom, so readers that trust
+ // either one agree.
+ if let ColorInfo::Nclc { primaries, transfer, matrix } = colr {
+ let code = |c| u8::try_from(c).unwrap_or(2);
+ cfg.color = filmcraft_prores::ColorInfo { primaries: code(primaries), transfer: code(transfer), matrix: code(matrix) };
+ }
ProRes { enc: filmcraft_prores::Encoder::with_config(cfg), profile, w, h, alpha, colr }
}
fn is_444(&self) -> bool {