* audio: bound project-driven buffer sizes before allocating
- read_resampled (standalone audio, Ogg PCM), GeneratorSource::audio and
the Ogg Opus reader check the requested shape with
validate_audio_buffer_shape before allocating, as the AVI/MP4/MKV/MXF
readers already do; Opus also gets the shared channel limit before any
packet is decoded.
- Varispeed clamps a clip's stored speed to 100x before it sizes the
source window of a playback block.
- Nested sequences are mixed at the same bounded sample rate that sized
their requests (audio::bounded_sample_rate), so a damaged rate cannot
multiply request sizes at each nesting level.
* address review: reject a zero Opus sample rate and bound the request before deriving frames
* address review: reject a zero output rate in read_resampled; block starts use the capped varispeed
* address review: transition handles shift by the capped read speed
* address review: keyframed volume and pan keep the clip's own timing across transition handles
* address review: keep raw_channels' doc comment on raw_channels
* audio-dsp: validate stored remix plans so pieces cannot stack on one output
* address review: remix plans are budgeted in output samples, above what the longest project holds
* Merge origin/main; address review: limit a stored remix plan in ticks, not output samples
* render: refuse mixer graphs whose latency or compensation delays are absurd
* address review: validate total compensation before allocating delay rings; keep the Mix width in the refused-graph silence
* address review: refusal test uses an audible source
* address review: remember refused mixer graphs by structure hash
* render: cap the effect scale a mismatched stored media width can produce
* address review: place mask outlines by the uncapped layer scale
* Merge origin/main; add mask_scale to the FxCtx initializers main added since
* address review: cap the GPU effect scale like the CPU path
* render: bound Lightning, Write-on, Warp Stabilizer smoothing and Simple Text work
* address review: bound write-on candidate work, NaN-safe stabilizer sigma, bounded device position and text check before the box for text
* address review: check the raster size from the rasterizer's own device bounds
* render: do not give style runs without glyphs a colour group, and hold graphic shadow values to their range
* project: clamp shadow extents without the manual clamp pattern
* address review: clamp the shadow distance at zero
* address review: clamp the shadow distance before narrowing to f32
Fixes#1868. Display labels only; effect ids (lumetri, ...), panel ids, automation ids, preference keys and project data are unchanged.
- Lumetri Color/Scopes/Presets -> Color Grading / Video Scopes / Color Grading Presets in the UI and all 16 catalogs; old names still resolve for panels, shortcuts, automation and Effects-panel search.
- FCP7 XML, FCPXML and EDL exports keep writing the previous Lumetri names, so interchange output is unchanged.
- Mercury Transmit -> External Video Output, shown disabled ("This preference is not available yet.") until it exists.
- Ultra Key, Warp Stabilizer and Morph Cut keep their names until RFC-0029 settles.
* render, gpu: adjustment layers composited on the GPU
An adjustment layer anywhere at a time sent the whole frame to the CPU
renderer, so GPU rendering did nothing for the frames under one. A
full-frame adjustment layer at 100 % opacity, Normal, unmasked and with
only effects the GPU stage runs is now a PlanStep::Adjust: its effects
run in the effect stage on the accumulator (the composite of the tracks
below) and the result replaces it before the tracks above are drawn.
Every other adjustment layer keeps the whole-frame CPU fallback.
The export renderer takes Composite plans without transitions; frames
with a Push still go to the CPU there, as before. perf.stats gpu gains
adjustments / cpuAdjustments.
* docs: adjustment layers on the GPU compositor in parity and performance
hardware-parity.md gains an Adjustment layers row; performance.md gains
the main-against-branch export timings with an adjustment layer.
* render, gpu: adjustment layer review fixes
- is_cpu_frame and plan_frame now ask the same adjustment_ops (evaluated
at the render scale, which is_cpu_frame takes from the RenderOptions):
a Transform that shrinks the frame no longer takes a pooled export
renderer only to be rendered on the CPU and counted as a GPU frame.
- FxOp::eval leaves a Transform with its shutter angle on (motion blur)
to the CPU; the GPU drew it sharp, on clips and adjustment layers.
- The effect stage's texture pool spans the whole composite frame, so an
adjustment step's working textures are reused instead of made again
every frame. Composite plans honour resolve = false (export).
- ExportRenderer::render hands frames with an adjustment layer back to
the CPU when the device has no effect stage, instead of compositing
them on the CPU and uploading the result to read it back.
- adjustment_covers_output checks the full-frame geometry without
building the coverage image.
- The GPU adjustment test also runs without an effect stage.
* render, gpu, export, ui: plan adjustment layers for the device's caps
plan_frame and is_cpu_frame take plan::DeviceCaps (how large a frame
the device runs adjustment layers on; none without an effect stage), so
a frame the compositing device can't adjust becomes a CPU image on the
thread that plans it, never on the UI thread or inside a renderer slot.
- Monitor: the caps are part of the frame key
(Target::SequencePlan(seq, caps)), so a plan made for another device
is never reused.
- Export: FrameRenderer::caps is required; the renderer pool plans with
the smallest caps of its renderers before it takes one.
- The compositor's own CPU fallback stays as a safety net for a plan
made for other caps; the tests check that nothing reaches it.
- Main's own-shutter Transform check replaces the duplicate guard in
gpufx.
Tests: a Push under an adjustment layer exported on the GPU against
render_sequence (forward and reversed, scales 1 and 0.5); routing
without an effect stage in the export pipeline and in the monitor's
frame server; GPU parity against render_sequence with colour and alpha
for a partly transparent canvas, stacked adjustment layers, an empty
canvas, a nested sequence below and one inside a nest, at scales 1 and
0.5; caps boundaries and is_cpu_frame agreeing with plan_frame.
* gpu: end a refused effect image's frame; count steps once drawn
effect_image began an effect stage frame and returned without ending it
when the stage refused the job, so the stage stayed mid-frame and kept
its working images. The compositor's step counters are added once the
whole frame is drawn on the GPU, so a frame that falls back half way
no longer counts the steps it threw away.
* #1468: Speed/Duration ▸ Maintain Audio Pitch time-stretches a clip's audio instead of resampling it
A speed-changed clip's audio was always resampled (varispeed): an octave
up at 200 %, down at 50 %. Premiere's Clip Speed / Duration dialog has
Maintain Audio Pitch; FilmCraft now does too.
- TrackItem::maintain_pitch (serde default, skipped when false);
clip.speedDuration takes "maintainPitch" (left out: unchanged), set on
the clip and its linked partners; sequence.inspect shows it; the dialog
has the checkbox between Reverse Speed and Ripple Edit, prefilled.
- filmcraft-audio-dsp::stretch::Wsola (L1): WSOLA with 30 ms
raised-cosine grains overlapped by half, each moved by up to 8 ms to
where it best continues the previous grain (normalised
cross-correlation, coarse then refined), so crossfades are in phase.
- filmcraft-render::stretch: output hops on an absolute grid of timeline
samples, grain positions chained per clip and kept like audio_fx keeps
effect chains, so ordered reads give the same samples however they are
cut; a seek starts a new chain four grains early; a source span over
2^24 samples falls back to varispeed. Forward, reversed and nested clips.
Tests: tones at 50-300 % keep pitch (2 %) and level (0.03 RMS) without
clicks; a 500 Hz nest at 2x, 0.5x, 3x and 1.5x reversed stays at 500 Hz,
and reads in blocks of 1024/997/4096 match one read within 1e-6; the
command sets, keeps, inspects, undoes and saves the setting.
Translations: es, fr, it, ja, ko, id, pt-BR, zh-CN.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Maintain Audio Pitch: keep the chains of playing clips; say why not PitchShifter
- The per-clip chain cache dropped every chain when it held more than
256 clips, so a clip playing at that moment restarted its chain a few
grains early and its samples changed there. Entries now carry a
last-read stamp, and a new clip evicts only the one read longest ago.
- A test pins the varispeed fallback for a read longer than 2^24
source samples, and that the source is not read for it.
- audio-dsp's README says why the shuttle's PitchShifter does not fit
clip reads: a stream with latency and state, where clips are read by
random access and every reader must get the same samples.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Maintain Audio Pitch: leave locked linked sound alone; README states the stretch's limits
- clip.speedDuration's last loop gave maintain_pitch to every selected
clip, including a linked sound on a locked track that the speed edit
itself skips. Only that assignment is now guarded, so interpolation
behaves as before. Test:
maintain_audio_pitch_leaves_a_locked_linked_sound_alone.
- audio-dsp's README no longer says every reader gets the same samples
for a span: a read in order continues a chain exactly, but a read
that starts a new chain (a seek, or after a cache eviction) can choose
slightly different grains for the same span. Known limits now says so,
and names the 2^24-sample read that falls back to varispeed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* edit: a cut between clips whose Maintain Audio Pitch differs is not a through edit (#1684 review)
* Speed/Duration: send Maintain Audio Pitch only when its checkbox changed, so a mixed selection keeps each clip's setting (#1684 review)
* render: Maintain Audio Pitch keeps one chain per reader, reads only the clip's source span and aligns on the channels it plays; noise tests (#1684 review)
* audio-dsp: README states what the stretch guarantees and its limits (#1684 review)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
* render: turn display-rotated video on the GPU (#3467)
A portrait phone clip (4K60 HEVC with a 90° display matrix) dropped ~97 %
of its frames: every decoded 4K frame was turned on the CPU, which is too
slow at 60 fps, and with the GOP cache's lock held.
- GopCache caches decoded frames raw when they need a crop or a rotation;
`frame_late` crops and turns them off the lock, and the new
`frame_late_unturned` hands them over as decoded with the quarter turns
still to apply.
- MediaSource gains `video_frame_unturned` (default: the upright frame, 0
turns). MP4 and Matroska implement it; the pool's wrapping sources and
the frame server's timed source pass it on.
- The render plan folds the turns into the layer matrix of plain layers,
and into the GPU effect stage (`LayerFx::turns`): `fs_fx_source` reads
the source on its decimated grid through the turn, and the CPU reference
decimates then turns, so effects still see the upright picture.
Other paths (CPU-only effects, log media, a clean aperture, export) still
turn on the CPU as before.
* codecs: cache intra-only frames raw too (#3467)
Intra-only decoders (ProRes, DNx) cropped and turned every frame before
caching it, so frame_late_unturned found it already turned and the GPU
had nothing left to do. Their frames are now cached raw like long-GOP
output: frame_late still crops and turns them off the lock, and
frame_late_unturned hands them over as decoded.
* docs: document the unturned-frame entry points (#3467)
* codecs: follow main's frame lookup in the unturned paths (#3467)
main changed `from_tick` (Matroska) to take the frame rate and `snap`, and
MP4 looks frames up with `lookup_time(.., rate, snap)`. `video_frame_unturned`
still used the old calls: the Matroska one no longer compiled, and the MP4 one
could pick another sample than `video_frame` when `snap` is on. Both now use
the same lookup as their `video_frame`.
Also repairs the merge of main into this branch: a closing brace was lost in
the #3467 test (the test module did not compile) and a blank line was doubled
(cargo fmt --check failed).
* codecs: test every display turn, crop with turn, drafts and eviction of raw frames
* gpu: give the neutral-corrector test LayerFx its turns field
Merging main added a LayerFx initializer without the turns field, which
breaks compilation of the gpu tests (E0063).
lumetri.exportCube samples the clip's Lumetri Color on a lattice in the
sequence's output encoding and writes a 3D .cube; vignette, sharpen and the
HSL Secondary denoise and blur cannot live in a LUT and are named in the
result. The Lumetri Color panel menu gets Export .cube...
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* render: cap Long Shadow and Glint lengths at the picture extent
Long Shadow doubled a step until it passed twice the stored length: an
infinite length never ended the loop, each pass cloning and scanning the
image. Glint ran one full-image pass per doubling up to three times its
length. Both lengths are now capped at the picture's width plus height,
beyond which a longer shadow or streak looks the same.
* address review: Glint and Long Shadow keep the requested length for weighting and fade; the extent bounds only the passes
* address review: assert the long shadow fade still depends on length
decode_cost_ms followed Subclip parents with no guard (only nested
sequences checked depth), so a subclip that names itself, or a cycle of
subclips, recursed until the stack ran out while drawing the render bar.
The depth bound now applies to every source kind.
An RGB PNG or a JPEG decodes to RGBA8 with alpha 255 everywhere, but only a frame with no alpha
plane counted as opaque, so each frame of a still was converted to a full-size region and mixed
over a zero-filled canvas: two 33 MB float images at 1080p instead of one, for every frame an
export renders at once. A region that is the whole picture with every alpha exactly 1 is now an
opaque full layer, which the compositor takes as the canvas. The output is the same bits.
With no colour tags, FilmCraft decodes with BT.709 transfer and
primaries and the matrix by frame size, and probe and media.colorInfo
showed those values with nothing saying they were defaults, so an
untagged file looked the same as one tagged BT.709.
VideoStreamInfo gets color_assumed (optional, left out when unknown):
which of the matrix, transfer and primaries no tag in the file gave.
MP4/MOV and Matroska take it from the same sources as the colour, APV
from its colour description, and AVI, MXF and Y4M mark all three.
probe prints it as video.color_assumed and media.colorInfo as assumed,
next to the unchanged metadata.
Co-authored-by: Brandon Thomas <echelon@gmail.com>
* #3948: time interpolation applies when a clip's frame rate differs from the sequence's
A 24 fps clip in a 29.97 sequence at 100 % rendered the same with Optical
Flow or Frame Blending as with Frame Sampling, repeating one frame in five:
interpolation_blend gave up whenever the speed was 100 %. It now gives up
at 100 % only when the media's frame rate matches the sequence's, so it
takes the sequence rate too. Clips at the sequence's own rate still never
fetch a second frame.
* #3948: a still image gets no in-between frame
A still reports 29.97 fps and returns the same picture at every time, so
in a sequence at another rate it now passed the frame rate check: Optical
Flow ran on two copies of one frame, and the GPU plan fell back to the CPU
for nothing. media_interpolation skips still sources, and the item layer,
media_image and the GPU plan all ask it.
* #3948: an in-between frame never comes from past the clip's source out
A reversed clip starts 1 tick before its source out, so on a source frame
boundary interpolation_blend paired its last frame with the frame at the
source out, at a weight near 1: the first frame showed media the trim had
cut. A forward clip could end the same way (23.976 on 29.97, 5 frames
ending on a source frame blended in 20 % of the next one). Speed changes
had this already; rate conforms at 100 % now take the same path. When the
later frame starts at or past the source out, the clip shows its last
frame alone. The later frame always starts after the source in, so the
other end needs nothing.
* lumetri.presetThumbnails: write through the host and keep the grid to the presets
The PNG was written with std::fs::write instead of the session's Services,
the path every other export takes (#379), so on hosts without a filesystem
it trapped and elsewhere it ignored the host's file handling. The grid was
also as wide as `columns` asked (up to 32) whatever the number of presets:
there are ten, and 32 columns of 1920 px cells made a 61 572 x 1 084 image,
over a gigabyte of f32 pixels and a 267 MB PNG for one query. Columns now
stop at the number of presets shown. Found by fuzzing commands with hostile
parameters (it took over 10 s per call in a debug build).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* render: the preset grid copies thumbnails with checked slices
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Luma Key only made pixels below Cutoff transparent, so a light
background could not be keyed. Add a Key Out Brights option (default
off) that inverts the matte; projects without the param render as before.
Tested: luma_key_can_key_out_brights (default, missing param, inverted).
Fixes#2648
Co-authored-by: Brandon Thomas <echelon@gmail.com>
* render, gpu: Bokeh Blur gathers through a kernel of whole-pixel weights, 5x faster on the GPU
Each bilinear tap's four weights fall on the same offsets around every pixel (a pixel's centre is
a whole number and a half), so vfx::bokeh_kernel sums them per offset once per frame: about 330
reads at amount 10 instead of 1764. The CPU gathers through it, and the GPU reads it from a small
texture in the gather pass's aux slot, in the same order. 1080x1920, M4 Max: amount 10 hexagon
15 -> 3.2 ms on the GPU, 781 -> 114 ms on the CPU; amount 12 disc 58 -> 6.7 ms on the GPU.
New test bokeh_kernel_matches_the_bilinear_taps keeps the old gather as the reference.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* render: Bokeh kernel offsets stay within 2^20 pixels; the CPU gather adds them saturating
A huge amount on an image too small to halve kept its whole radius, so an offset could reach
i32::MAX and wrap when added to a pixel position (on the GPU, and on 32-bit CPU targets). An
offset past any image's width reads the edge pixel either way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* effects: give 4-Color Gradient a position for each colour (#3682)
The four colour points were hard-coded a quarter in from the corners, so
the gradient could not be arranged (the reporter had no position for the
fourth colour). Point 1-4 are now parameters; a point left at its NaN
default keeps the old position, and a project saved before they existed
has no such params, so both render exactly as before.
Test: a project without the points and one with the old positions set
explicitly render the same as the default; moving Point 4 shifts the
colours.
Fixes#3682
* effects: resolve the 4-Color Gradient points to the quarter positions (#3682)
Responsive Design - Time remaps only a graphic clip's layer keyframes;
the clip's own effects and masks are read at plain clip time. Applying
the remap to them would move keyframes in existing projects, so keep the
behaviour, state it in docs/graphics.md and pin it with a test
(layer keyframe remapped, clip Opacity keyframe not).
Fixes#3361
New Three-Way Color Corrector (Obsolete folder, like Color Balance): a
hue/balance wheel and a level shift for shadows, midtones and
highlights, tonal range thresholds with softness, and Saturation. All
parameters go through the generic param path (keyframable, undoable).
CPU (FxOp::ThreeWay) and GPU (OP_THREE_WAY) share the arithmetic; the
wheel is converted to an RGB offset on the CPU so the shader stays
simple. Defaults are the identity.
Tested: three_way_color_corrector_works_per_tonal_range (identity, each
wheel affects only its range, saturation 0 is grey) and two GPU/CPU
parity cases in fx_tests.
Fixes#3465
* feat(text): strikethrough for graphic text
Text layers get a Strikethrough toggle next to Underline: per layer
(`strikethrough` parameter, Properties ▸ Text ▸ Style "S") and per
character (`graphics.setCharStyle` style `strikethrough`, stored in the
layer's style runs).
The stroke uses the font's OS/2 strikeout position and size; a font that
leaves them out gets a stroke centred on half the x-height. Strokes are
added to the layout's decoration rectangles next to underlines, so every
renderer and the path export draw them without further changes. Vertical
text gets a stroke down the middle of each cell.
generated with Claude Code
* contributors: add alexanderalber
generated with Claude Code
* graphics properties: draw the letter-button marks in a helper
Keeps the Properties scroll closure under the cognitive-complexity limit with the new
Strikethrough button.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
On the CPU compositor every monitor frame was converted from Y'CbCr to a
premultiplied linear f32 image (16 bytes per pixel) and from that to sRGB
bytes, even when the frame is a single opaque clip shown as it is. The canvas
now keeps such a frame unconverted until something needs its pixels (another
layer, a transition, an adjustment layer, a display transform, captions).
render_sequence_rgba8, which the monitor's CPU path uses, converts a frame
that stays that picture alone directly to the bytes the float path gives,
through per-code-pair tables for R and B and one table for G, at full size and
decimated. Tests compare it bit for bit with the float path for every matrix,
range, chroma layout and decimation, and through the compositor's shortcut
scenes.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
over_black_rgba8 and over_black_with_alpha_rgba8 computed each value with a
table fetch, a clamp, a saturating float-to-usize cast and, for the alpha, a
libm round call, which kept the loop scalar. The table indices of a batch of
64 pixels are now computed first in a loop that vectorises and looked up
after, and the alpha is rounded without the library call. The bytes are the
same; a test checks every table and rounding boundary and the floats around
them.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sequence Settings > Display Format now offers Feet + Frames 16mm, Feet + Frames
35mm and Frames. The choice is stored per sequence (old files load as Timecode)
and drives the timeline playhead readout and ruler, the Program and Source
monitor readouts and the comparison bar. Typed times in those readouts are
parsed in the chosen format. The Metadata & Timecode Burn-in effect gets a
Time Format option for its sequence and media timecode sources.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- The H.264 encoder's RGBA -> 4:2:0 conversion runs on the render
threads (VideoEncoder::prepare_ahead), which are idle while a batch is
encoded; encode() picks the planes up by picture index and converts a
picture itself when there are none (then on the encoder's own pool,
not the busy global one).
- rgba_to_yuv420_8 uses per-code tables of the same products, rounds
without roundf and works row by row so the divisions vectorise; the
output is pinned against the float formula for all 2^24 colours.
- Full-size opaque 8-bit Y'CbCr -> linear conversion tabulates R' and
B' per code pair with the expressions of the per-pixel loop.
- over_black_rgba8 fetches the sRGB table once per picture.
bench_export (1080p H.264 + AAC to H.264 + AAC, Ryzen 16 threads, 7
interleaved rounds) with the encoder change: median 7.86 s -> 6.14 s
(-21.9 %), min 7.78 s -> 6.02 s (-22.7 %). Same file (MD5) as
before, and the same for a ProRes export of the clip.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security(media): bound generator frames, imported audio dimensions, and render images
* fix(media): unwrap render result in demo_frames example
* fix(render, codecs): guard zero-sized images, check post-scale sequence pixels, and bound combined MXF channels
* fix(codecs): annotate channels as u32 in MXF sound track combination
* fix(render): preserve exact output_size scaling calculation for renderable_sequence validation
* fix(media,render): reject unsupported audio dimensions and invalid render scale
Sample rates above MAX_AUDIO_SAMPLE_RATE were clamped without resampling, so a
768 kHz stream was reported as 384 kHz and played at half speed. Reject them
instead, and drop the stream at the four codec call sites rather than
advertising dimensions the samples do not match.
output_size now treats a non-finite or non-positive scale as 1.0 instead of
casting it to zero and collapsing the frame to 1x1.
* fix(media): keep Matroska audio tracks and their metadata together; guard empty images
A track whose advertised sample rate or channel count is refused is dropped before the track list is built, so atracks[k] and audio_streams[k] stay the same track. over_black_with_alpha_rgba8 and Image::transformed return early for an empty image instead of chunking by zero.