Skip to content

refactor(producer): extract HDR compositing helpers and rename media metadata#373

Merged
vanceingalls merged 2 commits intomainfrom
vance/refactor-helpers
Apr 23, 2026
Merged

refactor(producer): extract HDR compositing helpers and rename media metadata#373
vanceingalls merged 2 commits intomainfrom
vance/refactor-helpers

Conversation

@vanceingalls
Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls commented Apr 21, 2026

Summary

Four behavior-preserving refactors that reduce complexity in renderOrchestrator.ts and clarify the engine ffprobe utility surface. Lands after the correctness fixes (Chunks 1–5) so the refactored code is already correct.

Why

Chunk 7 of plans/hdr-followups.md. The HDR composite block had grown a ~200 LOC inline closure with 14 captured deps, a repeated capture-options spread, a extractVideoMetadata name that now also handles still images, and per-frame re-creation of debug helpers.

What changed

7A — Hoist compositeToBuffer into a module-scoped helper. Extract the inline HDR closure into a top-level compositeHdrFrame() that takes an HdrCompositeContext struct. Construct the context once at the top of the HDR render block and pass it through. Removes a deeply-nested closure from the middle of the orchestrator.

7B — buildHdrCaptureOptions() helper. Factor the repeated { ...captureOptions, skipReadinessVideoIds: ... } spread into a named helper at the call site.

7C — Rename extractVideoMetadataextractMediaMetadata. Reflects that the helper handles still images (PNG/JPEG/WebP) in addition to video. Update all callers in engine + producer (videoFrameExtractor, htmlCompiler, regression-harness, producer ffprobe re-export, tests). Re-export the old name as a deprecated alias from @hyperframes/engine for backward compatibility, plus the producer re-export shim.

7D — Hoist debug counters to module scope. countNonZeroAlpha and countNonZeroRgb48 are now module-scoped so they aren't re-created per frame and so the closure has fewer captures.

Also touches the hdr-regression and hdr-hlg-regression README + meta.json files reviewed during this refactor.

Test plan

  • bunx tsc --noEmit -p packages/producer && bunx tsc --noEmit -p packages/engine clean.
  • Engine tests: 313 pass, 0 fail (1218 expect calls).
  • bunx oxlint + bunx oxfmt --check clean on 8 changed source files.
  • Diff is structural only — no behavioral changes.

Stack

Chunk 7 of plans/hdr-followups.md. Lands after the correctness fixes (Chunks 1–5) per the suggested merge order.

Copy link
Copy Markdown
Collaborator Author

vanceingalls commented Apr 21, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from bc48483 to 57d6459 Compare April 21, 2026 20:48
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch 2 times, most recently from 4f4682b to 78a6af9 Compare April 21, 2026 20:54
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from 57d6459 to 9b1f281 Compare April 21, 2026 20:54
@vanceingalls vanceingalls marked this pull request as ready for review April 21, 2026 20:57
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from 78a6af9 to 3838031 Compare April 21, 2026 22:37
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from 9b1f281 to 9199f7c Compare April 22, 2026 01:16
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from 3838031 to 95df8c6 Compare April 22, 2026 01:16
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from 9199f7c to a4b7030 Compare April 22, 2026 02:03
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from d22e419 to 44ff16f Compare April 23, 2026 00:01
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from 0922d9a to c1e9467 Compare April 23, 2026 00:05
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from 44ff16f to aa8b9be Compare April 23, 2026 00:05
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from c1e9467 to ebef5d5 Compare April 23, 2026 00:45
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch 2 times, most recently from c623430 to ba25661 Compare April 23, 2026 01:58
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch 2 times, most recently from 3643a05 to 7468d97 Compare April 23, 2026 02:53
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from ba25661 to ccc725f Compare April 23, 2026 02:53
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from 7468d97 to 3196e2c Compare April 23, 2026 03:16
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from ccc725f to 5589417 Compare April 23, 2026 03:16
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch from 3196e2c to 34926b3 Compare April 23, 2026 03:37
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from 5589417 to 6d73142 Compare April 23, 2026 03:38
@vanceingalls vanceingalls force-pushed the vance/cli-encode-overrides branch 2 times, most recently from 86e4952 to e7bae09 Compare April 23, 2026 04:46
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from 6d73142 to 52c6034 Compare April 23, 2026 04:46
@vanceingalls vanceingalls changed the base branch from vance/cli-encode-overrides to graphite-base/373 April 23, 2026 05:05
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from 52c6034 to 263d844 Compare April 23, 2026 05:06
@graphite-app graphite-app Bot changed the base branch from graphite-base/373 to main April 23, 2026 05:06
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch 3 times, most recently from 3d8b1dd to daae643 Compare April 23, 2026 05:15
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Apr 23, 2026

Merge activity

  • Apr 23, 5:15 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Apr 23, 5:41 AM UTC: @vanceingalls merged this pull request with Graphite.

@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from daae643 to 9678521 Compare April 23, 2026 05:18
vanceingalls and others added 2 commits April 22, 2026 22:20
notes/ and plans/ are working documents, not project docs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vanceingalls vanceingalls force-pushed the vance/refactor-helpers branch from 9678521 to 71e67e2 Compare April 23, 2026 05:22
@vanceingalls vanceingalls merged commit a3d7cc1 into main Apr 23, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants