Repository navigation
Tighten the small-change metrics and tile comparer after review (851-4476) - #1504
Merged
Merged
Conversation
pondorasti
added a commit
that referenced
this pull request
Nov 27, 2026
…851-4476) From the code review of #1504: requeueing after any drop marked the retry as a repeat, so a new change whose first encode was dropped never reached changeEncoded. The request now names the repeated tiles (a refinement, a refresh, or a dropped refinement queued again from the same capture) and the encoded tile carries it, which also keeps the flag off the wire-shaped update. changesKeptSharp leaves out keyframes, the chroma weight rounds up for odd sizes, and every Plan states its repeated tiles. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- changeEncoded times only changes encoded from their own capture: an update now says when it repeats a capture the host already encoded (repeatsCapture), such as a dropped refinement queued again from the last encoded capture. - The host's counter is renamed smallChangeRequests (what it asked for); changesKeptSharp counts in the VCP session when a frame comes out encoded at the kept cap. - The tile comparer keeps an inline path for a single candidate tile. - The small-change limit is in screen pixels in every plane: a CbCr sample of 420v counts 4. - The host-lab README example uses vcp=1; small does nothing on VideoToolbox. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…851-4476) From the code review of #1504: requeueing after any drop marked the retry as a repeat, so a new change whose first encode was dropped never reached changeEncoded. The request now names the repeated tiles (a refinement, a refresh, or a dropped refinement queued again from the same capture) and the encoded tile carries it, which also keeps the flag off the wire-shaped update. changesKeptSharp leaves out keyframes, the chroma weight rounds up for odd sizes, and every Plan states its repeated tiles. Co-Authored-By: Claude Opus 5.5 <[email protected]>
pondorasti
force-pushed
the
alexandru/851-4476-small-change-follow-ups
branch
from
November 27, 2026 06:14
01fa832 to
4b87ccd
Compare
From the review of #1504 at 4b87ccd: - The encoder's drop and failure outputs carry whether the submission repeated its capture, and the host requeues from that instead of from its state at drop time (a newer change could have cleared it, and the tile was then encoded and timed twice). - A plan whose encode throws requeues its repeated tiles as repeats. - changesKeptSharp is counted before the tile is delivered. - The capture slot compares captures by their timestamp, the key the encoders use. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Follow-up to #1484 (851-4476), from the review of b628ffe.
changeEncodedtimed requeued work. A refinement the encoder dropped is queued again as a change of the last encoded capture, with that capture's old capture time, so the metric recorded the capture's age. The encode request now names the tiles that repeat a capture already encoded (repeatedTiles), and the encoded tile carries it (repeatsCapture): a refinement, a refresh-only update, and a dropped refinement queued again from the same capture.changeEncodedleaves those out. A change whose first encode was dropped is not a repeat; its retry is timed from its own capture, the latency the viewer sees. The flag is kept offScreenSharingTileUpdate, which is also the frame metadata's type.tilesChangedSmallcounted requests. Renamed tosmallChangeRequests(the tiles the host passed as small), andchangesKeptSharpmoved to where the cap is decided and the frame is known to be encoded: the VCP session counts it when an encoded frame comes out with the kept cap. A refresh, a keyframe (requested or not), a bitrate under Apple's ladder, the session's own view of its last refinement, or a skipped frame are no longer counted.vcp=1(vcp=1,small=0/vcp=1/vcp=1,small=0) and sayssmallonly matters withvcp=1.concurrentPerformand the mutex.420vcapture: I chose to scale. Each plane is held to the limit in screen pixels, so a CbCr sample counts the 4 pixels it covers (rounded up for odd sizes), and the limit means the same area in every plane and capture format. In the product this only matters for VideoToolbox captures (420v), where the host doesn't measure at all since Keep the encoder quality cap for a small change to a sharpened tile, so typing is not 3 ms slower on the shipped encoder (851-4476) #1484; VCP captures are BGRA.Tests
ScreenSharingV2HostRepeatedCaptureTests: a dropped refinement encoded again as a change is marked as a repeat and the next new capture is not; a dropped first encode of a new capture is not marked as a repeat. Each fails with its rule switched off.ScreenSharingTileMetricsTests: a tile that repeats its capture is not timed. Fails without the metrics change.ScreenSharingV2TileComparerTests: a CbCr change of 20 samples (80 screen pixels) is large against a 64-pixel limit, also on a 641×361 capture. Each fails without the scaling, or with the scaling rounded down.ScreenSharingVCPSmallChangeTests(hardware, shipped encoder):changesKeptSharpis 1 after a small change and 0 after a large one. This does not fail without the move: forcing a session to skip, emit a keyframe or change bitrate mid-submit isn't possible on the hardware encoder in a test.Code review (medium) of this PR
Five findings, all fixed in 01fa832:
changeEncoded. Now only a dropped refinement repeats; tested.420vcaptures a CbCr sample counted 1 or 2 pixels. Rounded up; tested.changesKeptSharpcounted frames VCP emitted as keyframes. They are left out now.ScreenSharingTileUpdate, which the frame metadata decodes without it. Moved to the request and the encoded tile.Plandefaulted to "repeats". Every plan now states its repeated tiles.Ran locally (M1 Pro):
ScreenSharingV2Testswithout the hardware suites (163 tests) and the hardware codec suites (21 tests), all passing; the bench app builds. Proof on the minis is the PR's benchmark gate; no other runs dispatched.Second review (at 4b87ccd), fixed in 79f3a33
plan.repeatedas repeats. Tested (aRepeatWhoseEncodeThrowsIsStillARepeatWhenItIsEncodedAgain, fails without the fix)..droppedand.failedoutputs now carryrepeatsCapturefrom the submission (VCP, VideoToolbox, the fallback and the rate switch pass it on), and the host decides from that. Tested (aRefinementDroppedAfterANewerChangeStartedIsStillARepeatOfItsTile, fails without the fix). Such a tile is still encoded again from the newer capture, as before this PR; it is now just not timed.changesKeptSharpis counted before the tile is delivered, next toScreenSharingTileMetrics.record.frame.timestampNs, the key the encoders use.🤖 Generated with Claude Code