Repository navigation
实现 Dolby Vision RPU 映射并完善解码回退 - #2
Closed
1824239290 wants to merge 16 commits into
Closed
1824239290 wants to merge 16 commits into
1824239290 wants to merge 16 commits into
Conversation
Implements Dolby Vision profile 5/8 rendering for software-decoded HEVC, following mpv's approach (libplacebo pl_shader_dovi_reshape): - erika_ffmpeg_sys: expose libavutil/dovi_meta.h to bindgen. - ffmpeg.rs: convert the decoder's per-frame AV_FRAME_DATA_DOVI_METADATA into shader-ready floats (pivots normalized by bl_bit_depth, curve coefficients by 2^-coef_log2_denom, RPU ycc_to_rgb/rgb_to_lms matrices). - pipeline.rs: SourceColorState carries per-frame DoviSourceMetadata (peak from source_max_pq, primaries forced to BT.2020); DoviUniforms packs the reshaping curves into vec4-aligned uniforms, premultiplies the HPE LMS->RGB composite and folds the 1024/1023 signal-offset correction; render graph gains a DoviReshape pass. - Shaders (WGSL/Metal/HLSL): per-component pivot/polynomial/MMR reshaping of the raw full-range base-layer signal, RPU matrix + offsets to PQ-encoded IPT, then LMS->RGB after PQ linearization; range expansion and the YCbCr matrix are bypassed for RPU frames. - VideoFrameDescriptor carries dovi_metadata for hardware-frame paths. FEL (profile 7 residual) is not composed; profiles 4/7 render the base layer reshaping only, matching current mpv without a bound enhancement layer. No C ABI changes.
The MMR extraction loop dereferenced the enumerate index instead of the mutable coefficient slot (E0614 across all CI targets), and several manually formatted blocks deviated from rustfmt. Nested call formatting was also made deterministic where line width sat near the 100-column limit.
WGSL if-expressions are not portable across validators; use a var plus a plain if statement for the packed-luma sample.
- metal layout test expects the appended dovi uniform block (size 3104, dovi at offset 144) - dovi LMS composite golden values recomputed from the RPU default matrix expressed in exact 1/16384 fractions - remaining rustfmt deviations (assert wrapping, let-row split, blank line, copy_nonoverlapping join) applied verbatim from CI output
libplacebo's pl_map_avdovi_metadata unconditionally sets BT.2020/PQ from the RPU because P5/P8 VUI tags are unreliable. Erika's dovi() builder forced primaries and peak but left the transfer untouched, so streams with an unspecified trc decoded the reshaped PQ signal through the sRGB branch. Also sync reference_white_nits to the PQ reference white so the linearization scale stays consistent.
Produces a runnable macOS binary from the fork CI so the Dolby Vision color pipeline can be exercised against real content without a local Rust toolchain.
Hardware decoders (VideoToolbox/D3D11VA/MediaCodec) cannot convey the Dolby Vision RPU, so profile 5 streams rendered with the wrong colors under the default hardware path. Read the container's DOVI configuration record (AV_PKT_DATA_DOVI_CONF) at decoder-open time and switch to the software decoder for profile 5, matching mpv's behavior; the decoder event carries the requested backend plus a fallback reason. Profile 8 stays on hardware since its base layer is HDR10-compatible. Also raise the wgpu_decode_png example's deployment target to 13.0 so the VideoToolbox hwcontext symbols resolve at link time, and add dolby_vision_profile() tests (fixture: None; ERIKA_DV_SAMPLE: Some(5)).
av_stream_get_side_data no longer exists in ffmpeg 8.x; the container's DOVI configuration record lives in AVStream.coded_side_data and is read through av_packet_side_data_get.
The example binary never calls the VideoToolbox hwcontext path that references the version-check helper, so resolve it lazily like the release dylib does instead of failing the executable link.
-Wl,-U only defers resolution and dyld then fails at launch; the __isPlatformVersionAtLeast helper from FFmpeg's VideoToolbox hwcontext must be statically provided by the compiler runtime instead.
- Add comprehensive top-level documentation (docs/dolby-vision.md) - Complete pipeline architecture explanation - Profile 5 vs 8 comparison and decode strategy - Reshaping algorithm details (polynomial and MMR) - Color transform flow and testing instructions - Enhance inline documentation - Add field-level comments to DoviSourceMetadata - Clarify signal offset scaling formula (1024/1023 ratio) - Document uniform buffer size (~3KB, 20% of mobile limits) - Expand test coverage - Add Profile 8 detection test (ERIKA_DV_PROFILE_8_SAMPLE) - Add 3 unit tests for dolby_vision_decode_fallback logic - Verify Profile 5 forces software decode - Verify Profile 8 stays on hardware decode - Improve CI maintainability - Add comment explaining libclang_rt.osx linker workaround - Reference commits acae10f and 3498b8e for context - Add validation comments for bit depth and coefficient ranges These changes enhance documentation, testing, and maintainability without modifying the core Dolby Vision mapping algorithm. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The tests were incorrectly expecting DecoderBackend::AvCodec instead of DecoderBackend::Software. DecoderConfig::software() returns Software variant. - dolby_vision_profile_5_falls_back_to_software_decode: expect Software - dolby_vision_software_decode_stays_software: expect Software This fixes the CI failure on macOS arm64.
Owner
Author
|
该改动已转为向上游 AimesSoft/Erika 提交 PR AimesSoft#130,后续请以上游 PR 为准。 |
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.
概要
为 Erika 增加基于 FFmpeg RPU 元数据的 Dolby Vision 映射路径,按 libplacebo 的处理顺序完成曲线重塑、矩阵变换、PQ 线性化和 HDR 输出,并在无法安全映射时回退到普通 base layer。
主要改动
解码与兼容性策略
验证
测试边界
自动化测试覆盖元数据解析、映射数学、解码回退、ABI 和宿主编译;本 PR 尚未在 CI 中执行真实 Dolby Vision 样片的人工播放验收。