Skip to content

Fix Retina JPEG scaling for stream-video - #85

Merged
onevcat merged 1 commit into
lycorp-jp:mainfrom
EuanTop:fix/retina-jpeg-scaling
Jul 30, 2026
Merged

Fix Retina JPEG scaling for stream-video#85
onevcat merged 1 commit into
lycorp-jp:mainfrom
EuanTop:fix/retina-jpeg-scaling

Conversation

@EuanTop

@EuanTop EuanTop commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #83.

This updates JPEG frame scaling to produce the requested output pixel dimensions regardless of the host display backing scale. Previously, the macOS NSImage.lockFocus() path could render through the Retina backing scale, so --scale 0.5 could still emit frames at the original Retina-sized dimensions.

The new path decodes to CGImage, computes exact scaled dimensions, draws into an explicitly sized CGContext, and encodes the result with CGImageDestination.

Changes

  • Replace the AppKit-based JPEG scale/re-encode path with ImageIO/CoreGraphics encoding.
  • Add an explicit JPEG encode failure error.
  • Add tests that assert scaled JPEG output has exact pixel dimensions.
  • Add coverage that quality-only re-encoding preserves dimensions and changes output size.

Validation

  • make build
  • swift test --filter VideoFrameProcessingTests
  • git diff --check
  • Live simulator verification:
    • --scale 1.0: 1206x2622
    • --scale 0.5: 602x1310

Signed-off-by: EuanTop <euan@mail.bnu.edu.cn>
@EuanTop
EuanTop force-pushed the fix/retina-jpeg-scaling branch from 306794f to 8f3d0bb Compare July 29, 2026 08:45
@onevcat
onevcat merged commit 186eac8 into lycorp-jp:main Jul 30, 2026
4 checks passed
@onevcat

onevcat commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

LGTM! Thank you for this.

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.

fix: stream-video --scale renders via NSImage.lockFocus at the host's backing scale factor (no-op on Retina)

2 participants