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(remoteplay): add chroma-aware sampling and cubic presentation
Veyra Goal Agentf037f49a1349
diff --git a/apps/veyra/ui/RemotePlayPanel.cpp b/apps/veyra/ui/RemotePlayPanel.cppindex 9c0ec3f3..2f3227b5 100644--- a/apps/veyra/ui/RemotePlayPanel.cpp+++ b/apps/veyra/ui/RemotePlayPanel.cpp@@ -15,7 +15,7 @@namespace veyra::ui {namespace {HWND window=nullptr;HFONT font=nullptr;-enum {Host=1,Account,PairPin,Quality,CodecChoice,Pair,Connect,Cancel,Scan,Wake,LoginPin,SendPin,StatusText,Help,Bitrate,Forget,ViewOnly,Calibrate,DecodeChoice,LoginPsn,CompletePsn,ForgetPsn};+enum {Host=1,Account,PairPin,Quality,CodecChoice,Pair,Connect,Cancel,Scan,Wake,LoginPin,SendPin,StatusText,Help,Bitrate,Forget,ViewOnly,Calibrate,DecodeChoice,LoginPsn,CompletePsn,ForgetPsn,SamplingChoice};uint64_t psnLoginStarted=0,psnRefreshAfter=0;std::function<bool()> calibrate;std::function<void(source::RemotePlayConnectDesc)> connect;@@ -73,7 +73,7 @@ remoteplay::VideoProfile video(){p.width=q<2?1280:1920;p.height=q<2?720:1080;p.fps=(q==0||q==2)?30:60;p.codec=static_cast<remoteplay::Codec>(std::clamp<int>(int(SendDlgItemMessageW(window,CodecChoice,CB_GETCURSEL,0,0)),0,2));const auto rate=SendDlgItemMessageW(window,Bitrate,CB_GETCURSEL,0,0);p.bitrateKbps=bitrates[std::clamp<int>(int(rate),0,7)];return p;}-void buttons(){for(int id:{Pair,Connect,Scan,Wake,Host,Account,PairPin,Quality,CodecChoice,Bitrate,Forget,LoginPsn,CompletePsn,ForgetPsn})EnableWindow(GetDlgItem(window,id),!busy);EnableWindow(GetDlgItem(window,Cancel),busy);}+void buttons(){for(int id:{Pair,Connect,Scan,Wake,Host,Account,PairPin,Quality,CodecChoice,Bitrate,SamplingChoice,Forget,LoginPsn,CompletePsn,ForgetPsn})EnableWindow(GetDlgItem(window,id),!busy);EnableWindow(GetDlgItem(window,Cancel),busy);}template<class Work> void launch(Work work){if(busy)return;if(worker.joinable())worker.join();busy=true;done=false;buttons();SetDlgItemTextW(window,StatusText,L"正在处理…可随时取消");worker=std::jthread([work=std::move(work)](std::stop_token stop)mutable{@@ -84,13 +84,13 @@ template<class Work> void launch(Work work){}void arrange(){auto move=[](int id,int x,int y,int w,int h){MoveWindow(GetDlgItem(window,id),dip(window,x),dip(window,y),dip(window,w),dip(window,h),TRUE);};- move(LoginPsn,20,576,145,30);move(CompletePsn,175,576,200,30);move(ForgetPsn,385,576,167,30);+ move(LoginPsn,20,620,145,30);move(CompletePsn,175,620,200,30);move(ForgetPsn,385,620,167,30);move(Host,160,18,270,180);move(Scan,440,18,112,28);move(Account,160,62,392,28);move(PairPin,160,106,180,28);move(Pair,352,106,200,30);move(Quality,160,150,220,150);move(CodecChoice,392,150,160,150);move(Connect,160,199,180,36);move(Wake,352,199,200,36);move(LoginPin,160,250,180,28);move(SendPin,352,250,200,30);- move(Bitrate,160,295,180,180);move(Forget,352,295,80,32);move(Cancel,440,295,112,32);move(StatusText,20,341,530,64);move(ViewOnly,20,408,400,28);move(Calibrate,432,408,120,28);move(DecodeChoice,160,442,392,150);move(Help,20,485,530,86);+ move(Bitrate,160,295,180,180);move(Forget,352,295,80,32);move(Cancel,440,295,112,32);move(StatusText,20,341,530,64);move(ViewOnly,20,408,400,28);move(Calibrate,432,408,120,28);move(DecodeChoice,160,442,392,150);move(SamplingChoice,160,486,392,120);move(Help,20,529,530,86);}LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp)try{switch(msg){case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);@@ -104,6 +104,10 @@ case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);add(L"COMBOBOX",L"",DecodeChoice,CBS_DROPDOWNLIST|WS_TABSTOP);for(auto label:{L"自动 · 优先硬解",L"CPU 软件解码",L"D3D12VA 硬件解码"})SendDlgItemMessageW(h,DecodeChoice,CB_ADDSTRING,0,LPARAM(label));SendDlgItemMessageW(h,DecodeChoice,CB_SETCURSEL,std::min(2u,GetPrivateProfileIntW(L"RemotePlay",L"DecodeMode",0,(remoteplay::profileDirectory()/L"settings.ini").c_str())),0);+ add(L"STATIC",L"采样(重连生效)",107,0,20,489,138,25);+ add(L"COMBOBOX",L"",SamplingChoice,CBS_DROPDOWNLIST|WS_TABSTOP);+ for(auto label:{L"兼容采样 · 原有方式",L"精细采样 · 色度重建与双三次缩放"})SendDlgItemMessageW(h,SamplingChoice,CB_ADDSTRING,0,LPARAM(label));+ SendDlgItemMessageW(h,SamplingChoice,CB_SETCURSEL,std::min(1u,GetPrivateProfileIntW(L"RemotePlay",L"FineSampling",1,(remoteplay::profileDirectory()/L"settings.ini").c_str())),0);add(L"STATIC",L"PS5 地址",100,0,20,21,130,25);add(L"STATIC",L"PSN Account ID",101,0,20,65,130,25);add(L"STATIC",L"8 位配对码",102,0,20,109,130,25);add(L"STATIC",L"格式(重连生效)",103,0,20,153,130,25);add(L"STATIC",L"登录 PIN(可选)",104,0,20,253,135,25);add(L"STATIC",L"码率请求",105,0,20,298,130,25);add(L"COMBOBOX",L"",Host,CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_TABSTOP);SendDlgItemMessageW(h,Host,CB_LIMITTEXT,253,0);@@ -144,7 +148,8 @@ case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);{Forget,L"删除本机保存的这台主机配对信息;以后需要重新配对。"},{ViewOnly,L"只观看,不向PS5转发电脑手柄输入。不能保证同账号手柄仍能直连主机,这是PS5会话规则。"},{Calibrate,L"手柄放稳后校准陀螺仪,让镜头别自己散步。"},- {DecodeChoice,L"自动优先硬解,失败回软件;强制硬解失败会报错。软件解码主要用CPU,硬解用视频解码单元。重连生效。"}});+ {DecodeChoice,L"自动优先硬解,失败回软件;强制硬解失败会报错。软件解码主要用CPU,硬解用视频解码单元。重连生效。"},+ {SamplingChoice,L"精细模式按位置还原颜色采样,放大时用双三次插值并限制边缘光晕;1:1保留原像素。它不改变PS5码率,也不是AI超分:源头丢掉的细节,不能凭空变回来。会增加GPU工作;兼容模式可切回原有采样作对比。重连生效。"}});watching=connectionStatus().active;buttons();arrange();SetTimer(h,1,100,nullptr);if(auto auth=remoteplay::loadPsnAuthorization()){psnRefreshAfter=GetTickCount64()+300000;@@ -200,7 +205,7 @@ case WM_COMMAND:switch(LOWORD(wp)){auto result=remoteplay::pairLocalPs5(host,account,pin,stop);SecureZeroMemory(pin.data(),pin.size());Outcome out;if(result.result.ok&&!stop.stop_requested()){remoteplay::NativeConnectRequest request;request.host=host;request.video=format;request.credentials=std::move(result.credentials);for(auto byte:result.mac)request.consoleId+=std::format("{:02x}",byte);if(request.consoleId=="000000000000")request.consoleId.clear();if(remoteplay::saveProfile(targetPath,request)){out.savedPath=targetPath;out.message=L"配对成功并已加密保存,可以连接。";}else out.message=L"配对成功,但保存失败。请检查目录权限后重试。";}else out.message=result.canceled||stop.stop_requested()?L"已取消配对":std::format(L"配对失败({}),检查 PS5 配对码、Account ID 与网络。",result.result.code);return out;});break;}- case Connect:{if(busy)break;auto saved=remoteplay::loadProfile(profilePath());auto host=ascii(Host);if(!saved||!remoteplay::validHost(host)){SetDlgItemTextW(h,StatusText,L"请先完成配对,并填写有效主机地址。");break;}saved->host=host;saved->video=video();saved->viewOnly=IsDlgButtonChecked(h,ViewOnly)==BST_CHECKED;if(!remoteplay::saveProfile(currentProfile,*saved)){SetDlgItemTextW(h,StatusText,L"保存连接设置失败,请检查目录权限。");break;}source::RemotePlayConnectDesc desc;saved->viewOnly=IsDlgButtonChecked(h,ViewOnly)==BST_CHECKED;desc.request=std::move(*saved);const auto decode=std::clamp<int>(int(SendDlgItemMessageW(h,DecodeChoice,CB_GETCURSEL,0,0)),0,2);desc.decodeMode=static_cast<source::RemotePlayConnectDesc::DecodeMode>(decode);WritePrivateProfileStringW(L"RemotePlay",L"DecodeMode",std::to_wstring(decode).c_str(),(remoteplay::profileDirectory()/L"settings.ini").c_str());connect(std::move(desc));watching=true;EnableWindow(GetDlgItem(h,Cancel),TRUE);SetDlgItemTextW(h,StatusText,L"连接已开始。需要登录 PIN 时在下方提交。关闭面板不停止串流。");break;}+ case Connect:{if(busy)break;auto saved=remoteplay::loadProfile(profilePath());auto host=ascii(Host);if(!saved||!remoteplay::validHost(host)){SetDlgItemTextW(h,StatusText,L"请先完成配对,并填写有效主机地址。");break;}saved->host=host;saved->video=video();saved->viewOnly=IsDlgButtonChecked(h,ViewOnly)==BST_CHECKED;if(!remoteplay::saveProfile(currentProfile,*saved)){SetDlgItemTextW(h,StatusText,L"保存连接设置失败,请检查目录权限。");break;}source::RemotePlayConnectDesc desc;saved->viewOnly=IsDlgButtonChecked(h,ViewOnly)==BST_CHECKED;desc.request=std::move(*saved);const auto decode=std::clamp<int>(int(SendDlgItemMessageW(h,DecodeChoice,CB_GETCURSEL,0,0)),0,2);desc.decodeMode=static_cast<source::RemotePlayConnectDesc::DecodeMode>(decode);WritePrivateProfileStringW(L"RemotePlay",L"DecodeMode",std::to_wstring(decode).c_str(),(remoteplay::profileDirectory()/L"settings.ini").c_str());desc.highQualitySampling=SendDlgItemMessageW(h,SamplingChoice,CB_GETCURSEL,0,0)==1;WritePrivateProfileStringW(L"RemotePlay",L"FineSampling",desc.highQualitySampling?L"1":L"0",(remoteplay::profileDirectory()/L"settings.ini").c_str());connect(std::move(desc));watching=true;EnableWindow(GetDlgItem(h,Cancel),TRUE);SetDlgItemTextW(h,StatusText,L"连接已开始。需要登录 PIN 时在下方提交。关闭面板不停止串流。");break;}case Cancel:if(busy&&worker.joinable())worker.request_stop();else if(watching)disconnect();break;case Scan:launch([](std::stop_token stop){Outcome out;auto report=remoteplay::discoverLocalPs5(stop);for(const auto& line:report.diagnostics)veyra::log::info("remoteplay-discovery",line);out.hosts=std::move(report.hosts);out.message=stop.stop_requested()?L"已取消查找":out.hosts.empty()?(report.error?std::format(L"主机搜索发生错误({}),详情见日志;可手填 IP。",report.error):L"搜索完成,未收到 PS5 回应;可手填 IP,检查主机开机和局域网。"):L"已填入发现的 PS5 地址。多台主机可手工输入目标 IP。";return out;});break;case Wake:{if(busy)break;auto saved=remoteplay::loadProfile(profilePath());if(!saved){SetDlgItemTextW(h,StatusText,L"需要先配对才能唤醒。");break;}saved->host=ascii(Host);launch([request=std::move(*saved)](std::stop_token stop){Outcome out;if(stop.stop_requested()){out.message=L"已取消唤醒";return out;}auto r=remoteplay::wakeLocalPs5(request);out.message=r.ok?L"已发送唤醒请求,等待 PS5 启动后点击连接。":std::format(L"唤醒请求失败({})",r.code);return out;});break;}@@ -217,6 +222,6 @@ void showRemotePlayPanel(HWND parent,std::function<void(source::RemotePlayConneccalibrate=std::move(calibration);connect=std::move(start);login=std::move(pin);connectionStatus=std::move(status);disconnect=std::move(stop);if(window){SetForegroundWindow(window);return;}WNDCLASSW wc{};wc.lpfnWndProc=proc;wc.hInstance=GetModuleHandleW(nullptr);wc.lpszClassName=L"VeyraRemotePlaySetup";wc.hbrBackground=panelBrush();wc.hCursor=LoadCursorW(nullptr,IDC_ARROW);RegisterClassW(&wc);- CreateWindowExW(WS_EX_TOOLWINDOW,wc.lpszClassName,L"PS5 · Remote Play",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,dip(parent,590),dip(parent,665),parent,nullptr,wc.hInstance,nullptr);+ CreateWindowExW(WS_EX_TOOLWINDOW,wc.lpszClassName,L"PS5 · Remote Play",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,dip(parent,590),dip(parent,709),parent,nullptr,wc.hInstance,nullptr);}}diff --git a/docs/PS5_SAMPLING_REPAIR_PLAN_2026-09-13.md b/docs/PS5_SAMPLING_REPAIR_PLAN_2026-09-13.mdnew file mode 100644index 00000000..ca09cae7--- /dev/null+++ b/docs/PS5_SAMPLING_REPAIR_PLAN_2026-09-13.md@@ -0,0 +1,36 @@+# PS5 色度与显示采样修复++用户授权实施并在完成后关机;随后明确撤回音频缓冲选项,现有音频链路不改。基线320f860,存档checkpoint/ps5-sampling-2026-09-13,分支codex/ps5-sampling-repair。++范围:PS5可选精细采样(默认),保留兼容采样用于用户A/B。输入按实际chroma_location重建4:2:0色度;缺失时记录并采用left回退。输出仅在放大时使用带局部限幅的Catmull-Rom重采样,1:1保留像素,缩小时保留原路径。本次不改变NR/SR/FG执行顺序、音频、调度、PS5带宽反馈或增加来历不明的协议字段。++采样选项保存于现有RemotePlay本地settings.ini,重连生效;不改变已有配对、codec、码率、HDR选择。文件、采集、导出默认不启用此次PS5精细采样。++按用户要求不执行画面识别、PS5连接或运行时验收测试;完成shader与C++构建、差异检查并明确报告未执行项。构建通过不等于画质验收。更新施工记录和WORKLOG,创建本地Git存档,不推送发布。完成后发出Windows关机请求,不使用强制关闭应用参数。++## 实施结果++- `ColorDescription` 新增色度位置及显式PS5重建开关;`resolveFrameColor` 解析FFmpeg的left/center/top-left/top/bottom-left/bottom。RemotePlay按当前帧metadata解析,缺失时保持Unknown并在shader采用left回退;首帧日志记录fine、chromaLocation、assumedLeft。缺失值不冒充实际元数据。+- `YuvToLinearRgb.hlsl` 仅在重建开启时按位置做四邻域色度插值,边缘限制在可见尺寸内,不读取解码填充区。亮度仍逐像素读取。NV12/P010及软件planar上传共享该实现;兼容模式沿用2×2色度复制。+- `PresentBlit.hlsl` 增加Catmull-Rom放大采样和局部2×2范围限幅,限制负瓣引入的光晕,保留实际HDR邻域值。1:1像素中心直接读取;缩小仍用原双线性,不冒充高质量抗混叠缩小。参考画面与正常画面使用同一采样选项,sRGB编码单独用flag控制。+- `EnhanceGraphDesc` / `VideoPresenter` 将PS5设置接入现有呈现pass,没有新队列、新中间纹理或正常播放GPU回读;既有GPU呈现计时会包含新增采样工作。开关在初始化后随配置重建保留,PS5恢复重连保留同一connect desc。+- PS5面板新增“采样(重连生效)”:默认“精细采样 · 色度重建与双三次缩放”;可切“兼容采样 · 原有方式”。选择点击连接后存入 `%LOCALAPPDATA%/Veyra/remoteplay/settings.ini` 的 `FineSampling`。旧配对、codec、码率、HDR、解码模式不自动改变。面板下方内容下移44逻辑像素,增加窗口高度。新增悬停说明。+- **音频缓冲选项撤回,未新增。** 未修改音频同步、控制器、串流调度或带宽反馈。未声称本地采样等价Portal官方高质量模式,未伪造固定100Mbps、无损或更高源分辨率。++## 构建与未验收项++两次 `cmd /c out\remoteplay\build-clock-product.cmd` 均exit0,等价MSVC环境执行 `cmake --build out/remoteplay/product-repair --target veyra -j8`。++- 首次日志 `logs/ps5-sampling-product-build.log`:PresentBlit PS/VS、YuvToLinearRgb DXIL及C++主程序完成构建。+- 最终日志 `logs/ps5-sampling-final-build.log`:补充色度fallback与帮助文字后主程序链接成功。+- 保留既有FFmpeg C4244 / WX覆盖警告;本轮无编译失败。`git diff --check` 通过。+- 可执行文件:`out/remoteplay/product-repair/veyra.exe`,沿用桌面“Veyra PS5 测试版”入口。本次仅本机开发版,不是新的Github Release。+- 用户明确要求不测试:本轮未运行自动回归、未执行NR/SR/FG Create/Evaluate、未连接PS5、未检查游戏画面、未执行HDR或GUI视觉验收。此前320f860的旧采样测试不能当作本次新算法已通过。新增采样GPU成本尚未实测,不能保证一定改善观感或保持原延迟。++## 明天验收++1. 打开桌面PS5测试版,保持同一codec、码率和显示尺寸,先关闭增强;选择精细采样并连接。+2. 切换兼容采样并重连,肉眼对比人物、彩色细线及放大显示;不要把两个模式不同codec/倍率造成的差异算在采样上。+3. 如精细模式不合适,直接保持兼容采样,不需覆盖DLL。完整代码回退点为 `checkpoint/ps5-sampling-2026-09-13`,本轮没有不可逆配对迁移。++下一项唯一任务是用户验收精细/兼容采样。源头量化与Portal高质量协议仍是未解决的研究项,不能因本次本地修复宣称严重模糊已全部解决。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 643ac16e..9c5f8815 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1786,3 +1786,9 @@ apps/veyra/SettingsWindow.cpp调整布局;apps/veyra/ui/AppShell.cpp新增音新增SourceFidelityTests及CMake目标,build-source-fidelity.cmd成功;真实RTX5070灰阶/细线2组及1:1/1440p/2160p两交换链呈现12组通过,1:1误差0,灰阶最大误差0.584/255,普通缩放匹配独立CPU双线性参考。颜色既有4组通过;普通H264硬解4帧及并发纹理检查误差0。命令与结果logs/source-fidelity-{build,result,color,hw}.log,单项均不足300秒。新诊断无PS5连接、无主机操作;当时chiaki运行,不争抢会话。没有新NR/SR/FG Create/Evaluate,未改产品算法或运行DLL,未重新宣称PS5 H265/HDR实机通过。当前测试仅到呈现缓冲,不包括DWM或显示器。旧实际PS5同AU误差0是此前证据。修正旧画质审计中的视觉结论和换场景前提,详见docs/PS5_SOURCE_FIDELITY_AUDIT_2026-09-13.md。下一步是色度位置/普通显示采样的独立数值对照与用户肉眼验收,源头编码质量另查同码流元数据/量化,不能用SR掩盖。未推送发布;SDK、DLL、配对、日志与媒体不入Git。++## 2026-09-13 PS5 精细采样实现(等待用户验收)++用户授权修复后关机,随后撤回音频缓冲选项;未改任何音频逻辑。基线320f860,存档checkpoint/ps5-sampling-2026-09-13,分支codex/ps5-sampling-repair。新增显式色度位置契约与按位置插值(缺失left回退有日志);PS5普通放大使用带局部范围限幅的Catmull-Rom,像素中心1:1直接读取,缩小保留旧路径。默认精细、保留兼容采样,PS5面板可选且重连生效,选择保存在现有本地settings.ini;不改变主机配对、codec、码率和HDR选择,不另造播放循环/音频/队列或回读。文件、采集、导出默认不启用新采样。++cmd /c out/remoteplay/build-clock-product.cmd 两次成功,日志logs/ps5-sampling-product-build.log与logs/ps5-sampling-final-build.log;DXIL及C++编译链接成功,diff检查通过。按用户要求不运行测试、不连接PS5、不做肉眼判断;NR/SR/FG Create/Evaluate、GPU采样成本、HDR与UI显示均未执行,不能把编译成功说成视觉改善已验收。修改文件/链路边界/明天A-B方法见docs/PS5_SAMPLING_REPAIR_PLAN_2026-09-13.md。桌面测试版对应out/remoteplay/product-repair/veyra.exe。未推送发布,未提交SDK/运行时/凭据/日志/测试媒体;完成本地存档后执行用户授权的正常关机请求。diff --git a/include/veyra/pipeline/ColorMetadata.h b/include/veyra/pipeline/ColorMetadata.hindex a6300c66..6abbb6d3 100644--- a/include/veyra/pipeline/ColorMetadata.h+++ b/include/veyra/pipeline/ColorMetadata.h@@ -7,6 +7,15 @@ extern "C" {}namespace veyra::pipeline {inline ColorDescription resolveFrameColor(const AVFrame& frame,ColorDescription c={}){+ switch(frame.chroma_location){+ case AVCHROMA_LOC_LEFT:c.chromaLocation=ChromaLocation::Left;break;+ case AVCHROMA_LOC_CENTER:c.chromaLocation=ChromaLocation::Center;break;+ case AVCHROMA_LOC_TOPLEFT:c.chromaLocation=ChromaLocation::TopLeft;break;+ case AVCHROMA_LOC_TOP:c.chromaLocation=ChromaLocation::Top;break;+ case AVCHROMA_LOC_BOTTOMLEFT:c.chromaLocation=ChromaLocation::BottomLeft;break;+ case AVCHROMA_LOC_BOTTOM:c.chromaLocation=ChromaLocation::Bottom;break;+ default:break;+ }switch(frame.format){case AV_PIX_FMT_NV12:c.pixelFormat=SourcePixelFormat::NV12;break;case AV_PIX_FMT_YUV420P10LE:case AV_PIX_FMT_P010:c.pixelFormat=SourcePixelFormat::P010;break;diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.hindex 0828435a..5952f6d0 100644--- a/include/veyra/pipeline/EnhanceGraph.h+++ b/include/veyra/pipeline/EnhanceGraph.h@@ -70,6 +70,7 @@ struct EnhanceGraphDesc {bool noNgx = false; // VEYRA_NO_NGX: core/features skipped, NVOF onlybool hdrInput = false; // PS5 Main10 ingress; explicit SDR mapping unless hdrOutput.bool hdrOutput = false; // Native scRGB passthrough, no SDR-only enhancement.+ bool highQualityPresentation = false; // PS5 ordinary scaling, no AI SRbool rgbInput = false; // allocate direct RGBA ingestion before NGX creationbool yuy2Input = false; // packed Y0 U Y1 V -> linear FP16; never subsample to NV12bool stillImage = false; // no temporal motion/FG history for a single image@@ -185,6 +186,7 @@ public:bool nrEnabled() const { return nrEnabled_; }bool fgEnabled() const { return fgEnabled_; }bool hdrOutput() const { return desc_.hdrOutput; }+ bool highQualityPresentation() const { return desc_.highQualityPresentation; }bool xessEnabled() const { return desc_.enableFg && !desc_.noFeatures && !desc_.stillImage && desc_.frameGenerationBackend==engine::FrameGenerationBackend::XeSS; }ID3D12Resource* presentMotion(uint32_t slot) const { return presentMotion_[slot%2].Get(); }ID3D12Resource* presentDepth() const { return depthTex_.Get(); }diff --git a/include/veyra/pipeline/FramePacket.h b/include/veyra/pipeline/FramePacket.hindex c0ab6256..24fba83d 100644--- a/include/veyra/pipeline/FramePacket.h+++ b/include/veyra/pipeline/FramePacket.h@@ -70,6 +70,7 @@ enum class ColorRange : uint8_t { Unknown = 0, Limited, Full };enum class YuvMatrix : uint8_t { Unknown = 0, BT601, BT709, BT2020NCL, BT2020CL };enum class TransferFunction : uint8_t { Unknown = 0, SRGB, BT709, BT2020_10, Linear, PQ, HLG };enum class ColorPrimaries : uint8_t { Unknown = 0, BT601_525, BT601_625, BT709, BT2020 };+enum class ChromaLocation : uint8_t { Unknown = 0, Left, Center, TopLeft, Top, BottomLeft, Bottom };struct SampleAspectRatio {uint32_t num = 1;@@ -95,6 +96,9 @@ struct ColorDescription {bool matrixAssumed = false;bool transferAssumed = false;bool primariesAssumed = false;+ // PS5 opt-in reconstruction; legacy file/capture/export sampling is unchanged.+ ChromaLocation chromaLocation = ChromaLocation::Unknown;+ bool reconstructChroma = false;bool isHdrPath() const {return transfer == TransferFunction::PQ || transfer == TransferFunction::HLG || pixelFormat == SourcePixelFormat::P010diff --git a/include/veyra/source/RemotePlaySource.h b/include/veyra/source/RemotePlaySource.hindex 6557f24d..abdb68cf 100644--- a/include/veyra/source/RemotePlaySource.h+++ b/include/veyra/source/RemotePlaySource.h@@ -27,6 +27,7 @@ struct RemotePlayConnectDesc {remoteplay::QueueLimits queueLimits{};enum class DecodeMode { Automatic, Software, Hardware };DecodeMode decodeMode=DecodeMode::Automatic;+ bool highQualitySampling=true; // local reconstruction, never a server quality promise// Set by the engine; shared ownership keeps the exact presentation adapter// alive until the decoder owner has stopped, including failed connects.std::shared_ptr<ID3D12Device> decodeDevice;diff --git a/shaders/PresentBlit.hlsl b/shaders/PresentBlit.hlslindex a072557f..ebb0450f 100644--- a/shaders/PresentBlit.hlsl+++ b/shaders/PresentBlit.hlsl@@ -7,8 +7,8 @@ Texture2D<float4> sourceTex : register(t0);cbuffer PresentBlitConstants : register(b0){- float4 srcDims; // x=width y=height zw=pad- float4 dstDims; // x=width y=height zw=pad+ float4 srcDims; // x/y=content extent z=flags (1 encode, 2 fine sampling) w=zoom+ float4 dstDims; // x/y=client extent z/w=view center};SamplerState linearClamp : register(s0);@@ -28,6 +28,41 @@ VSOut vsMain(uint vertexId : SV_VertexID)return o;}+float4 CubicWeights(float t)+{+ float t2=t*t,t3=t2*t;+ return float4(-0.5*t+t2-0.5*t3,1.0-2.5*t2+1.5*t3,+ 0.5*t+2.0*t2-1.5*t3,-0.5*t2+0.5*t3);+}++float4 FineSample(float2 uv)+{+ uint width,height;sourceTex.GetDimensions(width,height);+ float2 p=uv*float2(width,height)-0.5;+ // A cubic magnifier is not an antialiased minifier. Preserve the legacy+ // minification path instead of applying an undersized kernel to downscale.+ float footprint=max(length(ddx(p)),length(ddy(p)));+ if(footprint>1.001)return sourceTex.SampleLevel(linearClamp,uv,0);+ int2 last=int2(width,height)-1;+ if(all(abs(p-round(p))<0.0005))return sourceTex.Load(int3(clamp(int2(round(p)),int2(0,0),last),0));+ int2 base=int2(floor(p));float2 t=frac(p);+ float4 wx=CubicWeights(t.x),wy=CubicWeights(t.y);+ float4 result=0;+ [unroll]for(int y=0;y<4;++y){+ [unroll]for(int x=0;x<4;++x){+ int2 q=clamp(base+int2(x-1,y-1),int2(0,0),last);+ result+=sourceTex.Load(int3(q,0))*wx[x]*wy[y];+ }+ }+ // Bound cubic lobes to the local 2x2 neighborhood to avoid bright/dark+ // halos. Keep negative/HDR values when present in the actual neighborhood.+ float4 a=sourceTex.Load(int3(clamp(base,int2(0,0),last),0));+ float4 b=sourceTex.Load(int3(clamp(base+int2(1,0),int2(0,0),last),0));+ float4 c=sourceTex.Load(int3(clamp(base+int2(0,1),int2(0,0),last),0));+ float4 d=sourceTex.Load(int3(clamp(base+int2(1,1),int2(0,0),last),0));+ return clamp(result,min(min(a,b),min(c,d)),max(max(a,b),max(c,d)));+}+float4 psMain(VSOut input) : SV_Target{// zoom==0 retains the original contract for diagnostic harness callers.@@ -37,7 +72,8 @@ float4 psMain(VSOut input) : SV_Targetuv=(input.uv-.5)*dstDims.xy/(srcDims.xy*fit)+dstDims.zw;if(any(uv<0)||any(uv>1))return float4(0,0,0,1);}- float4 color=sourceTex.SampleLevel(linearClamp,uv,0);- if(srcDims.z>0.5){float3 c=max(color.rgb,0);color.rgb=lerp(1.055*pow(c,1.0/2.4)-0.055,c*12.92,step(c,0.0031308));}+ uint flags=uint(srcDims.z+0.5);+ float4 color=(flags&2)?FineSample(uv):sourceTex.SampleLevel(linearClamp,uv,0);+ if(flags&1){float3 c=max(color.rgb,0);color.rgb=lerp(1.055*pow(c,1.0/2.4)-0.055,c*12.92,step(c,0.0031308));}return color;}diff --git a/shaders/YuvToLinearRgb.hlsl b/shaders/YuvToLinearRgb.hlslindex 30f7d3bc..1a3fcdfd 100644--- a/shaders/YuvToLinearRgb.hlsl+++ b/shaders/YuvToLinearRgb.hlsl@@ -7,7 +7,7 @@cbuffer YuvParams : register(b0){float4 colorParams0; // x=limitedRange y=matrix709 z=transferSRGB w=padding- uint4 yuvDimensions; // x=width y=height+ uint4 yuvDimensions; // x=width y=height z=nativeHDR w=chroma location (0=legacy)};Texture2D<float> lumaPlane : register(t0); // R8_UNORM or R16_UNORM@@ -57,6 +57,29 @@ float SrgbDecode(float c)return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4);}+float2 ReconstructChroma(uint2 pixel)+{+ uint location=yuvDimensions.w;+ if(location==0)return chromaPlane[pixel/2];+ // Chroma sample origin in luma pixel-center coordinates. Respect MPEG+ // left, JPEG center and vertical top/bottom placement; no luma filtering.+ float2 origin=float2(0.0,0.5);+ if(location==2)origin=float2(0.5,0.5);+ else if(location==3)origin=float2(0.0,0.0);+ else if(location==4)origin=float2(0.5,0.0);+ else if(location==5)origin=float2(0.0,1.0);+ else if(location==6)origin=float2(0.5,1.0);+ float2 position=(float2(pixel)-origin)*0.5;+ int2 base=int2(floor(position));float2 fraction=frac(position);+ // Clamp to the visible chroma extent, not decoder allocation padding.+ int2 last=int2((yuvDimensions.xy+1)/2)-1;+ float2 a=chromaPlane[clamp(base,int2(0,0),last)];+ float2 b=chromaPlane[clamp(base+int2(1,0),int2(0,0),last)];+ float2 c=chromaPlane[clamp(base+int2(0,1),int2(0,0),last)];+ float2 d=chromaPlane[clamp(base+int2(1,1),int2(0,0),last)];+ return lerp(lerp(a,b,fraction.x),lerp(c,d,fraction.x),fraction.y);+}+[numthreads(16, 16, 1)]void main(uint3 dispatchThreadId : SV_DispatchThreadID){@@ -64,7 +87,7 @@ void main(uint3 dispatchThreadId : SV_DispatchThreadID)return;}const float y = lumaPlane[uint2(dispatchThreadId.x, dispatchThreadId.y)];- const float2 uv = chromaPlane[uint2(dispatchThreadId.x / 2, dispatchThreadId.y / 2)];+ const float2 uv = ReconstructChroma(dispatchThreadId.xy);float3 rgb = YuvToRgb(y, uv);rgb = saturate(rgb);if(colorParams0.z>3.5){diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 15cdeda6..223d85b6 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -182,6 +182,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s}if(!pipeline::Extent{width,height}.valid()){status(L"图像尺寸超出单张GPU纹理能力,需要分块处理",true);break;}pipeline::EnhanceGraphDesc gd;gd.sourceWidth=width;gd.sourceHeight=height;gd.hdrInput=isRemote&&activeSource->info().color.isHdrPath();+ gd.highQualityPresentation=isRemote&&activeSource->info().color.reconstructChroma;gd.rgbInput=isImage||(isCapture&&activeSource->info().color.pixelFormat==pipeline::SourcePixelFormat::Bgra8);gd.yuy2Input=isCapture&&activeSource->info().color.pixelFormat==pipeline::SourcePixelFormat::Yuy2;gd.stillImage=isImage;const auto resolution=pipeline::ResolutionPlan::make({width,height},options.sr,options.realtime?pipeline::NrSizePolicy::Realtime:pipeline::NrSizePolicy::Native,isImage,options.settings.revision,options.settings.srTarget,options.settings.lowLatency&&options.nr);diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cppindex c243a0c6..4ffbd80d 100644--- a/src/engine/VideoPresenter.cpp+++ b/src/engine/VideoPresenter.cpp@@ -45,13 +45,14 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&D3D12_VIEWPORT viewport{0,0,float(sink_.bufferWidth()),float(sink_.bufferHeight()),0,1};D3D12_RECT rect{0,0,LONG(sink_.bufferWidth()),LONG(sink_.bufferHeight())};list->RSSetViewports(1,&viewport);list->RSSetScissorRects(1,&rect);ID3D12DescriptorHeap* heaps[]={pass_.heap.Get()};list->SetDescriptorHeaps(1,heaps);list->SetGraphicsRootSignature(pass_.rootSig.Get());list->SetPipelineState(pass_.pso.Get());- float dims[8]={float(graph.workWidth()),float(graph.workHeight()),0,view.zoom,float(rc.right),float(rc.bottom),view.centerX,view.centerY};list->SetGraphicsRoot32BitConstants(0,8,dims,0);+ const float samplingFlags=graph.highQualityPresentation()?2.0f:0.0f;+ float dims[8]={float(graph.workWidth()),float(graph.workHeight()),samplingFlags,view.zoom,float(rc.right),float(rc.bottom),view.centerX,view.centerY};list->SetGraphicsRoot32BitConstants(0,8,dims,0);list->SetGraphicsRootDescriptorTable(1,{pass_.heap->GetGPUDescriptorHandleForHeapStart().ptr+size_t(slot+(generated?2:0))*pass_.increment});list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);list->DrawInstanced(3,1,0,0);if(comparison&&!generated&&referencesValid){auto* reference=baseReference?graph.baseReference(slot):graph.sourceReference(slot);D3D12_RESOURCE_BARRIER b{};b.Type=D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;b.Transition.pResource=reference;b.Transition.Subresource=D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;b.Transition.StateBefore=D3D12_RESOURCE_STATE_COMMON;b.Transition.StateAfter=D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;list->ResourceBarrier(1,&b);- dims[2]=graph.hdrOutput()?0:1;list->SetGraphicsRoot32BitConstants(0,8,dims,0);list->SetGraphicsRootDescriptorTable(1,{pass_.heap->GetGPUDescriptorHandleForHeapStart().ptr+size_t(8+slot+(baseReference?2:0))*pass_.increment});+ dims[2]=samplingFlags+(graph.hdrOutput()?0:1);list->SetGraphicsRoot32BitConstants(0,8,dims,0);list->SetGraphicsRootDescriptorTable(1,{pass_.heap->GetGPUDescriptorHandleForHeapStart().ptr+size_t(8+slot+(baseReference?2:0))*pass_.increment});if(comparison==2)rect.right=LONG(std::clamp((rc.right*.5f+(std::clamp(split,0.0f,1.0f)-view.centerX)*graph.workWidth()*scale*view.zoom)*sink_.bufferWidth()/rc.right,0.0f,float(sink_.bufferWidth())));list->RSSetScissorRects(1,&rect);list->DrawInstanced(3,1,0,0);std::swap(b.Transition.StateBefore,b.Transition.StateAfter);list->ResourceBarrier(1,&b);if(veyra::log::verboseFrameLogs())veyra::log::info("comparison",std::format("real-frame source={} epoch={} revision={} reference={} mode={} split={} (same leased frame)",identity.sourceFrameId,identity.epoch,identity.settingsRevision,baseReference?"base":"input",comparison,split));diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex 84a7428c..d8732fb9 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -871,7 +871,8 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frameconst float constants[8] = { resolved.range==ColorRange::Full?0.0f:1.0f,resolved.matrix==YuvMatrix::BT2020NCL?2.0f:resolved.matrix==YuvMatrix::BT601?0.0f:1.0f,resolved.transfer==TransferFunction::PQ?4.0f:float(workingTransferCode(resolved)), (nv12Texture?nv12Texture->GetDesc().Format==DXGI_FORMAT_P010:desc_.hdrInput)?1.0f:0.0f,- uintBits(srcW_), uintBits(srcH_), uintBits(desc_.hdrOutput?1u:0u), 0.0f };+ uintBits(srcW_), uintBits(srcH_), uintBits(desc_.hdrOutput?1u:0u),+ uintBits(resolved.reconstructChroma?std::max(1u,unsigned(resolved.chromaLocation)):0u) };yuvPass_.bind(list, constants, gpuHandleOf(yuvPass_, nv12Texture ? 3 + parity * 2 : 0).ptr, gpuHandleOf(yuvPass_, 2).ptr);list->Dispatch((srcW_ + 15) / 16, (srcH_ + 15) / 16, 1);}diff --git a/src/source/RemotePlaySource.cpp b/src/source/RemotePlaySource.cppindex f8f5f6aa..3ae5619c 100644--- a/src/source/RemotePlaySource.cpp+++ b/src/source/RemotePlaySource.cpp@@ -127,6 +127,7 @@ bool RemotePlaySource::connect(const RemotePlayConnectDesc& desc)info_.color.matrix = pipeline::YuvMatrix::BT709;info_.color.matrixAssumed = true;info_.color.displayReferred709 = true;+ info_.color.reconstructChroma = desc.highQualitySampling;info_.color.transfer = pipeline::TransferFunction::BT709;info_.color.transferAssumed = true;info_.color.primaries = pipeline::ColorPrimaries::BT709;@@ -286,6 +287,9 @@ bool RemotePlaySource::drainDecoder(std::uint64_t sourceIndex, const pipeline::FpacketStamps_.erase(stamp);packet.sequence = ++sequence_;auto fallback=info_.color;+ // A previous stream profile's explicit siting must not survive a new+ // frame with unspecified siting; PS5 fallback is documented as left.+ fallback.chromaLocation=pipeline::ChromaLocation::Unknown;if(request_.video.codec==remoteplay::Codec::H265Hdr&&pixelFormatFromFrame(*decoderFrame_)!=pipeline::SourcePixelFormat::P010){// A negotiated 8-bit fallback is not automatically a PQ signal.fallback.transfer=pipeline::TransferFunction::BT709;fallback.transferAssumed=true;@@ -293,6 +297,7 @@ bool RemotePlaySource::drainDecoder(std::uint64_t sourceIndex, const pipeline::Ffallback.primaries=pipeline::ColorPrimaries::BT709;fallback.primariesAssumed=true;}packet.colorInfo = pipeline::resolveFrameColor(*decoderFrame_, fallback);+ if(sequence_==1)veyra::log::info("remoteplay-sampling",std::format("fine={} chromaLocation={} assumedLeft={}",packet.colorInfo.reconstructChroma,int(packet.colorInfo.chromaLocation),packet.colorInfo.chromaLocation==pipeline::ChromaLocation::Unknown));packet.colorInfo.pixelFormat = pixelFormatFromFrame(*decoderFrame_);if (decoderFrame_->width <= 0 || decoderFrame_->height <= 0 ||decoderFrame_->width > 1920 || decoderFrame_->height > 1080 ||