Address code-review findings across export, decode, and data model

Export correctness:
- Honor the user's color-range (Limited/Full) on the software encode path:
  thread full_range through gpu_yuv (new shader range uniform), the CPU
  swscale fallback (sws_setColorspaceDetails → BT.709 + range, fixing the
  BT.601 hue/level shift on odd-width exports), and the encoder color tags.
- Reject HDR + WebM up front with a clear message and log the forced HEVC
  override instead of producing an unplayable file.
- Delete dead render_frame_to_rgba_hdr (hardcoded Stretch; live HDR path
  already honors the fit mode).

Decode/playback (video.rs):
- Drain the decoder at EOF (send_eof + flush) so the final B-frame-delayed
  frames render instead of erroring; per-frame logic extracted to a helper.
- Missing-PTS frames continue monotonically rather than snapping to ts=0.
- Force exact thumbnail width so sub-128px sources aren't shown stretched.

Resource leaks (gpu-video-encoder):
- dmabuf import_raw: RAII guard frees the duped fd + partial VkImages/memory
  on every error path.
- vaapi alloc: free device/frames-ctx/AVFrames on the unexpected-DRM path.

Data model / robustness:
- collapse_boundary_spikes requires a full curve reversal (all control
  points) so it no longer deletes a real lens/sliver and drops the fill.
- Export audio spin-wait ignores a stale `finished` flag when a forward
  seek is pending (was rendering silence over real audio).
- RasterDiff apply_before/after take current dims and skip on a post-resize
  mismatch.
- beam_archive read_media_full caps the preallocation from untrusted total_len.

UI/visual:
- SVG export skips hidden layers/empty groups; import folds fill-opacity into
  gradients and surfaces failures as a notification.
- Active raster-layer border uses playback_time + overlay_transform.
- gpu_brush remove_layer_texture also evicts the stale low-res proxy.
- ensure_raster_resident_for_undo registers faulted frames in the LRU so
  resident RAM stays bounded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Skyler Lehmkuhl
2026-06-26 17:47:32 -04:00
co-authored by Claude Opus 4.8
parent 1fa4d744be
commit b301c63387
20 changed files with 527 additions and 440 deletions
@@ -2080,7 +2080,11 @@ impl egui_wgpu::CallbackTrait for VelloCallback {
// fills the black's gaps → interlocking black/yellow marching-ants.
if let Some(active_id) = self.ctx.active_layer_id {
if let Some(lightningbeam_core::layer::AnyLayer::Raster(rl)) = self.ctx.document.get_layer(&active_id) {
if let Some(kf) = rl.keyframe_at(self.ctx.document.current_time) {
// Use playback_time (clip-local when editing a movie clip) like every other
// keyframe lookup in prepare(), and overlay_transform so the outline tracks the
// layer's pixels through any clip-instance affine (it equals camera_transform
// outside clip-edit mode).
if let Some(kf) = rl.keyframe_at(self.ctx.playback_time) {
let rect = vello::kurbo::Rect::new(0.0, 0.0, kf.width as f64, kf.height as f64);
// Sizes are in document space; divide by zoom so they're ~constant on screen.
let inv_zoom = 1.0 / (self.ctx.zoom as f64).max(1e-3);
@@ -2089,14 +2093,14 @@ impl egui_wgpu::CallbackTrait for VelloCallback {
let pattern = [dash, dash];
scene.stroke(
&vello::kurbo::Stroke::new(stroke_w).with_dashes(0.0, pattern),
camera_transform,
overlay_transform,
vello::peniko::Color::new([0.0, 0.0, 0.0, 1.0]),
None,
&rect,
);
scene.stroke(
&vello::kurbo::Stroke::new(stroke_w).with_dashes(dash, pattern),
camera_transform,
overlay_transform,
vello::peniko::Color::new([1.0, 0.85, 0.0, 1.0]),
None,
&rect,