Skip to content

fix(video): preserve precise pixel aspect ratios - #869

Open
jonluca wants to merge 1 commit into
superuser404notfound:mainfrom
jonluca:fix/precise-pixel-aspect-ratios
Open

jonluca wants to merge 1 commit into
superuser404notfound:mainfrom
jonluca:fix/precise-pixel-aspect-ratios

Conversation

@jonluca

@jonluca jonluca commented Oct 25, 2026

Copy link
Copy Markdown

Summary

Preserve valid pixel aspect ratios whose rational components exceed 256. A 712×574 frame declaring 759:712 should display as 759×574, but the component cap discarded that declaration and displayed square pixels.

What changed

  • Bound the ratio's magnitude using overflow-safe integer arithmetic, preserving precise and unreduced representations.
  • Keep the existing frame-aware display-aspect gate and invalid/non-positive guards.
  • Extend the existing SAR suites with precise ratios, scaled boundary values and Int32 extremes; update the architecture description and changelog.

Test plan

  • Device / OS: Apple M4 Max, macOS 27.0.1, Xcode 27.1.
  • Source media: deterministic synthetic SAR/frame geometry, including 759:712 on 712×574; no external media required.
  • Red run: the added regression cases fail against the unchanged upstream policy (12 failed expectations).
  • Green run: 47 tests across the focused SAR, container-resolution and hardware-decoder aspect suites pass.
  • python3 Scripts/check-doc-links.py and git diff --check pass.

Checklist

  • CHANGELOG.md updated
  • Conventional commit
  • Fix lives in the engine
  • No public API change

Copilot AI balanced review requested due to automatic review settings October 25, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow arithmetic change safely handles Int32 components, retains existing safeguards, and has focused regression coverage with no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR fixes the engine’s pixel-aspect validation so precise ratios such as 759:712 are preserved instead of falling back to square pixels.

Changes:

  • Replace component limits with overflow-safe ratio-magnitude bounds while retaining existing validation safeguards.
  • Add regression cases for precise ratios, scaled boundaries, and Int32 extremes.
  • Update test terminology, architecture documentation, and the changelog.
File Description
Tests/​AetherEngineTests/​Issue290DisplayAspectGateTests.swift Update comments and test terminology to describe the magnitude gate.
Tests/​AetherEngineTests/​Issue177SARLatchTests.swift Add precision, boundary, and display-aspect regression cases.
Sources/​AetherEngine/​Decoder/​PixelAspectPolicy.swift Bound ratio magnitude using Int64 arithmetic while preserving declared components.
docs/​architecture.md Document the revised pixel-aspect gate.
CHANGELOG.md Record the precise pixel-aspect correction.

Review effort: Balanced

@jonluca
jonluca force-pushed the fix/precise-pixel-aspect-ratios branch from 01b518a to 4c31df9 Compare October 25, 2026 18:27
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.

2 participants