Repository navigation
fix(playback): keep a chosen resolution under a bandwidth cap - #2703
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: 🔵 Low · up to
|
| capHeight = capRungClassV3(streamClassV3(targetHeight, classLimit, source), capKbps) | ||
| } | ||
| if capHeight < targetHeight { | ||
| targetHeight = capHeight | ||
| classLimit = minPositiveV3(classLimit, capHeight) |
There was a problem hiding this comment.
Resolution-cap bypass in internal/playback/plan_v3.go occurs when the selected plain-resolution class exceeds a cropped source's pixel height: a 1920x600 source above a 1500 kbps cap with preference 1080p selects capHeight 720, but 720 < 600 is false, leaving classLimit at 1080 and encoding 1920x600 instead of the required 1280x400 at the 720p class. Compare capHeight against the current stream class and update classLimit even when targetHeight is already smaller than capHeight.
if capHeight < streamClassV3(targetHeight, classLimit, source) {
targetHeight = min(targetHeight, capHeight)
classLimit = minPositiveV3(classLimit, capHeight)
}Prompt for LLM
File internal/playback/plan_v3.go:
Line 1702 to 1706:
Resolution-cap bypass in internal/playback/plan_v3.go occurs when the selected plain-resolution class exceeds a cropped source's pixel height: a 1920x600 source above a 1500 kbps cap with preference `1080p` selects capHeight 720, but `720 < 600` is false, leaving classLimit at 1080 and encoding 1920x600 instead of the required 1280x400 at the 720p class. Compare capHeight against the current stream class and update classLimit even when targetHeight is already smaller than capHeight.
Suggested Code:
if capHeight < streamClassV3(targetHeight, classLimit, source) {
targetHeight = min(targetHeight, capHeight)
classLimit = minPositiveV3(classLimit, capHeight)
}
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Confirmed on 1e93d8e: a 1920x600 source with a 1080p preference under a 1500 kbps cap planned 1920x600 at 1500, wider than the 720p box. The rebase onto main in 51344a6 fixes it, because main (#2675) applies the cap's class limit even when the source is shorter than that class, and the resolved block keeps that. It now plans 1280x400. 67b2caf adds that case as a row in TestResolveQualityPolicyV3PlainResolutionKeepsItsRungUnderACap. The row fails on 1e93d8e and passes on the new head.
There was a problem hiding this comment.
Thanks for confirming. The original finding was valid on 1e93d8e and is now addressed by the rebase in 51344a6: the cap’s class limit applies even when the cropped source’s height is below that class, producing 1280×400 instead of 1920×600.
The regression row in 67b2caf, failing on the old commit and passing on the new head, covers this exact case. Based on your reported results, no further code change is needed for this finding.
|
Major validation impact: #1196 C1 records enforcement of inherited playback-quality and stream/transcode limits on server commit Suggested line: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
A profile with preferred quality 1080p and a 3000 kbps cap (what the web "1080p Low" choice saves) planned 720p at 2000 kbps on a 15 Mbps 1080p source. The plain preference sized its bitrate at the 1080p class rate (6000), and once that exceeded the cap it took the class the cap earns, which is 720p, although the menu's own 1080p Low rung costs 3000. A plain resolution now keeps its class while the cap reaches the lowest menu rung of that resolution and lowers only the bitrate to the cap, so 1080p under a 3000 kbps cap plans the same encode as 1080p-low. Below every rung of its resolution it steps down to the tallest resolution whose lowest rung the cap reaches, or 480p at the cap. Auto's class choice under a cap is unchanged.
On the branch before its rebase onto main, a 1920x600 source with a 1080p preference under a 1500 kbps cap encoded 1920x600, overflowing the 720p box the cap allows. Main's Silo-Server#2675 applies the cap's class limit even when the source is shorter than that class, and the rebase keeps that, so the source now encodes at 1280x400; this row guards it. The protocol doc's 1080p Low equivalence now says it holds for a full-frame source, since a plain label still fits a cropped source into its class's box. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
Review of 1e93d8e at medium effort, with a second review by another model.
Blocking: the branch conflicts with main. #2675 has merged as 749021d, and #2803 has since added TestPlanPlaybackV3NamesTheActiveQuality, which expects the old result for this case (1080p under a 3000 kbps cap named 720p-medium). I'm rebasing the last commit onto main and force-pushing it to this branch. That drops the #2675 commit, which main already has, and updates that test row to 1080p-low, the new behavior. There's no need to change it yourself.
The rebase keeps main's version of the cap block, which applies the cap's class limit even when the source is shorter than that class, and uses capRungClassV3 for plain labels on top of it. That also fixes the cropped-source case in the existing thread below.
The two inline notes below are lower severity.
| if capHeight := streamLadderClassV3(capKbps, source); capHeight < targetHeight { | ||
| capHeight := capLadderClassV3(capKbps) | ||
| if quality != QualityAutoV3 { | ||
| capHeight = capRungClassV3(streamClassV3(targetHeight, classLimit, source), capKbps) |
There was a problem hiding this comment.
Low, maintainer decision, not fixed. Under a server stream limit, planVideoTranscodeV3 takes 5% plus the AAC share out of the cap after this class is chosen. With a 3000 kbps server limit, a plain 1080p preference and a 15 Mbps 1080p source, the plan is now 1080 lines at 2658 kbps of video. activeQualityV3 matches plain labels by exact rung bitrate, so the plan names no active quality (""). On main it was 720p at 2000 kbps, named 720p-medium. An explicit 1080p-low under the same limit already plans 1080 lines at 2658 and is named 1080p-low from the request, so the encode matches the explicit rung and only the name is lost. The Risks section covers the bitrate (it says about 2800; the measured figure with stereo AAC is 2658). An empty active_quality is a state the contract already allows. Whether to compare the post-audio budget against the rung floor here is left for the maintainers.
1e93d8e to
67b2caf
Compare
Review summary (reviewed head 67b2caf)A plain resolution preference under a bandwidth cap now keeps its resolution down to that resolution's lowest menu rung, so the web "1080p Low" preset ( Branch rewritten. #2675 merged as 749021d, so the PR's last commit was rebased onto main and force-pushed with a lease. The #2675 commit is gone from the branch, and the PR now shows two commits. Addressed
Left for the maintainers
Verification
Validated features. #1196 C1 (inherited stream limits) is reachable through the server-limit path and changes in a minor way: the limit is still enforced, and only the resolution a plain preference plays under it changes. #1217 C1 is reachable but hasn't been run. The PR body's User manual. Unaffected. The manual describes stream bitrate limits but not which resolution a limit picks. Apple / Android. Server-only. Clients render the server's plan and Related PRs. #2675 is merged and already in this branch's base. #2699 doesn't overlap: its learned limits only apply to Auto through the estimate. Its open conflict in Fit: 8/10 · Readiness: 8/10 — conditional (assuming CI is green)
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: #2643
Validation tasks: changes #1196 C1 (minor: the resolution a plain preference plays under an inherited stream limit; the limit is still enforced); reaches #1217 C1 (not yet run) when a server stream limit meets a plain resolution preference
A viewer who picks 1080p with a 3000 kbps max bitrate gets 720p. The web app's "1080p Low" choice saves exactly that pair (
playback.preferred_quality = 1080p,playback.max_bitrate_kbps = 3000), and on a 15 Mbps 1080p source the planner logstarget_resolution=720p target_bitrate_kbps=2000, even though the menu's own 1080p Low rung is 1080p at 3000. #2675 doesn't fix this case: it fixes Auto, where a 6000 cap played 720p, but a plain1080ppreference still compares the 1080p class bitrate (6000) with the cap and drops a class whenever the cap is lower. With this change, 1080p under a 3000 cap plays 1080p at 3000, the same encode as picking 1080p Low directly. This affects every client on the native v3 planner (web, Apple, Android).Approach
Under a cap, a plain resolution preference (
480p,720p,1080p,2160p) now keeps its resolution while the cap reaches the lowest menu rung of that resolution inladderRungsV3, and lowers only the bitrate to the cap. That is how explicit rungs such as1080p-lowalready behave. If the cap is below every rung of the preferred resolution, it steps down to the tallest resolution whose lowest rung fits (1080p under 2999 plays 720p at 2000), or to 480p at the cap when none does. A source that already fits under the cap still plays as-is, and a source smaller than the preference is never upscaled.Auto keeps #2675's rule, the tallest class whose encode bitrate fits the cap. The difference is deliberate: Auto has no requested resolution, while a viewer who picked 1080p and a bitrate has already said which one they want to give up.
No API or client change.
decision_reasonstaysquality_bandwidth_capwith thebandwidth_cap_appliedwarning, andavailable_qualitiesdoes not depend on the cap. jellycompat doesn't use this path.docs/architecture/playback-protocol-v3.mdandquality-ladder.mddescribe the plain-label rule next to #2675's Auto rule.active_qualitynames1080p-lowfor 1080p under a 3000 kbps client cap, where it named720p-mediumbefore.Validation
go build,go vet,gofmt,make lint-changed(0 issues), and the contract, fixture, route and local-path verify targets pass. Two Dolby Vision tests ininternal/jellycompatfail locally onmaintoo. The web checks were not run because no web file changed.main, fix(playback): give a bitrate cap the tallest resolution it pays for #2675 alone and this branch on the same data. Each run started playback through/api/v2/playback/startand ffprobed the first 20 seconds of HLS output (results below).quality_preference=1080p bandwidth_cap_kbps=3000, received a 1920x1080 plan at 3000 kbps, and played a 1920x1080 video.Evidence
Same request on each build, plan
effective_recipe(width x height @ target bitrate). Source A is 1080p H.264 at 15275 kbps; source B is 720p at 5154 kbps.playback plan decidedfor source A, 1080p, 3000 kbps on this branch, trimmed:ffprobe of the first 10 HLS segments (20 s) for that case:
mainproduced h264 1280x720 at 2149 kbps video, and this branch produced h264 1920x1080 at 3216 kbps video. The encoder treats the cap as-maxrate, so the measured video rate runs a few percent over the target.Risks
A plain preference under a cap now encodes at a larger frame than before, for example 1080p instead of 720p at 3000 kbps. That costs more encoder time per stream, and the picture has fewer bits per pixel; both match what an explicit 1080p Low choice already does. Frame rate does not change the step-down under a cap, the same as for explicit rungs. A server stream limit takes the same path, and its audio share comes out of the video bitrate afterwards, so a plain 1080p preference under a 3000 server limit plays 1080p at about 2650 kbps of video with stereo AAC, the same encode as an explicit 1080p Low. That plan names no
active_quality, because a plain label matches a rung only at the rung's exact bitrate; onmainit was 720p at 2000 kbps, named720p-medium.Checklist
AI Disclosure
mainand again on the commit rebased onto fix(playback): give a bitrate cap the tallest resolution it pays for #2675, including the conflict resolution. Neither review reported a finding.mainafter fix(playback): give a bitrate cap the tallest resolution it pays for #2675 merged, updated one feat(playback): name the quality rung a plan delivers #2803 test row and added a cropped-source row and a docs fix; gpt-6.1-sol cross-checked the rebased head.Note
Fix playback v3 to keep a chosen resolution under a bandwidth cap
playback.ResolveQualityPolicyV3now keeps a plain resolution preference at its requested resolution while the cap fits that resolution's lowest menu rung, lowering only the bitrate. It steps down to a lower resolution only when no rung at the requested resolution fits. Auto quality still picks the tallest class whose class bitrate fits the cap.playback.capRungClassV3helper in plan_v3.go, which scans lowest rung bitrates per resolution and falls back to the 480p bottom rung.Macroscope summarized 67b2caf.