Skip to content

Commit 14ee1d6

Browse files
Vincent Herbstclaude
andcommitted
docs(dv): the host assertion no longer picks the P8.1 / P8.4 packaging (#493)
6.72.0 gave the non-DV branch its dvcC back and 6.73.0 its SUPPLEMENTAL-CODECS, which left nothing for panelPresentsDolbyVision to change about how a Profile 5, 8.1 or 8.4 source is served. The docs still described the flag as choosing the DV route (dvh1 tags, supplemental, master), which was true until yesterday and is now the opposite of measurable. Measured on macOS against the matched Dolby grades of one material, the engine's own loopback, only dvModeAvailable moving: master.m3u8, media.m3u8, init.mp4 and seg0.mp4 come back md5-identical in both arms for P5, P8.1 and P8.4. What the claim still moves is the published videoFormat, the tvOS criteria request, the HDR readiness that rides along with it, the Profile 7 and AV1 DV packaging that stay gated, and the AE#455 opt-in it disables. Two tests pin both halves of that, so "the claim changes nothing" cannot quietly grow into the rule. Suite green on both runners (607 XCTest, 1 skipped; 2761 swift-testing). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014tQ8MerNbZQdWBpDStitoD
1 parent c3dbdbd commit 14ee1d6

5 files changed

Lines changed: 117 additions & 14 deletions

File tree

‎Sources/AetherEngine/PlayerState.swift‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,26 @@ public struct LoadOptions: Sendable, Equatable {
381381
///
382382
/// AE#493: `AVPlayer.availableHDRModes` is `API_UNAVAILABLE(macos)`, so a Mac has no per-mode capability
383383
/// table at all, and `eligibleForHDRPlayback` answers HDR10 and HLG but cannot answer this one. Setting
384-
/// it serves the source the way a DV display is served (`dvh1` sample entry, `SUPPLEMENTAL-CODECS`,
385-
/// master playlist) and publishes `videoFormat = .dolbyVision`. HDR support rides along because DV is an
386-
/// HDR format; HDR10 and HLG capability are not implied.
384+
/// it publishes `videoFormat = .dolbyVision` and asks the tvOS display-criteria handshake for `dvh1`.
385+
/// HDR support rides along because DV is an HDR format; HDR10 and HLG capability are not implied.
386+
///
387+
/// It no longer decides the PACKAGING of a Profile 5, 8.1 or 8.4 source. 6.72.0 gave the non-DV branch
388+
/// its `dvcC` back and 6.73.0 its `SUPPLEMENTAL-CODECS`, so those three grades serve byte-identical
389+
/// manifests and segments either way (measured on macOS against the matched Dolby grades: master,
390+
/// media playlist, `init.mp4` and `seg0.mp4` md5-identical with and without the claim). Profile 7,
391+
/// whose RPU is converted to 8.1 per packet, and AV1 Dolby Vision, whose record is read only on a
392+
/// display that takes it, are still gated on it.
387393
///
388394
/// A wrong claim is cheap on the class of failure the engine classifies, and that class is not the whole
389395
/// space. AVPlayer refusing the master with -11868 / -11848 fails the ITEM, and the engine falls back to
390396
/// the media playlist once, in place, at the same position, where AVPlayer tone-maps the base layer;
391397
/// correctable mid-session through `reloadAtCurrentPosition(applying:)`. Two measured limits on that:
392398
/// on macOS the wrong claim was not refused at all (a DV master on a Mac with no DV display plays,
393-
/// macOS 26.5.2), and on tvOS an asserted Profile 8.1 reaches the DV packaging (`dvvC` in the sample
394-
/// entry plus `SUPPLEMENTAL-CODECS`), which on an HDR10-only panel was measured to reach `readyToPlay`,
395-
/// play for a second or two and then stall with -15628 in the item's error log (2026-05-26, AE#4). A
396-
/// stall is not an item failure, so the fallback above does not fire for it.
399+
/// macOS 26.5.2), and a stall is not an item failure, so the fallback above does not fire for the
400+
/// -15628 an HDR10-only panel showed on the DV packaging in May 2026 (AE#4). That stall is no longer
401+
/// the claim's to own: since 6.72.0 / 6.73.0 the same packaging reaches such a panel with or without
402+
/// it, and it did not reproduce on tvOS 26.6. What the claim can still move on the route is HDR
403+
/// readiness, since `supportsHDR` rides along, and that is the -11848 the fallback does catch.
397404
///
398405
/// Asserting also turns `forceDolbyVisionOnNonDVDisplay` off, since that one is gated on the display
399406
/// having no DV. On tvOS, DV composition on a panel without Dolby Vision is what that flag is for, and

‎Sources/aetherctl/main.swift‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,16 @@ func printUsage() {
157157
(AVPlayer.availableHDRModes is unavailable there)
158158
and HDR eligibility answers HDR10 and HLG but not
159159
DV, so a DV source otherwise plays as its HDR10
160-
base layer with effective-format=hdr10. With the
161-
flag the session serves the DV route (dvh1 tags,
162-
SUPPLEMENTAL-CODECS, master playlist). A wrong
163-
claim costs one in-place media-playlist fallback
164-
(-11868 / -11848), not the item.
160+
base layer with effective-format=hdr10. The flag
161+
moves that label and the tvOS criteria request; it
162+
no longer moves the packaging of a P5 / P8.1 / P8.4
163+
source, which since 6.72.0 / 6.73.0 carries its
164+
dvcC and SUPPLEMENTAL-CODECS on every display (the
165+
served master, media playlist, init.mp4 and
166+
segments are byte-identical either way). P7 and AV1
167+
DV are still gated on it. A wrong claim costs one
168+
in-place media-playlist fallback (-11868 / -11848),
169+
not the item.
165170
166171
Flags (serve / seektest):
167172
--throttle-kbps N

‎Tests/AetherEngineTests/Issue493HostDisplayAssertionTests.swift‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import Testing
3+
import AetherLibavcodec
34
import AetherLibavutil
45
@testable import AetherEngine
56

@@ -144,4 +145,94 @@ struct Issue493HostDisplayAssertionTests {
144145
#expect(SessionOptionCorrection.refusedFields(
145146
from: LoadOptions(), to: LoadOptions(panelPresentsDolbyVision: true)).isEmpty)
146147
}
148+
149+
// MARK: - What the assertion no longer changes about the served bytes
150+
151+
/// An HEVC / AV1 `AVCodecParameters` carrying a DOVI configuration record, freed with the test.
152+
private final class DVCodecpar {
153+
let ptr: UnsafeMutablePointer<AVCodecParameters>
154+
155+
init(codecID: AVCodecID, profile: UInt8, compat: UInt8, trc: AVColorTransferCharacteristic) {
156+
ptr = avcodec_parameters_alloc()
157+
ptr.pointee.codec_type = AVMEDIA_TYPE_VIDEO
158+
ptr.pointee.codec_id = codecID
159+
ptr.pointee.width = 3840
160+
ptr.pointee.height = 2160
161+
ptr.pointee.level = 153
162+
ptr.pointee.color_primaries = AVCOL_PRI_BT2020
163+
ptr.pointee.color_trc = trc
164+
ptr.pointee.color_space = AVCOL_SPC_BT2020_NCL
165+
let size = MemoryLayout<AVDOVIDecoderConfigurationRecord>.size
166+
guard let sd = av_packet_side_data_new(
167+
&ptr.pointee.coded_side_data, &ptr.pointee.nb_coded_side_data,
168+
AV_PKT_DATA_DOVI_CONF, size, 0
169+
) else { fatalError("could not attach a DOVI configuration record") }
170+
memset(sd.pointee.data, 0, size)
171+
sd.pointee.data.withMemoryRebound(to: AVDOVIDecoderConfigurationRecord.self, capacity: 1) { rec in
172+
rec.pointee.dv_version_major = 1
173+
rec.pointee.dv_profile = profile
174+
rec.pointee.dv_level = 6
175+
rec.pointee.rpu_present_flag = 1
176+
rec.pointee.el_present_flag = profile == 7 ? 1 : 0
177+
rec.pointee.bl_present_flag = 1
178+
rec.pointee.dv_bl_signal_compatibility_id = compat
179+
}
180+
}
181+
182+
deinit {
183+
var p: UnsafeMutablePointer<AVCodecParameters>? = ptr
184+
avcodec_parameters_free(&p)
185+
}
186+
}
187+
188+
private static func route(
189+
codecID: AVCodecID = AV_CODEC_ID_HEVC,
190+
profile: UInt8,
191+
compat: UInt8,
192+
trc: AVColorTransferCharacteristic = AVCOL_TRC_SMPTE2084,
193+
dvDisplay: Bool
194+
) throws -> HLSVideoEngine.CodecRoute {
195+
let par = DVCodecpar(codecID: codecID, profile: profile, compat: compat, trc: trc)
196+
let engine = HLSVideoEngine(url: URL(fileURLWithPath: "/dev/null"), dvModeAvailable: dvDisplay)
197+
return try engine.resolveCodecRoute(codecpar: UnsafePointer(par.ptr))
198+
}
199+
200+
/// Everything the muxer and the manifest read out of a route, as one comparable line.
201+
private static func packaging(_ r: HLSVideoEngine.CodecRoute) -> String {
202+
"tag=\(r.codecTagOverride ?? "nil") range=\(r.videoRange) codecs=\(r.primaryCodecs) "
203+
+ "supplemental=\(r.supplementalCodecs ?? "nil") dovi=\(r.doviConfig) "
204+
+ "p7convert=\(r.convertP7ToProfile81) variant=\(r.dvVariant)"
205+
}
206+
207+
/// 6.72.0 gave the non-DV branch its `dvcC` back and 6.73.0 its `SUPPLEMENTAL-CODECS`, which left the
208+
/// three grades a Dolby Vision display used to be served differently identical on both branches. So
209+
/// the assertion no longer decides a byte of the served stream for them, only the published
210+
/// `videoFormat`, the tvOS criteria request, and the HDR readiness that rides along. Measured the
211+
/// same day against the matched Dolby P5 / P8.1 / P8.4 grades on macOS: master, media playlist,
212+
/// init.mp4 and seg0.mp4 came back md5-identical with and without the claim.
213+
@Test("AE#493: the assertion does not move the packaging of P5, P8.1 or P8.4",
214+
arguments: [(UInt8(5), UInt8(0)), (UInt8(8), UInt8(1)), (UInt8(8), UInt8(4))])
215+
func assertionLeavesTheHEVCPackagingAlone(grade: (profile: UInt8, compat: UInt8)) throws {
216+
let trc: AVColorTransferCharacteristic = grade.compat == 4 ? AVCOL_TRC_ARIB_STD_B67 : AVCOL_TRC_SMPTE2084
217+
let asserted = try Self.route(profile: grade.profile, compat: grade.compat, trc: trc, dvDisplay: true)
218+
let control = try Self.route(profile: grade.profile, compat: grade.compat, trc: trc, dvDisplay: false)
219+
#expect(Self.packaging(asserted) == Self.packaging(control))
220+
}
221+
222+
/// The two grades where it still does, so "the claim changes nothing" cannot quietly become the rule:
223+
/// P7 needs the per-packet RPU conversion to 8.1 and its supplemental, and the AV1 DV record is read
224+
/// only on a display that takes it, so a non-DV display gets plain `av01` rather than `dav1`.
225+
@Test("AE#493: P7 and AV1 Dolby Vision are still packaged by the claim")
226+
func assertionStillMovesTheGatedGrades() throws {
227+
let p7Asserted = try Self.route(profile: 7, compat: 0, dvDisplay: true)
228+
let p7Control = try Self.route(profile: 7, compat: 0, dvDisplay: false)
229+
#expect(Self.packaging(p7Asserted) != Self.packaging(p7Control))
230+
#expect(p7Asserted.convertP7ToProfile81)
231+
#expect(p7Control.convertP7ToProfile81 == false)
232+
233+
let av1Asserted = try Self.route(codecID: AV_CODEC_ID_AV1, profile: 10, compat: 1, dvDisplay: true)
234+
let av1Control = try Self.route(codecID: AV_CODEC_ID_AV1, profile: 10, compat: 1, dvDisplay: false)
235+
#expect(av1Asserted.codecTagOverride == "dav1")
236+
#expect(av1Control.codecTagOverride == "av01")
237+
}
147238
}

