fix(hdr): 按码流自动识别 HDR Vivid - #98
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough本次变更扩展 HDR Vivid 检测范围,并根据码流或输出格式动态设置 NativeWindow HDR 类型。解码器继续设置颜色空间、白点亮度和静态 HDR 元数据。 ChangesHDR 元数据处理
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nativelib/src/main/cpp/video_decoder.cpp`:
- Around line 806-822: Update the video decoder’s output callback to read the
output OH_AVFormat and set the corresponding NativeWindow/Buffer metadata via
OH_NativeWindow_SetMetadataValue for OH_VIDEO_HDR_VIVID, OH_HDR_HLG, or
OH_HDR_HDR10 based on the detected HDR type, rather than only recording
hdrVividDetected_. Ensure each new session resets or overwrites stale Vivid
metadata when no CUVA is detected, so HLG/PQ content cannot inherit the previous
session’s Vivid setting.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2e694c96-7ef7-4575-a2fa-31f6e1b50266
📒 Files selected for processing (2)
nativelib/src/main/cpp/video_decoder.cppnativelib/src/main/cpp/video_decoder.h
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nativelib/src/main/cpp/video_decoder.cpp`:
- Around line 1590-1594: Remove the OH_MD_KEY_VIDEO_IS_HDR_VIVID lookup and
related vividFlag handling from ApplyOutputHdrMetadata(), including the
hdrVividDetected_ update based on the decoder output format. Preserve the
remaining output HDR metadata processing unchanged.
- Around line 1585-1609: Update SetNativeWindowHdrMetadataType to reject
non-OH_VIDEO_HDR_VIVID metadata when hasAppliedHdrMetadataType_ is already true
and the current applied type is OH_VIDEO_HDR_VIVID, while allowing the update
when the session has been reset and hasAppliedHdrMetadataType_ is false. Keep
normal metadata transitions unchanged and ensure the check occurs under the
existing synchronization used for the write.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5cc73e0e-cf68-4a5c-956a-68740c20e2a3
📒 Files selected for processing (2)
nativelib/src/main/cpp/video_decoder.cppnativelib/src/main/cpp/video_decoder.h
改了啥呀
OH_VIDEO_HDR_HDR10或OH_VIDEO_HDR_HLG,把上一会话残留的 Vivid 状态赶走OH_MD_KEY_VIDEO_IS_HDR_VIVIDOH_VIDEO_HDR_VIVID,并在当前会话内保持 Vivid,避免后到的输出格式回调把它降级为啥要改
PQ/HLG 是基础传递函数,Vivid 只由 CUVA 动态元数据决定。把普通 HLG 固定标记成 Vivid 会误判,依赖解码器输出的
OH_MD_KEY_VIDEO_IS_HDR_VIVID也不可靠,因为该字段面向媒体轨道而不是原始码流解码输出。现在新会话先明确覆盖基础 HDR 类型,检测到 CUVA 才升级到 Vivid;这个升级在会话内保持粘滞,下一次会话 reset 后仍能正常覆盖,残留状态这只杂鱼就钻不过来了。
验证
git diff --checkclang++ -std=c++17 -I nativelib/src/main/cpp nativelib/src/test/cpp/hdr_vivid_metadata_scanner_test.cpp nativelib/src/main/cpp/hdr_vivid_metadata_scanner.cpp -o /tmp/moonlight-hdr-vivid-scanner-test/tmp/moonlight-hdr-vivid-scanner-test,输出HDR Vivid metadata scanner tests passednpm run checkJAVA_HOME=/Applications/DevEco-Studio.app/Contents/jbr/Contents/Home DEVECO_SDK_HOME=/Applications/DevEco-Studio.app/Contents/sdk node hvigorw.js assembleApp --mode project -p product=default -p buildMode=debug --no-daemonBUILD SUCCESSFULSummary by CodeRabbit
新功能
改进