Skip to content

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(ui): T0 remove preset entry points, T1 NR exclusion zone with feather; fix v3 UI preference load

Veyra Goal Agentc6f94433594f
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index 23a756cc..d8f8cb0a 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -5,6 +5,7 @@
#include "veyra/RuntimePaths.h"
#include "veyra/gfx/XessMfgUnlock.h"
#include <filesystem>
+#include <format>
#include <sstream>
#include <iomanip>
#include <array>
@@ -53,7 +54,17 @@ void message(const std::wstring& text){putText(401,text.c_str());}
bool submit(engine::EnhancementSettings s){if(!apply(s)){dirty=true;message(L"总增强正在切换;本次修改未接受,请稍后重试。");return false;}dirty=false;return true;}
void syncProtection(const engine::ProtectionSettings& protection){
check(206,protection.enabled?BST_CHECKED:BST_UNCHECKED);unsigned count=0;for(auto q:protection.regions)count+=!q.empty();
- putText(206,(L"NR保护区域 · "+std::to_wstring(count)+L"/4").c_str());
+ putText(206,(L"NR剔除区 · "+std::to_wstring(count)+L"/4").c_str());
+ // The feather value is stored in working-extent pixels (see
+ // NrResidualComposite.hlsl); the panel only converts it for display.
+ const float feather=std::clamp(protection.featherPixels,0.0f,64.0f);
+ if(auto slider=item(622))SendMessageW(slider,TBM_SETPOS,TRUE,LPARAM(std::lround(feather)));
+ if(item(222))putText(222,std::to_wstring(int(std::lround(feather))).c_str());
+ if(auto label=item(1123)){
+ const unsigned extent=controller?controller->snapshot().metrics.resolution.base.height:0u;
+ if(extent>0)putText(1123,std::format(L"羽化 {} px · ≈{:.1f}% 画面高度",int(std::lround(feather)),feather*100.0f/float(extent)).c_str());
+ else putText(1123,std::format(L"羽化 {} px(工作分辨率像素)",int(std::lround(feather))).c_str());
+ }
}
void selectDiscrete(int group,int value){for(int j=0;j<(group==0?3:2);++j){auto h=item(700+group*10+j);if(j==value)SetPropW(h,L"veyra.selected",HANDLE(1));else RemovePropW(h,L"veyra.selected");InvalidateRect(h,nullptr,FALSE);}}
// Multiplier list is capability-driven: the DLSS runtime reports how many
@@ -114,7 +125,7 @@ bool read(engine::EnhancementSettings& s,bool allPages=false){s=enhancementEnabl
for(int i=4;i<7;++i)if(v[i]!=std::floor(v[i])||v[i]<0||v[i]>(i==4?2:1)){message(L"风格/遮罩/UI修正必须为整数");return false;}
s.model={v[0],v[1],v[2],v[3],int(v[4]),int(v[5]),int(v[6])};s.residual={v[7],v[8],v[9],v[10],v[11]};if(enhancementEnabled){s.nr=checked(200)==BST_CHECKED;s.sr=checked(201)==BST_CHECKED;}s.videoSrQuality=uint32_t(send(207,CB_GETCURSEL,0,0));s.nrPolicy=static_cast<pipeline::NrSizePolicy>(send(203,CB_GETCURSEL,0,0));if(allPages){
const auto multiplier=send(202,CB_GETCURSEL,0,0),generation=send(208,CB_GETCURSEL,0,0),flowBackend=send(209,CB_GETCURSEL,0,0),flowQuality=send(204,CB_GETCURSEL,0,0),content=send(205,CB_GETCURSEL,0,0);
- if(multiplier==CB_ERR||generation==CB_ERR||flowBackend==CB_ERR||flowQuality==CB_ERR||content==CB_ERR){message(L"设置控件未完成初始化;未保存预设");return false;}
+ if(multiplier==CB_ERR||generation==CB_ERR||flowBackend==CB_ERR||flowQuality==CB_ERR||content==CB_ERR){message(L"设置控件未完成初始化;未保存设置");return false;}
s.multiplier=(multiplier>=0&&multiplier<int(engine::kFgMultiplierChoiceCount))?engine::kFgMultiplierChoices[multiplier]:1;s.frameGenerationBackend=static_cast<engine::FrameGenerationBackend>(generation);s.opticalFlowBackend=static_cast<engine::OpticalFlowBackend>(flowBackend);s.amdFlowHalfResolution=checked(215)==BST_CHECKED;s.flow=static_cast<engine::FlowQuality>(flowQuality);s.content=static_cast<engine::ContentRate>(content);
{const int bitrate=send(508,CB_GETCURSEL,0,0);if(bitrate==CB_ERR||bitrate<0||bitrate>=int(engine::kExportBitrateChoiceCount)){message(L"导出码率控件未完成初始化;未保存设置");return false;}s.exportBitrateMbps=engine::kExportBitrateChoices[bitrate];}
s.audioSync=static_cast<engine::AudioSyncMode>(send(216,CB_GETCURSEL));
@@ -158,6 +169,7 @@ bool liveField(int id){
case 215:s.amdFlowHalfResolution=checked(id)==BST_CHECKED;break;
case 216:s.audioSync=static_cast<engine::AudioSyncMode>(send(id,CB_GETCURSEL));break;
case 217:{wchar_t value[32]{};GetWindowTextW(item(id),value,32);wchar_t* end=nullptr;const auto parsed=wcstol(value,&end,10);if(end==value||*end||parsed<-250||parsed>250){message(L"声音偏移须为 -250 至 250 ms");return false;}s.audioOffsetMs=int(parsed);break;}
+ case 222:{wchar_t value[32]{};GetWindowTextW(item(id),value,32);wchar_t* end=nullptr;const auto parsed=wcstol(value,&end,10);if(end==value||*end||parsed<0||parsed>64){message(L"剔除区羽化须为 0 至 64 像素");return false;}s.protection.featherPixels=float(parsed);break;}
case 207:s.videoSrQuality=uint32_t(send(id,CB_GETCURSEL));break;
case 508:{const int index=send(id,CB_GETCURSEL,0,0);if(index==CB_ERR||index<0||index>=int(engine::kExportBitrateChoiceCount))return false;s.exportBitrateMbps=engine::kExportBitrateChoices[index];break;}
case 700:case 701:case 702:s.model.style=id-700;break;
@@ -177,7 +189,6 @@ LRESULT CALLBACK scrollOnly(HWND h,UINT msg,WPARAM wp,LPARAM lp,UINT_PTR id,DWOR
return DefSubclassProc(h,msg,wp,lp);
}
-void refreshPresets(){auto list=item(300);SendMessageW(list,CB_RESETCONTENT,0,0);for(auto& p:store.entries())SendMessageW(list,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(p.name.c_str()));if(!store.entries().empty())SendMessageW(list,CB_SETCURSEL,0,0);PostMessageW(GetParent(window),WM_APP+42,0,0);}
void arrange(){
if(!window||!body)return;RECT r{};GetClientRect(window,&r);int width=MulDiv(r.right,96,veyra::ui::layoutDpi(window)),height=MulDiv(r.bottom,96,veyra::ui::layoutDpi(window));
const int sticky=128,viewport=std::max(1,height-sticky);contentHeight=0;
@@ -203,6 +214,8 @@ LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){
if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==219&&HIWORD(wp)==BN_CLICKED){liveField(219);return 0;}
if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==218&&HIWORD(wp)==CBN_SELCHANGE){liveField(218);return 0;}
if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==216&&HIWORD(wp)==CBN_SELCHANGE)||(LOWORD(wp)==217&&HIWORD(wp)==EN_CHANGE))){liveField(LOWORD(wp));return 0;}
+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==222&&HIWORD(wp)==EN_CHANGE){liveField(222);return 0;}
+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==222&&HIWORD(wp)==EN_KILLFOCUS){populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);return 0;}
if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==209&&HIWORD(wp)==CBN_SELCHANGE)||(LOWORD(wp)==215&&HIWORD(wp)==BN_CLICKED))){liveField(LOWORD(wp));return 0;}
switch(msg){
case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.clear();smoothMotionHelpExpanded=false;
@@ -240,9 +253,9 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.
add(L"EDIT",L"0",217,ES_AUTOHSCROLL|ES_RIGHT|WS_TABSTOP,1,182,692,-1,28);
SetPropW(item(217),L"veyra.tip",HANDLE(L"-250 至 250 ms;正值让声音更晚。负值只能减少已有延迟,实际补偿最低为0。"));
- add(L"STATIC",L"用户预设",1105,0,2,12,12,-1,30);combo(300,2,56,{});add(L"EDIT",L"新预设",301,ES_AUTOHSCROLL|WS_TABSTOP,2,12,108,-1,36);send(301,EM_SETLIMITTEXT,48,0);
- const wchar_t* names[]={L"载入所选预设",L"新建内建默认预设",L"保存当前参数为新预设",L"重命名所选",L"删除所选",L"设为启动增强默认"};for(int i=0;i<6;++i)button(names[i],310+i,2,12,164+i*44);
- add(L"STATIC",L"启动界面始终为日常模式。默认预设只决定增强参数;预设文件损坏时保留原文件。",1106,0,2,12,438,-1,82);
+ // Page 2 is the colour page. The old preset page (ids 300/301/310-315,
+ // statics 1105/1106) was deleted on purpose on 2026-09-17: named colour
+ // presets replace it and carry only look parameters, never NR/SR/FG.
add(L"STATIC",L"原生画质导出",1107,0,3,12,12,-1,32);combo(500,3,60,{L"H.264 · MP4",L"HEVC · MP4"});send(500,CB_SETCURSEL,0,0);
add(L"STATIC",L"冻结启动时整套参数;NR按原生尺寸处理。保留兼容音轨。VFR不改写为CFR;字幕不烧录。",1108,0,3,12,108,-1,94);
button(L"选择位置并导出视频",501,3,12,212);marked(item(501));button(L"保存当前图片 / 视频帧",502,3,12,256);
@@ -256,9 +269,9 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.
combo(508,3,132,{L"自动 · 恒定质量",L"6 Mbps",L"10 Mbps",L"16 Mbps",L"24 Mbps",L"40 Mbps",L"60 Mbps",L"100 Mbps",L"150 Mbps",L"200 Mbps"});
add(L"STATIC",L"",400,0,-1,12,900,-1,92);add(L"STATIC",L"",401,0,-1,12,996,-1,86);
for(auto& entry:items)if(entry.page==0&&entry.y>=146)entry.y+=176;
- add(L"BUTTON",L"NR保护区域",206,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,146,-1,36);
- button(L"框选区域",213,0,12,188,140);button(L"清除区域",214,0,162,188);
- add(L"STATIC",L"最多4区,左键拖框,Esc取消。仅抑制NR变化;不保护SR或补帧。可随预设保存;换源清空。",1109,0,0,12,232,-1,82);
+ add(L"BUTTON",L"NR剔除区",206,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,146,-1,36);
+ button(L"框选剔除区",213,0,12,188,140);button(L"清除剔除区",214,0,162,188);
+ add(L"STATIC",L"最多4区,左键拖框,Esc取消。仅抑制NR变化;不保护SR或补帧。随增强参数一起保存;换源清空。",1109,0,0,12,232,-1,82);
for(auto& entry:items)if(entry.page==0&&entry.y>=104)entry.y+=48;
combo(207,0,100,{L"DLSS SR",L"RTX 视频超分 · 低",L"RTX 视频超分 · 中",L"RTX 视频超分 · 高",L"RTX 视频超分 · 最高",L"AMD FSR 超分 · 3.1.x(N卡可用)"});
for(auto& entry:items)if(entry.page==0&&entry.y>=100)entry.y+=44;
@@ -298,27 +311,39 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.
for(auto& entry:items)if(entry.page==0&&entry.y>=176)entry.y+=44;
add(L"BUTTON",L"低延迟模式 · 实验",220,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,172,-1,36);
SetPropW(item(220),L"veyra.tip",HANDLE(L"默认先超分,再NR(DLSS5)。打开后先NR再超分,最后补帧:少搬点砖,可能更快,也可能多些鬼影或边缘瑕疵。只用于预览;导出不换顺序。需同时开启NR和超分才有作用。"));
+ // NR exclusion-zone feather lands directly under the zone help text; every
+ // later block moves down by the same amount so nothing overlaps.
+ for(auto& entry:items)if(entry.page==0&&entry.y>=530)entry.y+=80;
+ add(L"STATIC",L"",1123,0,0,12,530,-1,24);
+ add(L"EDIT",L"12",222,ES_AUTOHSCROLL|ES_RIGHT|WS_TABSTOP,0,202,530,-1,28);
+ auto featherSlider=add(TRACKBAR_CLASSW,L"",622,TBS_HORZ|TBS_NOTICKS|WS_TABSTOP,0,12,562,-1,16);
+ SendMessageW(featherSlider,TBM_SETRANGE,TRUE,MAKELPARAM(0,64));
+ SendMessageW(featherSlider,TBM_SETPOS,TRUE,12);
+ SetPropW(item(222),L"veyra.tip",HANDLE(L"剔除区边缘的过渡宽度,单位是工作分辨率像素。0 就是硬边;4K 上 12 px 约等于画面高度的 0.5%,越大边缘越柔和。"));
for(const auto& entry:items)if(auto help=settingHelp(GetDlgCtrlID(entry.h)))SetPropW(entry.h,L"veyra.tip",HANDLE(help));
- loadStore();refreshPresets();populate(controller->snapshot().desired);message(store.error());SetTimer(h,1,250,nullptr);arrange();return 0;}
+ loadStore();populate(controller->snapshot().desired);message(store.error());SetTimer(h,1,250,nullptr);arrange();
+ // Layout evidence for UI work: VEYRA_DUMP_SETTINGS_LAYOUT=1 prints the
+ // resolved position of every control once, in DIP units.
+ if(GetEnvironmentVariableW(L"VEYRA_DUMP_SETTINGS_LAYOUT",nullptr,0))
+ for(const auto& entry:items)veyra::log::info("settings-layout",std::format("id={} page={} x={} y={} w={} h={}",
+ GetDlgCtrlID(entry.h),entry.page,entry.x,entry.y,entry.w,entry.height));
+ return 0;}
case WM_SIZE:arrange();return 0;
case WM_ERASEBKGND:return 1;
case WM_PAINT:{PaintBuffer paint(h);fillSurface(paint.dc,paint.rect,h);return 0;}
case WM_VSCROLL:{switch(LOWORD(wp)){case SB_LINEUP:scroll-=40;break;case SB_LINEDOWN:scroll+=40;break;case SB_PAGEUP:scroll-=240;break;case SB_PAGEDOWN:scroll+=240;break;case SB_THUMBTRACK:{SCROLLINFO si{sizeof(si),SIF_TRACKPOS};GetScrollInfo(h,SB_VERT,&si);scroll=si.nTrackPos;break;}}arrange();return 0;}
case WM_MOUSEWHEEL:scroll-=GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*36;arrange();return 0;
case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORLISTBOX:case WM_CTLCOLORBTN:return colors(msg,wp,lp);
-case WM_COMMAND:{const int id=LOWORD(wp);if(!populating&&((id>=202&&id<=205||id==207||id==208)&&HIWORD(wp)==CBN_SELCHANGE||(id>=700&&id<=732)&&HIWORD(wp)==BN_CLICKED)){liveField(id);return 0;}if((id==206||id==213||id==214)&&HIWORD(wp)==BN_CLICKED){const auto accepted=SendMessageW(GetParent(h),WM_APP+45,id,checked(206));message(accepted?(id==213?L"请在画面中左键拖动框选;Esc取消。":L"已请求更新NR保护区域。"):L"未能操作:请先打开画面,或清除已满的4个区域。");return 0;}if((id==200||id==201)&&HIWORD(wp)==BN_CLICKED){const bool accepted=SendMessageW(GetParent(h),WM_APP+44,id,checked(id))!=0;message(accepted?L"已请求开关;确认帧边界结果后生效。":L"总增强正在切换,请待当前事务完成。");return 0;}if(HIWORD(wp)==EN_SETFOCUS){for(auto& item:items)if(GetDlgCtrlID(item.h)==id&&item.page==page){RECT r{};GetClientRect(h,&r);int height=MulDiv(r.bottom,96,veyra::ui::layoutDpi(h))-128;if(item.y<scroll)scroll=item.y;if(item.y+item.height>scroll+height)scroll=item.y+item.height-height;arrange();break;}}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_CHANGE){liveField(id);return 0;}
+case WM_COMMAND:{const int id=LOWORD(wp);if(!populating&&((id>=202&&id<=205||id==207||id==208)&&HIWORD(wp)==CBN_SELCHANGE||(id>=700&&id<=732)&&HIWORD(wp)==BN_CLICKED)){liveField(id);return 0;}if((id==206||id==213||id==214)&&HIWORD(wp)==BN_CLICKED){const auto accepted=SendMessageW(GetParent(h),WM_APP+45,id,checked(206));message(accepted?(id==213?L"请在画面中左键拖动框选;Esc取消。":L"已请求更新NR剔除区。"):L"未能操作:请先打开画面,或清除已满的4个区域。");return 0;}if((id==200||id==201)&&HIWORD(wp)==BN_CLICKED){const bool accepted=SendMessageW(GetParent(h),WM_APP+44,id,checked(id))!=0;message(accepted?L"已请求开关;确认帧边界结果后生效。":L"总增强正在切换,请待当前事务完成。");return 0;}if(HIWORD(wp)==EN_SETFOCUS){for(auto& item:items)if(GetDlgCtrlID(item.h)==id&&item.page==page){RECT r{};GetClientRect(h,&r);int height=MulDiv(r.bottom,96,veyra::ui::layoutDpi(h))-128;if(item.y<scroll)scroll=item.y;if(item.y+item.height>scroll+height)scroll=item.y+item.height-height;arrange();break;}}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_CHANGE){liveField(id);return 0;}
if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_KILLFOCUS){populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);return 0;}
- engine::EnhancementSettings s;wchar_t name[128]{};GetWindowTextW(item(301),name,128);const auto index=size_t(send(300,CB_GETCURSEL,0,0));bool ok=true;
- if(id==211){SetFocus(body);s={};if(submit(s)){populate(s);message(L"已还原内建默认;用户预设保留");}}
- else if(id==310&&index<store.entries().size()){s=store.entries()[index].settings;if(submit(s))populate(s);}
- else if(id==311){ok=store.put(name,{});refreshPresets();}
- else if(id==312){if(read(s,true))ok=store.put(name,s);refreshPresets();}
- else if(id==313){ok=store.rename(index,name);refreshPresets();}
- else if(id==314&&index<store.entries().size()){if(MessageBoxW(h,(L"删除预设“"+store.entries()[index].name+L"”?当前画质不受影响。").c_str(),L"删除预设",MB_YESNO|MB_ICONQUESTION)==IDYES){ok=store.erase(index);refreshPresets();}}
- else if(id==315)ok=store.setDefault(index);
+ engine::EnhancementSettings s;
+ if(id==211){SetFocus(body);s={};if(submit(s))populate(s);message(L"已还原内建默认。");}
else if(id>=501&&id<=505)SendMessageW(GetParent(h),WM_APP+41,id,id==501?send(500,CB_GETCURSEL,0,0):id==505?checked(505):0);
- if(!ok)message(store.error());return 0;}
-case WM_HSCROLL:{int id=GetDlgCtrlID(reinterpret_cast<HWND>(lp));if(id>=600&&id<612){int index=id-600;float v=float(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0))/(index>=4&&index<=6?1:100);if(index==3&&v<0)v=-1;std::wostringstream o;o<<std::setprecision(4)<<v;putText(100+index,o.str().c_str());}return 0;}
+ return 0;}
+case WM_HSCROLL:{int id=GetDlgCtrlID(reinterpret_cast<HWND>(lp));if(id>=600&&id<612){int index=id-600;float v=float(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0))/(index>=4&&index<=6?1:100);if(index==3&&v<0)v=-1;std::wostringstream o;o<<std::setprecision(4)<<v;putText(100+index,o.str().c_str());}
+ else if(id==622){// Feather slider: the edit box owns the value, its EN_CHANGE applies it.
+ const int value=std::clamp(int(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0)),0,64);putText(222,std::to_wstring(value).c_str());}
+ return 0;}
case WM_TIMER:{auto s=controller->snapshot();syncProtection(enhancementEnabled?s.desired.protection:configuredSettings.protection);if(enhancementEnabled&&!dirty&&displayedSettings!=s.desired)populate(s.desired);check(200,enhancementEnabled&&s.desired.nr?BST_CHECKED:BST_UNCHECKED);check(201,enhancementEnabled&&s.desired.sr?BST_CHECKED:BST_UNCHECKED);std::wostringstream o;if(!s.running&&!s.frames&&s.transport!=engine::TransportState::Opening)o<<L"未打开媒体 · 设置待启用\n";else{
o<<L"期望版本 "<<s.desired.revision<<L" / 已应用 "<<s.applied.revision<<(s.applying?L" · 应用中":L"");
const wchar_t* backend=s.applied.frameGenerationBackend==engine::FrameGenerationBackend::XeSS?L"XeSS":s.applied.frameGenerationBackend==engine::FrameGenerationBackend::Fsr?L"AMD FSR":L"DLSS";
@@ -332,8 +357,6 @@ case WM_DESTROY:KillTimer(h,1);DeleteObject(font);window=nullptr;body=nullptr;it
}
engine::EnhancementSettings defaultSettings(){loadStore();return store.defaultSettings();}
HWND settingsControlForTest(int id){return item(id);}
-std::vector<std::wstring> presetNames(){loadStore();std::vector<std::wstring> out;for(auto& p:store.entries())out.push_back(p.name);return out;}
-bool presetAt(size_t index,engine::EnhancementSettings& out){loadStore();if(index>=store.entries().size())return false;out=store.entries()[index].settings;return true;}
HWND createSettingsPanel(HWND parent,engine::EngineController& engine,std::function<bool(engine::EnhancementSettings)> callback){controller=&engine;apply=std::move(callback);WNDCLASSW wc{};wc.lpfnWndProc=proc;wc.hInstance=GetModuleHandleW(nullptr);wc.lpszClassName=L"VeyraInspector";wc.hbrBackground=panelBrush();wc.hCursor=LoadCursorW(nullptr,IDC_ARROW);RegisterClassW(&wc);return CreateWindowExW(WS_EX_CONTROLPARENT,wc.lpszClassName,L"专业参数",WS_CHILD|WS_CLIPCHILDREN,0,0,328,500,parent,nullptr,wc.hInstance,nullptr);}
void settingsVisibility(bool visible){if(window&&!visible&&IsChild(window,GetFocus()))SetFocus(GetParent(window));}
void settingsPage(int value){if(window&&IsChild(window,GetFocus()))SetFocus(body);page=std::clamp(value,0,4);scroll=0;arrange();}
diff --git a/apps/veyra/SettingsWindow.h b/apps/veyra/SettingsWindow.h
index 34bb0ef8..f9c49b02 100644
--- a/apps/veyra/SettingsWindow.h
+++ b/apps/veyra/SettingsWindow.h
@@ -4,8 +4,6 @@
#include <vector>
namespace veyra::ui {
engine::EnhancementSettings defaultSettings();
-std::vector<std::wstring> presetNames();
-bool presetAt(size_t,engine::EnhancementSettings&);
HWND createSettingsPanel(HWND,engine::EngineController&,std::function<bool(engine::EnhancementSettings)>);
void settingsEnabled(bool,const engine::EnhancementSettings&);
void settingsVisibility(bool);void settingsPage(int);void settingsDpi();
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index f540f324..124578e6 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -45,7 +45,10 @@ constexpr DWORD ShellStyle=WS_POPUP|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|
// Daily-mode multiplier combo lists 2X/3X/4X/6X (index 0..3), which maps to
// kFgMultiplierChoices[1..4]; index-independent so 5X can stay unoffered.
uint32_t multiplierFromDailyIndex(int index){const int i=index+1;return (index>=0&&i<int(veyra::engine::kFgMultiplierChoiceCount))?veyra::engine::kFgMultiplierChoices[i]:2;}
-enum {Open=101,Play,Stop,Save,Nr,Sr,Fg,Seek,Info,Capture,Export,Realtime,Recent,Multiplier,Settings,OriginalHold,CompareToggle,Split,Reference,Fullscreen,ModeSwitch=220,Master,DailyPreset,Volume,Mute,Subtitle,SubtitleLoad,SubtitleSize,ImageOpen,InspectorDrawer,TabEnhance,TabFg,TabPresets,TabExport,JobProgress,Details,Brand,MediaTitle,TimeLabel,EmptyTitle,EmptyHint,ProRailVideo,ProRailCapture,WindowMin,WindowMax,WindowClose,FpsLabel,RemotePlay,TabAudio,VideoSurface=1000};
+// RetiredPresetSlot keeps the control-id numbering stable after the preset UI
+// was deleted (2026-09-17). It is intentionally never created: named colour
+// presets live in the colour page and carry look parameters only.
+enum {Open=101,Play,Stop,Save,Nr,Sr,Fg,Seek,Info,Capture,Export,Realtime,Recent,Multiplier,Settings,OriginalHold,CompareToggle,Split,Reference,Fullscreen,ModeSwitch=220,Master,RetiredPresetSlot,Volume,Mute,Subtitle,SubtitleLoad,SubtitleSize,ImageOpen,InspectorDrawer,TabEnhance,TabFg,TabColor,TabExport,JobProgress,Details,Brand,MediaTitle,TimeLabel,EmptyTitle,EmptyHint,ProRailVideo,ProRailCapture,WindowMin,WindowMax,WindowClose,FpsLabel,RemotePlay,TabAudio,VideoSurface=1000};
veyra::engine::EngineController engine;
#ifdef VEYRA_ENABLE_REMOTEPLAY
veyra::remoteplay::ControllerInput remoteController;
@@ -59,7 +62,7 @@ veyra::engine::EnhancementSettings lastSuccessful,jobExpected;bool haveSuccessfu
std::wstring smokeView;bool smokeViewApplied=false;
std::wstring smokeDualOutput;bool smokeEmpty=false;DWORD modeGdiStart=0,modeHandlesStart=0;SIZE_T modePrivateStart=0;
bool smokeDual=false,smokeDualPause=false,smokeMaster=false,smokeMasterReject=false,smokeAudio=false,smokeJob=false,smokeJobCancel=false,smokeJobExit=false;int dualStep=0,masterStep=0,audioStep=0,jobStep=0;double pausedPosition=-1,jobPosition=0;uint64_t pausedFrames=0;ULONGLONG jobPauseTick=0;HANDLE workerMapping=nullptr;
-void switchMode();void selectInspector(int);void refreshDailyPresets();
+void switchMode();void selectInspector(int);
bool applySettings(veyra::engine::EnhancementSettings s){if(masterPendingRevision)return false;uiState.configured=s;if(uiState.enhanced)engine.requestSettings(s);else {auto effective=engine.snapshot().desired;if(effective.captureCompatible!=s.captureCompatible||effective.forceSdrPreview!=s.forceSdrPreview||effective.captureFlipVertical!=s.captureFlipVertical||effective.captureBuffer!=s.captureBuffer){effective.captureCompatible=s.captureCompatible;effective.forceSdrPreview=s.forceSdrPreview;effective.captureFlipVertical=s.captureFlipVertical;effective.captureBuffer=s.captureBuffer;engine.requestSettings(effective);}veyra::log::info("ui-settings","enhancement off: draft saved; presentation setting applied independently");}veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);return true;}
struct ToolbarItem{HWND hwnd;int width;};std::vector<ToolbarItem> toolbar;
@@ -279,7 +282,6 @@ ofn.Flags=OFN_EXPLORER|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST|(save?OFN_OVERWRITEPROM
return (save?GetSaveFileNameW(&ofn):GetOpenFileNameW(&ofn))?name.data():L"";}
void openFile(const std::wstring& file){if(file.empty())return;cancelProtection();auto openOptions=options();if(file!=currentFile){openOptions.settings.protection={};uiState.configured.protection={};}auto ext=std::filesystem::path(file).extension().wstring();for(auto& c:ext)c=towlower(c);if((ext==L".png"||ext==L".jpg"||ext==L".jpeg")&&uiState.mode==veyra::ui::Mode::Daily)switchMode();engine.previewView({});currentFile=file;refreshSubtitleTracks(file);paused=false;SetWindowTextW(GetDlgItem(mainWindow,Play),L"暂停");engine.open(video,file,openOptions);SetWindowTextW(mainWindow,veyra::ui::windowTitleForSource(file).c_str());if(smokeSeconds<=0)WritePrivateProfileStringW(L"Player",L"最近打开",file.c_str(),(veyra::runtime::localDataDirectory()/"veyra.ini").wstring().c_str());}
HWND control(const wchar_t* cls,const wchar_t* label,int id,DWORD style,int x,int y,int w,int h){auto hwnd=CreateWindowExW(0,cls,label,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|style|(_wcsicmp(cls,L"STATIC")?WS_TABSTOP:0),x,y,w,h,mainWindow,reinterpret_cast<HMENU>(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(hwnd,WM_SETFONT,reinterpret_cast<WPARAM>(font),TRUE);veyra::ui::themeControl(hwnd);if(id>=Open&&id<=Fullscreen&&id!=Seek)toolbar.push_back({hwnd,w});return hwnd;}
-void refreshDailyPresets(){auto h=GetDlgItem(mainWindow,DailyPreset);if(!h)return;SendMessageW(h,CB_RESETCONTENT,0,0);SendMessageW(h,CB_ADDSTRING,0,LPARAM(L"当前自定义设置"));for(auto& name:veyra::ui::presetNames())SendMessageW(h,CB_ADDSTRING,0,LPARAM(name.c_str()));SendMessageW(h,CB_SETCURSEL,0,0);}
void selectInspector(int page){uiState.inspector=page;veyra::ui::settingsPage(page);for(int i=0;i<4;++i)veyra::ui::selected(GetDlgItem(mainWindow,TabEnhance+i),i==page);veyra::ui::selected(GetDlgItem(mainWindow,TabAudio),page==4);}
void switchMode(){
cancelProtection();
@@ -312,11 +314,11 @@ void layout(){
put(WindowMin,w-124,14,32,32,!full&&pro);put(WindowMax,w-88,14,32,32,!full&&pro);put(WindowClose,w-52,14,32,32,!full&&pro);
for(int id:{WindowMin,WindowMax,WindowClose})surface(GetDlgItem(mainWindow,id),background);
put(InspectorDrawer,w-384,14,76,32,!full&&pro&&w<960);
- put(Master,g.left+(w<960?120:190),14,116,32,!full&&pro);put(DailyPreset,g.left+318,14,172,200,!full&&pro&&w>=1080);
+ put(Master,g.left+(w<960?120:190),14,116,32,!full&&pro);
put(Save,g.left+(w>=1080?502:w>=960?318:244),14,76,32,!full&&pro);
put(ProRailVideo,12,92,44,44,!full&&pro);put(ProRailCapture,12,148,44,44,!full&&pro);put(ImageOpen,12,204,44,44,!full&&pro);
for(int id:{ProRailVideo,ProRailCapture,ImageOpen})surface(GetDlgItem(mainWindow,id),RGB(16,17,18));
- const int tabs[]={TabEnhance,TabFg,TabAudio,TabPresets,TabExport};for(int i=0;i<5;++i)put(tabs[i],g.right+12+i*((g.panelWidth-24)/5),g.top+12,(g.panelWidth-24)/5,32,rightVisible);
+ const int tabs[]={TabEnhance,TabFg,TabAudio,TabColor,TabExport};for(int i=0;i<5;++i)put(tabs[i],g.right+12+i*((g.panelWidth-24)/5),g.top+12,(g.panelWidth-24)/5,32,rightVisible);
pos(inspector,g.right+12,g.top+56,g.panelWidth-24,g.statusTop-g.top-68,rightVisible);
pos(liveStatusPanel,g.right,g.statusTop,g.panelWidth,h-g.statusTop-20,rightVisible);
const bool transport=!full||fullControls;int barTop=full?h-88:g.bottom;int tx=full?16:g.left+16,tw=full?w-32:g.viewWidth-32;
@@ -469,7 +471,7 @@ control(L"BUTTON",L"采集",Capture,BS_PUSHBUTTON,690,10,75,30);control(L"BUTTON
control(L"BUTTON",L"实时NR档",Realtime,BS_AUTOCHECKBOX,952,10,100,30);
control(L"BUTTON",L"最近打开",Recent,BS_PUSHBUTTON,1072,10,75,30);
auto mult=control(L"COMBOBOX",L"",Multiplier,CBS_DROPDOWNLIST,1150,10,70,180);for(auto label:{L"2X",L"3X",L"4X",L"6X"})SendMessageW(mult,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(label));{int sel=0;for(size_t i=1;i<veyra::engine::kFgMultiplierChoiceCount;++i)if(veyra::engine::kFgMultiplierChoices[i]==initialOptions.fgMultiplier)sel=int(i)-1;SendMessageW(mult,CB_SETCURSEL,sel,0);}
-control(L"BUTTON",L"参数与预设",Settings,BS_PUSHBUTTON,1225,10,100,30);
+control(L"BUTTON",L"参数与色彩",Settings,BS_PUSHBUTTON,1225,10,100,30);
auto original=control(L"BUTTON",L"按住原图 V",OriginalHold,BS_PUSHBUTTON,0,0,110,30);SetWindowSubclass(original,interaction,OriginalHold,0);
control(L"BUTTON",L"原图/增强切换",CompareToggle,BS_PUSHBUTTON,0,0,120,30);control(L"BUTTON",L"分屏拖动",Split,BS_PUSHBUTTON,0,0,95,30);
auto ref=control(L"COMBOBOX",L"",Reference,CBS_DROPDOWNLIST,0,0,170,180);for(auto label:{L"对比:输入原画",L"对比:增强前底图"})SendMessageW(ref,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(label));SendMessageW(ref,CB_SETCURSEL,0,0);control(L"BUTTON",L"全屏",Fullscreen,BS_PUSHBUTTON,0,0,108,30);
@@ -483,10 +485,9 @@ auto brand=control(L"STATIC",L"",Brand,SS_CENTER,0,0,100,30);
SetWindowSubclass(brand,veyra::ui::brandIconProc,Brand,0);
control(L"BUTTON",L"专业模式",ModeSwitch,BS_PUSHBUTTON,0,0,164,36);
control(L"BUTTON",L"增强已开启",Master,BS_PUSHBUTTON,0,0,126,36);
-control(L"COMBOBOX",L"",DailyPreset,CBS_DROPDOWNLIST,0,0,180,200);
control(L"BUTTON",L"视频",ProRailVideo,BS_PUSHBUTTON,0,0,64,44);control(L"BUTTON",L"采集",ProRailCapture,BS_PUSHBUTTON,0,0,64,44);control(L"BUTTON",L"图片",ImageOpen,BS_PUSHBUTTON,0,0,64,44);control(L"BUTTON",L"参数",InspectorDrawer,BS_PUSHBUTTON,0,0,84,36);
control(L"BUTTON",L"音频",TabAudio,BS_PUSHBUTTON,0,0,60,36);
-const wchar_t* tabs[]={L"增强",L"运动",L"预设",L"导出"};for(int i=0;i<4;++i)control(L"BUTTON",tabs[i],TabEnhance+i,BS_PUSHBUTTON,0,0,76,36);
+const wchar_t* tabs[]={L"增强",L"运动",L"色彩",L"导出"};for(int i=0;i<4;++i)control(L"BUTTON",tabs[i],TabEnhance+i,BS_PUSHBUTTON,0,0,76,36);
control(L"BUTTON",L"音量",Mute,BS_PUSHBUTTON,0,0,54,36);auto vol=control(TRACKBAR_CLASSW,L"音量",Volume,TBS_HORZ|TBS_NOTICKS,0,0,80,26);SendMessageW(vol,TBM_SETRANGE,TRUE,MAKELPARAM(0,100));SendMessageW(vol,TBM_SETPOS,TRUE,100);
control(L"BUTTON",L"字幕",Subtitle,BS_PUSHBUTTON,0,0,62,36);control(L"STATIC",L"尚未打开媒体",MediaTitle,SS_LEFT|SS_ENDELLIPSIS,0,0,250,26);control(L"STATIC",L"00:00 / 00:00",TimeLabel,SS_LEFT,0,0,200,20);
control(L"STATIC",L"处理 0.0 fps",FpsLabel,SS_RIGHT,0,0,154,20);
@@ -499,7 +500,7 @@ veyra::ui::icon(GetDlgItem(hwnd,ProRailVideo),Icon::Video);veyra::ui::icon(GetDl
veyra::ui::icon(GetDlgItem(hwnd,Recent),Icon::Recent);veyra::ui::icon(GetDlgItem(hwnd,Open),Icon::Video,true);veyra::ui::icon(GetDlgItem(hwnd,Capture),Icon::Capture,true);
for(int id:{Open,Capture,Recent,Master,Save,Sr,ModeSwitch,WindowMin,WindowMax,WindowClose,Stop,Mute,Subtitle,Fullscreen,ProRailVideo,ProRailCapture,ImageOpen,Info})veyra::ui::ghost(GetDlgItem(hwnd,id));
SetPropW(GetDlgItem(hwnd,Open),L"veyra.tip",HANDLE(L"打开视频 / 图片 · Ctrl+O"));SetPropW(GetDlgItem(hwnd,Capture),L"veyra.tip",HANDLE(L"连接采集卡"));SetPropW(GetDlgItem(hwnd,Sr),L"veyra.tip",HANDLE(L"超分辨率 · 专业面板选择 DLSS / RTX 视频超分"));
-inspector=veyra::ui::createSettingsPanel(hwnd,engine,applySettings);liveStatusPanel=veyra::ui::createLiveStatusPanel(hwnd,engine);selectInspector(uiPreferences.inspector);refreshDailyPresets();SendDlgItemMessageW(hwnd,Volume,TBM_SETPOS,TRUE,LPARAM(uiPreferences.volume*100));veyra::ui::marked(GetDlgItem(hwnd,Play));
+inspector=veyra::ui::createSettingsPanel(hwnd,engine,applySettings);liveStatusPanel=veyra::ui::createLiveStatusPanel(hwnd,engine);selectInspector(uiPreferences.inspector);SendDlgItemMessageW(hwnd,Volume,TBM_SETPOS,TRUE,LPARAM(uiPreferences.volume*100));veyra::ui::marked(GetDlgItem(hwnd,Play));
for(auto [id,help]:std::initializer_list<std::pair<int,const wchar_t*>>{
{Nr,L"实验性DLSS5 NR增强:重建画面细节,效果看素材,不是游戏原生集成。"},
{Fg,L"开关补帧。专业模式可选倍率和后端;数字翻倍,显卡工作量也会涨。"},
@@ -507,7 +508,7 @@ for(auto [id,help]:std::initializer_list<std::pair<int,const wchar_t*>>{
{Multiplier,L"选择补帧倍率。帧数不是越多越好,跟不上时会跳过过期机会。"},
{Save,L"保存处理后的完整画面到系统图片文件夹的 Veyra Screenshots。SDR为PNG,HDR为保留高亮的JXR;只拍画面,不拍工具栏或驱动补帧。"},
{Master,L"总增强开关。关闭后保留设置,重新开启不用重调配方。"},
- {DailyPreset,L"载入保存的增强预设,一键换口味。"},{Volume,L"播放音量,不改变音画同步偏移。"},{Mute,L"静音或恢复声音,让耳朵休息一下。"},
+ {Volume,L"播放音量,不改变音画同步偏移。"},{Mute,L"静音或恢复声音,让耳朵休息一下。"},
{Subtitle,L"显示或隐藏字幕。字幕在增强后叠加,不让算法给字加戏。"},{SubtitleLoad,L"加载本地字幕文件。对白太快,给眼睛加个帮手。"},{SubtitleSize,L"调整字幕字号,不改变导出视频尺寸。"},
{OriginalHold,L"查看原始画面对照,松开回到增强效果。眼见为实。"},{Reference,L"选择对照底图。低延迟NR先行时,NR前底图为原图缩放,不是独立超分对照。"},{CompareToggle,L"切换画面对比,方便看清到底改了哪里。"},{Split,L"拖动对比边界,两边当面对质。"},
{Seek,L"拖动跳转;松手后等待解码和增强预热。跳转中保持目标位置,不会故意弹回。"}})SetPropW(GetDlgItem(hwnd,id),L"veyra.tip",HANDLE(help));
@@ -529,12 +530,11 @@ case WM_GETMINMAXINFO:{auto info=reinterpret_cast<MINMAXINFO*>(lp);info->ptMinTr
case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORBTN:case WM_CTLCOLORLISTBOX:return veyra::ui::colors(msg,wp,lp);
case WM_APP+45:{if(masterPendingRevision)return 0;auto settings=uiState.enhanced?engine.snapshot().desired:uiState.configured;
if(wp==213){auto current=engine.snapshot();if(uiState.mode!=veyra::ui::Mode::Professional||!current.running||!current.frames)return 0;bool space=false;for(auto q:settings.protection.regions)space|=q.empty();if(!space)return 0;cancelProtection();protectionArmed=true;SetFocus(video);return 1;}
- if(wp==214){cancelProtection();settings.protection={};}else if(wp==206)settings.protection.enabled=lp==BST_CHECKED;else return 0;
+ if(wp==214){cancelProtection();settings.protection={};}else if(wp==206)settings.protection.enabled=lp==BST_CHECKED;else if(wp==222)settings.protection.featherPixels=float(std::clamp(int(lp),0,64));else return 0;
return applySettings(settings)?1:0;}
case WM_APP+44:{if(masterPendingRevision)return 0;auto setting=uiState.enhanced?engine.snapshot().desired:uiState.configured;const bool enabled=wp==202?lp>1:lp==BST_CHECKED;if(wp==200)setting.nr=enabled;else if(wp==201)setting.sr=enabled;else if(wp==202){bool allowed=false;for(auto m:veyra::engine::kFgMultiplierChoices)if(uint32_t(lp)==m)allowed=true;if(!allowed)return 0;setting.multiplier=uint32_t(lp);if(!setting.validate().empty())return 0;}else return 0;
const bool enablesMaster=enabled&&!uiState.enhanced;if(enablesMaster){masterPreviousEnabled=false;uiState.enhanced=true;}applySettings(setting);if(auto pending=engine.snapshot();enablesMaster&&pending.running){masterPendingRevision=pending.desired.revision;masterPendingSession=pending.sessionId;}veyra::log::info("ui-feature",std::format("click={} enabled={} requestedRevision={} draft-independent=true",wp==200?"NR":wp==201?"SR":"FG",enabled,engine.snapshot().desired.revision));return 1;}
case WM_APP+43:showDiagnostics=false;layout();return 0;
-case WM_APP+42:refreshDailyPresets();return 0;
case WM_APP+41:switch(wp){case 501:startVideoExport(lp!=0);break;case 502:{auto path=fileDialog(true);if(!path.empty())engine.saveFrame(path);break;}case 503:jobPaused=!jobPaused;exportJob.pause(jobPaused);break;case 504:exportJob.cancel();break;case 505:preferWatching=lp==BST_CHECKED;break;}return 0;
case WM_SIZE:cancelProtection();if(wp!=SIZE_MINIMIZED){endTransition();layout();}return 0;
case WM_DROPFILES:{std::vector<wchar_t> file(32768);DragQueryFileW(reinterpret_cast<HDROP>(wp),0,file.data(),32768);DragFinish(reinterpret_cast<HDROP>(wp));openFile(file.data());layout();return 0;}
@@ -544,10 +544,9 @@ case Open:case ProRailVideo:case ImageOpen:openFile(fileDialog(false));layout();
case ModeSwitch:switchMode();break;
case WindowMin:ShowWindow(hwnd,SW_MINIMIZE);break;case WindowMax:toggleFullscreen();break;case WindowClose:SendMessageW(hwnd,WM_CLOSE,0,0);break;
case Master:if(masterPendingRevision)break;masterPreviousEnabled=uiState.enhanced;if(uiState.enhanced)uiState.configured=engine.snapshot().desired;uiState.enhanced=!uiState.enhanced;veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);engine.requestSettings(uiState.effective());if(auto pending=engine.snapshot();pending.running){masterPendingRevision=pending.desired.revision;masterPendingSession=pending.sessionId;}break;
-case DailyPreset:if(HIWORD(wp)==CBN_SELCHANGE){veyra::engine::EnhancementSettings setting;auto index=SendDlgItemMessageW(hwnd,DailyPreset,CB_GETCURSEL,0,0);if(index>0&&veyra::ui::presetAt(size_t(index-1),setting))applySettings(setting);}break;
case InspectorDrawer:uiState.drawer=!uiState.drawer;layout();break;
case TabAudio:selectInspector(4);break;
-case TabEnhance:case TabFg:case TabPresets:case TabExport:selectInspector(LOWORD(wp)-TabEnhance);break;
+case TabEnhance:case TabFg:case TabColor:case TabExport:selectInspector(LOWORD(wp)-TabEnhance);break;
case JobProgress:if(uiState.mode==veyra::ui::Mode::Daily)switchMode();uiState.drawer=true;selectInspector(3);layout();break;
case Details:uiState.diagnostics=!uiState.diagnostics;SetWindowTextW(GetDlgItem(hwnd,Details),uiState.diagnostics?L"性能 ▴":L"性能 ▾");layout();break;
case Mute:{auto s=engine.snapshot();engine.setVolume(s.volume,!s.muted);break;}
@@ -742,6 +741,11 @@ if(smokeSettings&&startTick){const auto elapsed=GetTickCount64()-startTick;
if(settingsStep==0&&s.frames>20){auto change=s.desired;change.model.intensity=.6f;change.model.tone=.7f;change.residual.total=.4f;change.residual.color=.8f;engine.requestSettings(change);settingsStep=1;}
if(settingsStep==1&&s.applied.model.intensity==.6f&&elapsed>3300){auto change=s.desired;change.sr=true;engine.requestSettings(change);settingsStep=2;}
if(settingsStep==2&&s.applied.sr&&elapsed>4500){auto invalid=s.desired;invalid.model.intensity=2;const bool rejected=!engine.requestSettings(invalid);veyra::log::info("settings-test",std::format("invalid-rejected={} position={} revision={} settingsStep={}",rejected,s.position,s.applied.revision,settingsStep));settingsStep=rejected?3:-1;}
+// NR exclusion feather (id 222) must reach the engine through the panel's own
+// live-edit path, not just the shader: this is the control users complained was
+// missing while the hard 2 px default made the zones unusable.
+if(settingsStep==3&&elapsed>6000){SetWindowTextW(veyra::ui::settingsControlForTest(222),L"48");settingsStep=4;}
+if(settingsStep==4&&uiState.configured.protection.featherPixels==48){veyra::log::info("settings-test",std::format("exclusion-feather draft={} desired={} applied={} position={}",uiState.configured.protection.featherPixels,s.desired.protection.featherPixels,s.applied.protection.featherPixels,s.position));settingsStep=5;}
}
tickRepairChecks(hwnd,s);
tickTransportChecks(hwnd,s);
@@ -762,7 +766,7 @@ if(smokeProtection&&startTick&&GetTickCount64()-startTick>1500){
protectionStep=pass?4:-1;veyra::log::info("protection-ui-test",std::format("master-off unchanged-revision dirty-draft-preserved pass={}",pass));SendMessageW(hwnd,WM_COMMAND,Master,0);}
}
-if(smokeSeconds>0&&startTick&&GetTickCount64()-startTick>ULONGLONG(smokeSeconds)*1000){veyra::log::info("app",std::format("smoke frames={} generated={} failed={} latenessMs={:.2f} absLatenessP95Ms={:.2f} controlsStep={} capture={} processedFps={:.2f} callbackFps={:.2f} captureDropped={} callbackToPresentReturnP95Ms={:.3f} schedulingWaitP95Ms={:.3f} processCpuP95Ms={:.3f} presentCpuP95Ms={:.3f} nrEvaluated={} nvofExecuted={}",s.frames,s.generated,s.failed,s.lateMs,s.lateP95Ms,smokeStep,s.capture,s.fps,s.captureFps,s.captureDropped,s.captureAgeP95Ms,s.schedulingWaitP95Ms,s.processCpuP95Ms,s.presentCpuP95Ms,s.nrEvaluated,s.nvofExecuted));resultCode=(s.frames>0||smokeEmpty)&&!s.failed&&(!smokeZoom||zoomStep==3)&&(!smokeProtection||protectionStep==4)&&(!smokeRepair||repairStep==10)&&(!smokeTransport||transportStep==10)&&(!smokeFgOnly||fgOnlyStep==4)&&(!smokeSettings||settingsStep==3)&&(!smokeRollback||settingsStep==3)&&(!smokeUi||uiStep==8)&&(!smokeDual||dualStep==40)&&(!smokeMaster||masterStep==3)&&(!smokeAudio||audioStep==4)&&(!(smokeJob||smokeJobCancel)||jobStep==4)&&(!smokeScreenshot||screenshotStep==2)?0:1;PostMessageW(hwnd,WM_CLOSE,0,0);}return 0;}
+if(smokeSeconds>0&&startTick&&GetTickCount64()-startTick>ULONGLONG(smokeSeconds)*1000){veyra::log::info("app",std::format("smoke frames={} generated={} failed={} latenessMs={:.2f} absLatenessP95Ms={:.2f} controlsStep={} capture={} processedFps={:.2f} callbackFps={:.2f} captureDropped={} callbackToPresentReturnP95Ms={:.3f} schedulingWaitP95Ms={:.3f} processCpuP95Ms={:.3f} presentCpuP95Ms={:.3f} nrEvaluated={} nvofExecuted={}",s.frames,s.generated,s.failed,s.lateMs,s.lateP95Ms,smokeStep,s.capture,s.fps,s.captureFps,s.captureDropped,s.captureAgeP95Ms,s.schedulingWaitP95Ms,s.processCpuP95Ms,s.presentCpuP95Ms,s.nrEvaluated,s.nvofExecuted));resultCode=(s.frames>0||smokeEmpty)&&!s.failed&&(!smokeZoom||zoomStep==3)&&(!smokeProtection||protectionStep==4)&&(!smokeRepair||repairStep==10)&&(!smokeTransport||transportStep==10)&&(!smokeFgOnly||fgOnlyStep==4)&&(!smokeSettings||settingsStep==5)&&(!smokeRollback||settingsStep==3)&&(!smokeUi||uiStep==8)&&(!smokeDual||dualStep==40)&&(!smokeMaster||masterStep==3)&&(!smokeAudio||audioStep==4)&&(!(smokeJob||smokeJobCancel)||jobStep==4)&&(!smokeScreenshot||screenshotStep==2)?0:1;PostMessageW(hwnd,WM_CLOSE,0,0);}return 0;}
case WM_CLOSE:endTransition();if(!closing&&smokeSeconds<=0&&exportJob.poll().active()&&MessageBoxW(hwnd,L"导出尚未完成。取消导出并退出?\n选择“否”返回播放器继续导出。",L"退出 Veyra",MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION)!=IDYES)return 0;if(!closing&&smokeSeconds<=0){auto snapshot=engine.snapshot();WINDOWPLACEMENT placement{sizeof(placement)};if(full)placement=windowPlacement;else GetWindowPlacement(hwnd,&placement);auto r=placement.rcNormalPosition;uiPreferences.width=MulDiv(r.right-r.left,96,veyra::ui::layoutDpi(hwnd));uiPreferences.height=MulDiv(r.bottom-r.top,96,veyra::ui::layoutDpi(hwnd));uiPreferences.x=r.left;uiPreferences.y=r.top;uiPreferences.positioned=true;uiPreferences.volume=snapshot.volume;uiPreferences.muted=snapshot.muted;uiPreferences.subtitles=uiState.subtitles;uiPreferences.subtitleSize=subtitlePixels;uiPreferences.subtitleOutline=uiState.subtitleOutline;uiPreferences.subtitleBackground=uiState.subtitleBackground;uiPreferences.subtitleSecondLanguage=uiState.subtitleSecondLanguage;uiPreferences.subtitleMargin=uiState.subtitleMargin;uiPreferences.subtitleFont=uiState.subtitleFont;uiPreferences.inspector=uiState.inspector;const bool confirmed=snapshot.frames>0&&!snapshot.applying&&!snapshot.failed;if(!preferences.save(uiPreferences,haveSuccessful?&lastSuccessful:nullptr))veyra::log::warn("ui-preferences","preferences not saved; corrupt original preserved");}exportJob.cancel();closing=true;engine.stop();SetWindowTextW(statusBar,L"正在释放当前任务资源…");return 0;
case WM_DESTROY:
#ifdef VEYRA_ENABLE_REMOTEPLAY
diff --git a/apps/veyra/ui/SettingHelp.h b/apps/veyra/ui/SettingHelp.h
index 8d9ae6fd..c1b2d80a 100644
--- a/apps/veyra/ui/SettingHelp.h
+++ b/apps/veyra/ui/SettingHelp.h
@@ -16,7 +16,7 @@ inline const wchar_t* settingHelp(int id){
L"肤质实验参数:-1用默认,其余0–2。效果尚未证实,不保证一键磨皮。",
L"切换0/1/2三个实验风格值。口味自己试,编号不是画质排名。",
L"自动遮罩实验开关。是否改善当前素材需要实测,不是万能遮羞布。",
- L"UI修正实验开关,效果尚未证实。想保护字幕,优先框选NR保护区域。",
+ L"UI修正实验开关,效果尚未证实。想保住字幕,优先框选NR剔除区。",
L"控制NR改动最终混入多少。0保留底图,往上加料;范围0–2。",
L"控制NR把画面变暗的那部分变化。0–2,暗部别一口气踩到底。",
L"控制NR把画面变亮的那部分变化。0–2,别把灯泡当太阳。",
@@ -33,28 +33,21 @@ inline const wchar_t* settingHelp(int id){
case 203:return L"选择NR内部处理上限,按画面比例缩放,再回填输出。低档省算力,高档留细节;原生档让显卡加班。视频导出仍用完整尺寸。";
case 204:return L"光流质量档:估计物体怎么移动。质量档更费工,运动估错了,补帧也可能跟着跑偏。";
case 205:return L"选择内容节奏。采集60→30适合60Hz信号里重复的30帧游戏内容;真60帧别硬砍半。时间戳仍保留。";
- case 206:return L"让框选区域少受NR改动,最多4块。只管NR,不给超分和补帧当保镖。";
+ case 206:return L"剔除区里的NR改动会被抑制、保留原图,最多4块。只管NR,不给超分和补帧当保镖。";
case 207:return L"选择DLSS SR或RTX视频超分,以及视频超分质量。两条路线各有脾气,试着看画质和耗时。";
case 208:return L"选择DLSS、实验XeSS或AMD FSR补帧。XeSS/FSR的生成帧只存在于显示交换链,导出管线拿不到;导出时会自动改用DLSS补帧,显卡不支持则关闭补帧,提示和日志都会写明。别只看名字,看实际效果。";
case 508:return L"导出码率:只决定导出文件的大小与画质,不影响预览。自动=编码器恒定质量档(NVENC CONSTQP / 系统编码器质量模式)。H.264 一般 10-40 Mbps 够用,4K 或高动态建议 60-150;HEVC 同等画质可以取更低。";
case 209:return L"选择运动估算后端。NVOF、FidelityFX、GPU DIS负责看出物体怎么动。DIS是实验算法,走通用计算单元,可能和NR抢活干,不保证更快;选它不会换掉你的补帧方式,也不会解锁AMD NR。";
- case 211:return L"把增强参数恢复为内建默认。调迷路了就走这里,保存的用户预设不会被删。";
- case 213:return L"在画面上拖框添加NR保护区域,Esc取消。把不想被改的地方圈出来。";
- case 214:return L"清空当前NR保护框。只是撤掉围栏,不会删除视频。";
+ case 211:return L"把增强参数恢复为内建默认。调迷路了就走这里,画质参数立即回到出厂状态。";
+ case 213:return L"在画面上拖框添加NR剔除区,Esc取消。把不想被NR改的地方圈出来。";
+ case 214:return L"清空当前NR剔除框。只是撤掉围栏,不会删除视频。";
+ case 222:return L"剔除区边缘的过渡宽度,单位是工作分辨率像素:0 就是硬边,12 约等于4K画面高度的0.5%,越大过渡越柔和。改完立即生效。";
case 215:return L"把AMD光流输入宽高各减半,少算一些像素。速度可能更好,细小运动可能看不清。";
case 216:return L"自动估算声音补偿,或改用手动偏移。目标是嘴和声音一起到,别让角色自带配音延迟。";
case 217:return L"-250到250ms:正值让声音更晚,负值减少已有补偿,不能把未来声音变出来。";
case 218:return L"选择NR运行文件。原版面向RTX50;社区修改版尝试兼容RTX40/50。切换会重建链路,短暂停顿正常。";
case 219:return L"切换直播兼容显示路径。给捕获软件搭个台阶,不是让所有捕获方式都突然开窍。";
case 220:return L"默认先超分→NR(DLSS5)→补帧。打开后NR→超分→补帧,可能更快,也可能多些鬼影或边缘瑕疵。默认关闭,仅预览;需同时开启NR和超分。导出顺序不变。";
- case 300:return L"选择保存过的增强配方。选中后点载入才上菜。";
- case 301:return L"给预设起个名字,最多48字。起得好找,下次少翻半天。";
- case 310:return L"载入选中的预设并应用参数。当前播放源不会换掉。";
- case 311:return L"用内建默认参数新建预设,不是复制当前参数。先打个干净的底。";
- case 312:return L"把当前参数另存为预设。调出好配方,先记下来。";
- case 313:return L"给选中的预设换名,配方不变。";
- case 314:return L"删除选中的预设,需要确认;当前画面不会跟着被删。";
- case 315:return L"设为下次启动的增强默认配方。软件仍从日常模式打开。";
case 500:return L"H.264兼容性广,HEVC通常更省空间。HDR视频须选HEVC,保存为Main10 / PQ;别把HDR硬塞进普通H.264。编码器按显卡自动选择:N卡用NVENC(零拷贝最快),A卡/I卡用系统硬件编码(驱动自带的H.264/HEVC编码器),HDR导出仍需N卡。";
case 501:return L"选保存位置并导出视频。参数在开始时冻结,NR按原生处理;低延迟预览顺序不带进导出。";
case 502:return L"保存当前图片或视频帧。精彩的一瞬间,留下来。";
diff --git a/apps/veyra/ui/UiPreferenceStore.h b/apps/veyra/ui/UiPreferenceStore.h
index e510a57d..e5727af4 100644
--- a/apps/veyra/ui/UiPreferenceStore.h
+++ b/apps/veyra/ui/UiPreferenceStore.h
@@ -21,11 +21,17 @@ public:
explicit UiPreferenceStore(std::filesystem::path folder):folder_(std::move(folder)){}
UiPreferences load(){UiPreferences result;auto path=folder_/"ui-preferences.v1";if(!std::filesystem::exists(path))return result;
if(std::filesystem::file_size(path)>2048){corrupt_=true;return result;}std::ifstream file(path);std::string magic;int version=0,mute,sub,pos;UiPreferences read;
- if(!(file>>magic>>version>>read.volume>>mute>>sub>>read.width>>read.height>>read.x>>read.y>>pos>>read.inspector>>read.subtitleSize)||magic!="VEYRA_UI"||(version<1||version>3)||!std::isfinite(read.volume)||read.volume<0||read.volume>1||mute<0||mute>1||sub<0||sub>1||pos<0||pos>1||read.width<720||read.width>10000||read.height<540||read.height>10000||abs(int64_t(read.x))>100000||abs(int64_t(read.y))>100000||read.inspector<0||read.inspector>3||read.subtitleSize<16||read.subtitleSize>56){corrupt_=true;return result;}
+ // inspector index 4 is the audio page (selectInspector(4)), so the valid
+ // range is 0..4. A narrower bound here silently discarded every saved
+ // window size, volume and subtitle style for users who last sat on it.
+ if(!(file>>magic>>version>>read.volume>>mute>>sub>>read.width>>read.height>>read.x>>read.y>>pos>>read.inspector>>read.subtitleSize)||magic!="VEYRA_UI"||(version<1||version>3)||!std::isfinite(read.volume)||read.volume<0||read.volume>1||mute<0||mute>1||sub<0||sub>1||pos<0||pos>1||read.width<720||read.width>10000||read.height<540||read.height>10000||abs(int64_t(read.x))>100000||abs(int64_t(read.y))>100000||read.inspector<0||read.inspector>4||read.subtitleSize<16||read.subtitleSize>56){corrupt_=true;return result;}
if(version==2&&(!(file>>read.inspectorWidth)||read.inspectorWidth<296||read.inspectorWidth>420)){corrupt_=true;return result;}
if(version>=3){
int outline=0,background=0,second=0;
- if(!(file>>outline>>background>>second>>read.subtitleMargin>>read.subtitleFont)||outline<0||outline>1||background<0||background>1||second<0||second>1||read.subtitleMargin<0||read.subtitleMargin>240||read.subtitleFont<0||read.subtitleFont>5){corrupt_=true;return result;}
+ // Field order must match save(): inspectorWidth precedes the three
+ // switches. It used to be read only for version 2, so every version
+ // 3 file was rejected as corrupt and all UI preferences were lost.
+ if(!(file>>read.inspectorWidth>>outline>>background>>second>>read.subtitleMargin>>read.subtitleFont)||read.inspectorWidth<296||read.inspectorWidth>420||outline<0||outline>1||background<0||background>1||second<0||second>1||read.subtitleMargin<0||read.subtitleMargin>240||read.subtitleFont<0||read.subtitleFont>5){corrupt_=true;return result;}
read.subtitleOutline=outline!=0;read.subtitleBackground=background!=0;read.subtitleSecondLanguage=second!=0;
}file>>std::ws;if(!file.eof()){corrupt_=true;return result;}read.muted=mute;read.subtitles=sub;read.positioned=pos;return read;
}
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index ca59f339..cbc2e68b 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,57 @@
# 2026-09-11 继续修复目标模式执行中
+## 2026-09-17 色彩页 P1:T0 删预设入口 + T1 NR 剔除区羽化(含两个设置记忆缺陷修复)
+
+目标(用户指令):按 `docs/COLOR_TAB_LR_FEATURE_PLAN_2026-09-17.md` v3 开工,先落 T0/T1。
+存档点 `checkpoint/color-p1-archive-20260917`(65e69b3),施工分支 `codex/color-tab-p1-20260917`,P1 全程不合并 main。
+
+**T0 预设入口删除(代码级,无残留入口)**
+
+- `SettingsWindow.cpp`:整页删除(静态 1105/1106、下拉 300、命名 301、按钮 310–315、`refreshPresets()`、WM_COMMAND 分支、`store.put/rename/erase/setDefault` 调用),第 2 页留作色彩页;
+- `SettingsWindow.h`:删除 `presetNames()` / `presetAt()`;`AppShell.cpp`:删除日常模式预设下拉
+ (`DailyPreset` 控件、`refreshDailyPresets()`、WM_APP+42 分支、帮助文本、布局槽位);
+ 枚举保留 `RetiredPresetSlot` 占位以**不改动后续控件 id**(不是入口,也不创建控件);
+- 页签 `预设` → `色彩`,主窗口按钮 `参数与预设` → `参数与色彩`;`SettingHelp.h` 删除 300/301/310–314 帮助;
+- 按批复保留行为、无 UI 入口:`last-applied.v1`(启动自动套用上次增强参数)与 `user-presets.v1`(只读迁移)。
+
+**T1 NR 剔除区 + 羽化**
+
+- 改名:`NR保护区域` → `NR 剔除区`(复选框 206、计数文本、按钮 213/214、帮助 19/206/213/214、设置页静态 1109);
+- 新增羽化控件:滑块 622(0–64 工作分辨率像素)+ 数值框 222 + 动态标签 1123(显示 px 与 ≈画面高度百分比,取自 `snapshot().metrics.resolution.base.height`);
+- `EnhancementSettings::validate()` 羽化上限 32 → 64;`TiledImageProcessor` 加
+ `static_assert(halo>=64)`,保证瓦片外扩(128 px)覆盖最大羽化、导出分块不穿帮;
+- 布局由实测决定:新增 `VEYRA_DUMP_SETTINGS_LAYOUT=1` 一次性打印全部控件坐标(DIP)。
+ 实测剔除区块 y=362/404/448,羽化行 y=530/530/562,与后续模型块 618+ 无重叠;
+- `--smoke-settings` 增加一步:把羽化框设为 48 并断言进入设置草稿(日志
+ `[settings-test] exclusion-feather draft=48 desired=2 applied=2` —— 首次启动增强关闭,草稿路径正确)。
+
+**验证时另修的三个缺陷(都不是本轮新引入,如实记录)**
+
+1. **v3 UI 偏好永远读不回来**:`UiPreferenceStore::load()` 的 v3 分支漏读 `inspectorWidth`(写 6 个字段只读 5 个),
+ 任何 `VEYRA_UI 3` 文件都被判 corrupt → 窗口尺寸/音量/字幕样式/页签索引每次启动静默重置。
+2. **inspector 范围写死 0..3**:音频页是 `selectInspector(4)`,用户最后停在音频页同样导致整份偏好被丢弃。范围改为 0..4。
+3. **`ImageDimensionTests::protectionPixels()` 自身失效**:`applySettings()` 会按设置快照开关 NR,而该用例构造的
+ `EnhancementSettings` 默认 `nr=false` → 整个保护段 `changed=0/nr=0`,永远不可能通过(旧构建同样失败,非本轮引入)。
+ 修正为 `settings.nr=true`,并把羽化用例扩到 2/32/64。
+
+**命令与结果(本机 RTX 5070,构建目录 `out/build/audio-continuity-repair-20260915`)**
+
+- 构建 `out\build\veyra-build-x64-release.cmd` → exit 0;
+- `veyra_image_dimension_tests <新目录>` → exit 0;
+ `PROTECTION_FEATHER pixels=2 mixedChannels=1581 / 32 → 15725 / 64 → 20248`,`envelopeError8=0`;
+ `PROTECTION_PIXELS ... changed=191323 protectedError8=0 outsideError8=0 nr=8 pass=1`;
+ `PROTECTION_PARTIAL_TILE feather=32 ... pass=1`;`PROTECTION_MOVING_RESULT ... pass=1`
+ (注:该用例输出目录必须为空,重复跑同一目录会在 1x1 PNG 往返处失败——既有测试卫生问题,未改);
+- `veyra_ui_contract_tests <临时目录>` → exit 0(新增 v3 往返与"音频页 inspector=4"回归断言);
+- `veyra_repair_preset_tests <临时文件>` → exit 0(66 组旧格式迁移 + v17 往返);
+- `veyra_popup_selector_tests` → exit 0;`veyra_repair_contract_tests` → 191 项 0 失败;
+- `scripts/gates/delivery.ps1 -Root . -BuildDirectory out/build/audio-continuity-repair-20260915` →
+ `DELIVERY SHORT GATE PASS`(`logs/delivery/566557c4ad5f401ab06960af1c9d2f5e/result.json`);
+- 布局证据:`VEYRA_DUMP_SETTINGS_LAYOUT=1` + `veyra.exe --smoke-empty --smoke-seconds 3`(92 条 `[settings-layout]`)。
+
+**未完成 / 下一步**:T2–T6(`ColorSettings` 模型与全浮点 Pass A、色彩页 UI 框架、各面板、LUT 与命名预设、HDR 标准处理与验收)。
+真机人工验收(1080/4K 目视对比、羽化手感)由用户执行;本轮未做发布。
+
## 2026-09-17 RTX 30(Ampere)帧生成攻坚:架构闸门定位 + 伪装实现(默认关闭)
目标(用户指令):把 30 系弄到能用,同时不改变 40/50 系行为;产出给 30 系用户测试的包。
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index c5f51270..21b0ce31 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -88,7 +88,9 @@ struct ProtectionSettings {
std::array<ProtectionRect,4> regions{};
bool operator==(const ProtectionSettings&)const=default;
std::string validate()const{
- if(!std::isfinite(featherPixels)||featherPixels<0||featherPixels>32)return "invalid protection feather";
+ // Upper bound is 64 px at the working extent; TiledImageProcessor keeps
+ // its tile halo above this value so export tiles cannot clip the ramp.
+ if(!std::isfinite(featherPixels)||featherPixels<0||featherPixels>64)return "invalid protection feather";
for(auto r:regions){for(float v:{r.left,r.top,r.right,r.bottom})if(!std::isfinite(v)||v<0||v>1)return "invalid protection rectangle";
if(r.left>r.right||r.top>r.bottom)return "inverted protection rectangle";}
return {};
diff --git a/src/engine/TiledImageProcessor.cpp b/src/engine/TiledImageProcessor.cpp
index f2728803..cbf64507 100644
--- a/src/engine/TiledImageProcessor.cpp
+++ b/src/engine/TiledImageProcessor.cpp
@@ -18,6 +18,9 @@ bool TiledImageProcessor::process(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotR
// This path preserves input resolution; SR is not an implicit tile resize.
if(desc.enableSr){veyra::log::error("image-tiles","SR requires a separate full-image output plan");return false;}
constexpr uint32_t coreLimit=1280,halo=128,overlap=64;
+ // The NR exclusion feather ramps inside the padding; a halo smaller than
+ // the accepted feather range (0-64 px) would clip the ramp at tile edges.
+ static_assert(halo>=64,"tile halo must cover the maximum protection feather");
const uint32_t coreW=std::min(coreLimit,input.width),coreH=std::min(coreLimit,input.height);
const uint32_t tileW=coreW+2*halo,tileH=coreH+2*halo;
const uint32_t countX=(input.width-1)/coreW+1,countY=(input.height-1)/coreH+1;
diff --git a/tests/integration/ImageDimensionTests.cpp b/tests/integration/ImageDimensionTests.cpp
index 6a60ac32..839bea9a 100644
--- a/tests/integration/ImageDimensionTests.cpp
+++ b/tests/integration/ImageDimensionTests.cpp
@@ -182,11 +182,17 @@ bool protectionPixels(){
if(av_frame_get_buffer(f,32)<0){av_frame_free(&f);return false;}
for(unsigned y=0;y<256;++y)for(unsigned x=0;x<256;++x){auto* p=f->data[0]+size_t(y)*f->linesize[0]+x*4;p[0]=(x*7+y*3)%256;p[1]=(x*3+y*11)%256;p[2]=(x*5+y*17)%256;p[3]=255;}
sink::RgbaImage baseline;bool ok=true;int protectedError=0,outsideError=0;uint64_t changed=0;
- for(unsigned mode=0;mode<7&&ok;++mode){
- engine::EnhancementSettings settings;settings.protection.enabled=mode>0;settings.protection.featherPixels=0;
+ for(unsigned mode=0;mode<8&&ok;++mode){
+ // applySettings() drives the NR stage from the settings snapshot, so a
+ // default struct would switch NR off and the protection math below
+ // would measure an unmodified image (pre-existing test defect: the
+ // section reported changed=0/nr=0 and could never pass).
+ engine::EnhancementSettings settings;settings.nr=true;settings.protection.enabled=mode>0;settings.protection.featherPixels=0;
if(mode==2)settings.protection.regions[0]={0,0,1,1};
if(mode>=3)settings.protection.regions[0]={.25f,.25f,.75f,.75f};
- if(mode==4||mode==5)settings.protection.featherPixels=mode==4?2.f:32.f;
+ // The accepted feather range is 0-64 px; 64 is the widest ramp the
+ // panel exposes and must stay inside the NR exclusion contract.
+ if(mode==4||mode==5||mode==7)settings.protection.featherPixels=mode==4?2.f:mode==5?32.f:64.f;
if(mode==6){settings.protection.regions[0]={.125f,.125f,.375f,.375f};settings.protection.regions[1]={.625f,.625f,.875f,.875f};}
pipeline::EnhanceGraph::FrameOutputs out;sink::RgbaImage result;
ok=graph.applySettings(settings)&&graph.process(f,0,true,out,mode+1)&&sink::readRgba8(ctx,ring,graph.videoFrameResource(out.videoSlot),result);
@@ -195,21 +201,21 @@ bool protectionPixels(){
for(unsigned y=0;y<256;++y)for(unsigned x=0;x<256;++x)for(unsigned c=0;c<3;++c){auto i=(size_t(y)*256+x)*4+c;auto original=f->data[0][size_t(y)*f->linesize[0]+x*4+c];
if(!mode){changed+=result.pixels[i]!=original;continue;}
float edge=std::min(std::min(x+.5f-64,192.f-x-.5f),std::min(y+.5f-64,192.f-y-.5f));
- if(mode==4||mode==5){
+ if(mode==4||mode==5||mode==7){
int v=result.pixels[i],a=original,b=baseline.pixels[i];
envelope=std::max(envelope,std::max(std::min(a,b)-v,v-std::max(a,b)));
if(edge>0&&edge<settings.protection.featherPixels){mixed+=std::abs(v-a)>1&&std::abs(v-b)>1;continue;}
}
- bool protectedPixel=mode==2||(mode>=3&&mode<=5&&edge>=settings.protection.featherPixels)||(mode==6&&((x>=32&&x<96&&y>=32&&y<96)||(x>=160&&x<224&&y>=160&&y<224)));
+ bool protectedPixel=mode==2||((mode>=3&&mode<=5||mode==7)&&edge>=settings.protection.featherPixels)||(mode==6&&((x>=32&&x<96&&y>=32&&y<96)||(x>=160&&x<224&&y>=160&&y<224)));
if(protectedPixel)protectedError=std::max(protectedError,std::abs(int(result.pixels[i])-int(original)));
else outsideError=std::max(outsideError,std::abs(int(result.pixels[i])-int(baseline.pixels[i])));
}
}
- if(mode==4||mode==5){ok=ok&&envelope<=1&&mixed>100;std::cout<<"PROTECTION_FEATHER pixels="<<settings.protection.featherPixels<<" mixedChannels="<<mixed<<" envelopeError8="<<envelope<<" pass="<<ok<<std::endl;}
+ if(mode==4||mode==5||mode==7){ok=ok&&envelope<=1&&mixed>100;std::cout<<"PROTECTION_FEATHER pixels="<<settings.protection.featherPixels<<" mixedChannels="<<mixed<<" envelopeError8="<<envelope<<" pass="<<ok<<std::endl;}
std::cout<<"PROTECTION_MODE mode="<<mode<<" protectedError8="<<protectedError<<" outsideError8="<<outsideError<<std::endl;
out={};
}
- ok=ok&&changed>100&&protectedError<=1&&outsideError==0&&graph.metrics().nrEvaluateCount==7;
+ ok=ok&&changed>100&&protectedError<=1&&outsideError==0&&graph.metrics().nrEvaluateCount==8;
std::cout<<"PROTECTION_PIXELS empty/full/rectangle/feather/disjoint changed="<<changed<<" protectedError8="<<protectedError<<" outsideError8="<<outsideError<<" nr="<<graph.metrics().nrEvaluateCount<<" pass="<<ok<<std::endl;
ring.drainQueue();graph.shutdown();av_frame_free(&f);ring.shutdown();ctx.shutdown();return ok;
}
diff --git a/tests/unit/UiContractTests.cpp b/tests/unit/UiContractTests.cpp
index 315dae6e..1f5f758e 100644
--- a/tests/unit/UiContractTests.cpp
+++ b/tests/unit/UiContractTests.cpp
@@ -69,6 +69,12 @@ int wmain(int argc,wchar_t** argv){try{
require(MulDiv(l.viewWidth,dpi,96)>0,"DPI physical extent");
}
std::vector<float> tone(4800*2,1);float gain=1;sink::applyStereoGain(tone.data(),4800,.5f,gain);require(std::abs(gain-.5f)<1e-6,"gain ramp reaches half");for(size_t i=480;i<tone.size();++i)require(std::abs(tone[i]-.5f)<1e-6,"actual PCM scaled");tone.assign(tone.size(),1);sink::applyStereoGain(tone.data(),4800,0,gain);require(gain==0,"mute reaches zero");for(size_t i=480;i<tone.size();++i)require(tone[i]==0,"muted PCM exactly zero");
- if(argc>1){auto dir=std::filesystem::path(argv[1]);ui::UiPreferenceStore prefs(dir);const auto fresh=prefs.startup({});require(!fresh.nr&&!fresh.sr&&fresh.multiplier==1,"missing preferences do not enable effects");ui::UiPreferences p;p.volume=.45f;p.muted=true;p.inspector=3;p.width=1180;require(prefs.save(p,&before),"atomic preferences save");ui::UiPreferenceStore loaded(dir);auto restored=loaded.load();require(restored.volume==p.volume&&restored.muted&&restored.inspector==3,"preferences round trip");auto setting=loaded.startup({});before.revision=setting.revision;require(setting==before,"all confirmed parameters round trip");auto path=dir/"ui-preferences.v1";{std::ofstream bad(path);bad<<"UNKNOWN 9 invalid";}ui::UiPreferenceStore damaged(dir);damaged.load();require(!damaged.save(p,nullptr),"corrupt preference cannot be overwritten");std::ifstream f(path);std::string data((std::istreambuf_iterator<char>(f)),{});require(data=="UNKNOWN 9 invalid","corrupt original preserved");}
+ if(argc>1){auto dir=std::filesystem::path(argv[1]);ui::UiPreferenceStore prefs(dir);const auto fresh=prefs.startup({});require(!fresh.nr&&!fresh.sr&&fresh.multiplier==1,"missing preferences do not enable effects");ui::UiPreferences p;p.volume=.45f;p.muted=true;p.inspector=3;p.width=1180;require(prefs.save(p,&before),"atomic preferences save");ui::UiPreferenceStore loaded(dir);auto restored=loaded.load();require(restored.volume==p.volume&&restored.muted&&restored.inspector==3,"preferences round trip");
+ // Regression (2026-09-17): version 3 preferences were rejected wholesale
+ // (inspectorWidth was read only for v2, so the first v3 field misaligned),
+ // and inspector 4 - the audio page, one of the five rail tabs - failed the
+ // range check. Both silently reset window size, volume and subtitle style.
+ {ui::UiPreferences audio;audio.volume=.9f;audio.muted=true;audio.inspector=4;audio.inspectorWidth=380;audio.width=1600;audio.height=900;require(prefs.save(audio,nullptr),"audio-page preferences save");ui::UiPreferenceStore reload(dir);const auto back=reload.load();require(std::abs(back.volume-.9f)<1e-6&&back.inspector==4&&back.inspectorWidth==380&&back.width==1600,"audio page and geometry survive the version 3 round trip");}
+ auto setting=loaded.startup({});before.revision=setting.revision;require(setting==before,"all confirmed parameters round trip");auto path=dir/"ui-preferences.v1";{std::ofstream bad(path);bad<<"UNKNOWN 9 invalid";}ui::UiPreferenceStore damaged(dir);damaged.load();require(!damaged.save(p,nullptr),"corrupt preference cannot be overwritten");std::ifstream f(path);std::string data((std::istreambuf_iterator<char>(f)),{});require(data=="UNKNOWN 9 invalid","corrupt original preserved");}
std::cout<<"PASS: mode/bypass, 384 layout cases at four DPI scales, actual PCM gain/mute, confirmed settings persistence/corruption\n";return 0;
}catch(const std::exception& e){std::cerr<<"FAIL: "<<e.what()<<'\n';return 1;}}