Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
Fix NR styles 1/2 color drift and expand picture controls
Veyra Goal Agent33d6685a3a75
diff --git a/README.md b/README.mdindex 74c3264b..94712eae 100644--- a/README.md+++ b/README.md@@ -22,7 +22,7 @@ A Windows enhancement player for videos, images, capture cards and streaming. Su## Highlights-**Local NR controls, 2026-10-05:** each NR layer's **Enhancement delta → Total strength** now reaches 5. **Picture control** defaults off; enable it and select Automatic or Manual. Manual controls cover hue, chroma, highlights, local compression and temporal stability. Automatic control preserves the source's colour direction and limits unsafe local changes; switching modes keeps the manual values. Turning control off preserves the original residual algorithm and strength. Five extrapolates one inference's residual; protection reduces gain in risky pixels, so it cannot promise full gain five with no artifacts on every video. Presets, List/Node sessions, PNGs and video exports share the settings. [Local validation and known limits](docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md); public 2.0.3 assets do not include this feature.+**Local NR controls, 2026-10-05:** each NR layer's **Enhancement delta → Total strength** now reaches 5. **Picture control** defaults off; enable it and select Automatic or Manual. Automatic values now adapt separately to styles 0/1/2, with an amount slider (0 retains raw strength, 1 applies full correction). The nine manual controls cover hue, chroma, neutral tint, source color retention, lightness retention, shadows, highlights, local compression and temporal stability. **Use this style’s automatic values** provides a manual starting point. Switching modes keeps manual values; turning control off preserves the original residual algorithm. Five extrapolates one inference's residual, and protection reduces the corresponding changes; it cannot promise full gain five with no artifacts on every video. Presets, List/Node sessions, PNGs and video exports share the settings. [Local validation and known limits](docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md); public 2.0.3 assets do not include this feature.- **Rebuilt interface:** Home, Cinema, Professional List, Nodes, Colour, Export and Settings; Simplified/Traditional Chinese, English and Japanese.- **Node editing and layered NR:** executable connections, independent NR/colour parameters, separate List/Node configurations, sessions and presets.diff --git a/README_CN.md b/README_CN.mdindex e0423e69..31710824 100644--- a/README_CN.md+++ b/README_CN.md@@ -20,7 +20,7 @@ Windows 视频、图片、采集卡与串流增强工具。在同一处理链组## 2.0.0 重点-**本地 NR 调控,2026-10-05:** 每层 NR 的“增强变化量 → 总变化强度”现在最高为 5。“画面调控”默认关闭,开启后可选自动/手动;手动可调色相保护、色度保护、高光保护、局部压缩和时域稳定。自动按原图约束色偏及过强变化,切换方式保留手动数值;关闭后保留原始残差算法与强度。5 是一次推理结果的残差外推,保护会降低危险像素的局部增益,不能保证所有素材在完整局部增益 5 下无失真。预设、列表/节点会话、PNG 与视频导出共用这些设置。验收与已知限制见[本轮记录](docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md),公开 2.0.3 包尚未包含此功能。+**本地 NR 调控,2026-10-05:** 每层 NR 的“增强变化量 → 总变化强度”最高为 5。“画面调控”默认关闭,开启可选自动/手动。自动分别适配风格 0/1/2,新增力度滑块(0 保留原始强度,1 完整纠偏)。手动共九项:色相、色度、中性色、原图色彩保留、亮度保持、暗部、高光、局部压缩和时域稳定;“采用当前风格的自动参数”可作为手动起点。切换方式保留手动数值,关闭调控保留原始残差算法。5 是一次推理结果的残差外推,保护会降低对应变化量,不能保证所有素材在完整局部增益 5 下无失真。预设、列表/节点会话、PNG 与视频导出共用这些设置。验收与已知限制见[本轮记录](docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md),公开 2.0.3 包尚未包含此功能。- **全新界面**:首页、极简、专业列表、节点、调色、导出和设置重新组织;支持简中、繁中、English、日本語。- **节点编辑与多层 NR**:连线编排处理顺序,NR/调色独立参数;列表与节点各自保存配置、会话和预设。diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex e01c79e2..db27d251 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -745,3 +745,9 @@ safety. `NrResidualComposite.hlsl` and `NrTemporal.hlsl` call that shared helperAutomatic/manual UI, settings persistence and graph controls are Veyra code.Temporal filtering reuses Veyra's already attributed Magpie motion route;no additional neural model or proprietary runtime is copied or modified here.++The style-protection follow-up adds Veyra's source-chromaticity retention,+quantization-aware neutral-tint guard, source-color gamut-ray lightness bound,+independent lightness/shadow controls, style-specific automatic coefficients+and an automatic amount slider. These additions are Veyra code; the upstream+port and public-domain matrix attribution above remain unchanged.diff --git a/docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md b/docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.mdindex 7add5bc1..4b204b85 100644--- a/docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md+++ b/docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md@@ -46,3 +46,41 @@目录:`E:/项目/Veyra/test-packages/nr-strength-protection-20261005/Veyra-2.0.3-nr-controls-NVIDIA-win64-portable/`。同级便携 ZIP、对应源码 ZIP、最终逐文件 manifest 及 `DELIVERY.json` 由 `nr-protection-package.py finalize` 在本地源码提交后生成和核验;最终包摘要以 `DELIVERY.json` 为准(不自引用包 hash)。开工与最终源码 Git bundle 保留在 `archives/nr-strength-protection-20261005/`。运行库/许可证继承已验收的 field-20261005b NVIDIA 包;本轮 export-worker 诊断移到任务 logs,不随包提供。主线、桌面旧工作树、其他工作区和用户配置保留;本功能没有合并、推送或发布。++## 风格 1/2 色偏与调控参数续修(2026-10-05)++用户明确反馈 NVIDIA 原版、总变化强度 5,风格 1/2 有明显色偏,风格 0 较自然,手动只有局部压缩明显。起点为首轮已交付 `9eb3b1cf4431362738081442e3f0e071a19962e5`;tag `checkpoint/pre-nr-style-controls-20261005`,续修前 bundle 已验证,SHA256 `19703EFD383E2B012AF6FFDE0663395CB2276D0A9FCA3D524DD6AE16D2EBF42C`。原包与原 `DELIVERY.json` 不覆盖。++审查和原版 runtime=3 的真实调用确认:三个风格原来都接入同一 shader,并非漏掉风格 1/2。旧自动规则没有分风格的颜色保留约束,灰轴处色相投影减弱,且仅约束绝对 Lab 色度仍会因亮度改变而改变饱和度。原五项多是超过阈值才生效,暂停画面不体现时域稳定。这些是保护策略和可调性缺口,不能称模型风格未接入。++续修保留原模型风格和总强度 5。自动分别设置中性色/原图色彩/亮度/暗部保护,风格 1 为 `1/.9/.25/.55`,风格 2 为 `1/.95/.2/.4`,风格 0 为 `1/0/0/0`(原来五项自动值仍为 1)。保持随当前亮度缩放的源色度而非把图像调成灰色,源色彩射线接近色域上限时约束亮度,避免最终色域映射再次脱色;灰区染色判断使用平滑风险门限,保留 FP16/proxy 的微小量化变化。无新的 NR Evaluate、全局逐帧白平衡/曝光、未来帧或 CPU 像素回读。++手动增加“中性色保护、原图色彩保留、亮度保持、暗部保护”,合计九项,各有适用说明;可显式采用当前风格自动值作为起点。自动力度 0–1,0 保留原始输出且不分配调控时域历史。自动、手动值分别保存。新参数仅非默认时写 PresetStore v30/PresetLibrary v9;旧 v29/v8 手动配置读取时新四项为 0、自动力度为 1,保留其原含义。残差/全栈保护/oracle 根常量统一 40,时域 44;公共 shared-memory settings 与同一个生产 EXE 内导出 worker 一起构建。++### 续修实际验证++下列路径均相对于 `E:/项目/Veyra/`,测试每进程≤300s、构建≤900s,串行正常负载,无压力程序。++| 检查 | 命令、结果与证据 |+|---|---|+| 生产构建 | `nr-protection-build.py style-build1 --styles veyra_qml_ui veyra_preset_library_tests veyra_repair_preset_tests veyra_effect_chain_tests veyra_nr_antiflicker_tests veyra_nr_correction_gpu_tests veyra_repair_shader_tests veyra_nr_temporal_gpu_tests veyra_qml_quick_tests`;修复量化风险后 `style-build2 --styles veyra_qml_ui`,均退出 0;`logs/nr-strength-protection-20261005/style-build*.log`。新增声明对应 `veyra_nr_video_quality_probe` 另构建通过(`style-probe-build.log`),未将其未执行的实卡场景记为通过。仍继承 field-fixes/B 的 libass 与 patched FFmpeg 路径。 |+| 预设、会话与链 | `nr-protection-tests.py style-cpu preset-library preset-legacy effect-chain nr-tiers` 全过;原 v29/v8 和新增 v30/v9,隐藏手动数值、两模式/多层/节点 editor、自动力度 0 的拓扑与自动值转手动等均检查。`logs/nr-strength-protection-20261005/style-cpu/results.json`。 |+| GPU 与时域 | `nr-protection-tests.py style-gpu2 legacy-shader temporal correction correction-fp16` 全过。FP32/FP16 各 45 checks、2048 像素,关调控 0/1/2/5 与冻结旧 shader 逐位一致;自动力度 0、四项独立响应、源色彩比率、亮度/暗部、signed HDR、零残差、全栈保护与既有运动/切镜/reset 检查;两种精度 D3D12 errors/warnings 均 0。`logs/nr-strength-protection-20261005/style-gpu2/`。 |+| 真鼠标 QML | `nr-protection-quick.py style-mouse1`,40 passed/0 failed;新增力度和全部九项滑块真实鼠标响应,模式往返保存值;`logs/nr-strength-protection-20261005/qml-style-mouse1/result.json`。夹具画布 1500 高,覆盖展开后的九行说明;不改生产窗口尺寸。 |+| 原版实际视频/保存/导出 | `nr-protection-ui.py first style-ui1 --styles`,原版风格 2 强度 5,自动值转手动、九项编辑、复制/重置/预设、节点与列表贯通,实际 4K HEVC NVENC 导出 60 帧。随后 `restore style-restore1 --styles` 在第二进程恢复新增参数;`logs/nr-strength-protection-20261005/production-style-*/` 与 export-probe.json。 |+| 不同风格多层 | `nr-protection-ui.py multi style-multi1 --styles` 原版两层强度 5,第一层风格 1 自动、第二层风格 2 手动,真实创建/播放/全栈保护及 PNG 成功;`production-style-multi1/`。 |+| 真实视频三个风格 | `nr-protection-styles.py original-fixed --app <新候选> --media E:/项目/Veyra/tests/hotfix-2.0.0-20261002/media/gta6-1080p30-12s-audio.mp4` 以及 `original-fixed2 --manual` 均通过;原版 runtime=3,三风格 raw/auto、独立四项与自动 0 实际 PNG 输出。第一次新旧视频 run 分别停在 0.8/0.8333s,因此不拿它们计算严格跨版本同帧收益。 |+| 严格同源对照 | `nr-protection-styles.py original-baseline3 --app <首轮包> --media <固定 source.png>` 与 `original-fixed3 --manual --app <新候选> --media <同一 source.png>` 均过;源 PNG SHA256 `1a620d8bdfaaaccb03d139038861156b93399ed2a429e38d586d79e308ccf025` 相同,三个风格的 raw 输出也分别逐位相同。`nr-protection-image-metrics.py` 两次测量后,`nr-protection-style-audit.py` 通过;`logs/nr-strength-protection-20261005/style-picture-comparison.json`。 |+| 字幕与翻译 | `nr-protection-smoke.py style-inherited1 <新候选>`,真实 MKV ASS 和内嵌字体启用通过;`smoke-style-inherited1/result.json`。`scripts/i18n/extract.py --check`:1995 entries,繁中/英文/日文 missing=0,placeholder problems=0。 |++固定输入的源相对平均色彩距离:风格 1 从旧自动 `0.0100369` 降到 `0.00113989`,风格 2 从 `0.0125284` 降到 `0.00101397`。这只是该 SDR 帧的颜色变化数值,不是所有素材的画质评分。四项新手动控制的独立结果不同:原图色彩保留 1 时颜色距离 `0.0009387` 而亮度变化仍 `0.0590955`;亮度保持 1 时亮度变化 `0.0007461` 而颜色变化仍 `0.0178619`;暗部保护 1 时暗部进一步压黑从 `0.0140620` 降至 `0.0024489`;中性色保护 1 时灰区颜色距离从 `0.0230654` 降至 `0.0052643`。同一固定输入下,所有手动项为 0/自动力度为 0 的 PNG 与风格 1 原始强度 5 完全同 hash。++### 续修失败与边界++- `style-gpu` 首次 FP16 的“安全比例细节保留 5”失败,中性色规则把微小量化色差也当染色修复。加入平滑 tint-risk 下界后 `style-gpu2` 两精度全部通过,未放宽原检查阈值。失败日志保留。+- 视频 `original-baseline2` 夹具同 tick 暂停/关闭 NR/seek 的严格位置检查仍读到 0.8s,未取得要求的 0.8333s;没有据此修改播放/seek 引擎。另一次 `original-fixed2` 视频 seek 对照成功。严格跨版本对照改用同一固定 PNG,并审计源图与 raw 输出字节相同;失败不计为通过,不以相邻帧差异冒充纠偏收益。+- 首轮本地 native HDR 的 8 项基线失败、RTX 20/30/40/AMD/真实 HDR/长时运动拖影与主观质量未验边界仍存在。续修重点核验本机 RTX 5070 的 NVIDIA 原版,未替换或修改任何运行库。不宣称模型重造纹理/几何错误可被色彩调控完全修复。++### 续修本地交付++新目录 `E:/项目/Veyra/test-packages/nr-strength-protection-20261005/Veyra-2.0.3-nr-controls2-NVIDIA-win64-portable/`,同级新便携 ZIP 和源码 ZIP,`DELIVERY-styles2.json` 记录最终源码提交、逐文件清单和包 hash;续修源码 bundle 在 `archives/nr-strength-protection-20261005/style-controls/`。最终以 `nr-protection-package.py finalize --styles` 核验、生成,不覆盖首轮产物。仍无 merge/push/Release。diff --git a/docs/NR_STRENGTH_PROTECTION_PLAN_2026-10-05.md b/docs/NR_STRENGTH_PROTECTION_PLAN_2026-10-05.mdindex f39eeab6..863cd9f2 100644--- a/docs/NR_STRENGTH_PROTECTION_PLAN_2026-10-05.md+++ b/docs/NR_STRENGTH_PROTECTION_PLAN_2026-10-05.md@@ -29,3 +29,9 @@- 已建隔离工作树、tag 与已验证源码 bundle。- README 范围包含中英文入口 `README.md`、`README_CN.md`、`README_EN.md`;仅补充本地功能状态及使用方法,已同步本轮 guard 白名单,不改历史基线。- 实施与验收记录:`docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md`。++## 真人反馈续修:风格 1/2 色偏与手动参数(2026-10-05)++用户在首轮候选 `9eb3b1c` 反馈 NVIDIA 原版、强度 5,风格 1/2 色偏比风格 0 明显;需要更丰富且可见生效的调控参数。继续同一隔离分支,首轮完整包不覆盖;存档 tag `checkpoint/pre-nr-style-controls-20261005`。三个风格当前都调用同一纠偏 shader,接近灰轴的色相保护与固定色度预算存在遗漏风险,先以原版 runtime=3 做同帧 source/raw/auto 对照再决定自动策略。新增参数必须具有独立作用、真实 GPU 响应与列表/节点/预设/会话/导出贯通;旧 v29/v8 的五项手动配置可读,新增手动参数默认关闭以保持旧配置含义。沿用本方案文件范围与不可变 guard,不改 DLL、main、其他分支、发布包。++续修合同:自动按模型风格分别选择保护系数,不替换模型风格、不降低保存的总强度 5。新增中性色保护、原图色彩保留(保持亮度变化后的源色相/饱和度)、亮度保持和暗部保护;手动共九项,明确各项适用条件。自动力度 0–1 保存,0 无时域历史且保留原始残差,非零力度可实时调整。手动可显式采用当前风格的自动数值(含已选力度),自动/手动正常切换保留各自保存值。v29/v8 原五项手动配置读取时新字段为 0、自动力度为 1;仅新增字段非默认才写 v30/v9。新完整本地候选 `Veyra-2.0.3-nr-controls2-NVIDIA-win64-portable`;来源与运行库沿用,重验 libass 和实际 NVENC。续修前 bundle `archives/nr-strength-protection-20261005/style-controls/source-before.bundle`,SHA256 `19703EFD383E2B012AF6FFDE0663395CB2276D0A9FCA3D524DD6AE16D2EBF42C`。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex f5b14390..2bff71b2 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,13 @@# Veyra 工作记录+## 2026-10-05 NR 风格 1/2 色偏与调控参数续修++用户反馈原版 NR 强度 5 的风格 1/2 色偏较大、旧手动控制主要局部压缩明显;接续已验首轮 `9eb3b1c`,原包保留。tag `checkpoint/pre-nr-style-controls-20261005` 与续修前 bundle `E:/项目/Veyra/archives/nr-strength-protection-20261005/style-controls/source-before.bundle`(SHA256 `19703EFD383E2B012AF6FFDE0663395CB2276D0A9FCA3D524DD6AE16D2EBF42C`)已核验。三个风格原本均已接入,问题是共用规则遗漏低色度染色及亮度变化后的饱和度,已分别设置自动参数。++新增中性色保护、原图色彩保留、亮度保持、暗部保护,手动共九项;自动力度 0–1 和采用当前风格自动值按钮。旧手动 v29/v8 保持含义,只有新增参数非默认才写 v30/v9;原始强度 5、关调控和自动 0 的输出保留。已完成生产构建、四组 CPU、FP32/FP16 各 45 项 GPU、时域回归、40 项真实鼠标 QML、原版三风格严格同图及每项独立响应、两层风格 1/2 与全栈保护、预设/会话第二进程恢复、4K HEVC NVENC 60 帧和真实 libass 字幕。失败(FP16 量化误判、视频夹具 seek 位置不一致)、修复、所有命令与证据见 `docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md` 续修段,不将单帧颜色距离冒充全内容画质/闪烁验收。++本轮产物在 `E:/项目/Veyra/{build,tests,logs,tmp,test-packages,archives}/nr-strength-protection-20261005/`,新候选 `Veyra-2.0.3-nr-controls2-NVIDIA-win64-portable`,续修归档在 `archives/.../style-controls`。继承原组件、patched FFmpeg 和 Claude libass;不改 DLL、不制造压力负载、不改其他工作树、main 或用户配置,无新 merge/push/Release。新交付摘要见 `test-packages/.../DELIVERY-styles2.json`,旧摘要不覆盖。+## 2026-10-05 NR 强度 5 与自动/手动调控开工用户明确授权本功能实施。已从本地 main `de18fc4` 建 `codex/nr-strength-protection-20261005`,工作树 `E:/项目/Veyra/worktrees/nr-strength-protection-20261005`;开工 tag 和已验证 `source-before.bundle` 在 `E:/项目/Veyra/archives/nr-strength-protection-20261005`。方案 `docs/NR_STRENGTH_PROTECTION_PLAN_2026-10-05.md`;独立不可变 `start.json` SHA256 `909bdde5eb460e4b69c5548cc5e504c90d8dbd7e8001e2e47dfe9260d60fd46e`。`py -3.11 -B scripts/acceptance/nr-protection-control.py guard` 通过,其他工作树 HEAD/status 不变。全部新产物按用途写入 E 盘同任务目录;禁止压力测试、不换运行库、不合并/推送/发布。此条仅记录开工,验收结果待实际执行。diff --git a/i18n/catalog.json b/i18n/catalog.jsonindex 3dc01241..7225d933 100644--- a/i18n/catalog.json+++ b/i18n/catalog.json@@ -434,6 +434,13 @@"en": "0 = use the selected format; a device that returns another frame rate reports an error instead of frames being dropped silently","ja": "0 = 選択したフォーマットのまま。デバイスが別のフレームレートを返した場合はエラーになり、黙ってフレームを捨てることはしません"},+ {+ "zh": "0 保留原始变化;1 按当前风格完整纠偏",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "0 保留原始變化;1 按目前風格完整糾偏",+ "en": "0 retains raw changes; 1 applies this style’s full correction",+ "ja": "0 は元の変化を保持、1 は現在のスタイルの補正を完全に適用"+ },{"zh": "1080p · 默认","src": "qml/NrLayerEditor.qml",@@ -1988,6 +1995,13 @@"en": "medium latency","ja": "中遅延"},+ {+ "zh": "中性色保护",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "中性色保護",+ "en": "Neutral color protection",+ "ja": "無彩色保護"+ },{"zh": "中灰","src": "qml/NodePage.qml",@@ -2380,6 +2394,13 @@"en": "Brightness change","ja": "明るさの変化"},+ {+ "zh": "亮度保持",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "亮度保持",+ "en": "Lightness retention",+ "ja": "明度を保持"+ },{"zh": "仅美乐威 Pro Capture(PCIe 内置卡)可用;USB Capture 系列不支持","src": "qml/DialogHost.qml",@@ -2632,6 +2653,20 @@"en": "Keep all","ja": "すべて保持"},+ {+ "zh": "保留原图色相与饱和度;1 为完全保留色彩",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "保留原圖色相與飽和度;1 為完全保留色彩",+ "en": "Retain source hue and saturation; 1 fully retains color",+ "ja": "元の色相と彩度を保持。1 で色を完全に保持します"+ },+ {+ "zh": "保留原图色相;没有色相偏移时变化较小",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "保留原圖色相;沒有色相偏移時變化較小",+ "en": "Retain source hue; little change when hue already matches",+ "ja": "元の色相を保持。色相ずれがない場合は変化が小さくなります"+ },{"zh": "信号","src": "qml/ProPage.qml",@@ -2866,7 +2901,7 @@},{"zh": "关闭时保留原始变化量,最高 5",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "關閉時保留原始變化量,最高 5","en": "Off preserves the original residual gain up to 5","ja": "オフでは元の変化量を保持(最大 5)"@@ -3011,6 +3046,13 @@"en": "Sets the output resolution","ja": "出力解像度を決めます"},+ {+ "zh": "减少 NR 明暗改动;1 为保留原图亮度",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "減少 NR 明暗改動;1 為保留原圖亮度",+ "en": "Reduce NR lightness changes; 1 retains source lightness",+ "ja": "NR の明暗変化を減らします。1 で元の明度を保持します"+ },{"zh": "减少动画","src": "qml/SettingsPage.qml",@@ -3025,6 +3067,13 @@"en": "Less queuing; no claim of lower latency","ja": "キューを減らします。遅延が下がるとは限りません"},+ {+ "zh": "减少暗部被进一步压黑,保留提亮细节",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "減少暗部被進一步壓黑,保留提亮細節",+ "en": "Reduce further shadow darkening while retaining brighter detail",+ "ja": "暗部のさらなる黒つぶれを抑え、明るくなる細部は保持します"+ },{"zh": "减少软件排队;屏幕延迟需要实测","src": "qml/ProPage.qml",@@ -3480,6 +3529,13 @@"en": "Compressed capture uses the stream's color information; for manual color and range choose a native capture format.","ja": "圧縮キャプチャーはストリームの色情報を使います。手動の色や範囲を使うにはネイティブのキャプチャーフォーマットを選んでください。"},+ {+ "zh": "原图色彩保留",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "原圖色彩保留",+ "en": "Source color retention",+ "ja": "元の色を保持"+ },{"zh": "原始 = 一个输出像素对一个屏幕像素","src": "qml/ProPage.qml",@@ -3711,6 +3767,13 @@"en": "Removes only this host from this PC; you will need to pair again later","ja": "この PC に保存したこのホストだけを削除します。次回は再ペアリングが必要です"},+ {+ "zh": "只压缩向白色溢出的变化,保留高光回暗",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "只壓縮向白色溢出的變化,保留高光回暗",+ "en": "Compress changes toward blown whites; retain highlight darkening",+ "ja": "白飛びする変化だけを圧縮し、ハイライトの減光は保持します"+ },{"zh": "只有节点模式使用编辑连接","src": "src/engine/EffectChain.cpp",@@ -3802,6 +3865,13 @@"en": "A preset with this name already exists","ja": "同じ名前のプリセットがすでにあります"},+ {+ "zh": "同时软化过大的亮度和颜色变化",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "同時柔化過大的亮度和顏色變化",+ "en": "Soften excessive lightness and color changes together",+ "ja": "過大な明度と色の変化を同時に抑えます"+ },{"zh": "名称会显示在极简模式和导出页的预设菜单里","src": "qml/DialogHost.qml",@@ -5246,7 +5316,7 @@},{"zh": "局部压缩",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "局部壓縮","en": "Local compression","ja": "局所圧縮"@@ -5890,7 +5960,7 @@},{"zh": "开启调控",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "開啟調控","en": "Enable correction","ja": "調整を有効化"@@ -6658,6 +6728,13 @@"en": "Use this PC's controller as a controller on the console","ja": "この PC のコントローラーを本体のコントローラーとして使う"},+ {+ "zh": "抑制白墙、云和灰色区域的额外染色",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "抑制白牆、雲和灰色區域的額外染色",+ "en": "Suppress added tint on white walls, clouds and gray areas",+ "ja": "白い壁、雲、灰色領域への余計な着色を抑えます"+ },{"zh": "抗闪烁档位","src": "qml/NrLayerEditor.qml",@@ -6714,13 +6791,6 @@"en": "Hold for original","ja": "押してオリジナル"},- {- "zh": "按原图约束色偏、高光和过强变化;风险区域会降低局部变化量。时域稳定复用光流,快速运动或切镜时拒绝历史。切换自动/手动保留手动数值。",- "src": "qml/Veyra/NrLayerEditor.qml",- "zh-TW": "按原圖約束色偏、高光和過強變化;風險區域會降低局部變化量。時域穩定重用光流,快速運動或切鏡時拒絕歷史。切換自動/手動保留手動數值。",- "en": "Uses the original image to constrain hue shifts, highlights and excessive changes. Risky regions receive less gain. Temporal stability reuses optical flow and rejects history during fast motion or cuts. Switching Auto/Manual retains manual values.",- "ja": "元画像を基準に色相ずれ、ハイライト、過剰な変化を抑えます。問題のある領域では局所的に強度を下げます。時間方向の安定化は光学フローを再利用し、速い動きやカットでは履歴を破棄します。自動/手動の切り替え後も手動値を保持します。"- },{"zh": "按键可在 设置 → 快捷键 里改","src": "qml/ProPage.qml",@@ -6855,6 +6925,13 @@"en": "Playback speed","ja": "再生速度"},+ {+ "zh": "播放时减闪;暂停单帧不体现时域效果",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "播放時減閃;暫停單幀不體現時域效果",+ "en": "Reduce flicker during playback; a paused frame does not show temporal effects",+ "ja": "再生時のちらつきを抑えます。一時停止の1フレームでは時間的効果は見えません"+ },{"zh": "播放条已显示","src": "qml/Main.qml",@@ -7326,7 +7403,7 @@},{"zh": "时域稳定",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "時域穩定","en": "Temporal stability","ja": "時間方向の安定化"@@ -7611,6 +7688,13 @@"en": "Darkening change","ja": "暗くなる変化"},+ {+ "zh": "暗部保护",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "暗部保護",+ "en": "Shadow protection",+ "ja": "暗部保護"+ },{"zh": "曝光(EV)","src": "src/ui/QmlPlayerBridge.cpp",@@ -9111,14 +9195,14 @@},{"zh": "画面调控",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "畫面調控","en": "Image correction","ja": "画質調整"},{"zh": "画面调控已接管时域稳定;关闭调控后恢复此设置",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "畫面調控已接管時域穩定;關閉調控後恢復此設定","en": "Image correction controls temporal stability; this setting returns when correction is off","ja": "画質調整が時間方向の安定化を制御中。オフにするとこの設定に戻ります。"@@ -9970,6 +10054,13 @@"en": "Auto estimate: applies to live capture card / PS5 input","ja": "自動推定:キャプチャーカード / PS5 のライブ入力時に有効"},+ {+ "zh": "自动参数分别适配风格 0/1/2。手动可独立保留颜色、亮度和暗部;保护会降低对应变化量。时域稳定复用光流,切换方式保留手动数值。",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "自動參數分別適配風格 0/1/2。手動可獨立保留顏色、亮度和暗部;保護會降低對應變化量。時域穩定重用光流,切換方式保留手動數值。",+ "en": "Automatic values are tuned for styles 0/1/2. Manual controls independently retain color, lightness and shadows, reducing the corresponding changes. Temporal stability uses optical flow; switching modes preserves manual values.",+ "ja": "スタイル 0/1/2 ごとに自動値を調整します。手動では色、明度、暗部を個別に保持し、対応する変化を抑えられます。時間的安定化はオプティカルフローを使い、モードを切り替えても手動値を保持します。"+ },{"zh": "自动对齐","src": "qml/DialogHost.qml",@@ -10005,6 +10096,13 @@"en": "Detect content pacing automatically","ja": "コンテンツのペーシングを自動判別"},+ {+ "zh": "自动调控力度",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "自動調控力度",+ "en": "Automatic control amount",+ "ja": "自動調整の強度"+ },{"zh": "自动遮罩 · 实验","src": "qml/NrLayerEditor.qml",@@ -10119,7 +10217,7 @@},{"zh": "色度保护",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "色度保護","en": "Chroma protection","ja": "彩度保護"@@ -10231,7 +10329,7 @@},{"zh": "色相保护",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "色相保護","en": "Hue protection","ja": "色相保護"@@ -11197,7 +11295,7 @@},{"zh": "调控方式",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "調控方式","en": "Correction mode","ja": "調整モード"@@ -11496,6 +11594,13 @@"en": "Software decoding","ja": "ソフトウェアデコード"},+ {+ "zh": "软化过量色度变化;小幅变化保留",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "柔化過量色度變化;小幅變化保留",+ "en": "Soften excessive chroma changes; retain small changes",+ "ja": "過剰な色度変化を抑え、小さな変化は保持します"+ },{"zh": "软解","src": "qml/SettingsPage.qml",@@ -12238,6 +12343,13 @@"en": "Sampling","ja": "サンプリング中"},+ {+ "zh": "采用当前风格的自动参数",+ "src": "qml/NrLayerEditor.qml",+ "zh-TW": "採用目前風格的自動參數",+ "en": "Use this style’s automatic values",+ "ja": "現在のスタイルの自動値を使う"+ },{"zh": "采用源时间戳","src": "qml/NodePage.qml",@@ -13563,7 +13675,7 @@},{"zh": "高光保护",- "src": "qml/Veyra/NrLayerEditor.qml",+ "src": "qml/NrLayerEditor.qml","zh-TW": "高光保護","en": "Highlight protection","ja": "ハイライト保護"diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.hindex 1ecfa8ad..21cf05eb 100644--- a/include/veyra/engine/EnhancementSettings.h+++ b/include/veyra/engine/EnhancementSettings.h@@ -128,17 +128,35 @@ struct NrCorrectionSettings {bool enabled=false,automatic=true;// Manual values survive switching automatic control on and off.float hue=1,chroma=.75f,highlight=1,compression=.75f,stability=.8f;+ // New manual protections default to zero so schema29/schema8 keep their+ // original five-control meaning. Auto presets are explicit per style.+ float neutral=0,colorKeep=0,lumaKeep=0,shadow=0,autoAmount=1;bool operator==(const NrCorrectionSettings&) const = default;bool valid() const {- for(float v:{hue,chroma,highlight,compression,stability})+ for(float v:{hue,chroma,highlight,compression,stability,neutral,colorKeep,lumaKeep,shadow,autoAmount})if(!std::isfinite(v)||v<0||v>1)return false;return true;}- bool usesHistory() const {return enabled&&(automatic||stability>0);}- std::array<float,8> constants(bool hdr=false) const {- return {enabled?1.f:0.f,automatic?1.f:hue,automatic?1.f:chroma,- automatic?1.f:highlight,automatic?1.f:compression,automatic?1.f:stability,- automatic?1.f:0.f,hdr?1.f:0.f};+ bool usesHistory() const {return enabled&&(automatic?autoAmount>0:stability>0);}+ bool extendedControls() const {return neutral!=0||colorKeep!=0||lumaKeep!=0||shadow!=0||autoAmount!=1;}+ static std::array<float,9> automaticValues(int32_t style) {+ // Style 1 changes contrast/neutral saturation more; style 2 leaves+ // larger colored-area drift. Preserve source chromaticity separately+ // from texture/lightness; never replace the requested model style.+ if(style==1)return {1,1,1,1,1,1,.9f,.25f,.55f};+ if(style==2)return {1,1,1,1,1,1,.95f,.2f,.4f};+ return {1,1,1,1,1,1,0,0,0};+ }+ void useAutomaticValues(int32_t style) {+ auto v=automaticValues(style);for(auto& value:v)value*=autoAmount;+ hue=v[0];chroma=v[1];highlight=v[2];compression=v[3];stability=v[4];+ neutral=v[5];colorKeep=v[6];lumaKeep=v[7];shadow=v[8];automatic=false;+ }+ std::array<float,16> constants(bool hdr=false,int32_t style=0) const {+ auto v=automatic?automaticValues(style):std::array<float,9>{hue,chroma,highlight,compression,stability,neutral,colorKeep,lumaKeep,shadow};+ if(automatic)for(auto& value:v)value*=autoAmount;+ return {enabled?1.f:0.f,v[0],v[1],v[2],v[3],v[4],automatic?1.f:0.f,hdr?1.f:0.f,+ v[5],v[6],v[7],v[8],0,0,0,0};}};struct ResidualSettings {diff --git a/include/veyra/engine/NrCorrectionCodec.h b/include/veyra/engine/NrCorrectionCodec.hindex e77db096..76065993 100644--- a/include/veyra/engine/NrCorrectionCodec.h+++ b/include/veyra/engine/NrCorrectionCodec.h@@ -5,14 +5,18 @@namespace veyra::engine {// Appended only in the new preset schema; legacy files retain default/off.-inline void writeNrCorrection(std::ostream& out,const NrCorrectionSettings& c){+inline void writeNrCorrection(std::ostream& out,const NrCorrectionSettings& c,bool extended=false){out<<int(c.enabled)<<' '<<int(c.automatic)<<' '<<c.hue<<' '<<c.chroma<<' '<<c.highlight<<' '<<c.compression<<' '<<c.stability;+ if(extended)out<<' '<<c.neutral<<' '<<c.colorKeep<<' '<<c.lumaKeep<<' '<<c.shadow<<' '<<c.autoAmount;}-inline bool readNrCorrection(std::istream& in,NrCorrectionSettings& c){+inline bool readNrCorrection(std::istream& in,NrCorrectionSettings& c,bool extended=false){+ c={};int enabled,automatic;if(!(in>>enabled>>automatic>>c.hue>>c.chroma>>c.highlight>>c.compression>>c.stability)||- enabled<0||enabled>1||automatic<0||automatic>1||!c.valid())return false;+ enabled<0||enabled>1||automatic<0||automatic>1)return false;+ if(extended&&!(in>>c.neutral>>c.colorKeep>>c.lumaKeep>>c.shadow>>c.autoAmount))return false;+ if(!c.valid())return false;c.enabled=enabled!=0;c.automatic=automatic!=0;return true;}}diff --git a/qml/Veyra/NrLayerEditor.qml b/qml/Veyra/NrLayerEditor.qmlindex 9ac2a6ca..cd3a42c4 100644--- a/qml/Veyra/NrLayerEditor.qml+++ b/qml/Veyra/NrLayerEditor.qml@@ -43,6 +43,7 @@ ColumnLayout {required property double amountsignal edited(double amount)label: spec.label+ hint: spec.hint ?? ""value: amount.toFixed(2)VSlider {objectName: "nr-" + valueRow.spec.key@@ -221,7 +222,7 @@ ColumnLayout {VSubGroup {objectName: "nr-correction-group"Layout.fillWidth: true- label: qsTr("画面调控"); count: editor.layerData.correctionEnabled ? (editor.layerData.correctionAuto ? 2 : 7) : 1+ label: qsTr("画面调控"); count: editor.layerData.correctionEnabled ? (editor.layerData.correctionAuto ? 3 : 12) : 1VRow {label: qsTr("开启调控")hint: qsTr("关闭时保留原始变化量,最高 5")@@ -242,11 +243,15 @@ ColumnLayout {}}Repeater {- model: [{key:"hueProtection",label:qsTr("色相保护"),min:0,max:1,defaultValue:1},- {key:"chromaProtection",label:qsTr("色度保护"),min:0,max:1,defaultValue:0.75},- {key:"highlightProtection",label:qsTr("高光保护"),min:0,max:1,defaultValue:1},- {key:"localCompression",label:qsTr("局部压缩"),min:0,max:1,defaultValue:0.75},- {key:"temporalStability",label:qsTr("时域稳定"),min:0,max:1,defaultValue:0.8}]+ model: [{key:"hueProtection",label:qsTr("色相保护"),hint:qsTr("保留原图色相;没有色相偏移时变化较小"),min:0,max:1,defaultValue:1},+ {key:"chromaProtection",label:qsTr("色度保护"),hint:qsTr("软化过量色度变化;小幅变化保留"),min:0,max:1,defaultValue:0.75},+ {key:"neutralProtection",label:qsTr("中性色保护"),hint:qsTr("抑制白墙、云和灰色区域的额外染色"),min:0,max:1,defaultValue:0},+ {key:"colorRetention",label:qsTr("原图色彩保留"),hint:qsTr("保留原图色相与饱和度;1 为完全保留色彩"),min:0,max:1,defaultValue:0},+ {key:"luminanceRetention",label:qsTr("亮度保持"),hint:qsTr("减少 NR 明暗改动;1 为保留原图亮度"),min:0,max:1,defaultValue:0},+ {key:"shadowProtection",label:qsTr("暗部保护"),hint:qsTr("减少暗部被进一步压黑,保留提亮细节"),min:0,max:1,defaultValue:0},+ {key:"highlightProtection",label:qsTr("高光保护"),hint:qsTr("只压缩向白色溢出的变化,保留高光回暗"),min:0,max:1,defaultValue:1},+ {key:"localCompression",label:qsTr("局部压缩"),hint:qsTr("同时软化过大的亮度和颜色变化"),min:0,max:1,defaultValue:0.75},+ {key:"temporalStability",label:qsTr("时域稳定"),hint:qsTr("播放时减闪;暂停单帧不体现时域效果"),min:0,max:1,defaultValue:0.8}]delegate: NrValueRow {required property var modelDatavisible: (editor.layerData.correctionEnabled ?? false) && !(editor.layerData.correctionAuto ?? true)@@ -254,10 +259,22 @@ ColumnLayout {onEdited: amount => editor.edited(editor.layerData.index,modelData.key,amount)}}+ NrValueRow {+ visible: (editor.layerData.correctionEnabled ?? false) && (editor.layerData.correctionAuto ?? true)+ spec: ({key:"correctionAmount",label:qsTr("自动调控力度"),hint:qsTr("0 保留原始变化;1 按当前风格完整纠偏"),min:0,max:1,defaultValue:1})+ amount: editor.layerData.correctionAmount ?? 1+ onEdited: amount => editor.edited(editor.layerData.index,"correctionAmount",amount)+ }+ VButton {+ objectName: "nr-use-auto-defaults"+ visible: (editor.layerData.correctionEnabled ?? false) && !(editor.layerData.correctionAuto ?? true)+ text: qsTr("采用当前风格的自动参数"); ghost: true+ onClicked: editor.edited(editor.layerData.index,"correctionUseAuto",1)+ }Text {Layout.fillWidth: truevisible: editor.layerData.correctionEnabled ?? false- text: qsTr("按原图约束色偏、高光和过强变化;风险区域会降低局部变化量。时域稳定复用光流,快速运动或切镜时拒绝历史。切换自动/手动保留手动数值。")+ text: qsTr("自动参数分别适配风格 0/1/2。手动可独立保留颜色、亮度和暗部;保护会降低对应变化量。时域稳定复用光流,切换方式保留手动数值。")color: Theme.t3; font.pixelSize: 11; wrapMode: Text.WordWrap}}diff --git a/scripts/acceptance/nr-protection-build.py b/scripts/acceptance/nr-protection-build.pyindex 50af6330..a2384f62 100644--- a/scripts/acceptance/nr-protection-build.py+++ b/scripts/acceptance/nr-protection-build.py@@ -8,6 +8,9 @@ ROOT = Path(__file__).resolve().parents[2]BASE = Path('E:/项目/Veyra')TASK = 'nr-strength-protection-20261005'label = sys.argv[1]+display='2.0.3-nr-controls'+if '--styles' in sys.argv:+ sys.argv.remove('--styles');display='2.0.3-nr-controls2'assert label.replace('-', '').isalnum()BUILD = BASE / 'build' / TASKTMP = BASE / 'tmp' / TASK / 'build'@@ -34,7 +37,7 @@ for line in cache.read_text(encoding='utf-8').splitlines():if key == 'VEYRA_LIBASS_ROOT':assert (Path(value) / 'include/ass/ass.h').is_file(), 'Accepted libass SDK is unavailable'settings.append(f'set({key} [[{value}]] CACHE {kind} "Audited field-fix dependency" FORCE)')-settings.append('set(VEYRA_DISPLAY_VERSION [[2.0.3-nr-controls]] CACHE STRING "Local NR controls candidate" FORCE)')+settings.append(f'set(VEYRA_DISPLAY_VERSION [[{display}]] CACHE STRING "Local NR controls candidate" FORCE)')(TMP / 'dependencies.cmake').write_text('\n'.join(settings), encoding='utf-8')targets = sys.argv[2:] or ['veyra_qml_ui']assert all(t.replace('_', '').isalnum() for t in targets)diff --git a/scripts/acceptance/nr-protection-image-metrics.py b/scripts/acceptance/nr-protection-image-metrics.pynew file mode 100644index 00000000..347d253a--- /dev/null+++ b/scripts/acceptance/nr-protection-image-metrics.py@@ -0,0 +1,32 @@+"""SDR screenshot measurements; color change is not a subjective quality score."""+from pathlib import Path+import json,sys+import numpy as np+from PIL import Image+folder=Path(sys.argv[1]);output=Path(sys.argv[2])+BASE=Path('E:/项目/Veyra')+assert folder.resolve().is_relative_to(BASE.resolve()) and output.resolve().is_relative_to(BASE.resolve())+def lab(path):+ rgb=np.asarray(Image.open(path).convert('RGB'),dtype=np.float64)/255+ linear=np.where(rgb<=.04045,rgb/12.92,((rgb+.055)/1.055)**2.4)+ [email protected]([[.4122214708,.2119034982,.0883024619],[.5363325363,.6806995451,.2817188376],[.0514459929,.1073969566,.6299787005]])+ return np.cbrt(lms)@np.array([[.2104542553,1.9779984951,.0259040371],[.7936177850,-2.4285922050,.7827717662],[-.0040720468,.4505937099,-.8086757660]])+source=lab(folder/'source.png');o=source[...,0];c=np.linalg.norm(source[...,1:],axis=-1)+neutral=(c/np.maximum(o,.03)<.08)&(o>.08)&(o<.96)+colored=(c/np.maximum(o,.03)>=.08)&(o>.08)&(o<.96)+stats={}+for path in sorted(folder.glob('*.png')):+ if path.stem=='source':continue+ frame=lab(path);assert frame.shape==source.shape+ # Chroma is rebased to current lightness: ordinary brightening should not+ # be falsely counted as a hue/saturation change of the source RGB ratios.+ chromaError=np.linalg.norm(frame[...,1:]-source[...,1:]*(frame[...,0]/np.maximum(o,.03))[...,None],axis=-1)+ stats[path.stem]={'meanColorChange':float(chromaError.mean()),'neutralColorChange':float(chromaError[neutral].mean()),+ 'coloredColorChange':float(chromaError[colored].mean()),'p95ColorChange':float(np.quantile(chromaError,.95)),+ 'meanLightnessChange':float(np.abs(frame[...,0]-o).mean()),'meanLightness':float(frame[...,0].mean()),+ 'shadowDarkening':float(np.maximum(o-frame[...,0],0)[o<.35].mean()),+ 'lightnessEdgeEnergy':float(np.abs(np.diff(frame[...,0],axis=0)).mean()+np.abs(np.diff(frame[...,0],axis=1)).mean())}+result={'source':str(folder/'source.png'),'neutralPixels':int(neutral.sum()),'coloredPixels':int(colored.sum()),'results':stats,+ 'interpretation':'Source-relative color/brightness changes on one SDR frame; not a subjective quality or flicker score.'}+output.write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf8')+print(json.dumps(result,ensure_ascii=False,indent=2))diff --git a/scripts/acceptance/nr-protection-package.py b/scripts/acceptance/nr-protection-package.pyindex 64df319b..4b59c024 100644--- a/scripts/acceptance/nr-protection-package.py+++ b/scripts/acceptance/nr-protection-package.py@@ -5,8 +5,13 @@ ROOT=Path(__file__).resolve().parents[2]BASE=Path('E:/项目/Veyra');TASK='nr-strength-protection-20261005'SOURCE=BASE/'test-packages/field-fixes-20261005/Veyra-2.0.3-field-20261005b-NVIDIA-win64-portable'PARENT=BASE/'test-packages'/TASK-APP=PARENT/'Veyra-2.0.3-nr-controls-NVIDIA-win64-portable'+styles='--styles' in sys.argv+if styles:sys.argv.remove('--styles')+version='2.0.3-nr-controls2' if styles else '2.0.3-nr-controls'+APP=PARENT/f'Veyra-{version}-NVIDIA-win64-portable'BUILD=BASE/'build'/TASK;LOG=BASE/'logs'/TASK;ARCHIVE=BASE/'archives'/TASK+if styles:ARCHIVE=ARCHIVE/'style-controls'+receiptLabel='styles2' if styles else ''mode=sys.argv[1] if len(sys.argv)>1 else 'stage';assert mode in ('stage','finalize')subprocess.run([sys.executable,'-B',str(ROOT/'scripts/acceptance/nr-protection-control.py'),'guard'],check=True)def sha(p):@@ -26,15 +31,22 @@ else:assert APP.is_dir() and not git('status','--porcelain'),'Commit the validated source before finalizing'assert sha(APP/'veyra_qml_ui.exe')==sha(BUILD/'veyra_qml_ui.exe')assert sha(APP/'qml/Veyra/Main.qml')==sha(ROOT/'qml/Veyra/Main.qml'),'Remove test injection before delivery'- for suite in ('final-cpu','final-gpu'):+ for suite in (('style-cpu','style-gpu2') if styles else ('final-cpu','final-gpu')):checks=json.loads((LOG/suite/'results.json').read_text(encoding='utf8'))assert checks and all(c['exit']==0 for c in checks),suite- assert json.loads((LOG/'qml-mouse4/result.json').read_text(encoding='utf8'))['exit']==0- ass=json.loads((LOG/'smoke-inherited2/result.json').read_text(encoding='utf8'))+ assert json.loads((LOG/('qml-style-mouse1' if styles else 'qml-mouse4')/'result.json').read_text(encoding='utf8'))['exit']==0+ ass=json.loads((LOG/('smoke-style-inherited1' if styles else 'smoke-inherited2')/'result.json').read_text(encoding='utf8'))assert ass['passed'] and ass['exeSha256']==sha(APP/'veyra_qml_ui.exe')- for label,marker in [('final1','UI'),('finalrestore1','RESTORE'),('multilayer1','MULTI'),('realvideo1','VISUAL')]:+ uiChecks=[('style-ui1','UI'),('style-restore1','RESTORE'),('style-multi1','MULTI')] if styles else [('final1','UI'),('finalrestore1','RESTORE'),('multilayer1','MULTI'),('realvideo1','VISUAL')]+ for label,marker in uiChecks:console=(LOG/('production-'+label)/'console.log').read_text(encoding='utf8',errors='replace')assert 'NR_CONTROLS_'+marker+'_PASS' in console and 'NR_CONTROLS_UI_FAIL' not in console,label+ if styles:+ comparisons=json.loads((LOG/'styles-original-fixed3/result.json').read_text(encoding='utf8'))+ assert comparisons['passed'] and comparisons['exeSha256']==sha(APP/'veyra_qml_ui.exe')+ assert {s['style'] for s in comparisons['scenarios']}=={0,1,2}+ audit=json.loads((LOG/'style-picture-comparison.json').read_text(encoding='utf8'))+ assert audit['passed'] and audit['exeSha256']==sha(APP/'veyra_qml_ui.exe')# Move only this task's named diagnostic files; never recursively delete a tree.workerLogs=LOG/'export-workers';workerLogs.mkdir(exist_ok=True)for p in (APP/'logs').glob('export-worker-*.log'):@@ -49,10 +61,13 @@ for name in ('THIRD_PARTY_NOTICES.md','README.md','README_CN.md','README_EN.md')for name in ('NR_STRENGTH_PROTECTION_PLAN_2026-10-05.md','NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md'):shutil.copy2(ROOT/'docs'/name,APP/'docs'/name)(APP/'NR_CONTROLS_LOCAL.md').write_text('本地 NR 画面调控版(未发布)\n\nNR → 增强变化量 → 总变化强度:0–5。NR → 画面调控 → 开启调控:默认关闭,开启后选自动/手动。关闭保留原始变化量;手动可调色相、色度、高光、局部压缩、时域稳定,切换自动仍保留手动值。开启调控接管时间域防闪,关闭恢复原设置。\n\n沿用已核验 Lecram / SFv2 / NVIDIA 原版 NR,未替换 Swapper DLL;保留 Claude 的 libass 字幕及其他主线修复。5 是残差外推,保护会降低危险区域的局部增益,不能保证所有视频无失真。RTX 20/30/40/AMD、真实 HDR 显示及长时主观质量还需验收;全局 native HDR 有八项起点已存在的测试失败,不能宣称 HDR 全过。详见 docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md。\n',encoding='utf8')+if styles:+ with (APP/'NR_CONTROLS_LOCAL.md').open('a',encoding='utf8') as out:+ out.write('\n风格续修版:自动分别适配 0/1/2;增加自动调控力度,0 精确保留原始强度 5,1 完整纠偏。手动共九项:新增中性色保护、原图色彩保留、亮度保持和暗部保护。可用“采用当前风格的自动参数”作为手动起点。色彩保留 1 保留原图色相与饱和度,亮度保持 1 保留原图明暗;若两项同时为 1,增强变化会大幅减少。时域稳定需要连续播放,暂停帧不能判断减闪效果。旧五项手动预设保持原意,新字段仅在使用后升级格式。\n')for rel,digest in expected.items():assert sha(APP/rel).upper()==digest,relreceipt={'sourcePackage':str(SOURCE),'candidate':str(APP),'runtimeHashes':expected,'executableSha256':sha(APP/'veyra_qml_ui.exe'),'mainQmlSha256':sha(APP/'qml/Veyra/Main.qml'),'status':mode}-save(LOG/'package-stage.json',receipt)+save(LOG/('package-'+receiptLabel+'-stage.json' if styles else 'package-stage.json'),receipt)if mode=='stage':print('CANDIDATE staged',APP);raise SystemExit(0)head=git('rev-parse','HEAD');assert git('branch','--show-current')=='codex/'+TASK# Audit every inherited component, including codecs, VFG/CUDA, models and manifests.@@ -67,25 +82,25 @@ for p in APP.rglob('*'):rel=p.relative_to(APP).as_posix()assert not rel.startswith(('logs/','tmp/','outputs/','screenshots/','profile/')),relassert p.suffix.lower() not in ('.lib','.pdb','.addon64','.pyc','.whl'),rel-sourceZip=PARENT/'Veyra-2.0.3-nr-controls-veyra-source.zip';assert not sourceZip.exists()+sourceZip=PARENT/f'Veyra-{version}-veyra-source.zip';assert not sourceZip.exists()tracked=subprocess.check_output(['git','-C',str(ROOT),'ls-files','-z']).decode('utf8').split('\0')with zipfile.ZipFile(sourceZip,'x',compression=zipfile.ZIP_DEFLATED,compresslevel=6) as z:- for rel in sorted(filter(None,tracked)):z.write(ROOT/rel,arcname='Veyra-2.0.3-nr-controls-source/'+rel)+ for rel in sorted(filter(None,tracked)):z.write(ROOT/rel,arcname=f'Veyra-{version}-source/'+rel)with zipfile.ZipFile(sourceZip) as z:assert z.testzip() is None- for rel in filter(None,tracked):assert hashlib.sha256(z.read('Veyra-2.0.3-nr-controls-source/'+rel)).hexdigest()==sha(ROOT/rel),rel+ for rel in filter(None,tracked):assert hashlib.sha256(z.read(f'Veyra-{version}-source/'+rel)).hexdigest()==sha(ROOT/rel),relbundle=ARCHIVE/'source-final.bundle';assert not bundle.exists()subprocess.run(['git','-C',str(ROOT),'bundle','create',str(bundle),'HEAD'],check=True)with (LOG/'final-bundle-verify.log').open('w',encoding='utf8') as out:subprocess.run(['git','-C',str(ROOT),'bundle','verify',str(bundle)],stdout=out,stderr=subprocess.STDOUT,check=True)manifest=json.loads((SOURCE/'package-manifest.json').read_text(encoding='utf8'))-manifest.update(candidate='2.0.3-nr-controls-20261005',baseCommit='de18fc4f71843049dc7fd691898598c17af308f0',- sourceCommit=head,sourceArchiveCommit=head,worktreeDirty=False,releaseReady=False,localOnly=True,displayVersion='2.0.3-nr-controls',+manifest.update(candidate=version+'-20261005',baseCommit='de18fc4f71843049dc7fd691898598c17af308f0',+ sourceCommit=head,sourceArchiveCommit=head,worktreeDirty=False,releaseReady=False,localOnly=True,displayVersion=version,executableSha256=receipt['executableSha256'],validationRecord='docs/NR_STRENGTH_PROTECTION_EXECUTION_2026-10-05.md',softwareValidation='NR targeted checks passed; eight pre-existing native HDR test failures reproduced on starting main',hardwareValidation='RTX 5070 local short tests only; RTX 20/30/40, AMD, real HDR/capture and long subjective quality unverified')manifest['correspondingSource'].update(application='../'+sourceZip.name,applicationSha256=sha(sourceZip),- displayVersionOverride='-DVEYRA_DISPLAY_VERSION=2.0.3-nr-controls')+ displayVersionOverride='-DVEYRA_DISPLAY_VERSION='+version)excluded={'package-manifest.json','local-package-manifest.json'}records=[{'path':p.relative_to(APP).as_posix(),'size':p.stat().st_size,'sha256':sha(p)}for p in sorted(APP.rglob('*')) if p.is_file() and p.name not in excluded]@@ -111,5 +126,5 @@ receipt.update(status='local delivery; targeted NR tests passed, hardware/qualitfileCount=len(records)+len(excluded),unchangedComponentCount=len(immutable),packageManifestSha256=sha(APP/'package-manifest.json'),scopePassed=True,zipCrcAndAllPayloadHashesPassed=True)subprocess.run([sys.executable,'-B',str(ROOT/'scripts/acceptance/nr-protection-control.py'),'guard'],check=True)-save(PARENT/'DELIVERY.json',receipt);save(LOG/'delivery.json',receipt)+save(PARENT/('DELIVERY-'+receiptLabel+'.json' if styles else 'DELIVERY.json'),receipt);save(LOG/('delivery-'+receiptLabel+'.json' if styles else 'delivery.json'),receipt)print(json.dumps(receipt,ensure_ascii=False,indent=2),flush=True)diff --git a/scripts/acceptance/nr-protection-style-audit.py b/scripts/acceptance/nr-protection-style-audit.pynew file mode 100644index 00000000..844907bb--- /dev/null+++ b/scripts/acceptance/nr-protection-style-audit.py@@ -0,0 +1,32 @@+"""Audit same-input native captures; do not confuse color distance with quality."""+from pathlib import Path+import hashlib,json+BASE=Path('E:/项目/Veyra');TASK='nr-strength-protection-20261005';LOG=BASE/'logs'/TASK+def read(label,file):return json.loads((LOG/('styles-'+label)/file).read_text(encoding='utf8'))+old=read('original-baseline3','result.json');new=read('original-fixed3','result.json')+oldImages={c['label']:c['sha256'] for c in old['captures']};newImages={c['label']:c['sha256'] for c in new['captures']}+assert old['passed'] and new['passed'] and oldImages['source']==newImages['source']+assert old['media']==new['media'] and new['media'].lower().endswith('.png')+for style in range(3):assert oldImages[f'style{style}-raw']==newImages[f'style{style}-raw']+raw=newImages['style1-raw']+assert raw==newImages['style1-manual-none']==newImages['style1-auto-zero']+for key in ('neutralProtection','colorRetention','luminanceRetention','shadowProtection'):+ assert newImages['style1-manual-'+key]!=raw+a=read('original-baseline3','image-metrics.json')['results'];b=read('original-fixed3','image-metrics.json')['results']+for style in (1,2):assert b[f'style{style}-auto']['meanColorChange']<a[f'style{style}-auto']['meanColorChange']*.2+assert b['style0-auto']['neutralColorChange']<a['style0-auto']['neutralColorChange']*.5+assert b['style1-manual-neutralProtection']['neutralColorChange']<b['style1-manual-none']['neutralColorChange']*.5+assert b['style1-manual-colorRetention']['meanColorChange']<b['style1-raw']['meanColorChange']*.15+assert b['style1-manual-colorRetention']['meanLightnessChange']>b['style1-raw']['meanLightnessChange']*.85+assert b['style1-manual-luminanceRetention']['meanLightnessChange']<b['style1-raw']['meanLightnessChange']*.1+assert b['style1-manual-luminanceRetention']['meanColorChange']>b['style1-raw']['meanColorChange']*.6+assert b['style1-manual-shadowProtection']['shadowDarkening']<b['style1-raw']['shadowDarkening']*.4+runtime=BASE/'test-packages'/TASK/'Veyra-2.0.3-nr-controls2-NVIDIA-win64-portable/runtime/experimental/nr-original/nvngx_dlssnr.dll'+assert hashlib.sha256(runtime.read_bytes()).hexdigest().upper()=='E16BCF15E16E13F527491CDF7845B2FE6521A738D8F7C9C721866A8496E1FC8E'+result={'passed':True,'sourceSha256':oldImages['source'],'exeSha256':new['exeSha256'],+ 'allThreeRawStylesByteIdentical':True,'zeroManualAndZeroAutoByteIdentical':True,'newManualControlsIndependent':True,+ 'autoColorChanges':{str(s):{'before':a[f'style{s}-auto']['meanColorChange'],'after':b[f'style{s}-auto']['meanColorChange']} for s in range(3)},+ 'interpretation':'One fixed SDR input on RTX 5070/NVIDIA original. Source-relative color distance; not a subjective quality, flicker or all-content score.'}+path=LOG/'style-picture-comparison.json'+with path.open('x',encoding='utf8') as out:json.dump(result,out,ensure_ascii=False,indent=2)+print(json.dumps(result,ensure_ascii=False,indent=2))diff --git a/scripts/acceptance/nr-protection-styles.py b/scripts/acceptance/nr-protection-styles.pynew file mode 100644index 00000000..12490d63--- /dev/null+++ b/scripts/acceptance/nr-protection-styles.py@@ -0,0 +1,49 @@+"""Three real NR styles on one paused frame; immutable input package copy."""+from pathlib import Path+import argparse,hashlib,json,os,shutil,subprocess,sys+ROOT=Path(__file__).resolve().parents[2];BASE=Path('E:/项目/Veyra');TASK='nr-strength-protection-20261005'+parser=argparse.ArgumentParser()+parser.add_argument('label');parser.add_argument('--app',required=True);parser.add_argument('--media',required=True)+parser.add_argument('--scenarios')+parser.add_argument('--manual',action='store_true')+a=parser.parse_args();assert a.label.replace('-','').isalnum()+source=Path(a.app);media=Path(a.media)+assert source.is_dir() and media.is_file()+assert source.resolve().is_relative_to(BASE.resolve()) and media.resolve().is_relative_to(BASE.resolve())+subprocess.run([sys.executable,'-B',str(ROOT/'scripts/acceptance/nr-protection-control.py'),'guard'],check=True)+OUT=BASE/'tests'/TASK/('styles-'+a.label);LOG=BASE/'logs'/TASK/('styles-'+a.label);TMP=BASE/'tmp'/TASK/('styles-'+a.label)+for p in (OUT,LOG,TMP):p.mkdir(parents=True,exist_ok=False)+(OUT/'screenshots').mkdir()+APP=OUT/'app';shutil.copytree(source,APP,ignore=shutil.ignore_patterns('logs','outputs','screenshots'))+scenarios=json.loads(Path(a.scenarios).read_text(encoding='utf8')) if a.scenarios else [+ {'label':f'style{s}-{mode}', 'style':s,'enabled':mode=='auto','automatic':True}+ for s in range(3) for mode in ('raw','auto')]+if a.manual:+ keys=('hueProtection','chromaProtection','highlightProtection','localCompression','temporalStability',+ 'neutralProtection','colorRetention','luminanceRetention','shadowProtection')+ for key in ('none','neutralProtection','colorRetention','luminanceRetention','shadowProtection'):+ values=dict.fromkeys(keys,0)+ if key!='none':values[key]=1+ scenarios.append({'label':'style1-manual-'+key,'style':1,'enabled':True,'automatic':False,'values':values})+ scenarios.append({'label':'style1-auto-zero','style':1,'enabled':True,'automatic':True,'values':{'correctionAmount':0}})+main=APP/'qml/Veyra/Main.qml';original=main.read_bytes();text=original.decode('utf8')+loader='\nLoader { source: '+json.dumps((ROOT/'scripts/acceptance/nr-protection-styles.qml').as_uri())+'; onLoaded: {item.media='+json.dumps(str(media))+';item.evidence='+json.dumps(str(OUT))+';item.scenarios='+json.dumps(scenarios)+';item.fixedImage='+str(media.suffix.lower() in ('.png','.jpg','.jpeg')).lower()+'} }\n'+env=os.environ.copy();env.update(TEMP=str(TMP),TMP=str(TMP),VEYRA_LOG_FILE=str(LOG/'veyra.log'),QT_FORCE_STDERR_LOGGING='1',QML_DISABLE_DISK_CACHE='1')+for key in ('QT_QPA_PLATFORM','QT_QUICK_BACKEND','VEYRA_UI_RHI','VEYRA_TEST_IGNORE_RTSS','VEYRA_TEST_REJECT_NR_STYLE2'):env.pop(key,None)+args=[str(APP/'veyra_qml_ui.exe'),'--page','pro','--size','1280x900','--reduced-motion','--obs-game-capture','--data-dir',str(OUT/'profile'),'--exit-after','240000']+try:+ pos=text.rfind('}');main.write_text(text[:pos]+loader+text[pos:],encoding='utf8')+ with (LOG/'console.log').open('xb') as log:+ rc=subprocess.run(args,cwd=APP,env=env,stdout=log,stderr=subprocess.STDOUT,timeout=260).returncode+finally:main.write_bytes(original)+console=(LOG/'console.log').read_text(encoding='utf8',errors='replace')+assert rc==0 and 'NR_STYLES_PASS' in console and 'NR_STYLES_FAIL' not in console,console[-5000:]+images=sorted((OUT/'screenshots').glob('*.png'));labels=['source']+[s['label'] for s in scenarios]+assert len(images)==len(labels),(len(images),len(labels))+records=[]+for label,path in zip(labels,images):+ target=path.with_name(label+'.png');path.rename(target)+ records.append({'label':label,'path':str(target),'sha256':hashlib.sha256(target.read_bytes()).hexdigest()})+receipt={'passed':True,'package':str(source),'exeSha256':hashlib.sha256((source/'veyra_qml_ui.exe').read_bytes()).hexdigest(),'media':str(media),'scenarios':scenarios,'captures':records}+(LOG/'result.json').write_text(json.dumps(receipt,ensure_ascii=False,indent=2),encoding='utf8')+print('NR styles PASS',OUT,flush=True)diff --git a/scripts/acceptance/nr-protection-styles.qml b/scripts/acceptance/nr-protection-styles.qmlnew file mode 100644index 00000000..add667b2--- /dev/null+++ b/scripts/acceptance/nr-protection-styles.qml@@ -0,0 +1,58 @@+// Same source frame, real Feature-18 provider, three styles at residual gain 5.+import QtQuick+Item {+ id: test+ property string media: ""+ property string evidence: ""+ property var scenarios: []+ property int step: 0+ property int ticks: 0+ property int entered: 0+ property int current: -1+ property bool fixedImage: false+ function require(ok,why){if(!ok){console.error("NR_STYLES_FAIL",why);timer.stop();Qt.quit();throw new Error(why)}}+ function edit(key,value){require(veyra.setNrLayerParameter(veyra.nrLayers[0].index,key,value),"edit "+key)}+ function next(s){step=s;entered=ticks}+ Timer {+ id: timer;interval: 100;repeat: true;running: true+ onTriggered: {+ if(++test.ticks>2300){test.require(false,"230s deadline");return}+ if(!test.media.length||test.ticks<12)return+ if(test.step===0){+ veyra.nodeMode=0;veyra.nrEnabled=true;veyra.srEnabled=false;veyra.fgEnabled=false+ test.edit("runtime",3);test.edit("style",0);test.edit("total",5)+ test.require(veyra.setPreference("screenshotDir",test.evidence+"/screenshots"),"screenshot path")+ veyra.openPath(test.media);test.next(1)+ }else if(test.step===1){+ test.require(!veyra.failed,"preview failed: "+veyra.statusText)+ if(!veyra.nrActive||(!test.fixedImage&&veyra.position<.8))return+ if(!test.fixedImage&&!veyra.paused)veyra.togglePlayPause()+ veyra.nrEnabled=false;test.next(2)+ }else if(test.step===2){+ if(test.ticks-test.entered<20)return+ console.log("NR_STYLES_CAPTURE","source",veyra.position,JSON.stringify(veyra.nrLayers))+ veyra.takeScreenshot();test.next(3)+ }else if(test.step===3){+ if(test.ticks-test.entered<12)return+ ++test.current+ if(test.current>=test.scenarios.length){+ console.log("NR_STYLES_PASS");timer.stop();Qt.quit();return+ }+ const s=test.scenarios[test.current]+ veyra.nrEnabled=true+ test.edit("style",s.style);test.edit("correctionEnabled",s.enabled?1:0)+ test.edit("correctionAuto",s.automatic?1:0)+ for(const key of Object.keys(s.values||{}))test.edit(key,s.values[key])+ test.next(4)+ }else if(test.step===4){+ if(test.ticks-test.entered<25)return+ test.require((test.fixedImage||veyra.paused)&&veyra.nrActive&&!veyra.failed,"inactive controlled preview")+ const s=test.scenarios[test.current],n=veyra.nrLayers[0]+ test.require(n.style===s.style&&n.runtime===3&&n.total===5,"wrong provider/style/gain")+ console.log("NR_STYLES_CAPTURE",s.label,veyra.position,JSON.stringify(n),JSON.stringify(veyra.stageTimings))+ veyra.logUi("nr-styles",s.label+" "+JSON.stringify(n))+ veyra.takeScreenshot();test.next(3)+ }+ }+ }+}diff --git a/scripts/acceptance/nr-protection-translations.py b/scripts/acceptance/nr-protection-translations.pynew file mode 100644index 00000000..ee0e109f--- /dev/null+++ b/scripts/acceptance/nr-protection-translations.py@@ -0,0 +1,34 @@+"""Complete translations for the style-protection follow-up after extraction."""+from pathlib import Path+import json+root=Path(__file__).resolve().parents[2]+translations={+ '中性色保护':('中性色保護','Neutral color protection','無彩色保護'),+ '原图色彩保留':('原圖色彩保留','Source color retention','元の色を保持'),+ '亮度保持':('亮度保持','Lightness retention','明度を保持'),+ '暗部保护':('暗部保護','Shadow protection','暗部保護'),+ '自动调控力度':('自動調控力度','Automatic control amount','自動調整の強度'),+ '采用当前风格的自动参数':('採用目前風格的自動參數','Use this style’s automatic values','現在のスタイルの自動値を使う'),+ '保留原图色相;没有色相偏移时变化较小':('保留原圖色相;沒有色相偏移時變化較小','Retain source hue; little change when hue already matches','元の色相を保持。色相ずれがない場合は変化が小さくなります'),+ '软化过量色度变化;小幅变化保留':('柔化過量色度變化;小幅變化保留','Soften excessive chroma changes; retain small changes','過剰な色度変化を抑え、小さな変化は保持します'),+ '抑制白墙、云和灰色区域的额外染色':('抑制白牆、雲和灰色區域的額外染色','Suppress added tint on white walls, clouds and gray areas','白い壁、雲、灰色領域への余計な着色を抑えます'),+ '保留原图色相与饱和度;1 为完全保留色彩':('保留原圖色相與飽和度;1 為完全保留色彩','Retain source hue and saturation; 1 fully retains color','元の色相と彩度を保持。1 で色を完全に保持します'),+ '减少 NR 明暗改动;1 为保留原图亮度':('減少 NR 明暗改動;1 為保留原圖亮度','Reduce NR lightness changes; 1 retains source lightness','NR の明暗変化を減らします。1 で元の明度を保持します'),+ '减少暗部被进一步压黑,保留提亮细节':('減少暗部被進一步壓黑,保留提亮細節','Reduce further shadow darkening while retaining brighter detail','暗部のさらなる黒つぶれを抑え、明るくなる細部は保持します'),+ '只压缩向白色溢出的变化,保留高光回暗':('只壓縮向白色溢出的變化,保留高光回暗','Compress changes toward blown whites; retain highlight darkening','白飛びする変化だけを圧縮し、ハイライトの減光は保持します'),+ '同时软化过大的亮度和颜色变化':('同時柔化過大的亮度和顏色變化','Soften excessive lightness and color changes together','過大な明度と色の変化を同時に抑えます'),+ '播放时减闪;暂停单帧不体现时域效果':('播放時減閃;暫停單幀不體現時域效果','Reduce flicker during playback; a paused frame does not show temporal effects','再生時のちらつきを抑えます。一時停止の1フレームでは時間的効果は見えません'),+ '0 保留原始变化;1 按当前风格完整纠偏':('0 保留原始變化;1 按目前風格完整糾偏','0 retains raw changes; 1 applies this style’s full correction','0 は元の変化を保持、1 は現在のスタイルの補正を完全に適用'),+ '自动参数分别适配风格 0/1/2。手动可独立保留颜色、亮度和暗部;保护会降低对应变化量。时域稳定复用光流,切换方式保留手动数值。':(+ '自動參數分別適配風格 0/1/2。手動可獨立保留顏色、亮度和暗部;保護會降低對應變化量。時域穩定重用光流,切換方式保留手動數值。',+ 'Automatic values are tuned for styles 0/1/2. Manual controls independently retain color, lightness and shadows, reducing the corresponding changes. Temporal stability uses optical flow; switching modes preserves manual values.',+ 'スタイル 0/1/2 ごとに自動値を調整します。手動では色、明度、暗部を個別に保持し、対応する変化を抑えられます。時間的安定化はオプティカルフローを使い、モードを切り替えても手動値を保持します。')+}+path=root/'i18n/catalog.json';data=json.loads(path.read_text(encoding='utf8'));found=set()+for entry in data['entries']:+ if entry['zh'] in translations:+ entry.update(zip(('zh-TW','en','ja'),translations[entry['zh']]))+ found.add(entry['zh'])+assert found==set(translations),set(translations)-found+path.write_text(json.dumps(data,ensure_ascii=False,indent=1)+'\n',encoding='utf8')+print('NR style translations complete',len(found))diff --git a/scripts/acceptance/nr-protection-ui.py b/scripts/acceptance/nr-protection-ui.pyindex f072cb98..10c9f1eb 100644--- a/scripts/acceptance/nr-protection-ui.py+++ b/scripts/acceptance/nr-protection-ui.py@@ -4,6 +4,9 @@ import hashlib,json,os,subprocess,sysROOT=Path(__file__).resolve().parents[2]BASE=Path('E:/项目/Veyra');TASK='nr-strength-protection-20261005'APP=BASE/'test-packages'/TASK/'Veyra-2.0.3-nr-controls-NVIDIA-win64-portable'+styles='--styles' in sys.argv+if styles:+ sys.argv.remove('--styles');APP=APP.with_name('Veyra-2.0.3-nr-controls2-NVIDIA-win64-portable')mode=sys.argv[1];assert mode in ('first','restore','multi','visual')label=sys.argv[2] if len(sys.argv)>2 else modeassert label.replace('-','').isalnum()@@ -18,14 +21,14 @@ for key in ('QT_QPA_PLATFORM','QT_QUICK_BACKEND','VEYRA_UI_RHI','VEYRA_TEST_IGNOif mode=='first' and not media.exists():with (LOG/'fixture.log').open('xb') as log:subprocess.run(['ffmpeg','-v','warning','-n','-f','lavfi','-i','testsrc2=size=1280x720:rate=30','-t','2','-c:v','mpeg4','-q:v','3','-threads','2',str(media)],env=env,stdout=log,stderr=subprocess.STDOUT,timeout=60,check=True)-receipt=BASE/'logs'/TASK/'production-profile.json'+receipt=BASE/'logs'/TASK/('production-styles-profile.json' if styles else 'production-profile.json')if mode=='first':profile=OUT/'profile'receipt.write_text(json.dumps({'profile':str(profile)}),encoding='utf8')elif mode=='restore':profile=Path(json.loads(receipt.read_text(encoding='utf8'))['profile'])else:profile=OUT/'profile'main=APP/'qml/Veyra/Main.qml';original=main.read_bytes();source=original.decode('utf8')-loader='\nLoader { anchors.fill: parent; source: '+json.dumps((ROOT/'scripts/acceptance/nr-protection-ui.qml').as_uri())+'; onLoaded: { item.media='+json.dumps(str(media))+'; item.evidence='+json.dumps(str(OUT))+'; item.resume='+str(mode=='restore').lower()+'; item.multi='+str(mode=='multi').lower()+'; item.visual='+str(mode=='visual').lower()+' } }\n'+loader='\nLoader { anchors.fill: parent; source: '+json.dumps((ROOT/'scripts/acceptance/nr-protection-ui.qml').as_uri())+'; onLoaded: { item.media='+json.dumps(str(media))+'; item.evidence='+json.dumps(str(OUT))+'; item.resume='+str(mode=='restore').lower()+'; item.multi='+str(mode=='multi').lower()+'; item.visual='+str(mode=='visual').lower()+'; item.styleFollowup='+str(styles).lower()+' } }\n'args=[str(APP/'veyra_qml_ui.exe'),'--page','pro','--size','1280x900','--reduced-motion','--obs-game-capture','--export-out',str(OUT/'outputs'),'--data-dir',str(profile),'--exit-after','250000']try:at=source.rfind('}');main.write_text(source[:at]+loader+source[at:],encoding='utf8')diff --git a/scripts/acceptance/nr-protection-ui.qml b/scripts/acceptance/nr-protection-ui.qmlindex 96217f12..37d8ffeb 100644--- a/scripts/acceptance/nr-protection-ui.qml+++ b/scripts/acceptance/nr-protection-ui.qml@@ -8,6 +8,7 @@ Item {property bool resume: falseproperty bool multi: falseproperty bool visual: false+ property bool styleFollowup: falseproperty var appWindow: Window.windowproperty int step: 0property int ticks: 0@@ -51,9 +52,11 @@ Item {if(test.multi){if(test.step===0){veyra.nodeMode=0;veyra.nrEnabled=true;veyra.srEnabled=false;veyra.fgEnabled=false+ if(test.styleFollowup){test.edit("runtime",3);test.edit("style",1)}test.edit("total",5);test.edit("correctionEnabled",1)test.require(veyra.duplicateNrLayer(veyra.nrLayers[0].index)>=0,"two-layer creation failed")const second=veyra.nrLayers[1].index+ if(test.styleFollowup)test.require(veyra.setNrLayerParameter(second,"style",2),"second style rejected")test.require(veyra.setNrLayerParameter(second,"correctionAuto",0),"second manual mode rejected")test.require(veyra.setNrLayerParameter(second,"temporalStability",.5),"second stability rejected")test.require(veyra.setProtectionRegion(.1,.1,.3,.3,0),"stack protection region rejected")@@ -79,11 +82,13 @@ Item {test.require(veyra.nodeMode===0&&veyra.nrLayers.length===1,"list session not restored")const n=veyra.nrLayers[0]test.require(n.total===5&&n.correctionEnabled&&!n.correctionAuto&&Math.abs(n.hueProtection-.4)<1e-5&&Math.abs(n.chromaProtection-.3)<1e-5,"manual session values not restored")+ if(test.styleFollowup)test.require(n.style===2&&n.runtime===3&&Math.abs(n.neutralProtection-.6)<1e-5&&Math.abs(n.colorRetention-.35)<1e-5&&Math.abs(n.luminanceRetention-.2)<1e-5&&Math.abs(n.shadowProtection-.5)<1e-5&&Math.abs(n.correctionAmount-.7)<1e-5,"extended list session lost parameters")veyra.nodeMode=1;test.next(1)}else if(test.step===1){if(!test.elapsed(8))returnconst n=veyra.nrLayers[0]test.require(n&&n.total===5&&n.correctionEnabled&&!n.correctionAuto&&Math.abs(n.hueProtection-.42)<1e-5,"node session values not restored")+ if(test.styleFollowup)test.require(Math.abs(n.neutralProtection-.43)<1e-5&&Math.abs(n.colorRetention-.52)<1e-5&&Math.abs(n.luminanceRetention-.31)<1e-5&&Math.abs(n.shadowProtection-.64)<1e-5&&Math.abs(n.correctionAmount-.62)<1e-5,"extended node session lost parameters")veyra.nodeMode=0console.log("NR_CONTROLS_RESTORE_PASS")timer.stop();Qt.quit()@@ -94,6 +99,7 @@ Item {veyra.nodeMode=0;veyra.nrEnabled=true;veyra.srEnabled=false;veyra.fgEnabled=falseif(!veyra.nrLayers.length)veyra.addEffect("nr")test.require(veyra.nrLayers.length===1,"expected isolated default NR layer")+ if(test.styleFollowup){test.edit("runtime",3);test.edit("style",2)}test.require(!veyra.nrLayers[0].correctionEnabled,"new profile correction must default off")test.require(veyra.setPreference("screenshotDir",test.evidence+"/screenshots"),"task screenshot directory rejected")const residual=test.find(controls,"nr-residual-group"),group=test.find(controls,"nr-correction-group")@@ -118,12 +124,23 @@ Item {if(!test.elapsed(45))returntest.require(!veyra.failed&&veyra.nrActive,"controlled paused preview failed")test.capture("auto-five")+ if(test.styleFollowup)test.find(controls,"nr-correctionAmount").moved(.7)test.find(controls,"nr-correctionAuto").picked("0")+ if(test.styleFollowup){+ test.find(controls,"nr-use-auto-defaults").clicked()+ test.require(Math.abs(veyra.nrLayers[0].colorRetention-.665)<1e-5&&Math.abs(veyra.nrLayers[0].luminanceRetention-.14)<1e-5,"style-specific automatic values not copied")+ }test.find(controls,"nr-hueProtection").moved(.4)test.find(controls,"nr-chromaProtection").moved(.3)test.find(controls,"nr-highlightProtection").moved(.9)test.find(controls,"nr-localCompression").moved(.7)test.find(controls,"nr-temporalStability").moved(.8)+ if(test.styleFollowup){+ test.find(controls,"nr-neutralProtection").moved(.6)+ test.find(controls,"nr-colorRetention").moved(.35)+ test.find(controls,"nr-luminanceRetention").moved(.2)+ test.find(controls,"nr-shadowProtection").moved(.5)+ }test.next(4)}else if(test.step===4){if(!test.elapsed(30))return@@ -146,12 +163,15 @@ Item {test.require(veyra.nrLayers[0].total===1&&!veyra.nrLayers[0].correctionEnabled,"NR reset defaults wrong")test.require(veyra.applyPresetIndex(test.savedIndex),"NR preset apply failed")test.require(veyra.nrLayers[0].total===5&&veyra.nrLayers[0].correctionEnabled&&!veyra.nrLayers[0].correctionAuto,"preset did not restore mode and gain")+ if(test.styleFollowup)test.require(Math.abs(veyra.nrLayers[0].colorRetention-.35)<1e-5&&Math.abs(veyra.nrLayers[0].correctionAmount-.7)<1e-5,"extended preset did not restore values")const duplicate=veyra.duplicateNrLayer(veyra.nrLayers[0].index)test.require(duplicate>=0&&veyra.nrLayers.length===2&&Math.abs(veyra.nrLayers[1].hueProtection-.4)<1e-5&&veyra.nrLayers[1].total===5,"duplicate lost correction values")+ if(test.styleFollowup)test.require(Math.abs(veyra.nrLayers[1].colorRetention-.35)<1e-5,"duplicate lost source-color value")test.require(veyra.removeEffect(duplicate),"duplicate cleanup failed")veyra.nodeMode=1if(!veyra.nrLayers.length)veyra.addEffect("nr")test.edit("total",5);test.edit("correctionEnabled",1);test.edit("correctionAuto",0);test.edit("hueProtection",.42)+ if(test.styleFollowup){test.edit("neutralProtection",.43);test.edit("colorRetention",.52);test.edit("luminanceRetention",.31);test.edit("shadowProtection",.64);test.edit("correctionAmount",.62)}test.require(veyra.nrLayers[0].total===5&&Math.abs(veyra.nrLayers[0].hueProtection-.42)<1e-5,"node parameter editing failed")veyra.nodeMode=0;test.next(6)}else if(test.step===6){diff --git a/shaders/NrCorrection.hlsli b/shaders/NrCorrection.hlsliindex 213ab5be..541e3a62 100644--- a/shaders/NrCorrection.hlsli+++ b/shaders/NrCorrection.hlsli@@ -74,8 +74,9 @@ float NrHighlightShoulder(float target,float original,float limit){return span>1e-7?knee+span*(1-exp(-(target-knee)/span)):start;}float3 NrApplyCorrection(float3 original,float3 candidate,bool hdr,- float hue,float chroma,float highlight,float compression){- if(hue+chroma+highlight+compression==0||all(original==candidate))return candidate;+ float hue,float chroma,float highlight,float compression,+ float neutral,float colorKeep,float lumaKeep,float shadow){+ if(hue+chroma+highlight+compression+neutral+colorKeep+lumaKeep+shadow==0||all(original==candidate))return candidate;if(!all(isfinite(candidate)))return original;float unit=NrUnit(hdr),ceiling=NrCeiling(original,hdr);float3 o=NrLinearToLab(original/unit),d=NrLinearToLab(candidate/unit)-o;@@ -98,6 +99,29 @@ float3 NrApplyCorrection(float3 original,float3 candidate,bool hdr,// gets the shoulder. Classification always uses the original base.if(d.x>0)d.x=lerp(target,NrHighlightShoulder(target,o.x,pow(ceiling,1.0/3.0)),highlight)-o.x;}+ // Lightness is independent of chromaticity. A manual value of one keeps+ // original lightness; shadow protection only restores excessive darkening+ // in source shadows, so positive shadow detail does not get suppressed.+ d.x*=1-lumaKeep;+ if(d.x<0)d.x*=1-shadow*(1-smoothstep(.12,.5,o.x));+ // Rebase source chroma to CURRENT lightness. Holding raw Lab a/b while+ // changing L changes saturation and can make styles 1/2 look color-shifted.+ // This preserves original RGB ratios at full retention, not a gray overlay.+ float2 prospectiveChroma=o.yz*((o.x+d.x)/max(o.x,1e-6));+ // Ignore tiny chromaticity noise from proxy/FP16 quantization. Source+ // color retention remains explicit; the neutral guard only repairs tint.+ float tintRisk=smoothstep(.001,.004,length(o.yz+d.yz-prospectiveChroma));+ float keep=1-(1-colorKeep)*(1-neutral*tintRisk*(1-smoothstep(.04,.14,c/max(o.x,.02))));+ // A source-color ray can hit the gamut ceiling before the gray axis does.+ // Respect that ray's lightness bound; otherwise the final gamut mapper+ // would desaturate a "fully retained" color near white.+ if(keep>0){+ float sourcePeak=NrMaximum(hdr?NrTo2020(original/unit):original/unit);+ float sourceLimit=o.x*pow(ceiling/max(sourcePeak,1e-9),1.0/3.0);+ d.x=lerp(o.x+d.x,min(o.x+d.x,sourceLimit),keep)-o.x;+ }+ float2 sourceChroma=o.yz*((o.x+d.x)/max(o.x,1e-6));+ d.yz=lerp(o.yz+d.yz,sourceChroma,keep)-o.yz;return NrMapLab(o+d,ceiling,hdr)*unit;}float3 NrTemporalSafety(float3 base,float3 candidate,bool hdr,bool spatial){diff --git a/shaders/NrResidualComposite.hlsl b/shaders/NrResidualComposite.hlslindex 97dc4f3c..1640b69a 100644--- a/shaders/NrResidualComposite.hlsl+++ b/shaders/NrResidualComposite.hlsl@@ -8,6 +8,8 @@ cbuffer Params:register(b0){float total;float darken;float brighten;float color;float luminance;float protectionEnabled;float featherPixels;float unused;float4 regions[4];float correctionEnabled;float hueProtection;float chromaProtection;float highlightProtection;float localCompression;float temporalStability;float correctionAutomatic;float correctionPad;+ float neutralProtection;float colorRetention;float luminanceRetention;float shadowProtection;+ float4 correctionReserved;}// Extrapolating a negative linear-light residual can cross zero even when// both input images contain shadow detail. Continue below the unboosted@@ -47,6 +49,7 @@ float shadowSafe(float base,float rawDelta,float requestedDelta){shadowSafe(base.g,rawDelta.g,delta.g),shadowSafe(base.b,rawDelta.b,delta.b));if(correctionEnabled>0.5)- result=NrApplyCorrection(base.rgb,result,unused>0.5,hueProtection,chromaProtection,highlightProtection,localCompression);+ result=NrApplyCorrection(base.rgb,result,unused>0.5,hueProtection,chromaProtection,highlightProtection,localCompression,+ neutralProtection,colorRetention,luminanceRetention,shadowProtection);outputTex[id.xy]=float4(unused>0.5?result:max(0,result),base.a);}diff --git a/shaders/NrTemporal.hlsl b/shaders/NrTemporal.hlslindex c2397923..a1a50a55 100644--- a/shaders/NrTemporal.hlsl+++ b/shaders/NrTemporal.hlsl@@ -32,6 +32,8 @@ cbuffer Settings:register(b0){uint Route;float2 LowSize;float RoutePad;float CorrectionEnabled;float HueProtection;float ChromaProtection;float HighlightProtection;float LocalCompression;float TemporalStability;float CorrectionAutomatic;float CorrectionHdr;+ float NeutralProtection;float ColorRetention;float LuminanceRetention;float ShadowProtection;+ float4 CorrectionReserved;}float GuideChannel(float c){// The matching tolerance must distinguish visible changes in shadows,@@ -240,7 +242,7 @@ groupshared float TileError[100];float3 composited=resolved+detail;if(CorrectionEnabled>0.5){composited=NrTemporalSafety(base.rgb,composited,CorrectionHdr>0.5,- HueProtection+ChromaProtection+HighlightProtection+LocalCompression>0);+ HueProtection+ChromaProtection+HighlightProtection+LocalCompression+NeutralProtection+ColorRetention+LuminanceRetention+ShadowProtection>0);resolved=composited-detail;}NextHistory[p]=float4(clamp(resolved-base.rgb,-65504,65504),Route==3?1+support:1);diff --git a/src/engine/PresetLibrary.cpp b/src/engine/PresetLibrary.cppindex 5f4e19b0..fd0064a8 100644--- a/src/engine/PresetLibrary.cpp+++ b/src/engine/PresetLibrary.cpp@@ -586,7 +586,10 @@ std::string PresetLibrary::encodeEntries(const std::vector<PresetEntry>& entriesconst bool correction=std::any_of(entries_.begin(),entries_.end(),[](const auto& e){for(unsigned i=0;i<e.chain.nodeCount;++i)if(e.chain.nodes[i].nr.residual.extendedSchema())return true;return false;});- const int version=std::max(minimumVersion, correction?8:vfg?7:rendering?6:globals?5:editor?4:layerSizes?3:multi?2:1);+ const bool correctionExtended=std::any_of(entries_.begin(),entries_.end(),[](const auto& e){+ for(unsigned i=0;i<e.chain.nodeCount;++i)if(e.chain.nodes[i].nr.residual.correction.extendedControls())return true;+ return false;});+ const int version=std::max(minimumVersion, correctionExtended?9:correction?8:vfg?7:rendering?6:globals?5:editor?4:layerSizes?3:multi?2:1);o << "VEYRA_PRESET_LIBRARY " << version << '\n' << std::quoted(utf8(defaultName_)) << ' ' << entries_.size() << '\n';for (const auto& e : entries_) {o << std::quoted(utf8(e.name)) << ' ' << std::quoted(utf8(e.note)) << ' '@@ -611,7 +614,7 @@ std::string PresetLibrary::encodeEntries(const std::vector<PresetEntry>& entrieso << ' ' << (n.videoHdr.enabled ? 1 : 0) << ' ' << n.videoHdr.contrast << ' ' << n.videoHdr.saturation << ' '<< n.videoHdr.middleGray << ' ' << n.videoHdr.peakNits << ' ';if(version>=3)o<<int(n.nr.sizePolicy)<<' ';- if(version>=8){writeNrCorrection(o,n.nr.residual.correction);o<<' ';}+ if(version>=8){writeNrCorrection(o,n.nr.residual.correction,version>=9);o<<' ';}if (version>=2 && n.type == EffectType::Color) {writeColorSettings(o, n.color, utf8(n.color.lutNameString()));o << ' ';@@ -646,7 +649,7 @@ bool PresetLibrary::parse(const std::string& data, std::vector<PresetEntry>& outstd::string magic, quoted;int version = 0;size_t count = 0;- if (!(in >> magic >> version) || magic != "VEYRA_PRESET_LIBRARY" || version < 1 || version > 8) { error = L"预设库格式或版本不支持"; return false; }+ if (!(in >> magic >> version) || magic != "VEYRA_PRESET_LIBRARY" || version < 1 || version > 9) { error = L"预设库格式或版本不支持"; return false; }if (!(in >> std::quoted(quoted) >> count) || count > 64) { error = L"预设库条目数非法"; return false; }def = wide(quoted);for (size_t i = 0; i < count; ++i) {@@ -702,7 +705,7 @@ bool PresetLibrary::parse(const std::string& data, std::vector<PresetEntry>& outif(!(in>>size)||!pipeline::validNrSizePolicy(static_cast<pipeline::NrSizePolicy>(size))){error=L"预设库 NR 分辨率非法";return false;}node.nr.sizePolicy=static_cast<pipeline::NrSizePolicy>(size);}- if(version>=8&&!readNrCorrection(in,node.nr.residual.correction)){error=L"预设库 NR 调控参数损坏";return false;}+ if(version>=8&&!readNrCorrection(in,node.nr.residual.correction,version>=9)){error=L"预设库 NR 调控参数损坏";return false;}if (version >= 2 && node.type == EffectType::Color) {std::string lut;if (!readColorSettings(in, node.color, lut, 19) ||diff --git a/src/engine/PresetStore.cpp b/src/engine/PresetStore.cppindex 9e8b364e..66bf7899 100644--- a/src/engine/PresetStore.cpp+++ b/src/engine/PresetStore.cpp@@ -41,8 +41,12 @@ std::string PresetStore::serialize()const{for(unsigned i=0;i<p.settings.nrLayerCount;++i)if(p.settings.nrLayers[i].residual.extendedSchema())return true;return false;});const bool fullSchema=fsr4||higher||rendering||vfg||correction;+ const bool correctionExtended=std::any_of(entries_.begin(),entries_.end(),[](const auto& p){+ if(p.settings.residual.correction.extendedControls())return true;+ for(unsigned i=0;i<p.settings.nrLayerCount;++i)if(p.settings.nrLayers[i].residual.correction.extendedControls())return true;+ return false;});// v26 introduces appended resolution IDs; old readers reject this schema.- std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS "<<(correction?29:vfg?28:rendering?27:higher?26:fsr4?25:hold?24:stack?23:multi?22:21)<<'\n'<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';+ std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS "<<(correctionExtended?30:correction?29:vfg?28:rendering?27:higher?26:fsr4?25:hold?24:stack?23:multi?22:21)<<'\n'<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<' '<<int(s.frameGenerationBackend)<<' '<<int(s.srTarget)<<' '<<int(s.opticalFlowBackend)<<' '<<s.amdFlowHalfResolution<<' '<<int(s.audioSync)<<' '<<s.audioOffsetMs<<' '<<int(s.nrRuntime)<<' '<<s.captureCompatible<<' '<<s.lowLatency<<' '<<s.forceSdrPreview<<' '<<int(s.captureAudio)<<' '<<s.exportBitrateMbps<<' '<<s.captureFlipVertical<<' '<<int(s.captureBuffer)<<' ';writeColorSettings(o,s.color,utf8(s.color.lutNameString()));o<<' '<<s.videoHdr.enabled<<' '<<s.videoHdr.contrast<<' '<<s.videoHdr.saturation<<' '<<s.videoHdr.middleGray<<' '<<s.videoHdr.peakNits<<' '<<s.nrTemporal;if(multi||fullSchema){o<<' '<<s.additionalColorCount;for(unsigned i=0;i<s.additionalColorCount;++i){o<<' ';writeColorSettings(o,s.additionalColors[i],utf8(s.additionalColors[i].lutNameString()));}}if(stack||fullSchema){@@ -64,15 +68,15 @@ std::string PresetStore::serialize()const{if(rendering||vfg||correction)o<<' '<<int(s.hdrOutputMode)<<' '<<int(s.fgMotion)<<' '<<int(s.srMotion)<<' '<<int(s.nrMotion);if(vfg||correction)o<<' '<<s.vfgQuality;if(correction){- o<<' ';writeNrCorrection(o,s.residual.correction);- for(unsigned i=0;i<s.nrLayerCount;++i){o<<' ';writeNrCorrection(o,s.nrLayers[i].residual.correction);}+ o<<' ';writeNrCorrection(o,s.residual.correction,correctionExtended);+ for(unsigned i=0;i<s.nrLayerCount;++i){o<<' ';writeNrCorrection(o,s.nrLayers[i].residual.correction,correctionExtended);}}o<<'\n';}return o.str();}bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,std::wstring& def){if(data.size()>kMaxPresetBytes)return false;std::istringstream in(data);in.imbue(std::locale::classic());std::string magic,d;int version=0;size_t count=0;- if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version<1||version>29)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;+ if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version<1||version>30)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;for(size_t i=0;i<count;++i){UserPreset p;std::string n;int policy,flow,content,nr,sr;auto& s=p.settings;auto& m=s.model;auto& r=s.residual;if(!(in>>std::quoted(n)>>m.intensity>>m.tone>>m.structure>>m.skin>>m.style>>m.autoMask>>m.uiCorrection>>r.total>>r.darken>>r.brighten>>r.color>>r.luminance>>nr>>sr>>s.multiplier>>policy>>flow>>content))return false;if(version>=2){int enabled;if(!(in>>enabled>>s.protection.featherPixels)||enabled<0||enabled>1)return false;s.protection.enabled=enabled!=0;@@ -135,8 +139,8 @@ bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,stdif(version>=27){int hdr,fg,sr,nr;if(!(in>>hdr>>fg>>sr>>nr))return false;s.hdrOutputMode=HdrOutputMode(hdr);s.fgMotion=MotionSource(fg);s.srMotion=MotionSource(sr);s.nrMotion=MotionSource(nr);}if(version>=28&&!(in>>s.vfgQuality))return false;if(version>=29){- if(!readNrCorrection(in,s.residual.correction))return false;- for(unsigned j=0;j<s.nrLayerCount;++j)if(!readNrCorrection(in,s.nrLayers[j].residual.correction))return false;+ if(!readNrCorrection(in,s.residual.correction,version>=30))return false;+ for(unsigned j=0;j<s.nrLayerCount;++j)if(!readNrCorrection(in,s.nrLayers[j].residual.correction,version>=30))return false;}p.name=wide(n);if(!nameOk(p.name)||std::any_of(out.begin(),out.end(),[&](auto& a){return a.name==p.name;})||nr<0||nr>1||sr<0||sr>1)return false;s.nr=nr;s.sr=sr;s.nrPolicy=static_cast<pipeline::NrSizePolicy>(policy);s.flow=static_cast<FlowQuality>(flow);s.content=static_cast<ContentRate>(content);diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex 7fe87aca..6c5712e4 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -1259,9 +1259,11 @@ bool EnhanceGraph::initNgxFeatures()instance->protection = index < desc_.nrLayersProtection.size() ? desc_.nrLayersProtection[index] : desc_.protection;instance->temporalEnabled = index < desc_.nrLayersTemporal.size() ? desc_.nrLayersTemporal[index] : desc_.nrTemporal;const auto& correction=instance->residualSettings.correction;- veyra::log::info("nr-correction",std::format("build layer={} gain={} mode={} temporal={} hdr={} manual={}/{}/{}/{}/{}",+ veyra::log::info("nr-correction",std::format("build layer={} gain={} mode={} temporal={} hdr={} style={} amount={} manual={}/{}/{}/{}/{}/{}/{}/{}/{}",index+1,instance->residualSettings.total,correction.enabled?(correction.automatic?"auto":"manual"):"off",- instance->temporalEnabled,desc_.hdrWorking(),correction.hue,correction.chroma,correction.highlight,correction.compression,correction.stability));+ instance->temporalEnabled,desc_.hdrWorking(),instance->model.style,correction.autoAmount,+ correction.hue,correction.chroma,correction.highlight,correction.compression,correction.stability,+ correction.neutral,correction.colorKeep,correction.lumaKeep,correction.shadow));if(lmxxfNr_){failedBackend_=engine::FailedBackend::Nr;// The upstream ABI owns encode/network/decode; feed the stable@@ -1496,10 +1498,10 @@ bool EnhanceGraph::createComputePasses(){const UINT residualLayers=UINT(std::max<size_t>(1,nrInstances_.size()));if(!residualPass_.loadShader("NrResidualComposite.dxil",cs)||- !residualPass_.create(context_.device(),cs,4*residualLayers,3*residualLayers,residualLayers,32))return false;+ !residualPass_.create(context_.device(),cs,4*residualLayers,3*residualLayers,residualLayers,40))return false;// The existing residual shader can mask the complete stack against its// original base. No extra texture: the final layer owns outputFull().- if(nrInstances_.size()>1&&!stackProtectionPass_.create(context_.device(),cs,4,3,1,32))return false;+ if(nrInstances_.size()>1&&!stackProtectionPass_.create(context_.device(),cs,4,3,1,40))return false;}if(!flowAdaptPass_.loadShader("FlowAdapt.dxil",cs)||!flowAdaptPass_.create(context_.device(),cs,3+UINT(nrInstances_.size()),1,1))return false;// Stage-5 output stabiliser. Only allocated when the setting is non-zero:@@ -2478,9 +2480,9 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame// last layer's delta. Keep unmasked per-layer histories in a stack.const auto protection=nrInstances_.size()>1?engine::ProtectionSettings{}:layer->protection;tracker_.transition(list,destination,D3D12_RESOURCE_STATE_UNORDERED_ACCESS);- float c[32]={r.total,r.darken,r.brighten,r.color,r.luminance,protection.enabled?1.0f:0.0f,protection.featherPixels,desc_.hdrWorking()?1.0f:0.0f};+ float c[40]={r.total,r.darken,r.brighten,r.color,r.luminance,protection.enabled?1.0f:0.0f,protection.featherPixels,desc_.hdrWorking()?1.0f:0.0f};for(size_t i=0;i<4;++i){const auto q=engine::protectionConstants(protection.regions[i]);c[8+i*4]=q[0];c[9+i*4]=q[1];c[10+i*4]=q[2];c[11+i*4]=q[3];}- const auto controls=r.correction.constants(desc_.hdrWorking());+ const auto controls=r.correction.constants(desc_.hdrWorking(),layer->model.style);std::copy(controls.begin(),controls.end(),c+24);const UINT residualLayers=UINT(std::max<size_t>(1,nrInstances_.size()));residualPass_.bind(list,c,gpuHandleOf(residualPass_,3u*UINT(layerIndex)).ptr,@@ -2520,7 +2522,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frametracker_.transition(list,output,D3D12_RESOURCE_STATE_UNORDERED_ACCESS);// The original and upstream stack share this boundary's// extent. Later NR layers consume the masked result.- float c[32]={1,1,1,1,1,1,desc_.protection.featherPixels,1.f};+ float c[40]={1,1,1,1,1,1,desc_.protection.featherPixels,1.f};for(size_t i=0;i<4;++i){const auto q=engine::protectionConstants(desc_.protection.regions[i]);c[8+i*4]=q[0];c[9+i*4]=q[1];c[10+i*4]=q[2];c[11+i*4]=q[3];}stackProtectionPass_.bind(list,c,gpuHandleOf(stackProtectionPass_,0).ptr,gpuHandleOf(stackProtectionPass_,3).ptr);list->Dispatch((extent.width+15)/16,(extent.height+15)/16,1);@@ -2710,7 +2712,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame// Each layer already applies its own SDR/HDR residual policy.// This final exclusion mask must preserve the stack's signed// temporal output, including pixels outside protected regions.- float c[32]={1,1,1,1,1,1,desc_.protection.featherPixels,1.f};+ float c[40]={1,1,1,1,1,1,desc_.protection.featherPixels,1.f};for(size_t i=0;i<4;++i){const auto q=engine::protectionConstants(desc_.protection.regions[i]);c[8+i*4]=q[0];c[9+i*4]=q[1];c[10+i*4]=q[2];c[11+i*4]=q[3];}stackProtectionPass_.bind(list,c,gpuHandleOf(stackProtectionPass_,0).ptr,gpuHandleOf(stackProtectionPass_,3).ptr);list->Dispatch(((desc_.nrBeforeSr?srcW_:workW_)+15)/16,((desc_.nrBeforeSr?srcH_:workH_)+15)/16,1);@@ -3106,9 +3108,11 @@ bool EnhanceGraph::applySettings(const engine::EnhancementSettings& s){layer.model=i<desc_.nrLayersModel.size()?desc_.nrLayersModel[i]:s.model;layer.residualSettings=i<desc_.nrLayersResidual.size()?desc_.nrLayersResidual[i]:s.residual;const auto& correction=layer.residualSettings.correction;- veyra::log::info("nr-correction",std::format("live revision={} layer={} gain={} mode={} temporal={} manual={}/{}/{}/{}/{}",+ veyra::log::info("nr-correction",std::format("live revision={} layer={} gain={} mode={} temporal={} style={} amount={} manual={}/{}/{}/{}/{}/{}/{}/{}/{}",s.revision,i+1,layer.residualSettings.total,correction.enabled?(correction.automatic?"auto":"manual"):"off",- layer.temporalEnabled,correction.hue,correction.chroma,correction.highlight,correction.compression,correction.stability));+ layer.temporalEnabled,layer.model.style,correction.autoAmount,+ correction.hue,correction.chroma,correction.highlight,correction.compression,correction.stability,+ correction.neutral,correction.colorKeep,correction.lumaKeep,correction.shadow));layer.protection=i<desc_.nrLayersProtection.size()?desc_.nrLayersProtection[i]:s.protection;}layer.temporal().reset();diff --git a/src/pipeline/NrTemporalPass.cpp b/src/pipeline/NrTemporalPass.cppindex aede227c..b82eed8c 100644--- a/src/pipeline/NrTemporalPass.cpp+++ b/src/pipeline/NrTemporalPass.cpp@@ -35,8 +35,8 @@ bool NrTemporalPass::initialize(ID3D12Device* device,ID3D12Resource* base,ID3D12for(unsigned i=0;i<2;++i){history_[i]=makeTexture(device,width_,height_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);guide_[i]=makeTexture(device,width_,height_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);if(!history_[i]||!guide_[i])return false;}std::vector<uint8_t> shader;// 7 SRVs (base, raw, history, guide, motion, low residual, low guide), 3 UAVs,- // 36 constants: original 24, Route/LowSize/pad, optional correction block.- if(!raw_||!pass_.loadShader("NrTemporal.dxil",shader)||!pass_.create(device,shader,20,7,3,36))return false;+ // 44 constants: original 24, Route/LowSize/pad, optional 16-float correction.+ if(!raw_||!pass_.loadShader("NrTemporal.dxil",shader)||!pass_.create(device,shader,20,7,3,44))return false;if(lowFrequency){std::vector<uint8_t> reduce;// 3 SRVs + 2 UAVs = 5 slots per phase, two phases.@@ -76,7 +76,7 @@ void NrTemporalPass::run(ID3D12GraphicsCommandList* list,StateTracker& tracker,bif(!intervalSane&&valid_)valid_=false;const bool useHistory=valid_&&!reset&&haveMotion&&intervalSane;// 80 ms past-history EMA; no future frames or presentation holdback.- const float stability=correction.enabled?(correction.automatic?1.f:correction.stability):1.f;+ const float stability=correction.enabled?(correction.automatic?correction.autoAmount:correction.stability):1.f;const float weight=useHistory?float(std::exp(-frameMs/80.0))*stability:0.f;const unsigned route=routeOf(tier_);if(route==4){@@ -98,7 +98,7 @@ void NrTemporalPass::run(ID3D12GraphicsCommandList* list,StateTracker& tracker,btracker.transition(list,history_[1-i].Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);tracker.transition(list,guide_[1-i].Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);for(auto* r:{output_,history_[i].Get(),guide_[i].Get()})tracker.transition(list,r,D3D12_RESOURCE_STATE_UNORDERED_ACCESS);- float c[36]={std::bit_cast<float>(width_),std::bit_cast<float>(height_),weight,total,protection.enabled?1.f:0.f,protection.featherPixels,0,0};+ float c[44]={std::bit_cast<float>(width_),std::bit_cast<float>(height_),weight,total,protection.enabled?1.f:0.f,protection.featherPixels,0,0};for(unsigned n=0;n<4;++n){const auto r=engine::protectionConstants(protection.regions[n]);c[8+n*4]=r[0];c[9+n*4]=r[1];c[10+n*4]=r[2];c[11+n*4]=r[3];}// Route and the low-frequency extent follow the region block. The shader// reads LowSize only on route 4 and the pad is never read: they exist todiff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cppindex 221b18c7..9076f2b3 100644--- a/src/ui/QmlPlayerBridge.cpp+++ b/src/ui/QmlPlayerBridge.cpp@@ -4117,7 +4117,10 @@ QVariantList QmlPlayerBridge::nrLayers() const {{"correctionEnabled",n.residual.correction.enabled},{"correctionAuto",n.residual.correction.automatic},{"hueProtection",n.residual.correction.hue},{"chromaProtection",n.residual.correction.chroma},{"highlightProtection",n.residual.correction.highlight},{"localCompression",n.residual.correction.compression},- {"temporalStability",n.residual.correction.stability}};+ {"temporalStability",n.residual.correction.stability},+ {"neutralProtection",n.residual.correction.neutral},{"colorRetention",n.residual.correction.colorKeep},+ {"luminanceRetention",n.residual.correction.lumaKeep},{"shadowProtection",n.residual.correction.shadow},+ {"correctionAmount",n.residual.correction.autoAmount}};}return out;}@@ -4173,6 +4176,11 @@ bool QmlPlayerBridge::setNrLayerParameter(int index,const QString& key,double vaelse if(key=="highlightProtection")n.residual.correction.highlight=float(value);else if(key=="localCompression")n.residual.correction.compression=float(value);else if(key=="temporalStability")n.residual.correction.stability=float(value);+ else if(key=="neutralProtection")n.residual.correction.neutral=float(value);+ else if(key=="colorRetention")n.residual.correction.colorKeep=float(value);+ else if(key=="luminanceRetention")n.residual.correction.lumaKeep=float(value);+ else if(key=="shadowProtection")n.residual.correction.shadow=float(value);+ else if(key=="correctionAmount")n.residual.correction.autoAmount=float(value);else {if(value!=std::floor(value)||value<0||value>6)return false;if(key=="sizePolicy"){@@ -4185,6 +4193,7 @@ bool QmlPlayerBridge::setNrLayerParameter(int index,const QString& key,double vaelse if(key=="temporal"&&value<=1)n.temporal=value!=0;else if(key=="correctionEnabled"&&value<=1)n.residual.correction.enabled=value!=0;else if(key=="correctionAuto"&&value<=1)n.residual.correction.automatic=value!=0;+ else if(key=="correctionUseAuto"&&value==1)n.residual.correction.useAutomaticValues(n.model.style);else if(key=="antiFlicker"&&validNrAntiFlicker(engine::NrAntiFlicker(int(value))))n.antiFlicker=static_cast<engine::NrAntiFlicker>(int(value));else return false;}diff --git a/tests/integration/NrCorrectionGpuTests.cpp b/tests/integration/NrCorrectionGpuTests.cppindex 8b3602fc..125b2eec 100644--- a/tests/integration/NrCorrectionGpuTests.cpp+++ b/tests/integration/NrCorrectionGpuTests.cpp@@ -58,9 +58,9 @@ struct Fixture{bd.Height=1;bd.DepthOrArraySize=1;bd.MipLevels=1;bd.SampleDesc.Count=1;bd.Layout=D3D12_TEXTURE_LAYOUT_ROW_MAJOR;if(FAILED(ctx.device()->CreateCommittedResource(&hp,D3D12_HEAP_FLAG_NONE,&bd,D3D12_RESOURCE_STATE_COPY_DEST,nullptr,IID_PPV_ARGS(&readback))))return false;std::vector<uint8_t> shader;- if(!pass.loadShader("NrResidualComposite.dxil",shader)||!pass.create(ctx.device(),shader,4,3,1,32))return false;+ if(!pass.loadShader("NrResidualComposite.dxil",shader)||!pass.create(ctx.device(),shader,4,3,1,40))return false;std::ifstream f(archived,std::ios::binary);std::vector<uint8_t> old((std::istreambuf_iterator<char>(f)),{});- if(!f||old.empty()||!legacy.create(ctx.device(),old,4,3,1,32))return false;+ if(!f||old.empty()||!legacy.create(ctx.device(),old,4,3,1,40))return false;for(auto* p:{&pass,&legacy}){makeSrv(ctx.device(),base.Get(),format,cpuHandleOf(*p,0));makeSrv(ctx.device(),base.Get(),format,cpuHandleOf(*p,1));@@ -84,7 +84,7 @@ struct Fixture{list->CopyTextureRegion(&dst,0,0,0,&src,nullptr);return ring.submitAndSignal(slot)&&ring.waitIdle();}- std::vector<Pixel> render(const std::array<float,32>& c,bool old=false){+ std::vector<Pixel> render(const std::array<float,40>& c,bool old=false){unsigned slot;auto* list=ring.acquireNext(slot,status);if(!list)return {};for(auto* tex:{base.Get(),neural.Get()})states.transition(list,tex,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);states.transition(list,output.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);@@ -122,7 +122,7 @@ int wmain(int argc,wchar_t** argv){for(unsigned i=32;i<128;++i){const float e=(float(i)-80)*1e-7f;base[i]={.2f+e,.2f,.2f-e,.7f};nr[i]={.9f,.05f,.3f,1};}if(fp16){quantize(base);quantize(nr);}if(!f.fill(f.base.Get(),base)||!f.fill(f.neural.Get(),nr))return 2;- std::array<float,32> c{};c[0]=c[1]=c[2]=c[3]=c[4]=1;+ std::array<float,40> c{};c[0]=c[1]=c[2]=c[3]=c[4]=1;for(float gain:{0.f,1.f,2.f,5.f}){c[0]=gain;auto old=f.render(c,true),now=f.render(c);if(old.size()!=Count||now.size()!=Count)return 2;@@ -171,6 +171,35 @@ int wmain(int argc,wchar_t** argv){c[0]=5;std::fill(c.begin()+24,c.end(),0);c[24]=1;auto zero=f.render(c),off=f.render(c,true);bool identical=true;for(unsigned i=0;i<Count;++i)identical&=distance(zero[i],off[i])==0;check("all manual protections zero retains raw gain five",identical);+ // Style-specific auto and each extra manual control through production+ // constants, measured independently in double precision.+ auto chromaError=[&](const std::vector<Pixel>& values){+ double error=0;for(unsigned i=0;i<Count;++i){auto a=lab(base[i]),b=lab(values[i]);+ error+=std::hypot(b[1]-a[1]*b[0]/std::max(a[0],1e-6),b[2]-a[2]*b[0]/std::max(a[0],1e-6));}+ return error/Count;+ };+ std::copy(controls.begin(),controls.end(),c.begin()+24);auto style0=f.render(c);double originalError=chromaError(style0);+ for(int style:{1,2}){+ auto profile=control.constants(false,style);std::copy(profile.begin(),profile.end(),c.begin()+24);+ auto result=f.render(c);double error=chromaError(result);bool legal=true;+ for(auto p:result)legal&=finite(p)&&std::min({p.r,p.g,p.b})>=0&&std::max({p.r,p.g,p.b})<=1;+ std::cout<<"auto style="<<style<<" source-relative color error="<<error<<" style0="<<originalError<<std::endl;+ check("styles 1/2 preserve more source color without disabling NR",legal&&error<originalError*.4&&distance(result[0],base[0])>0);+ }+ for(unsigned field=32;field<=35;++field){auto raw=c;std::fill(raw.begin()+24,raw.end(),0);raw[24]=1;+ auto isolated=raw;isolated[field]=1;auto before=f.render(raw),after=f.render(isolated);float response=0;+ for(unsigned i=0;i<Count;++i)response=std::max(response,distance(before[i],after[i]));+ check("extra manual spatial control has independent response",response>.0001f);+ if(field==32){auto o=lab(base[80]),p=lab(after[80]);+ check("neutral protection repairs gray tint without hue direction",std::hypot(p[1],p[2])<(fp16?.001:.00001)&&p[0]>0);}+ if(field==33)check("full color retention preserves source RGB ratios",chromaError(after)<(fp16?.0003:.000003));+ if(field==34){double error=0;for(unsigned i=0;i<Count;++i)error=std::max(error,std::abs(lab(after[i])[0]-lab(base[i])[0]));+ check("full lightness retention keeps source lightness independently",error<(fp16?.0008:.00001));}+ if(field==35)check("shadow control restores dark detail",lab(after[3])[0]>lab(before[3])[0]);+ }+ control.autoAmount=0;auto none=control.constants();std::copy(none.begin(),none.end(),c.begin()+24);+ auto amountZero=f.render(c);identical=true;for(unsigned i=0;i<Count;++i)identical&=distance(amountZero[i],off[i])==0;+ check("automatic amount zero retains exact original gain five",identical);control.autoAmount=1;// A full user exclusion bypasses every colour control.std::copy(controls.begin(),controls.end(),c.begin()+24);c[5]=1;c[6]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=1;auto protectedFrame=f.render(c);identical=true;diff --git a/tests/integration/NrVideoQualityProbe.cpp b/tests/integration/NrVideoQualityProbe.cppindex e3740fb9..19e780bd 100644--- a/tests/integration/NrVideoQualityProbe.cpp+++ b/tests/integration/NrVideoQualityProbe.cpp@@ -233,7 +233,7 @@ int wmain(int argc,wchar_t** argv){if(featherStack){std::vector<uint8_t> shader;protectionExpected=pipeline::makeTexture(ctx.device(),info.width,info.height,DXGI_FORMAT_R16G16B16A16_FLOAT,true);- if(!protectionExpected||!protectionOracle.loadShader("NrResidualComposite.dxil",shader)||!protectionOracle.create(ctx.device(),shader,4,3,1,32))return 2;+ if(!protectionExpected||!protectionOracle.loadShader("NrResidualComposite.dxil",shader)||!protectionOracle.create(ctx.device(),shader,4,3,1,40))return 2;pipeline::DescriptorStager staging;if(!staging.initialize(ctx.device(),3))return 2;staging.stageSrv(graph.diagnosticNrBase(),nullptr,protectionOracle.heap.Get(),0);staging.stageSrv(graph.diagnosticNrBase(),nullptr,protectionOracle.heap.Get(),1);@@ -282,7 +282,7 @@ int wmain(int argc,wchar_t** argv){unsigned slot=0;auto* list=ring.acquireNext(slot,status);if(!list)return 2;expectedStates.transition(list,protectionExpected.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);// Protect the complete stack, preserving signed residuals outside it.- float constants[32]={1,1,1,1,1,1,32,1};+ float constants[40]={1,1,1,1,1,1,32,1};constants[8]=.45f;constants[9]=.3f;constants[10]=.8f;constants[11]=.7f;protectionOracle.bind(list,constants,pipeline::gpuHandleOf(protectionOracle,0).ptr,pipeline::gpuHandleOf(protectionOracle,3).ptr);list->Dispatch((info.width+15)/16,(info.height+15)/16,1);diff --git a/tests/integration/RepairShaderTests.cpp b/tests/integration/RepairShaderTests.cppindex c950e279..510b40ff 100644--- a/tests/integration/RepairShaderTests.cpp+++ b/tests/integration/RepairShaderTests.cpp@@ -15,7 +15,7 @@ int main(){D3D12_HEAP_PROPERTIES hp{};hp.Type=D3D12_HEAP_TYPE_READBACK;D3D12_RESOURCE_DESC bd{};bd.Dimension=D3D12_RESOURCE_DIMENSION_BUFFER;bd.Width=16*256;bd.Height=1;bd.DepthOrArraySize=1;bd.MipLevels=1;bd.SampleDesc.Count=1;bd.Layout=D3D12_TEXTURE_LAYOUT_ROW_MAJOR;ComPtr<ID3D12Resource> readback;if(FAILED(ctx.device()->CreateCommittedResource(&hp,D3D12_HEAP_FLAG_NONE,&bd,D3D12_RESOURCE_STATE_COPY_DEST,nullptr,IID_PPV_ARGS(&readback))))return 2;ComputePass down,residual;std::vector<uint8_t> cs;- if(!down.loadShader("NrDownsample.dxil",cs)||!down.create(ctx.device(),cs,2,1,1)||!residual.loadShader("NrResidualComposite.dxil",cs)||!residual.create(ctx.device(),cs,4,3,1,32))return 2;+ if(!down.loadShader("NrDownsample.dxil",cs)||!down.create(ctx.device(),cs,2,1,1)||!residual.loadShader("NrResidualComposite.dxil",cs)||!residual.create(ctx.device(),cs,4,3,1,40))return 2;makeSrv(ctx.device(),base.Get(),DXGI_FORMAT_R32G32B32A32_FLOAT,cpuHandleOf(down,0));makeUav(ctx.device(),low.Get(),DXGI_FORMAT_R32G32B32A32_FLOAT,cpuHandleOf(down,1));makeSrv(ctx.device(),base.Get(),DXGI_FORMAT_R32G32B32A32_FLOAT,cpuHandleOf(residual,0));makeSrv(ctx.device(),low.Get(),DXGI_FORMAT_R32G32B32A32_FLOAT,cpuHandleOf(residual,1));makeSrv(ctx.device(),low.Get(),DXGI_FORMAT_R32G32B32A32_FLOAT,cpuHandleOf(residual,2));makeUav(ctx.device(),result.Get(),DXGI_FORMAT_R32G32B32A32_FLOAT,cpuHandleOf(residual,3));StateTracker states;uint32_t slot;auto* list=ring.acquireNext(slot,status);states.transition(list,base.Get(),D3D12_RESOURCE_STATE_COPY_DEST);@@ -27,7 +27,7 @@ int main(){std::cout<<"area downsample checkerboard mean="<<ok<<std::endl;for(float strength:{0.0f,1.0f,2.0f}){list=ring.acquireNext(slot,status);states.transition(list,low.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);states.transition(list,result.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);- float c[32]={strength,0.5f,1.5f,2,0,0,0,0};residual.bind(list,c,gpuHandleOf(residual,0).ptr,gpuHandleOf(residual,3).ptr);list->Dispatch(1,1,1);states.uavBarrier(list,result.Get());states.transition(list,result.Get(),D3D12_RESOURCE_STATE_COPY_SOURCE);copy(result.Get(),16,16);if(!ring.submitAndSignal(slot)||!ring.waitIdle())return 2;+ float c[40]={strength,0.5f,1.5f,2,0,0,0,0};residual.bind(list,c,gpuHandleOf(residual,0).ptr,gpuHandleOf(residual,3).ptr);list->Dispatch(1,1,1);states.uavBarrier(list,result.Get());states.transition(list,result.Get(),D3D12_RESOURCE_STATE_COPY_SOURCE);copy(result.Get(),16,16);if(!ring.submitAndSignal(slot)||!ring.waitIdle())return 2;readback->Map(0,&range,&data);values=static_cast<float*>(data);bool identity=true;for(int y=0;y<16;++y)for(int x=0;x<16;++x)identity=identity&&values[y*64+x*4]==(((x+y)%2)?0.75f:0.25f);readback->Unmap(0,&written);ok=ok&&identity;std::cout<<"zero residual strength="<<strength<<" base identity="<<identity<<std::endl;}auto neural=makeTexture(ctx.device(),8,8,DXGI_FORMAT_R32G32B32A32_FLOAT,true);@@ -45,7 +45,7 @@ int main(){// .10 + 2*(.04-.10) negative, destroying all of this patch's detail.ok=ok&&fill(base.Get(),16,16,.10f,.10f,.10f)&&fill(low.Get(),8,8,.10f,.10f,.10f)&&fill(neural.Get(),8,8,.04f,.04f,.04f);for(unsigned control=0;control<5;++control)for(float strength:{0.f,.5f,1.f,2.f}){- float c[32]={1,1,1,1,1,0,0,0};c[control]=strength;+ float c[40]={1,1,1,1,1,0,0,0};c[control]=strength;list=ring.acquireNext(slot,status);states.transition(list,result.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);residual.bind(list,c,gpuHandleOf(residual,0).ptr,gpuHandleOf(residual,3).ptr);list->Dispatch(1,1,1);states.uavBarrier(list,result.Get());states.transition(list,result.Get(),D3D12_RESOURCE_STATE_COPY_SOURCE);copy(result.Get(),16,16);@@ -64,7 +64,7 @@ int main(){// highlights. Default residual settings must not clamp either boundary.ok=ok&&fill(base.Get(),16,16,-.1f,2.f,.5f)&&fill(low.Get(),8,8,-.1f,2.f,.5f)&&fill(neural.Get(),8,8,-.2f,3.f,.75f);list=ring.acquireNext(slot,status);states.transition(list,result.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);- float hdr[32]={1,1,1,1,1,0,0,1};residual.bind(list,hdr,gpuHandleOf(residual,0).ptr,gpuHandleOf(residual,3).ptr);list->Dispatch(1,1,1);+ float hdr[40]={1,1,1,1,1,0,0,1};residual.bind(list,hdr,gpuHandleOf(residual,0).ptr,gpuHandleOf(residual,3).ptr);list->Dispatch(1,1,1);states.uavBarrier(list,result.Get());states.transition(list,result.Get(),D3D12_RESOURCE_STATE_COPY_SOURCE);copy(result.Get(),16,16);if(!ring.submitAndSignal(slot)||!ring.waitIdle())return 2;readback->Map(0,&range,&data);values=static_cast<float*>(data);diff --git a/tests/qml/quick/tst_components.qml b/tests/qml/quick/tst_components.qmlindex 1bd30e6a..b9050c1a 100644--- a/tests/qml/quick/tst_components.qml+++ b/tests/qml/quick/tst_components.qml@@ -8,7 +8,7 @@ import VeyraTest 1.0Item {id: rootwidth: 1480- height: 900+ height: 1500VSwitch { id: sw; x: 10; y: 10 }SignalSpy { id: swSpy; target: sw; signalName: "toggled" }@@ -67,7 +67,7 @@ Item {id: nrFixtureItem {id: fixture- width: 1480; height: 900; z: 20+ width: 1480; height: 1500; z: 20property int lastIndex: -1property string lastKey: ""property var rows: [0,1,2,3].map(i => ({@@ -77,7 +77,9 @@ Item {color: 1, luminance: 1, temporal: false, antiFlicker: 2,correctionEnabled: false, correctionAuto: true,hueProtection: 1, chromaProtection: 0.75, highlightProtection: 1,- localCompression: 0.75, temporalStability: 0.8+ localCompression: 0.75, temporalStability: 0.8,+ neutralProtection: 0, colorRetention: 0, luminanceRetention: 0,+ shadowProtection: 0, correctionAmount: 1}))function edit(nodeIndex,key,amount) {lastIndex=nodeIndex; lastKey=key@@ -451,11 +453,14 @@ Item {compare(fixture.rows[0].correctionEnabled,true)const mode=findChild(card,"nr-correctionAuto")compare(mode.current,"1")+ const amount=findChild(card,"nr-correctionAmount")+ verify(amount.visible);mouseClick(amount,amount.trackWidth*0.65,amount.height/2)+ fuzzyCompare(fixture.rows[0].correctionAmount,0.65,0.015)verify(!findChild(card,"nr-temporal").enabled)mouseClick(mode,mode.width-15,mode.height/2)compare(fixture.rows[0].correctionAuto,false)verify(waitForPolish(root.Window.window));wait(550)- for(const key of ["hueProtection","chromaProtection","highlightProtection","localCompression","temporalStability"]){+ for(const key of ["hueProtection","chromaProtection","neutralProtection","colorRetention","luminanceRetention","shadowProtection","highlightProtection","localCompression","temporalStability"]){const control=findChild(card,"nr-"+key)verify(control.visible)mouseClick(control,control.trackWidth*0.35,control.height/2)@@ -465,6 +470,8 @@ Item {compare(fixture.rows[0].correctionAuto,true)compare(findChild(card,"nr-hueProtection").visible,false)fuzzyCompare(fixture.rows[0].hueProtection,0.35,0.015)+ fuzzyCompare(fixture.rows[0].colorRetention,0.35,0.015)+ fuzzyCompare(fixture.rows[0].correctionAmount,0.65,0.015)mouseClick(enabled)compare(fixture.rows[0].correctionEnabled,false)verify(findChild(card,"nr-temporal").enabled)diff --git a/tests/unit/EffectChainTests.cpp b/tests/unit/EffectChainTests.cppindex 7370c34c..9abbceeb 100644--- a/tests/unit/EffectChainTests.cpp+++ b/tests/unit/EffectChainTests.cpp@@ -934,6 +934,18 @@ void testNrCorrectionDescription(){check(requiresGraphRebuild(s,corrected),"NR correction switch rebuilds history topology");describeStages(request,corrected,d);check(d.nrTemporal&&d.enableNvofStandalone,"NR auto requests real flow even with zero model motion");+ auto noAmount=corrected;noAmount.residual.correction.autoAmount=0;+ check(requiresGraphRebuild(corrected,noAmount),"zero automatic amount releases corrected history");+ describeStages(request,noAmount,d);+ check(!d.nrTemporal&&!d.enableNvofStandalone,"zero automatic amount has no correction history");+ auto halfAmount=corrected;halfAmount.residual.correction.autoAmount=.5f;+ check(!requiresGraphRebuild(corrected,halfAmount),"nonzero automatic amount changes live without new history");+ for(int style:{0,1,2}){+ NrCorrectionSettings automatic;automatic.enabled=true;automatic.autoAmount=.6f;+ const auto a=automatic.constants(false,style);automatic.useAutomaticValues(style);const auto b=automatic.constants(false,style);+ bool same=true;for(unsigned i=0;i<a.size();++i)if(i!=6)same&=a[i]==b[i];+ check(same&&!automatic.automatic,"copy automatic profile into manual preserves effective values");+ }auto manual=corrected;manual.residual.correction.automatic=false;manual.residual.correction.stability=.5f;check(!requiresGraphRebuild(corrected,manual),"NR manual/auto with history is a live parameter update");manual.residual.correction.stability=0;diff --git a/tests/unit/PresetLibraryTests.cpp b/tests/unit/PresetLibraryTests.cppindex abccf380..dfa3acc2 100644--- a/tests/unit/PresetLibraryTests.cpp+++ b/tests/unit/PresetLibraryTests.cpp@@ -905,24 +905,26 @@ void testNrVariants() {void testNrCorrectionStorage() {// Exercise the public store/session/chain paths, including hidden manual// values while the switch is off. Never rely on serialising a test struct.- for(unsigned mode=0;mode<3;++mode){+ for(unsigned mode=0;mode<3;++mode)for(bool extended:{false,true}){EnhancementSettings s;s.nr=true;s.nrLayerCount=2;for(unsigned i=0;i<s.nrLayerCount;++i){auto& n=s.nrLayers[i];n.enabled=true;n.residual.total=5-float(i);n.residual.correction={mode!=0,mode!=2,.35f+float(i)*.1f,.2f,.7f,.5f,.65f};+ if(extended){auto& c=n.residual.correction;c.neutral=.8f-float(i)*.1f;c.colorKeep=.7f;c.lumaKeep=.3f;c.shadow=.6f;c.autoAmount=.75f;}}s.residual=s.nrLayers[0].residual;- const auto path=scratch((L"nr-correction-"+std::to_wstring(mode)+L".v1").c_str());+ const auto suffix=extended?L"-extended":L"";+ const auto path=scratch((L"nr-correction-"+std::to_wstring(mode)+suffix+L".v1").c_str());PresetLibrary writer(path);writer.setIncludeBuiltins(false);PresetEntry entry;entry.name=L"strength five";entry.chain=toChain(s);check(writer.load()&&writer.put(entry),"NR correction: preset save");- check(readBytes(path).starts_with("VEYRA_PRESET_LIBRARY 8\n"),"NR correction: explicit new schema");+ check(readBytes(path).starts_with(extended?"VEYRA_PRESET_LIBRARY 9\n":"VEYRA_PRESET_LIBRARY 8\n"),"NR correction: lowest compatible schema");PresetLibrary reader(path);reader.setIncludeBuiltins(false);check(reader.load()&&reader.entries().size()==1&&reader.entries()[0]==entry,"NR correction: enabled/mode/manual values survive reload");auto session=std::make_unique<ChainSession>(ChainSession::initial(s));check(session->select(ChainMode::Node),"NR correction: node session initializes");- ChainSessionStore store(scratch((L"nr-correction-session-"+std::to_wstring(mode)+L".v1").c_str()));+ ChainSessionStore store(scratch((L"nr-correction-session-"+std::to_wstring(mode)+suffix+L".v1").c_str()));auto restored=std::make_unique<ChainSession>(ChainSession::initial({}));check(store.save(*session)&&store.load(*restored)&&*restored==*session,"NR correction: list/node and editor session roundtrip");@@ -937,6 +939,10 @@ void testNrCorrectionStorage() {check(!invalid.validate().empty(),"NR correction: component gain retains old limit");invalid.residual.color=1;invalid.residual.correction.highlight=1.01f;check(!invalid.validate().empty(),"NR correction: invalid protection rejected even while disabled");+ invalid.residual.correction={};invalid.residual.correction.neutral=1.001f;+ check(!invalid.validate().empty(),"NR correction: neutral value range enforced");+ invalid.residual.correction={};invalid.residual.correction.autoAmount=-.1f;+ check(!invalid.validate().empty(),"NR correction: automatic amount range enforced");}int main() {testNrCorrectionStorage();diff --git a/tests/unit/RepairPresetTests.cpp b/tests/unit/RepairPresetTests.cppindex 3613a265..b1243207 100644--- a/tests/unit/RepairPresetTests.cpp+++ b/tests/unit/RepairPresetTests.cpp@@ -303,16 +303,18 @@ ok=ok&&b.entries().size()==1&&b.defaultSettings()==s;ok=ok&&!corruptLoaded&&!corruptPut&&corruptPreserved;f.close();ok=legacyBackends(p)&&ok;ok=retiredSrMode(p)&&ok;ok=schemaVersions(p)&&ok;- for(unsigned mode=0;mode<3;++mode){+ for(unsigned mode=0;mode<3;++mode)for(bool extended:{false,true}){EnhancementSettings corrected;corrected.nr=true;corrected.residual.total=5;corrected.residual.correction={mode!=0,mode!=2,.35f,.25f,.8f,.7f,.5f};+ if(extended){auto& c=corrected.residual.correction;c.neutral=.65f;c.colorKeep=.75f;c.lumaKeep=.2f;c.shadow=.6f;c.autoAmount=.85f;}corrected.nrLayerCount=2;for(unsigned i=0;i<2;++i){auto& n=corrected.nrLayers[i];n.enabled=true;n.residual=corrected.residual;n.residual.correction.hue+=float(i)*.1f;}auto path=p;path+=L"-nr-correction-"+std::to_wstring(mode);+ if(extended)path+=L"-extended";std::error_code ec;std::filesystem::remove(path,ec);PresetStore writer(path);bool roundtrip=writer.load()&&writer.put(L"strength five",corrected);PresetStore reload(path);roundtrip=roundtrip&&reload.load()&&reload.entries().size()==1&&reload.entries()[0].settings==corrected;- std::ifstream header(path);std::string magic;unsigned version=0;roundtrip=roundtrip&&bool(header>>magic>>version)&&version==29;- ok&=roundtrip;std::cout<<"strength five correction mode "<<mode<<" schema29 roundtrip="<<roundtrip<<'\n';+ std::ifstream header(path);std::string magic;unsigned version=0;roundtrip=roundtrip&&bool(header>>magic>>version)&&version==(extended?30:29);+ ok&=roundtrip;std::cout<<"strength five correction mode "<<mode<<" schema="<<version<<" roundtrip="<<roundtrip<<'\n';}std::cout<<"preset roundtrip, all fields, duplicate, rename-default, delete, validation, unknown schema, corrupt-preservation="<<ok<<'\n';return ok?0:1;}