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++
feat(color): carry source MaxCLL/MaxFALL into HDR exports and mark them as not recomputed when grading
Veyra Goal Agent50f1ad4cf954
diff --git a/docs/COLOR_TAB_P1_DELIVERY_2026-09-17.md b/docs/COLOR_TAB_P1_DELIVERY_2026-09-17.mdindex d2d287d6..fdbf7461 100644--- a/docs/COLOR_TAB_P1_DELIVERY_2026-09-17.md+++ b/docs/COLOR_TAB_P1_DELIVERY_2026-09-17.md@@ -80,11 +80,22 @@- **LUT 输入空间不匹配必须拒绝**:HDR 内容选 sRGB、SDR 内容选 PQ 都会被拒(`colorLutNotice()` 非空、像素与无 LUT 逐字节一致),并且通过 `colorStatus` 在状态面板可见,不只写日志。+**HDR 导出的静态元数据(部分完成,按方案 §5.3 的兜底条款实现)**++已做:HDR 导出会把源文件的 **MaxCLL / MaxFALL 原样写进 MP4 的 `clli` box**(走+`videoStream->codecpar->coded_side_data`,由 FFmpeg movenc 落盘),调色开启时额外写一条+`[color-export] … carried over from the source and NOT recomputed … (marked as not updated)` 警告。+证据(本机真跑,命令与结果在 WORKLOG):++- 源(x265 写的 SEI):`maxCLL=1000 maxFALL=400`;+- 导出:`side_data_type="Content light level metadata", max_content=1000, max_average=400`,+ 同时保留 PQ/BT.2020/HEVC Main10;+- 带调色导出:同一条元数据 + 警告,且画面确实被调色(与不调色导出的同一帧 PSNR 5.39 dB)。+**未完成(如实列出,不冒充通过)**-1. **导出时重算 MaxCLL / MaxFALL**:需要“写 header 前先跑一遍全片直方图”的两遍流程,外加把结果- 通过 NVENC SEI / MP4 `clli` 写进码流,本轮没实现。当前行为:HDR + 调色开启时明确写一条- `[color-export] … not recomputed … (marked as not updated)` 警告,**不静默**写与实际不符的元数据。+1. **导出时“重算” MaxCLL / MaxFALL**:需要“写 header 前先跑一遍全片直方图”的两遍流程+ (再加 mastering-display `mdcv` box),本轮只做了“原样带上 + 明确标注未更新”的兜底,没有重算。2. 分组眼睛(每组 bypass)、点曲线编辑器、黑白混色器开关:模型里已留字段,UI 未做(方案 §9 的P1 清单里属于 T3/T4 的“眼睛/曲线”子项,本轮用“整组折叠 + 一键还原”替代,未做独立 bypass 位)。3. 预设导出 `.vpcolor` 只带参数与 LUT **文件名**,不带 LUT 文件本体(换机导入需自行拷 `.cube`)。@@ -92,8 +103,8 @@## 6. 回归与闸门-- `scripts/gates/delivery.ps1` → **DELIVERY SHORT GATE PASS**- (`logs/delivery/fd83775cedd04e7c9716ead6f1127d33/result.json`,含 `color-page`、`player-sync`、+- `scripts/gates/delivery.ps1`(最终代码上重跑)→ **DELIVERY SHORT GATE PASS**+ (`logs/delivery/fbb42f3f08e8482a96c817d3883569e0/result.json`,含 `color-page`、`player-sync`、`controls` 等用例);- 52 个测试程序逐个单跑:**45 个 exit 0**;7 个未执行,原因是需要真实硬件/素材或运行库放置策略(`capture_tests` 采集卡、`live_presentation_tests`/`ps5_*`/`hw_import_image` PS5 素材、diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 2fa48444..e7eb1596 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,23 @@# 2026-09-11 继续修复目标模式执行中+## 2026-09-17 色彩页 P1:HDR 导出的 MaxCLL/MaxFALL 兜底(原样带上 + 标注未更新)++方案 §5.3 要求“能测就测;不能测时保留原值并标注未更新,不允许静默写入与实际不符的静态元数据”。+本轮实现前半段的兜底:`VideoExportJob` 在建立 HEVC Main10 输出流时,把源的 `MaxCLL/MaxFALL`+写进 `videoStream->codecpar->coded_side_data`(`AV_PKT_DATA_CONTENT_LIGHT_LEVEL`),+FFmpeg 的 movenc 会据此写 MP4 `clli` box;调色开启时额外写+`[color-export] … carried over from the source and NOT recomputed … (marked as not updated)` 警告。++实测(`%TEMP%\veyra-hdr\hdr-sample.mp4`,x265 写入 `max-cll=1000,400` 的 HDR10 素材):++- 源侧日志:`[hdr-metadata] … contentSource=frame maxCLL=1000 maxFALL=400`;+- `veyra.exe hdr-sample.mp4 --export-out hdr-export.mp4 --hevc --max-frames 6` → exit 0,+ ffprobe:`side_data_type=Content light level metadata, max_content=1000, max_average=400`,+ 输出仍为 `smpte2084 / bt2020 / HEVC Main10`;+- 加 `--color-grade=1.0`:警告出现、元数据同样带上、画面确实被调色(与不调色导出同帧 PSNR 5.39 dB)。++**仍未做**:真正“重算” MaxCLL/MaxFALL(写 header 前的全片直方图两遍流程)与 mastering display `mdcv` 写入。+## 2026-09-17 色彩页 P1:T6 收尾——三入口一致性 + 全量回归 + 交付报告**三入口一致性验收抓到一个功能缺口并修掉**@@ -15,8 +33,8 @@**全量回归**-- `scripts/gates/delivery.ps1` → **DELIVERY SHORT GATE PASS**- (`logs/delivery/fd83775cedd04e7c9716ead6f1127d33/result.json`);+- `scripts/gates/delivery.ps1`(最终代码上重跑)→ **DELIVERY SHORT GATE PASS**+ (`logs/delivery/fbb42f3f08e8482a96c817d3883569e0/result.json`);- 52 个测试程序逐个单跑(带各自所需参数):**45 个 exit 0**;未执行 7 个,全部是硬件/素材/放置策略原因:`capture_tests`(需采集卡)、`live_presentation_tests`、`ps5_quality_tests`、`ps5_hw_image_tests`、`hw_import_image_tests`(需 PS5 素材)、`nr_ampere_tests`diff --git a/src/engine/VideoExportJob.cpp b/src/engine/VideoExportJob.cppindex 9c9ced03..436a6806 100644--- a/src/engine/VideoExportJob.cpp+++ b/src/engine/VideoExportJob.cpp@@ -17,6 +17,7 @@ extern "C" {#include <libavcodec/avcodec.h>#include <libavutil/mathematics.h>#include <libavutil/pixdesc.h>+#include <libavutil/mastering_display_metadata.h>}namespace veyra::engine {namespace { std::string utf8(const std::wstring& s){const int n=WideCharToMultiByte(CP_UTF8,0,s.data(),int(s.size()),nullptr,0,nullptr,nullptr);std::string r(n,0);WideCharToMultiByte(CP_UTF8,0,s.data(),int(s.size()),r.data(),n,nullptr,nullptr);return r;} }@@ -87,7 +88,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOpti// written, which this exporter does not do yet, so say so instead of// letting the user assume the static metadata tracks the graded output.if(gd.hdrOutput&&options.settings.color.enabled&&!options.settings.color.neutral())- veyra::log::warn("color-export","HDR export with the colour grade active: MaxCLL/MaxFALL are not recomputed and no content-light metadata is written (marked as not updated)");+ veyra::log::warn("color-export","HDR export with the colour grade active: MaxCLL/MaxFALL are carried over from the source and NOT recomputed for the graded output (marked as not updated)");gd.captureBitDepth=info.color.pixelFormat==pipeline::SourcePixelFormat::P010?10:info.color.pixelFormat==pipeline::SourcePixelFormat::P016?16:8;if(gd.hdrOutput&&!hevc){failureReason=L"HDR视频请使用HEVC Main10导出(选择HEVC)";break;}// Adapter gate mirrors the preview rules (EngineController): DLSS NR,@@ -139,6 +140,17 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptivideoStream=avformat_new_stream(mux,nullptr);if(!videoStream)break;videoStream->time_base={rate.den,rate.num};videoStream->avg_frame_rate=rate;auto* cp=videoStream->codecpar;cp->codec_type=AVMEDIA_TYPE_VIDEO;cp->codec_id=hevc?AV_CODEC_ID_HEVC:AV_CODEC_ID_H264;cp->width=gd.workWidth;cp->height=gd.workHeight;cp->format=AV_PIX_FMT_YUV420P;cp->color_range=AVCOL_RANGE_MPEG;cp->color_space=AVCOL_SPC_BT709;cp->color_primaries=AVCOL_PRI_BT709;cp->color_trc=AVCOL_TRC_IEC61966_2_1;if(gd.hdrOutput){cp->format=AV_PIX_FMT_YUV420P10LE;cp->color_space=AVCOL_SPC_BT2020_NCL;cp->color_primaries=AVCOL_PRI_BT2020;cp->color_trc=AVCOL_TRC_SMPTE2084;cp->profile=AV_PROFILE_HEVC_MAIN_10;}+ // Plan v5.3: this exporter cannot recompute content light levels (that+ // needs a full pre-pass before the header is written), so the source+ // declaration is carried into the 'clli' box verbatim and the graded case+ // is flagged as "not updated" instead of silently changing meaning.+ if(gd.hdrOutput&&info.color.hdrMaxCllNits>0.0f){+ if(auto* side=av_packet_side_data_new(&cp->coded_side_data,&cp->nb_coded_side_data,AV_PKT_DATA_CONTENT_LIGHT_LEVEL,sizeof(AVContentLightMetadata),0)){+ auto* cll=reinterpret_cast<AVContentLightMetadata*>(side->data);+ cll->MaxCLL=unsigned(info.color.hdrMaxCllNits);+ cll->MaxFALL=unsigned(info.color.hdrMaxFallNits);+ }else failureReason=L"无法写入内容亮度元数据(MaxCLL/MaxFALL)";+ }auto inputUtf8=utf8(input);if(avformat_open_input(&audioInput,inputUtf8.c_str(),nullptr,nullptr)<0||avformat_find_stream_info(audioInput,nullptr)<0){progress(0,L"无法读取源音轨信息,已停止导出");break;}{