Repository navigation
Clear reserved colour tags before decodes that convert the pixel format - #161
Draft
StuartCameronCode wants to merge 3 commits into
Draft
StuartCameronCode wants to merge 3 commits into
StuartCameronCode wants to merge 3 commits into
Conversation
…format ProRes that writes colour as "unknown" the Apple way (code 0) is read by FFmpeg as `reserved`, and FFmpeg 9's scaler refuses to convert such a frame. The app's before frame and thumbnails, --detect-crop and --detect-native all failed on it, and so did the encode/preview of a ProRes 4444 with alpha, whose decoder converts to the pipe format. Every decode now puts a setparams that clears only the invalid tags first in its one -vf: ColorMetadata's decode_tag_neutraliser in the worker (all three source_decode builders, hence every detector), ColorTags.decodeNeutraliser in the app (PreviewGenerator.beforeFrameArgs / thumbnailArgs). A valid tag is never touched: clearing a valid matrix changes yuv->gray pixels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/reports/2026-11-reserved-colour-tags with its probe scripts (the per-call-site table on the reported clip, the per-tag and valid-matrix measurements, the 4444-alpha encode), an ENGINEERING_NOTES entry, a reports-index row, and the rule under CLAUDE.md's "Colour metadata". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ProRes files tagged
color_primaries=reserved/color_transfer=reserved(ProRes writes code 0 for "unknown", which FFmpeg reads as ISO 23091'sreserved) break every decode that converts the pixel format. FFmpeg 9's scaler refuses the frame:Reported on the videohelp forum (thread 419911, posts #123/#140/#150) with a ProRes 422 capture. Symptoms:
Descale Detect and a ProRes 4444-with-alpha encode, where the decoder converts to the pipe format, failed the same way.
Fix
Every decode of the source that may convert the pixel format clears only the invalid tags, each one separately, with a
setparamsplaced first in its single-vf. Clearing a valid matrix would change pixels: yuv → gray16le moves by up to 28 levels.color_metadata::decode_tag_neutraliser/VideoJob::decode_tag_neutraliser. It reaches the encode, preview and timeline decoders throughsource_decode::decoder_filter, and every detector through it too (crop_detect::decode_samples, so noise/halo as well, andnative_res). When the tags are usable, the args are byte-identical to before.ColorTags, a byte-identical twin of the worker's lists and neutraliser. A test parses the Rust source to keep the two in step.PreviewGenerator.beforeFrameArgs/thumbnailArgsapply it ahead of the HDR tone-map andscale.colorTagkeeps forwarding ffprobe's rawreserved, as it always did, because the worker needs it to know the decoder must clear it.ColorMetadata::from_rawstill keeps it off the encoder's flags.Docs
docs/reports/2026-11-reserved-colour-tags/, with the probe scripts that produced its numbers.Tests
reserved_colour_tags.mov(ProRes 422, laid out like the reported clip) andreserved_colour_tags_4444a.mov, 2.3 MB together.generate_reserved_colour_tags_test.shregenerates them.-vfwith the fix first; and the before-frame and thumbnail args compose with the tone-map.integration_reserved_colour_tags_test.dartpasses 8/8 on macOS arm64 with deps 1.16.0. Before frame, thumbnail,--detect-crop,--detect-native,--detect-noise-halo, preview (422 and 4444a) and a 4444a encode each match a validly-tagged twin exactly.cargo test): passes.subtitle_integration_testfails only on a machine without the whisper add-on.Merge note
#157 (seek alignment) also changes
source_decode::decoder_filter, adding aseeksparameter. Whichever of the two merges second needs a small manual merge: the chain issetparams → setpts → size guard, and the call sites need updating too.Follow-up, not in this PR: Descale Detect's luma depends on the source's matrix tag (tracked separately).
🤖 Generated with Claude Code