fix(hdr): 打通 HEVC/AV1 CUVA HDR Vivid 链路 - #92
Conversation
📝 WalkthroughWalkthroughChangesHDR SEI 处理
Estimated code review effort: 2 (Simple) | ~10 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/moonlight-common-c`:
- Line 1: 将子模块引用 nativelib/src/main/cpp/moonlight-common-c
更新为可公开访问远端中的对应提交;先把所需提交推送到公开仓库,再更新 gitlink,确保 CI 和干净检出环境能够正常拉取。
🪄 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: b4b11305-e120-43c5-8750-4e23347a6104
📒 Files selected for processing (3)
nativelib/src/main/cpp/moonlight-common-cnativelib/src/main/cpp/moonlight_bridge.cppnativelib/src/test/cpp/hdr_vivid_metadata_scanner_test.cpp
| @@ -1 +1 @@ | |||
| Subproject commit e9319eec44f6c866b7c5a2b1fc342f34d3d42612 | |||
| Subproject commit 2b913d47a4d29b0825c3fe748493fd336d80a241 | |||
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
submodule="nativelib/src/main/cpp/moonlight-common-c"
expected="2b913d47a4d29b0825c3fe748493fd336d80a241"
actual="$(git ls-tree HEAD -- "$submodule" | awk '{print $3}')"
test "$actual" = "$expected"
git -C "$submodule" cat-file -e "$expected^{commit}"
git -C "$submodule" grep -n 'CAPABILITY_PRESERVE_HEVC_SEI' "$expected" -- .
git -C "$submodule" show --stat --oneline "$expected"Repository: AlkaidLab/moonlight-harmony
Length of output: 341
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== repo submodule entry =="
git ls-tree -l HEAD -- nativelib/src/main/cpp/moonlight-common-c || true
echo "== submodule config =="
if [ -f .gitmodules ]; then
sed -n '/\[submodule "nativelib\/src\/main\/cpp\/moonlight-common-c"\]/,/^\[/p' .gitmodules
else
sed -n '/\[submodule "moonlight-common-c"\]/,/^\[/p' .gitmodules 2>/dev/null || true
fi
echo "== .git/config relevant refs/remotes =="
git config --get-regexp 'submodule\.nativelib/src/main/cpp/moonlight-common-c|core\.worktree|branch' | sed -n '1,120p' || true
echo "== local presence =="
if [ -e nativelib/src/main/cpp/moonlight-common-c ]; then
echo "exists"
git -C nativelib/src/main/cpp/moonlight-common-c rev-parse --is-inside-work-tree || true
git -C nativelib/src/main/cpp/moonlight-common-c config --get-regexp 'remote|fetch|url' || true
git -C nativelib/src/main/cpp/moonlight-common-c branch --show-current || true
else
echo "missing"
fi
echo "== tracked references to commit in local submodule repo (if present) =="
if [ -e nativelib/src/main/cpp/moonlight-common-c/.git ]; then
cd nativelib/src/main/cpp/moonlight-common-c
git cat-file -e2> /dev/null 2b913d47a4d29b0825c3fe748493fd336d80a241^{commit} || true
git rev-parse --is-inside-work-tree
git status -s
git branch -a --contains 2b913d47a4d29b0825c3fe748493fd336d80a241 2>/dev/null | sed -n '1,20p' || true
for r in $(git remote -v | awk '{print $1}' | sort -u); do
echo "--- remote $r ---"
git ls-remote "$r" 2>/dev/null | grep -E '2b913d47a4d29b0825c3fe748493fd336d80a241' | sed -n '1,20p' || true
done
fiRepository: AlkaidLab/moonlight-harmony
Length of output: 1054
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import subprocess, pathlib, textwrap, hashlib, urllib.request, urllib.error
sha = "2b913d47a4d29b0825c3fe748493fd336d80a241"
print("SHA length:", len(sha), "valid_hex:", all(c in "0123456789abcdef" for c in sha))
print("submodule path:", "nativelib/src/main/cpp/moonlight-common-c")
def fetch(url):
req = urllib.request.Request(url, headers={"User-Agent": "CodeRabbit/verify-submodule-sha"})
try:
resp = urllib.request.urlopen(req, timeout=10)
except urllib.error.HTTPError as e:
raise
return resp.read()
for fmt in ["text", "json"]:
base = "https://api.github.com/repos/LizardByte/moonlight-common-c/git/ref" if fmt == "text" else "https://api.github.com/repos/LizardByte/moonlight-common-c/git/refs"
url = f"{base}/heads/{sha}" if fmt == "text" else f"{base}/{sha[0:2]}/{sha[2:]}"
print(f"\n== trying {fmt}: {url} ==")
try:
data = fetch(url)
text = data.decode("utf-8", "replace")
print(text[:2000])
print("status found")
except urllib.error.HTTPError as e:
print(e.code, e.reason)
print(e.read().decode("utf-8", "replace")[:800])
# Check GitHub raw object without fetching the full commit content too aggressively.
for url in [
f"https://api.github.com/repos/LizardByte/moonlight-common-c/commits/{sha}",
f"https://raw.githubusercontent.com/LizardByte/moonlight-common-c/{sha}/.github/workflows/ci.yml",
f"https://raw.githubusercontent.com/LizardByte/moonlight-common-c/{sha}/platform/android/src/main/cpp/.../CUVA"
]:
print(f"\n== raw probe: {url} ==")
try:
data = urllib.request.urlopen(url, timeout=15)
print("exists", data.status)
except urllib.error.HTTPError as e:
print(e.code, e.reason)
PYRepository: AlkaidLab/moonlight-harmony
Length of output: 2711
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sha="2b913d47a4d29b0825c3fe748493fd336d80a241"
remote="https://github.com/qiin2333/moonlight-common-c.git"
remote_private="$(git config --get submodule.nativelib/src/main/cpp/moonlight-common-c.url || true)"
echo "== configured submodule URL =="
echo "$remote_private"
echo "== git ls-remote from configured submodule remote =="
git ls-remote "$remote_private" "$sha" "$sha^{commit}" 2>&1 | sed -n '1,20p' || true
echo "== git ls-remote from configured ref names containing sha (if any branch/tag) =="
git ls-remote "$remote_private" | grep -E "^[0-9a-f]+[[:space:]]+.*(refs/heads/(mic|master|main)|refs/tags/).*${sha#2b9}" | sed -n '1,20p' || true
echo "== local gitmodules entry =="
sed -n '/\[submodule "nativelib\/src\/main\/cpp\/moonlight-common-c"\]/,/^\[[^]]*]/p' .gitmodules | sed -n '1,24p'Repository: AlkaidLab/moonlight-harmony
Length of output: 638
请提供可公开获取的子模块提交。
nativelib/src/main/cpp/moonlight-common-c 指向 qiin2333/moonlight-common-c 非公开仓库中的 private 提交;CI 或其他干净检出环境无法拉取该 gitlink,合并前需将所需提交推送到可公开访问的子模块仓库远端并更新引用。
🤖 Prompt for 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.
In `@nativelib/src/main/cpp/moonlight-common-c` at line 1, 将子模块引用
nativelib/src/main/cpp/moonlight-common-c 更新为可公开访问远端中的对应提交;先把所需提交推送到公开仓库,再更新
gitlink,确保 CI 和干净检出环境能够正常拉取。
Source: Path instructions
改了啥呀
moonlight-common-c到配套 HEVC 修复: fix(video): preserve HEVC SEI for opted-in renderers qiin2333/moonlight-common-c#15CAPABILITY_PRESERVE_HEVC_SEI,让 CUVA SEI 同时到达硬件解码器和状态扫描器。HDR Vivid。为啥要改
Foundation Sunshine 已经在两条编码路径注入同一份 CUVA T.35 动态元数据:HEVC 使用
seiPayloadArray,AV1 使用obuPayloadArray。客户端原来有两只杂鱼断点:HEVC SEI 在解包层提前被删掉,AV1 虽然完整透传给硬解,但探测器被硬编码成只扫描 HEVC,因此覆盖层永远无法确认 AV1 Vivid。现在链路变为:
Sunshine CUVA SEI/OBU → common-c 完整 decode unit → HarmonyOS AVCodec → HEVC/AV1 元数据扫描 → HDR Vivid 覆盖层状态AV1 解码输入没有被改写,只增加只读扫描;是否实际呈现动态效果仍由设备的 HarmonyOS AV1 HDR Vivid 硬解能力决定。
用户影响
HDR HLG,不会把 HDR10+ 误判为 Vivid。验证
g++ -std=c++17 -Wall -Wextra -Werror nativelib/src/main/cpp/hdr_vivid_metadata_scanner.cpp nativelib/src/test/cpp/hdr_vivid_metadata_scanner_test.cpp -I nativelib/src/main/cpp -o .codex-build/hdr_vivid_metadata_scanner_test.exe.codex-build/hdr_vivid_metadata_scanner_test.exe:HDR Vivid metadata scanner tests passedninja -C C:\Users\mohaha\StudioProjects\moonlight-harmonyos\nativelib\.cxx\default\default\debug\arm64-v8a moonlight_nativelib:arm64 原生库编译并链接成功。git diff --check:通过,仅有工作区 CRLF 转换提示。覆盖用例包括:HEVC prefix/suffix SEI、同一 SEI 中 HDR10+ 后跟 CUVA、AV1 OBU 跨分段、extension header、多字节 LEB128 size、末尾无 size OBU,以及 HEVC/AV1 HDR10+ 排除。
补充:Hvigor 顶层任务仍被现有的
The root node is not yet available for build配置错误阻断,因此使用已有 HarmonyOS arm64 Ninja 构建树完成原生链路验证。设备端 AV1 Vivid 实际渲染仍需在支持 AV1 HDR Vivid 的 HarmonyOS 设备上验收。