Skip to content

Software path: publish the display size the renderer settled on, so an overlay lays out against the picture and not the coded frame #353

Closed

Description

@superuser404notfound

Raised by @edde746 while adopting #311 (comment), filed here so it is tracked separately from the frame-time work.

What should the engine do?

Publish the display size the software path settled on: the coded frame with the sample aspect ratio the renderer actually attached. Nothing on the public surface carries it today, and no host can derive it.

Motivating media or use case

Laying out a frame-exact overlay (libass, ASS/SSA) over software-decoded video. #311 gave the overlay its clock and its frame boundaries; what is still missing is the rectangle to draw into.

A host derives that rectangle from a picture aspect under the active gravity. The only public size is sourceVideoWidth/sourceVideoHeight, which are coded dimensions, so anamorphic content lays out against a rect off by the pixel aspect: 720x576 with a 64:45 SAR presents as 1024x576, and an overlay sized 5:4 sits inside a 16:9 picture.

AVSampleBufferDisplayLayer offers no videoRect, unlike AVPlayerLayer, so there is nothing to measure on the layer either.

Why the host cannot compute it

The SAR that reaches the screen is decided per frame inside SoftwareVideoDecoder.attachPixelAspectRatio, and neither input nor result is reachable:

SourceProbe carries videoWidth/videoHeight and no SAR, so a host reconstructing the ratio from container metadata disagrees with the picture in exactly the cases the policy exists for: for a rejected SAR the engine shows square pixels while the container still declares the ratio it rejected.

Shape

Read it from the format description the renderer enqueues rather than recomputing the policy:

CMVideoFormatDescriptionGetPresentationDimensions(desc, usePixelAspectRatio: true, useCleanAperture: true)

That description is the object on screen, so the published value cannot drift from the picture, and its cache key already invalidates on a dimension or PAR change (#177), which is exactly when the size has to be republished.

Two constraints:

Not a field on SoftwareVideoFrameTime: it changes once per format, and that callback runs on the decode thread.

Scope

Software path only. The native and bypass paths mount an AVPlayerLayer, which measures its own videoRect and carries AVPlayerItem.presentationSize.

Area

Public API surface

Activity

  1. superuser404notfound commented on Aug 9, 2026

    @superuser404notfound
    OwnerAuthor

    Shipped in 6.17.0, 998650e3. Left open for @edde746's retest against a host overlay on anamorphic content.

    Two notes on what the API does not claim:

    • It is the size the picture presents at, not a rect. Layer bounds and gravity stay the host's, which is what the report asked for.
    • It settles when the first sample buffer is built, not at load, because that is the first moment the ratio the decoder resolved is observable. For an overlay that is early enough by construction: before it there is no picture to sit over.
  2. superuser404notfound commented on Sep 22, 2026

    @superuser404notfound
    OwnerAuthor

    Housekeeping pass over the open tracker, and this one has been waiting on a retest for 44 days with nothing owed on the engine side, so it goes on the closed pile.

    What is in 7.11.0 and has been since 6.17.0 (998650e3):

    • softwareDisplaySize: CGSize? on the engine (AetherEngine.swift:859), cleared per load in stopInternal (:6672), measured at CMVideoFormatDescriptionGetPresentationDimensions where the renderer builds its first sample buffer (SampleBufferRenderer.swift:468), and mirrored from the host (SoftwarePlaybackHost.swift:615).
    • Ten regression cases in Tests/AetherEngineTests/Issue353SoftwareDisplaySizeTests.swift, including the 720x576 to 1024x576 anamorphic case this report was built on, the "reported on change, not per frame" promise, and the one that a flush rebuild is not a change.
    • docs/api.md, which PublicAPIDocumentationTests enforces, and aetherctl play prints display size: or never published so the behaviour is checkable from the harness.

    @edde746, the invitation stands unchanged: if an overlay rect still disagrees with the picture on real anamorphic content, reopen this with the numbers and it picks up where it left off. Same for #311, #315 and #316, which are parked on the same round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions