Repository navigation
Description
What should the engine do?
Description
Add support for HDR Vivid (CUVA HDR Vivid) video playback in AetherEngine.
The goal is to allow HDR Vivid content to be correctly detected, decoded, and presented through both the hardware and software video decoding paths.
Requirements
- Detect HDR Vivid / CUVA HDR Vivid video content and expose it through the existing video format / HDR detection mechanism.
HardwareVideoDecodershould be able to decode and handle HDR Vivid streams correctly.SoftwareVideoDecodershould be able to decode and handle HDR Vivid streams correctly.- Preserve HDR Vivid dynamic metadata during the decoding pipeline when available.
- Make HDR Vivid distinguishable from SDR, HDR10, HDR10+, Dolby Vision, and HLG.
- Ensure HDR Vivid playback does not cause visible flashing, incorrect colors, or loss of HDR metadata.
- Support common HDR Vivid MP4/MKV sources supported by FFmpeg.
Expected Result
AetherEngine should be able to:
- Identify a video as HDR Vivid (CUVA HDR Vivid).
- Decode HDR Vivid through
HardwareVideoDecoderwhen the hardware path is available. - Fall back to
SoftwareVideoDecoderand decode the same content correctly when hardware decoding is unavailable. - Preserve and expose HDR Vivid metadata required by the rendering pipeline.
- Report the detected format through the existing
VideoFormat/ video state mechanism.
FFmpeg Reference
FFmpeg 8.1.3 already provides HDR Vivid metadata definitions and related codec-side support. These files may be used as references for the AetherEngine implementation:
-
libavutil/hdr_dynamic_vivid_metadata.h
FFmpeg n8.1.3 — hdr_dynamic_vivid_metadata.h -
libavcodec/dynamic_hdr_vivid.h
FFmpeg n8.1.3 — dynamic_hdr_vivid.h
Motivation
HDR Vivid is increasingly used in real-world video content. Supporting it as a first-class HDR format would allow AetherEngine-based players to correctly identify and play these files instead of treating them as generic SDR/HDR content.
The desired result is similar to the existing HDR10/HDR10+ handling, with dedicated HDR Vivid / CUVA HDR Vivid detection and support across both hardware and software decoding paths.
Acceptance Criteria
- HDR Vivid content is correctly detected.
HardwareVideoDecodercan play HDR Vivid content.SoftwareVideoDecodercan play the same HDR Vivid content.- HDR Vivid metadata is retained throughout the decoding pipeline where available.
- No visible flashing or incorrect HDR/color behavior occurs during playback.
- Existing SDR, HDR10, HDR10+, Dolby Vision, and HLG playback remains unaffected.
Apple Platform / Metal Rendering
Since Apple platforms do not provide native HDR Vivid support, would it be possible to consider using Metal for the HDR Vivid rendering/conversion stage?
For example, AetherEngine could preserve the HDR Vivid dynamic metadata from the decoder and use a Metal-based processing pipeline to convert the decoded HDR Vivid frames into a format suitable for Apple's HDR/EDR display pipeline.
The goal would be to support HDR Vivid playback on Apple platforms without relying on native system-level HDR Vivid support.
The exact implementation is open to discussion, but a Metal-based HDR Vivid conversion/rendering path may be worth considering.
Would this architecture fit the direction of AetherEngine, and would you be open to adding HDR Vivid support?
Motivating media or use case
Visible flashing or incorrect HDR/color behavior occurs during playback.
Area
Codec / container support
Host app / integration context
No response
Would you be willing to open a PR?
No
Activity
superuser404notfound commentedon Oct 5, 2026
Thanks for the sample, it made this quick to pin down.
The flicker is not caused by HDR Vivid.
B.1-04.mp4is an MP4 with B pictures but noctts(composition offset) table, so every sample reportsPTS == DTSand the container hands out decode order as presentation order. The engine already repairs that shape for H.264 (#409) by reading the picture order count from the slice headers, but the repair only armed on H.264, so this HEVC file was shown in decode order. Measured on the sample: the first 88 frames stepped backwards 35 times. With the fix in #700 the served stream has 0 backward steps across all 1500 frames. That PR extends the repair to HEVC and will go out in the next release.On HDR Vivid itself:
probe(ProbeDetail). That is planned as a follow-up.CAMetalLayer.wantsExtendedDynamicRangeContentis unavailable there), so the app cannot know the panel's peak brightness, and dynamic tone mapping needs exactly that number. And the output is an HDR signal to the TV, which does its own tone mapping. Applying Vivid metadata on the device would mean tone mapping twice.Merge pull request #700 from superuser404notfound/fix/699-hevc-compos…
superuser404notfound commentedon Oct 5, 2026
Released in 7.27.3 (
b27f2971, fix commitadb80da8): HEVC MP4s without composition offsets are now presented in display order, which removes the flicker onB.1-04.mp4. A retest on your side would be welcome. HDR Vivid detection follows separately, as mentioned above.fix(demux): repair HEVC MP4s without composition offsets (superuser40…
ijuniorfu commentedon Oct 6, 2026
After testing, the screen flickering did not disappear.
Merge pull request #701 from superuser404notfound/feat/699-hdr-vivid-…
superuser404notfound commentedon Oct 6, 2026
The detection half is released in 7.28.0 (
7de2d5a0, feature commitbbdb254f).AetherEngine.probe(url:detecting: .hdrVivid)now reports CUVA carriage asSourceProbe.carriesHDRVividMetadata. It runs in the same packet pass and budget as.hdr10Plus, and only a complete CUVA message counts (definedsystem_start_code, every field present, zero bits after the last one).videoFormatstays.hlg/.hdr10, since that base layer is what the display is switched to. OnB.1-04.mp4:Together with the display-order fix in 7.27.3, that covers the detection and playback parts of this request. The Metal tone-mapping path stays out of scope for the reasons given above. A retest of both on your side would be welcome.
feat(probe): detect HDR Vivid (CUVA) carriage (superuser404notfound#699)
ijuniorfu commentedon Oct 6, 2026
SourceProbe.carriesHDRVividMetadataAetherEngine.probe(url: url, detecting: .hdrVivid)is already capable of detection, whereasengine.load(url: url, options: options)is not yet able to do so.superuser404notfound commentedon Oct 6, 2026
Thanks for testing. I went back to the sample with the engine out of the loop entirely, and the remaining flicker is in the encoded picture itself.
B.1-04.mp4is a self-test pattern that flickers by design on any display that ignores the CUVA metadata. The caption burned into every frame reads "HDR Vivid Self-Test: Dynamic Metadata Synchronous HLG". Decoding it with plain FFmpeg (no AetherEngine involved, frames in display order) and measuring the average luma per frame gives a strict two-frame alternation between two brightness levels for the whole clip:The CUVA dynamic metadata alternates in lockstep with it: in
ffprobe -show_framesone tone-mapping curve parameter switches between563/1023and510/1023, and every frame carrying563is a dark one, every frame carrying510a bright one, with no exception. So the test checks whether the display applies the per-frame metadata synchronously: a Vivid-capable pipeline that does should render a steady patch, while a pipeline that shows the HLG base layer as is (which is what Apple's display pipeline does, since it has no CUVA support) shows the alternation at 12.5 Hz. That is the intended fallback rendering of this particular clip, not a playback defect, and ordinary Vivid content does not encode a picture that alternates like this.The ordering fix from 7.27.3 is a separate, real defect in the same file: before it, the engine presented the frames in decode order (35 backward steps in the first 88 frames). Now the decoded ladder is monotonic on both paths (
aetherctl swdecode: 0 backward steps across 229 frames, and 0 across all 1500 on the served native stream), and the luma sequence the engine presents matches FFmpeg's above.On
load()reporting HDR Vivid: that is intentional, and it matches HDR10+. Neither shows up in any container header, so detecting them means reading and parsing SEI from video packets, whichload()would otherwise not do. Putting that pass in front of every playback start would add open latency for information that changes nothing about how the file plays: there is no Vivid output mode on Apple platforms, the display is switched to the HLG or PQ base layer either way, andvideoFormatalready reports that. The intended pattern is to run the probe alongside the load (or ahead of it, for a detail page badge):Both open the source independently, so the probe does not delay the start of playback.
ijuniorfu commentedon Oct 6, 2026
Thanks a lot for a reply!
cmcpherson274 commentedon Oct 6, 2026
On your retest request for 7.27.3 (
b27f2971, fix commitadb80da8): not a retest ofB.1-04.mp4or of HDR Vivid, but a device confirmation of the display-order fix on a different file shape, x265 encodes in MP4 whose first video packets all read PTS == DTS. On the head of the file it agrees with your reading that the decoded ladder is monotonic on both paths; the one case we found outside it is a resume onto a CRA on the software path, at the end, as a report.The files. Of the 2,058 HEVC titles in MP4 or MOV files in the library we test against, 77 read PTS == DTS on each of their first 80 video packets while the stream declares reordering (
has_b_frames2). All 77 are SDR films; 76 are x265 10-bit encodes and one an 8-bit HEVC web encode. The one we checked at the box level, the film measured below, has noctts. In the six we traced withtrace_headers, the head is anIDR_N_LPfollowed by the stock x265 pyramid (POC5 3 1 2 4 | 10 8 6 7 9 …in decode order in five of them, groups of four in the sixth) with no leading pictures, and the sync sample nearest 600 s is a CRA in all six (in one with three RASL pictures).Setup. Apple TV 4K (3rd generation,
AppleTV14,1, tvOS 26.6), Debug builds of our app, our loopback route (the engine's local HLS server feeding AVPlayer), 7.24.0 (9bd00968) and 7.27.3 in one session on 2026-10-06, the same positions and waits, one run per row. One of the 77 (1920×1040, 23.976 fps) and, as a control, an x265 10-bit MP4 of the same kind that does carry composition offsets. We kept an HDMI capture of each run (29.97 fps, about 22 s) and counted backward steps over the distinct pictures (192-px grey frames, mean absolute difference): a triple of consecutive pictures whose outer pair differs by less than 0.8 × the larger of its two steps. Synthetic clips permuted into x265's decode order read 0.21 to 0.40 on this measure, and 0.00 in display order.#409line; decode order, 76 backward steps in 194 triples (0.39)#409 … confirmed; display order, 0 in 177#409line; decode order, 159 in 380 (0.42)#409 … confirmed; display order, 0 in 387#409line; display order, 0 in 518#409line; display order, 0 in 521Both 7.27.3 runs of the film logged the same line:
On this route the resume is covered because the decision reads the file's head at open, before the resume seek (
HLSVideoEngine.swift:1233-1238). At twice the width (384 px) the 7.27.3 captures read 1 backward step in 400 (resume) and 3 in 196 (head), against 0.39 and 0.38 for 7.24.0, so nothing near the decode-order rate appeared at that width either. The measure cannot see a picture AVPlayer drops; our drop and stall counters did not move on any of the six runs. AVPlayer reached its firsttimeControlStatus=playingat t+3.00 to t+3.06 s on all six, both versions.The software path, as a report. On the tvOS simulator, where our VOD plays on the engine's software path, the head start is repaired too, as you found with
swdecode: 7.27.3 logs the sameconfirmedline and reads display order (0 in 130), where 7.24.0 read decode order (48 in 198) and logged[Renderer] frame at 0.000s arrived after 0.042s was handed over; dropped, reorder depth raised to 4. A resume at 600 s is not repaired: the software host seeks before its first read (SoftwarePlaybackHost.swift:995-998), so the sample starts at the CRA and the classifier declines it (H264CompositionOffsetRepair.swift:225-226):That session plays in decode order as on 7.24.0 (142 in 354, against 141 in 366), and both versions log
[Renderer] frame at 599.886s arrived after 600.011s was handed over; dropped, reorder depth raised to 4. On an Apple TV our app reaches the software path for these files only through the #461 escape or a #561 escalation, not on their ordinary start. The simulator's 7.27.3 captures were taken under a system dialog that dimmed the picture; the picture underneath moved and was scored, and the two log lines do not depend on it. One run each.Not measured: a second film of the 77, a Dolby Vision file of this shape, a Release build.
7.27.3 is our app's engine pin as of today (2026-10-06).
superuser404notfound commentedon Oct 6, 2026
Thanks for the measurement, the software-path finding holds and the fix is up as #707.
There were two defects behind it:
Both are covered by an x265 open-GOP twin with four RASL pictures at its CRA, for a resume-shaped seek and a seek during playback. It ships with the next release.
Merge pull request #707 from superuser404notfound/fix/699-repair-befo…
superuser404notfound commentedon Oct 7, 2026
Released in 7.28.3 (
3cc256a0, fix commit4a86b522): the composition-offset repair now holds for a resume onto a CRA on the software path, and for any seek onto a CRA with leading pictures on both paths. A retest on your side would be welcome.fix(demux): repair missing composition offsets across a seek onto an …
cmcpherson274 commentedon Oct 8, 2026
On your retest request for 7.28.3 (
3cc256a0, fix commit4a86b522): the same frame-order measure as in our comment above, on both routes, now on three of the 77 films: A Serious Man (the film measured before), A Perfect World, and Carnage, the one of our six traces whose CRA near 600 s carries leading pictures (three RASL pictures, POC 210, 209 and 211, decoded after the CRA at POC 212); the other two films' CRAs there carry none. Every run that played in decode order on 7.27.3 plays in display order on 7.28.3, on both routes.Setup. As before (the same Apple TV on our loopback route, and the tvOS simulator, where our VOD plays on the engine's software path), Debug builds, 7.27.3 (
b27f2971) and 7.28.3 in one session per instrument on 2026-10-08, the same positions and waits, one run per cell. Resume opens the file at 600 s; seek starts at the head and seeks to 600 s twenty seconds after playback started. The measure is unchanged: backward steps over the distinct pictures of a recording (192-px grey frames), display order at most 0.03 of the scored triples on a moving picture, decode order at least 0.10, both over at least 100 scored triples. On the Apple TV the recording is 21 to 22 s of HDMI capture at 29.97 fps, starting at least 40 s after a resume started or at least 6 s after a seek was issued; on the simulator it is the last 20 s of a screen recording started just before the launch, so it begins about 40 s after the launch on a resume and about 7 to 9 s after the seek landed on a seek run.Software route (the simulator):
left the stream untouched, 39 ms after the read at the resume offset; decode order, 143 backward steps in 358 triples (0.399)confirmed, 2 ms before that read; display order, 5 in 355 (0.014)left the stream untouched, 30 ms after; decode order, 132 in 398 (0.332)confirmed, 3 ms before; display order, 0 in 386left the stream untouched, 27 ms after; decode order, 152 in 424 (0.358)confirmed, 1 ms before; display order, 0 in 409confirmedat the head; decode order after the seek, 180 in 324 (0.556)confirmedat the head; display order, 0 in 354confirmedat the head; display order, 3 in 256confirmed; display order, 0 in 191The three resumes show your first defect: 7.27.3 decided at the CRA and declined, while 7.28.3 decides at the head before the resume read (Carnage's resume also lands on its RASL CRA, so it needs the second fix as well). The Carnage seek is your second defect alone: 7.27.3 had already decided at the head, yet the landing on the RASL CRA played in decode order, while the same seek on A Serious Man, whose CRA has no leading pictures, did not. Each of the four decode-order runs on 7.27.3 also logged, right after the landing,
(
599.886s/600.011son A Serious Man); 7.28.3 logged no such line on any run. The two#409lines, each identical on all three films; the first is 7.27.3's on the three resumes, the second every 7.28.3 run's (and 7.27.3's on the head and seek runs):Deciding at the head showed no start cost on this route in these single runs: from the play request to our app's own start mark, 0.6 s on both versions for A Serious Man, 1.9 s against 2.2 s for Carnage and 3.0 s against 3.2 s for A Perfect World (7.28.3 against 7.27.3). No stall on any run; our drop counter read one frame after the seek on 7.28.3's Carnage seek and on both versions' A Serious Man seek, and none on the other runs.
Loopback route (the Apple TV). Every run logged the
confirmedline at open on both versions, as before:Both Carnage runs serve from the segment that begins at the CRA near 595.9 s (
producer restarted at idx=73 (seek=595.88s …)for the seek,initial producer anchored at idx=73 (startPosition=600.00s)for the resume, the same first read offset on both versions), and they are the only runs on this route that played in decode order on 7.27.3, as your note on the native path predicted; the two films whose CRA has no leading pictures were already in display order there. AVPlayer dropped no frame on any run. Stalls were 0 except on the two marked runs and on 7.28.3's A Serious Man seek (1, in the 10 s after the seek).The control, an x265 film of the same kind that carries composition offsets, resumed at 600 s, logged no
#409line and read display order on both versions and both routes (0 backward steps in 445 to 450 triples over three runs per version on the simulator, 0 in 522 and 525 on the Apple TV).Marked runs.
-66665, and the engine's Loopback-HLS: a single backward seek on heavy 4K can wedge the segment producer (video stalls, audio continues -> A/V desync) #93 revive reloaded it at 601.68 s, all more than 30 s before its recording began. Its rate sits with the clean seek run's (0.608 against 0.645), so we count it, but not as a clean run; its two stalls are from that episode.-66681; we are reproducing that before saying more.Not measured: a Dolby Vision file of this shape (all 77 are SDR), more than three of the 77, more than one run per cell, a Release build.
7.28.3 is our app's engine pin as of today (2026-10-08).
superuser404notfound commentedon Oct 8, 2026
Thanks for the retest across three films and both routes. That closes the 7.28.3 side: the three resumes show the head verdict, and Carnage's seek isolates the leading-picture landing, which is the case the old anchoring got wrong.
On the two marked runs, for when you have the repro: both failure codes are AudioQueue start errors, not media verdicts.
-66665iskAudioQueueErr_CannotStartYetand-66681iskAudioQueueErr_CannotStart(AudioQueue.h). Both followed an HDMI audio route drop, so they point at the output route not being ready when the rebuilt item tried to start, and they are independent of the #409 repair. The difference between the two outcomes is worth pinning down: after-66665the engine's #93 revive picked the session up again, after-66681the session ended. If it reproduces, a separate issue with the log from the route drop through to the stop would be the best place for it, including whether the item reached.failedor postedfailedToPlayToEndTime, since those take different recovery paths in the engine.