‎docs/api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ All flags default to safe values; the table is the full set. Depth for the media
697697
| `suppressDisplayCriteria` | false | Skip the display-criteria handshake entirely. For previews and headless runs. |
698698
| `matchContentEnabled` | true | Mirror of `AVDisplayManager.isDisplayCriteriaMatchingEnabled`. False routes HDR through the auto-tonemap path. |
699699
| `panelIsInHDRMode` | false | **Host assertion** that the panel is presenting HDR right now, and the gate on whether the HDR10-to-DV upgrade is accepted upfront. It is an OR term over the engine's own readout on every platform, not a replacement for it and no longer confined to `suppressDisplayCriteria` hosts (AE#459). The readout it backs up is `currentEDRHeadroom > 1`, which answers only around a dynamic-range transition: an Apple TV whose output format is locked to HDR never makes one and reads as an SDR panel forever, and on tvOS 27 the property has stopped answering at all on at least one box. A wrong assertion costs one in-place media-playlist fallback (`-11848`), not the item. |
700-
| `panelPresentsDolbyVision` | false | **Host assertion** that this display presents Dolby Vision, for the platforms where the engine cannot observe it (AE#493). `AVPlayer.availableHDRModes` is `API_UNAVAILABLE(macos)`, so a Mac has no per-mode table at all, and `eligibleForHDRPlayback` answers HDR10 and HLG but not this: it proves EDR, not that AVFoundation will accept a DV variant here. Setting it serves the DV route (`dvh1` sample entry, `SUPPLEMENTAL-CODECS`, master playlist) and publishes `videoFormat = .dolbyVision`; HDR support rides along because DV is an HDR format, while HDR10 and HLG capability are not implied. An assertion only ever adds, so `false` cannot hide a capability the system reports. A wrong assertion costs one in-place media-playlist fallback (`-11868` / `-11848`) at the same position, where AVPlayer tone-maps the base layer, and it is correctable mid-session through `reloadAtCurrentPosition(applying:)`. That net covers the item-failure class only: on tvOS an asserted Profile 8.1 takes the DV packaging, which on an HDR10-only panel was measured to stall with `-15628` after a second or two (AE#4), and a stall is not an item failure. Asserting also disables `forceDolbyVisionOnNonDVDisplay`, the tvOS route for that panel class (AE#455). |
700+
| `panelPresentsDolbyVision` | false | **Host assertion** that this display presents Dolby Vision, for the platforms where the engine cannot observe it (AE#493). `AVPlayer.availableHDRModes` is `API_UNAVAILABLE(macos)`, so a Mac has no per-mode table at all, and `eligibleForHDRPlayback` answers HDR10 and HLG but not this: it proves EDR, not that AVFoundation will accept a DV variant here. Setting it publishes `videoFormat = .dolbyVision` and asks the tvOS display-criteria handshake for `dvh1`; HDR support rides along because DV is an HDR format, while HDR10 and HLG capability are not implied. It does not decide the packaging of a Profile 5, 8.1 or 8.4 source: 6.72.0 gave the non-DV branch its `dvcC` back and 6.73.0 its `SUPPLEMENTAL-CODECS`, so those three serve byte-identical manifests and segments either way (measured on macOS against the matched Dolby grades). Profile 7 and AV1 Dolby Vision are still gated on it. An assertion only ever adds, so `false` cannot hide a capability the system reports. A wrong assertion costs one in-place media-playlist fallback (`-11868` / `-11848`) at the same position, where AVPlayer tone-maps the base layer, and it is correctable mid-session through `reloadAtCurrentPosition(applying:)`. That net covers the item-failure class only, and the `-15628` an HDR10-only panel showed on the DV packaging in May 2026 (AE#4) is a stall rather than an item failure. It is no longer the claim's to own either: the same packaging reaches such a panel with or without it since 6.72.0 / 6.73.0, and it did not reproduce on tvOS 26.6. What the claim still moves on the route is HDR readiness, since `supportsHDR` rides along. Asserting also disables `forceDolbyVisionOnNonDVDisplay`, the tvOS route for that panel class (AE#455). |
701701
| `omitCriteriaColorExtensions` | false | Diagnostic lever: leave colour out of `AVDisplayCriteria` so AVPlayer re-reads it from the bitstream. |
702702
| `keepDvh1TagWithoutDV` | false | Diagnostic lever: force dvh1 tags and a master playlist regardless of display capability. |
703703
| `forceDolbyVisionOnNonDVDisplay` | false | **Experimental (AE#455).** On a display with no Dolby Vision of its own, serve an HEVC Profile 8.1 source the way a Profile 5 source is served (`dvh1` sample entry, `dvcC` rewritten to profile 5 / compatibility 0, `CODECS="dvh1.05.LL"`), so AVPlayer composes the RPU itself instead of handing the panel the static-metadata HDR10 base layer. The bitstream is untouched; only the container's claim about it changes. Ignored on a display that does Dolby Vision, and Profile 8.1 only. See [formats.md](formats.md#dolby-vision-signaling) for what it buys and what it risks. |

0 commit comments

Comments
 (0)