feat(dovi): libplacebo-style Dolby Vision RPU mapping and HDR tone/gamut pipeline - #136
Open
1824239290 wants to merge 1 commit into
Open
1824239290 wants to merge 1 commit into
1824239290 wants to merge 1 commit into
Conversation
…mut pipeline Implements end-to-end Dolby Vision and HDR color mapping aligned with libplacebo/mpv gpu-next. RPU path - Parse AV_FRAME_DATA_DOVI_METADATA with bounds/alignment checks; scale pivots by base-layer bit depth and coefficients by 2^-coef_log2_denom. - Piecewise polynomial + MMR reshaping, nonlinear ycc_to_rgb, PQ linearization, and HPE-LMS composite (forced BT.2020/PQ for P5/P8). - Per-frame L1 drives the tone-map peak/scene average; static L0 still decides output-mode negotiation and tone-map/LUT enablement. - Profile 5 falls back to software decode on MediaCodec/AvCodec; desktop VideoToolbox/D3D11VA keep hardware decode. - Profile 7 FEL residual is reported (DoviElStatus) rather than dropping the whole RPU; base-layer mapping still applies. - Structured reject reasons + throttled diagnostics. Tone and gamut mapping - IPT-domain single-pass tone map with BT.2390 default, plus spline, BT.2446 method A, ST 2094-10, Mobius, Reinhard, clip. Black-point compensation via contrast_ratio (auto 1000:1 for SDR). - ST 2094-10 knee picked in the PQ domain; degenerate anchors fall back to Clip instead of a black frame. - Perceptual gamut mapping via a CPU-generated 48x32x256 IPT 3D LUT (RGBA16F) shared by Metal/wgpu/D3D11, generated off-thread, cached by (source, target, target black, target peak). Chroma rolloff is a simplified dead-zone blend rather than libplacebo's full boundary search (documented). - HDR10 scene-adaptive pivot via CPU luma measurement (luma_stats), honoring limited range and yuv420p10le vs P010 packing. Platform - Metal: negotiate EDR/Auto HDR from the presenting screen; linearize subtitles/danmaku into EDR drawables; do not bind the placeholder LUT while it regenerates. - D3D11: upload the LUT as true RGBA16F Texture3D; mask gamut_lut_enabled while generation is pending (constants are passed into draw_video, not a discarded local). - CI: build/upload wgpu_decode_png and erika-capi bundle on macOS arm64. Docs - New docs/dolby-vision.md; CHANGELOG Unreleased covers the feature set; architecture.md default operator corrected to BT.2390. Tests: cargo test -p erika --lib (583) pass locally; fmt clean.
1824239290
pushed a commit
to 1824239290/Erika
that referenced
this pull request
Sep 10, 2026
Based on upstream v0.1.9. Squashed Dolby Vision RPU mapping + HDR tone/gamut pipeline (see AimesSoft#136).
1824239290
force-pushed
the
agent/dolby-vision-mapping
branch
from
September 10, 2026 05:10
9f7870f to
8d55281
Compare
1824239290
pushed a commit
to 1824239290/Erika
that referenced
this pull request
Sep 10, 2026
Based on upstream v0.1.9. Squashed Dolby Vision RPU mapping + HDR tone/gamut pipeline (see AimesSoft#136).
1824239290
force-pushed
the
agent/dolby-vision-mapping
branch
2 times, most recently
from
September 10, 2026 05:21
7de7210 to
1694e55
Compare
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.
概要
按 libplacebo 实现 Dolby Vision RPU 映射与 HDR tone/gamut 管线:读取 FFmpeg
AV_FRAME_DATA_DOVI_METADATA,完成 polynomial/MMR reshape → 非线性矩阵 → PQ 线性化 → HPE-LMS → IPT tone map(默认 BT.2390)→ 感知色域 LUT → SDR/EDR 输出。取代已关闭的 #130(历史已 squash 为单 commit,并按该 PR review 修正后重新提交)。#133 / #134 的改动已包含在本 PR 内,无需再单独合入。
相对 #130 review 的回应
[P1] Profile 5 不应一律切软解 — 已改
dolby_vision_decode_fallback仅在 MediaCodec / generic AvCodec 上对 Profile 5 回退软件解码;VideoToolbox 与 D3D11VA 保留硬解(FFmpeg CPU 解析 RPU 并 attach 到硬件 AVFrame 的路径与 review 实验一致)。[P2] coef_log2_denom 31/32 被误拒 — 已改
接受 FFmpeg 的 13..=32 范围(
coef_denom > 32才拒绝)。系数用powi浮点缩放,不再因 31/32 拒绝合法元数据。文档与范围 — 已改
docs/dolby-vision.md;删除DOLBY_VISION_IMPROVEMENTS.md。pl_gamut_map_perceptual。图像验证 — 已补
真实样片 + mpv v0.41.0 / libplacebo v7.360.1(
--vo=gpu-next --tone-mapping=bt.2390)同帧对比:FEL 策略调整
不再整帧丢弃 FEL RPU;基层曲线/矩阵/L1 照常映射,不可合成的 residual 通过
Frame::dovi_el_status()与dovi_el_not_composed诊断上报(对齐 libplacebo 对nlq_active的切分)。主要改动
ffmpeg.rs):bounds/alignment 校验、pivot/系数缩放、L1 提取、结构化DoviRejectReason、单次 parse probe。pipeline.rs+ WGSL/MSL/HLSL):reshape、IPT tone map(BT.2390 默认 + spline/BT.2446a/ST 2094-10/Mobius/Reinhard/clip)、感知色域 3D LUT(48×32×256,RGBA16F,后台生成)。luma_stats.rs):CPU luma 测量,区分yuv420p10le/ P010,honor limited range。已知限制(合并不阻塞)
CAMetalLayer.delegate(示例已改)。验证
cargo test -p erika --lib→ 583 passed(本机)cargo fmt --check干净wgpu_decode_png,ERIKA_TEST_RENDER_PASSES=4)vs mpv,见上表main@905d5fc,单 commit9f7870f,28 files / +7686 −226验证边界
CI 全绿仍不覆盖真实 DV 片源的跨后端像素一致性;上表样片对比为 macOS Metal wgpu 离屏路径。Windows D3D11 真机与移动端 MediaCodec 待后续真机验收。
cc #130(原 review:P5 硬解、coef_denom、图像验证)