Skip to content

fix(hdr): 应用解码器颜色元数据 - #94

Merged
qiin2333 merged 1 commit into
masterfrom
codex/fix-avcodec-color-metadata
Jul 29, 2026
Merged

fix(hdr): 应用解码器颜色元数据#94
qiin2333 merged 1 commit into
masterfrom
codex/fix-avcodec-color-metadata

Conversation

@qiin2333

@qiin2333 qiin2333 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

改了啥呀

  • 直接向解码器写入 range、color primaries、transfer characteristics 和 matrix coefficients
  • 记录每个颜色字段的实际写入结果,失败时给出统一告警
  • 移除 OH_MD_KEY_VIDEO_IS_HDR_VIVID 的解码器 Configure 用法,继续依赖码流内 CUVA 元数据触发 HDR Vivid

为啥要改

这些 AVCodec key 在 Harmony SDK 中是导出的 const char* 变量,不是预处理宏。原来的 #ifdef 会把写入逻辑悄悄裁掉——杂鱼预处理判断把真正该工作的 key 挡在门外啦。

另外,最新版 OpenHarmony 将 OH_MD_KEY_VIDEO_IS_HDR_VIVID 定义为媒体文件轨道标记,仅支持 demuxer/muxer;解码器应从保留的 HEVC/AV1 CUVA 元数据识别 Vivid。

影响范围

  • 让客户端请求的 limited/full range、BT.2020、HLG/PQ 和矩阵信息真正进入解码器配置
  • 不修改 NativeWindow、GL 后处理、白点亮度或服务端 CUVA 生成
  • 这是客户端链路硬化,不宣称单独解决当前鸿蒙 V+ 的 Vivid 暗部死黑问题

验证

  • npm run check
  • node hvigorw.js assembleHar --mode module -p module=nativelib@default -p product=default -p buildMode=debug --no-daemon --stacktrace
  • ARM64 与 x86_64 原生 HAR 构建成功
  • llvm-nm -D 确认产物引用四个颜色 metadata key,且不再引用 OH_MD_KEY_VIDEO_IS_HDR_VIVID
  • git diff --check

Summary by CodeRabbit

  • 改进
    • 优化视频解码器对颜色范围、色彩原色、传输特性及矩阵系数等颜色元数据的处理,并增加设置失败提示。
    • 改进 HLG 类型 HDR Vivid 视频的识别与解码,支持依据码流内元数据呈现更准确的 HDR 效果。

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2ea22358-9ba2-416b-b083-2591d9b0c8dd

📥 Commits

Reviewing files that changed from the base of the PR and between 87d0da9 and a69939e.

📒 Files selected for processing (1)
  • nativelib/src/main/cpp/video_decoder.cpp

📝 Walkthrough

Walkthrough

VideoDecoder::Init 无条件设置四项颜色元数据并记录返回结果;任一设置失败时输出告警。HLG HDR Vivid 分支移除显式标记写入,改为依赖码流内 CUVA metadata。

Changes

解码器元数据初始化

Layer / File(s) Summary
颜色元数据设置与 HLG HDR Vivid 处理
nativelib/src/main/cpp/video_decoder.cpp
颜色范围、主色、传输特性和矩阵系数改为无条件设置并记录结果;新增汇总日志和失败告警;HLG 分支不再写入 HDR Vivid 标记。

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题与变更核心一致,明确指向解码器颜色元数据应用修复。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-avcodec-color-metadata

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qiin2333
qiin2333 force-pushed the codex/fix-avcodec-color-metadata branch from 2291af6 to a69939e Compare July 29, 2026 10:37
@qiin2333
qiin2333 marked this pull request as ready for review July 29, 2026 11:08
@qiin2333
qiin2333 merged commit 27e1c6a into master Jul 29, 2026
2 checks passed
@qiin2333
qiin2333 deleted the codex/fix-avcodec-color-metadata branch July 29, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant