fix(ios): weight resolution pixel-distance so targetResolution isn't overridden by FPS#3964
Open
richkuo wants to merge 1 commit into
Open
fix(ios): weight resolution pixel-distance so targetResolution isn't overridden by FPS#3964richkuo wants to merge 1 commit into
richkuo wants to merge 1 commit into
Conversation
…overridden by FPS The resolution-bias penalty puts pixel-distance on a raw log scale (~0-1.4), far weaker than the FPS penalty (raw frame units, up to 30). So when a requested FPS isn't available at the target resolution, the session escalates resolution to satisfy FPS — e.g. a front-camera 1080p@60 request lands on 4K@60 even though a native 1080p@60 format exists. Scale pixel-distance by aspectMismatchWeight so the requested resolution stays a first-class signal, with FPS as a tiebreaker among equally-close resolutions. Addresses mrousavy#3963
|
@richkuo is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a case where
targetResolutionis effectively ignored when a higher FPS is requested: on an iPhone front TrueDepth camera, asking for 1080p @ 60fps records 3840×2160@60 instead of the device's native 1920×1080@60 format.Addresses #3963.
Root cause
In
CMVideoDimensions.penalty(_:), pixel-distance is the raw log-ratio of pixel counts (range ~0–1.4), while the FPS penalty (AVFrameRateRange.penalty(for:)) is in raw frame units (max(undershoot, overshoot), up to 30) and carries a higher weight inConstraintResolver's weighted sum. So resolution distance is a very weak signal — when the requested FPS isn't available at the target resolution, the resolver escalates resolution to satisfy FPS.Per-format penalties at target
1080p / 60fpson a front TrueDepth camera (lower = selected):The
resolutionBiasterm actually favors 1080p (itslogPixelDistanceis0; 4K's is1.386), but it's swamped by the other constraints.Change
Scale
logPixelDistanceby the existingaspectMismatchWeightso pixel-distance is weighted comparably to the aspect-ratio term — keeping the requested resolution a first-class signal. This is intentionally local to the resolution penalty and does not change FPS tie-breaking among equally-close resolutions.Notes
1920×1080@60(no escalation, no re-encode); 4k mode is unaffected.LLM: Claude Opus 4.8 (1M) | Effort: High | Harness: Claude Code