Skip to content

Feature Request: Add HDR Vivid (CUVA HDR Vivid) Support #699

Closed as not planned

Description

@ijuniorfu

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.
  • HardwareVideoDecoder should be able to decode and handle HDR Vivid streams correctly.
  • SoftwareVideoDecoder should 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:

  1. Identify a video as HDR Vivid (CUVA HDR Vivid).
  2. Decode HDR Vivid through HardwareVideoDecoder when the hardware path is available.
  3. Fall back to SoftwareVideoDecoder and decode the same content correctly when hardware decoding is unavailable.
  4. Preserve and expose HDR Vivid metadata required by the rendering pipeline.
  5. 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:

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.
  • HardwareVideoDecoder can play HDR Vivid content.
  • SoftwareVideoDecoder can 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

B.1-04.mp4

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

  1. added
    enhancement
    on Oct 5, 2026
  2. superuser404notfound commented on Oct 5, 2026

    @superuser404notfound
    Owner

    Thanks for the sample, it made this quick to pin down.

    The flicker is not caused by HDR Vivid. B.1-04.mp4 is an MP4 with B pictures but no ctts (composition offset) table, so every sample reports PTS == DTS and 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:

    • The format is designed to be backward compatible: the base layer is plain HLG or PQ in BT.2020, and the CUVA dynamic metadata is an optional SEI on top. The engine already identifies this sample as HLG (BT.2020 / HLG / 10-bit), plays it on the native path with hardware decode, and the display switches into HLG mode. A Vivid-unaware display shows exactly that static HLG/PQ picture, which is the intended fallback.
    • Detection fits well: FFmpeg already parses the CUVA metadata into frame side data, so the engine can report Vivid the same way it reports HDR10+ from probe (ProbeDetail). That is planned as a follow-up.
    • A Metal conversion stage is not a fit, for three reasons. The native path hands the bitstream to AVPlayer, so there is no pixel stage to insert anything into without giving up hardware decode and the system's HDR output. tvOS offers no EDR API for an app (CAMetalLayer.wantsExtendedDynamicRangeContent is 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.
  3. added a commit that references this issue on Oct 5, 2026
  4. superuser404notfound commented on Oct 5, 2026

    @superuser404notfound
    Owner

    Released in 7.27.3 (b27f2971, fix commit adb80da8): HEVC MP4s without composition offsets are now presented in display order, which removes the flicker on B.1-04.mp4. A retest on your side would be welcome. HDR Vivid detection follows separately, as mentioned above.

  5. ijuniorfu commented on Oct 6, 2026

    @ijuniorfu
    Author

    Released in 7.27.3 (b27f2971, fix commit adb80da8): HEVC MP4s without composition offsets are now presented in display order, which removes the flicker on B.1-04.mp4. A retest on your side would be welcome. HDR Vivid detection follows separately, as mentioned above.

    After testing, the screen flickering did not disappear.

  6. added a commit that references this issue on Oct 6, 2026
  7. superuser404notfound commented on Oct 6, 2026

    @superuser404notfound
    Owner

    The detection half is released in 7.28.0 (7de2d5a0, feature commit bbdb254f).

    AetherEngine.probe(url:detecting: .hdrVivid) now reports CUVA carriage as SourceProbe.carriesHDRVividMetadata. It runs in the same packet pass and budget as .hdr10Plus, and only a complete CUVA message counts (defined system_start_code, every field present, zero bits after the last one). videoFormat stays .hlg / .hdr10, since that base layer is what the display is switched to. On B.1-04.mp4:

    aetherctl probe --detect-hdr-vivid B.1-04.mp4
      format:    hlg
      HDR Vivid: CUVA metadata seen
    

    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.

  8. ijuniorfu commented on Oct 6, 2026

    @ijuniorfu
    Author

    The detection half is released in 7.28.0 (7de2d5a0, feature commit bbdb254f).

    AetherEngine.probe(url:detecting: .hdrVivid) now reports CUVA carriage as SourceProbe.carriesHDRVividMetadata. It runs in the same packet pass and budget as .hdr10Plus, and only a complete CUVA message counts (defined system_start_code, every field present, zero bits after the last one). videoFormat stays .hlg / .hdr10, since that base layer is what the display is switched to. On B.1-04.mp4:

    aetherctl probe --detect-hdr-vivid B.1-04.mp4
      format:    hlg
      HDR Vivid: CUVA metadata seen
    

    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.

    SourceProbe.carriesHDRVividMetadata

    AetherEngine.probe(url: url, detecting: .hdrVivid) is already capable of detection, whereas engine.load(url: url, options: options) is not yet able to do so.

  9. superuser404notfound commented on Oct 6, 2026

    @superuser404notfound
    Owner

    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.mp4 is 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:

    ffmpeg -i B.1-04.mp4 -vf signalstats,metadata=print:key=lavfi.signalstats.YAVG -f null -
    182.6 197.8 197.8 182.6 197.8 197.8 182.6 182.6 197.8 197.8 182.6 182.6 ...
    

    The CUVA dynamic metadata alternates in lockstep with it: in ffprobe -show_frames one tone-mapping curve parameter switches between 563/1023 and 510/1023, and every frame carrying 563 is a dark one, every frame carrying 510 a 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, which load() 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, and videoFormat already reports that. The intended pattern is to run the probe alongside the load (or ahead of it, for a detail page badge):

    // probe(url:detecting:) is synchronous and blocking, so it runs off the main actor.
    let vivid = Task.detached {
        (try? AetherEngine.probe(url: url, detecting: .hdrVivid))?.carriesHDRVividMetadata ?? false
    }
    try await engine.load(url: url, options: options)
    let isVivid = await vivid.value

    Both open the source independently, so the probe does not delay the start of playback.

  10. ijuniorfu commented on Oct 6, 2026

    @ijuniorfu
    Author

    Thanks a lot for a reply!

  11. cmcpherson274 commented on Oct 6, 2026

    @cmcpherson274

    On your retest request for 7.27.3 (b27f2971, fix commit adb80da8): not a retest of B.1-04.mp4 or 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_frames 2). 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 no ctts. In the six we traced with trace_headers, the head is an IDR_N_LP followed by the stock x265 pyramid (POC 5 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.

    run 7.24.0 7.27.3
    from the head no #409 line; decode order, 76 backward steps in 194 triples (0.39) #409 … confirmed; display order, 0 in 177
    resume at 600 s (a CRA sync sample) no #409 line; decode order, 159 in 380 (0.42) #409 … confirmed; display order, 0 in 387
    control film, resume at 600 s no #409 line; display order, 0 in 518 no #409 line; display order, 0 in 521

    Both 7.27.3 runs of the film logged the same line:

    [Demuxer] #409 missing HEVC composition offsets confirmed on stream 0: repair step=50050 lead=100099 shift=100099 pocStep=1 cadence=250248/5 phase=3 ladderAhead=2 samples=12
    

    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 first timeControlStatus=playing at 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 same confirmed line 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):

    [Demuxer] #409 composition-offset probe on stream 0 left the stream untouched: sample does not start on a picture-order origin (samples=12)
    

    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).

  12. superuser404notfound commented on Oct 6, 2026

    @superuser404notfound
    Owner

    Thanks for the measurement, the software-path finding holds and the fix is up as #707.

    There were two defects behind it:

    1. The verdict came too late. The demuxer decided the repair at its first read, and the software host seeks to the resume position before that read, so the sample started on the CRA and was declined, exactly as your log line shows. A seek before the first read now settles the verdict at the head of the file first.
    2. The landing was anchored as if it were the first picture displayed. A CRA is displayed after the leading pictures decoded behind it, so after any seek onto one with leading pictures the axis sat one slot early per leading picture, and the B pictures that then fell below their own decode time went out untouched. This one is not specific to the software path: a native-path seek onto a CRA with RASL pictures was affected too. Your measured film resumed cleanly on the native route, which fits a landing without leading pictures (five of your six traces). The session now holds from the landing to the first trailing picture, counts the leading pictures and anchors with that count.

    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.

  13. added a commit that references this issue on Oct 7, 2026
  14. superuser404notfound commented on Oct 7, 2026

    @superuser404notfound
    Owner

    Released in 7.28.3 (3cc256a0, fix commit 4a86b522): 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.

  15. cmcpherson274 commented on Oct 8, 2026

    @cmcpherson274

    On your retest request for 7.28.3 (3cc256a0, fix commit 4a86b522): 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):

    run 7.27.3 7.28.3
    A Serious Man, resume 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)
    A Perfect World, resume left the stream untouched, 30 ms after; decode order, 132 in 398 (0.332) confirmed, 3 ms before; display order, 0 in 386
    Carnage, resume left the stream untouched, 27 ms after; decode order, 152 in 424 (0.358) confirmed, 1 ms before; display order, 0 in 409
    Carnage, seek confirmed at the head; decode order after the seek, 180 in 324 (0.556) confirmed at the head; display order, 0 in 354
    A Serious Man, seek confirmed at the head; display order, 3 in 256 display order, 0 in 247
    A Serious Man, from the head confirmed; display order, 0 in 191 display order, 0 in 193

    The 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,

    [Renderer] frame at 600.011s arrived after 600.053s was handed over; dropped, reorder depth raised to 4
    

    (599.886s / 600.011s on A Serious Man); 7.28.3 logged no such line on any run. The two #409 lines, 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):

    [Demuxer] #409 composition-offset probe on stream 0 left the stream untouched: sample does not start on a picture-order origin (samples=12)
    [Demuxer] #409 missing HEVC composition offsets confirmed on stream 0: repair step=50050 lead=100099 shift=100099 pocStep=1 cadence=250248/5 phase=3 ladderAhead=2 samples=12
    

    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 confirmed line at open on both versions, as before:

    run 7.27.3 7.28.3
    Carnage, seek decode order, 249 in 386 (0.645) display order, 0 in 438
    Carnage, resume decode order, 242 in 398 (0.608) ‡ display order, 0 in 480
    A Perfect World, resume display order, 0 in 459 display order, 1 in 419
    A Serious Man, resume / seek / from the head display order, 0 in 394 / 5 in 260 / 0 in 176 no reading † / 2 in 269 / 0 in 176

    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 #409 line 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.

    • ‡ 7.27.3's Carnage resume on the Apple TV lost its HDMI audio route 0.5 s after it started; our app rebuilt the session in place at the same position (the same first read offset), the rebuilt item failed once with -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.
    • † 7.28.3's A Serious Man resume on the Apple TV has no reading: the HDMI audio route dropped 0.7 s after the start (an HDMI event on our side), and the session stopped after the rebuilt item failed with -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).

  16. superuser404notfound commented on Oct 8, 2026

    @superuser404notfound
    Owner

    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. -66665 is kAudioQueueErr_CannotStartYet and -66681 is kAudioQueueErr_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 -66665 the engine's #93 revive picked the session up again, after -66681 the 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 .failed or posted failedToPlayToEndTime, since those take different recovery paths in the engine.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions