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(playback): add temporal NR, subtitle layout, pacing controls

Veyra Goal Agent6404edabe27d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c4ab684..36a425a4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -251,6 +251,7 @@ veyra_add_compute_shader(veyra_shader_present_motion PresentMotion)
veyra_add_compute_shader(veyra_shader_nvof_densify NvofDensify)
veyra_add_compute_shader(veyra_shader_nr_downsample NrDownsample)
veyra_add_compute_shader(veyra_shader_nr_residual NrResidualComposite)
+veyra_add_compute_shader(veyra_shader_nr_temporal NrTemporal)
veyra_add_compute_shader(veyra_shader_flow_adapt FlowAdapt)
veyra_add_compute_shader(veyra_shader_rgb_nv12 RgbToNv12)
@@ -406,7 +407,7 @@ endif()
# EnhanceGraph (the real GPU chain) needs the NGX + NVOF backends; wire it
# into veyra_pipeline only when both exist so bare contract builds still work.
if(TARGET veyra_ngx AND TARGET veyra_nvof AND VEYRA_FFMPEG_ROOT)
- target_sources(veyra_pipeline PRIVATE src/pipeline/EnhanceGraph.cpp src/core/SceneCadenceAnalyzer.cpp)
+ target_sources(veyra_pipeline PRIVATE src/pipeline/EnhanceGraph.cpp src/pipeline/NrTemporalPass.cpp src/core/SceneCadenceAnalyzer.cpp)
target_include_directories(veyra_pipeline PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(veyra_pipeline PRIVATE veyra_ngx veyra_nvof ${FFMPEG_LIBRARIES})
add_dependencies(veyra_pipeline
@@ -485,7 +486,7 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
# veyra_sources: product input sources (Playbook R3/R7). MediaFileSource
# composes veyra_media; no second decode implementation exists.
- add_dependencies(veyra_pipeline veyra_shader_nr_downsample veyra_shader_nr_residual veyra_shader_flow_adapt)
+ add_dependencies(veyra_pipeline veyra_shader_nr_downsample veyra_shader_nr_residual veyra_shader_nr_temporal veyra_shader_flow_adapt)
add_library(veyra_sources STATIC
src/source/NativeCaptureSink.cpp
src/source/MediaFileSource.cpp
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index 7eaaf3aa..57788641 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -46,6 +46,18 @@ The provider DLL on disk is never modified, re-signed or renamed; only the mappe
XeSS pacing adaptation (2026-09-19): `include/veyra/gfx/XessPacing.h` and `src/gfx/XessPacing.cpp` also adapt the above pinned OptiScaler `XeFGPacing.h` NoteFrame/PaceFrame/WaitUntil logic: a bounded 15-period median, generated-frame deadlines, and the provider-owned tail limiter condition. Veyra retains its audited call-site hooks, adds synchronized statistics and complete hooked-present-return gap measurements, and does not port upstream timestamp hooks. Provider scheduling remains preferred; wall-clock pacing is used only when its scheduler is unavailable. No on-disk runtime changes.
+### Magpie NR temporal residual route (2026-09-20)
+
+Veyra's optional `src/pipeline/NrTemporalPass.cpp` and
+`shaders/NrTemporal.hlsl` adapt the motion-guided residual-history design from
+SAOG0721/Magpie, commit
+`3841698348bfb246623d4acf791984c8b68a577b`,
+`src/Magpie.Core/DLSSNRTemporalShader.h` (GPL-3.0). The Veyra version keeps
+the existing D3D12 graph, uses its source motion extent and signed HDR working
+space, and adds its own resource/reset plumbing; it is not a binary or runtime
+copy. The switch is default-off until affected RTX hardware and motion-scene
+quality tests reject ghosting and flicker regressions.
+
## AMD FidelityFX Optical Flow
FidelityFX SDK 1.1.4, upstream commit `c6efa6bf7f2027b3ec94f28578bb5965eabb9e55`, https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK . The optical-flow and DX12 backend libraries are statically linked. Copyright (C) 2024 Advanced Micro Devices, Inc.; MIT license, reproduced in the package's `licenses/AMD_FIDELITYFX_LICENSE.txt`. This is optical flow, not AMD NR or AMD super resolution.
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index 0d7cbb20..754c7776 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -933,6 +933,7 @@ void populate(engine::EnhancementSettings s){
send(508,CB_SETCURSEL,int(engine::exportBitrateIndex(s.exportBitrateMbps)),0);
send(218,CB_SETCURSEL,int(s.nrRuntime));
check(219,s.captureCompatible?BST_CHECKED:BST_UNCHECKED);check(220,s.lowLatency?BST_CHECKED:BST_UNCHECKED);
+ check(223,s.nrTemporal?BST_CHECKED:BST_UNCHECKED);
check(230,enhancementEnabled&&s.videoHdr.enabled?BST_CHECKED:BST_UNCHECKED);
const unsigned hdrValues[]={s.videoHdr.contrast,s.videoHdr.saturation,s.videoHdr.middleGray,s.videoHdr.peakNits};
for(int i=0;i<4;++i){send(631+i,TBM_SETPOS,TRUE,hdrValues[i]);putText(1131+i,(std::to_wstring(hdrValues[i])+(i==3?L" nit":L"")).c_str());}
@@ -956,7 +957,7 @@ bool read(engine::EnhancementSettings& s,bool allPages=false){s=enhancementEnabl
{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));
s.nrRuntime=static_cast<engine::NrRuntime>(send(218,CB_GETCURSEL));
- s.captureCompatible=checked(219)==BST_CHECKED;s.lowLatency=checked(220)==BST_CHECKED;
+ s.captureCompatible=checked(219)==BST_CHECKED;s.lowLatency=checked(220)==BST_CHECKED;s.nrTemporal=checked(223)==BST_CHECKED;
wchar_t offset[32]{};GetWindowTextW(item(217),offset,32);wchar_t* offsetEnd=nullptr;const auto parsed=wcstol(offset,&offsetEnd,10);
if(offsetEnd==offset||*offsetEnd||parsed<-250||parsed>250){message(L"声音偏移须为 -250 至 250 ms");return false;}s.audioOffsetMs=int(parsed);
for(int j=0;j<3;++j)if(GetPropW(item(730+j),L"veyra.selected")){s.srTarget=static_cast<pipeline::SrTarget>(j);break;}
@@ -994,6 +995,8 @@ bool liveField(int id){
case 208:{s.frameGenerationBackend=static_cast<engine::FrameGenerationBackend>(send(id,CB_GETCURSEL));if(engine::presentSinkFrameGeneration(s.frameGenerationBackend)){const int choices=multiplierChoiceCount(s.frameGenerationBackend);const size_t index=size_t(std::clamp(choices-1,1,int(engine::kFgMultiplierChoiceCount)-1));s.multiplier=std::min(s.multiplier,engine::kFgMultiplierChoices[index]);}break;}
case 209:s.opticalFlowBackend=static_cast<engine::OpticalFlowBackend>(send(id,CB_GETCURSEL));break;
case 220:s.lowLatency=checked(id)==BST_CHECKED;break;
+ case 223:s.nrTemporal=checked(id)==BST_CHECKED;break;
+
case 631:s.videoHdr.contrast=unsigned(send(id,TBM_GETPOS));break;
case 632:s.videoHdr.saturation=unsigned(send(id,TBM_GETPOS));break;
case 633:s.videoHdr.middleGray=unsigned(send(id,TBM_GETPOS));break;
@@ -1411,8 +1414,11 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.
add(L"BUTTON",L"帧节奏 / 显示同步",240,BS_AUTOCHECKBOX|WS_TABSTOP,1,12,550,-1,32);
combo(241,1,590,{L"低排队",L"均匀呈现 · 前端同步",L"NVIDIA Reflex · 实验"});
combo(242,1,634,{L"显示:允许撕裂",L"显示:垂直同步",L"显示:自动"});
- add(L"STATIC",L"",1150,SS_NOPREFIX,1,12,678,-1,70);
- {const auto p=controller->snapshot().presentation;check(240,p.enabled?BST_CHECKED:BST_UNCHECKED);send(241,CB_SETCURSEL,unsigned(p.mode));send(242,CB_SETCURSEL,unsigned(p.display));EnableWindow(item(241),p.enabled);EnableWindow(item(242),p.enabled);}
+ combo(243,1,678,{L"输出限帧:关闭",L"输出限帧:跟随显示器",L"输出限帧:自定义"});
+ add(L"EDIT",L"60",244,ES_AUTOHSCROLL|ES_RIGHT|WS_TABSTOP,1,182,722,90,28);
+ add(L"STATIC",L"FPS",1147,0,1,276,722,40,28);
+ add(L"STATIC",L"",1150,SS_NOPREFIX,1,12,764,-1,90);
+ {const auto p=controller->snapshot().presentation;check(240,p.enabled?BST_CHECKED:BST_UNCHECKED);send(241,CB_SETCURSEL,unsigned(p.mode));send(242,CB_SETCURSEL,unsigned(p.display));send(243,CB_SETCURSEL,unsigned(p.outputRate));putText(244,std::format(L"{:.3f}",p.customFps).c_str());EnableWindow(item(241),p.enabled);EnableWindow(item(242),p.enabled);EnableWindow(item(243),true);EnableWindow(item(244),p.outputRate==engine::OutputRateMode::Custom);}
button(L"Smooth Motion · 开启方法 ▾",221,1,12,358);
ghost(item(221));
SetPropW(item(221),L"veyra.tip",HANDLE(L"查看 NVIDIA App 的 AI 插帧开启方法。这里只提供说明,不修改驱动,也不限制叠加补帧。"));
@@ -1423,6 +1429,9 @@ 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和超分才有作用。"));
+ for(auto& entry:items)if(entry.page==0&&entry.y>=216)entry.y+=44;
+ add(L"BUTTON",L"NR 时间域防闪烁 · 实验",223,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,212,-1,36);
+ SetPropW(item(223),L"veyra.tip",HANDLE(L"使用前一帧的 NR 残差并按光流对齐,抑制闪烁。默认关闭;快速运动、切镜时会自动丢弃旧历史,可能增加少量 GPU 开销。"));
// 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;
@@ -1471,13 +1480,15 @@ __declspec(noinline) LRESULT settingsCommand(HWND h,UINT msg,WPARAM wp,LPARAM lp
return 0;
}
}
- if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==240&&HIWORD(wp)==BN_CLICKED)||((LOWORD(wp)==241||LOWORD(wp)==242)&&HIWORD(wp)==CBN_SELCHANGE))){
+ if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==240&&HIWORD(wp)==BN_CLICKED)||((LOWORD(wp)==241||LOWORD(wp)==242||LOWORD(wp)==243)&&HIWORD(wp)==CBN_SELCHANGE)|| (LOWORD(wp)==244&&HIWORD(wp)==EN_KILLFOCUS))){
auto setting=controller->snapshot().presentation;setting.enabled=checked(240)==BST_CHECKED;
setting.mode=engine::PacingMode(send(241,CB_GETCURSEL));setting.display=engine::DisplaySync(send(242,CB_GETCURSEL));
- if(setting.valid()){controller->requestPresentation(setting);EnableWindow(item(241),setting.enabled);EnableWindow(item(242),setting.enabled);SendMessageW(GetParent(window),WM_APP+46,0,0);}return 0;
+ setting.outputRate=static_cast<engine::OutputRateMode>(send(243,CB_GETCURSEL));
+ if(setting.outputRate==engine::OutputRateMode::Custom){wchar_t fps[64]{};GetWindowTextW(item(244),fps,64);wchar_t* end=nullptr;const auto value=wcstod(fps,&end);if(end==fps||*end||!std::isfinite(value)||value<1||value>1000){message(L"自定义限帧须为 1–1000 FPS");return 0;}setting.customFps=value;}
+ if(setting.valid()){controller->requestPresentation(setting);EnableWindow(item(241),setting.enabled);EnableWindow(item(242),setting.enabled);EnableWindow(item(244),setting.outputRate==engine::OutputRateMode::Custom);SendMessageW(GetParent(window),WM_APP+46,0,0);}return 0;
}
if(msg==WM_COMMAND&&LOWORD(wp)==221&&HIWORD(wp)==BN_CLICKED){smoothMotionHelpExpanded=!smoothMotionHelpExpanded;putText(221,smoothMotionHelpExpanded?L"Smooth Motion · 收起说明 ▴":L"Smooth Motion · 开启方法 ▾");arrange();return 0;}
- if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==220&&HIWORD(wp)==BN_CLICKED){liveField(220);return 0;}
+ if(msg==WM_COMMAND&&!populating&&(LOWORD(wp)==220||LOWORD(wp)==223)&&HIWORD(wp)==BN_CLICKED){liveField(LOWORD(wp));return 0;}
if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==230&&HIWORD(wp)==BN_CLICKED){SendMessageW(GetParent(window),WM_APP+44,230,checked(230));return 0;}
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;}
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index acc8e8b8..c364d22f 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -52,7 +52,7 @@ uint32_t multiplierFromDailyIndex(int index){const int i=index+1;return (index>=
// 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};
+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,FullscreenLock,VideoSurface=1000};
// Settings-panel status text: it belongs to the player's bottom bar now, next to
// the submitted-FPS readout (id 64 is free in the main window's id space).
constexpr int ColourStatus=64;
@@ -98,7 +98,7 @@ struct ToolbarItem{HWND hwnd;int width;};std::vector<ToolbarItem> toolbar;
bool full=false,holdOriginal=false,referenceBase=false;int compareMode=0;float compareSplit=.5f;WINDOWPLACEMENT windowPlacement{sizeof(windowPlacement)};
HWND mainWindow=nullptr,video=nullptr,statusBar=nullptr,seekBar=nullptr,playbackBar=nullptr;
veyra::ui::WorkspaceTransition transition;veyra::ui::GlassBackdrop backdrop;
-bool fullControls=true,menuOpen=false;ULONGLONG pointerTick=0,dashboardTick=0;
+bool fullControls=true,fullLocked=false,menuOpen=false;ULONGLONG pointerTick=0,dashboardTick=0;
void layout();
enum : UINT_PTR { TelemetryTimer=1, TransitionTimer=2, ControllerTimer=3 };
void startShellTimer(HWND window,UINT_PTR id,UINT interval){
@@ -112,7 +112,7 @@ veyra::ui::ChromeLayout chromeLayout(int w,int h){
target=pro;target.left=transition.mix(daily.left,pro.left);target.top=transition.mix(daily.top,pro.top);target.viewWidth=transition.mix(daily.viewWidth,pro.viewWidth);target.viewHeight=transition.mix(daily.viewHeight,pro.viewHeight);target.bottom=transition.mix(daily.bottom,pro.bottom);target.right=transition.mix(w+20,pro.right);return target;
}
LRESULT CALLBACK barProc(HWND h,UINT m,WPARAM w,LPARAM l){if(m==WM_ERASEBKGND)return 1;if(m==WM_PAINT){veyra::ui::PaintBuffer paint(h);veyra::ui::fillSurface(paint.dc,paint.rect,h);return 0;}return DefWindowProcW(h,m,w,l);}
-void pointerActivity(){if(!full)return;pointerTick=GetTickCount64();if(!fullControls){fullControls=true;layout();}SetCursor(LoadCursorW(nullptr,IDC_ARROW));}
+void pointerActivity(){if(!full||fullLocked)return;pointerTick=GetTickCount64();if(!fullControls){fullControls=true;layout();}SetCursor(LoadCursorW(nullptr,IDC_ARROW));}
std::wstring currentFile,autoInput;bool paused=false,dragging=false,closing=false;int smokeSeconds=0;ULONGLONG startTick=0;int resultCode=0;
std::wstring exportOutput;unsigned exportFrames=0;unsigned cancelAfterMs=0;bool exportHevc=false;veyra::engine::PlayerOptions initialOptions;
@@ -266,7 +266,8 @@ std::wstring screenshotPath;ULONGLONG screenshotTick=0;bool screenshotPending=fa
void openFile(const std::wstring&);
void layout();
void updateComparison(){engine.comparison(holdOriginal?1:compareMode,holdOriginal?false:referenceBase,compareSplit);}
-void toggleFullscreen(){endTransition();full=!full;if(tooltips){SendMessageW(tooltips,TTM_POP,0,0);SendMessageW(tooltips,TTM_ACTIVATE,full?FALSE:TRUE,0);}DWORD corner=full?1:2;DwmSetWindowAttribute(mainWindow,33,&corner,sizeof(corner));fullControls=true;pointerTick=GetTickCount64();if(full){GetWindowPlacement(mainWindow,&windowPlacement);SetWindowLongPtrW(mainWindow,GWL_STYLE,WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromWindow(mainWindow,MONITOR_DEFAULTTONEAREST),&mi);SetWindowPos(mainWindow,HWND_TOP,mi.rcMonitor.left,mi.rcMonitor.top,mi.rcMonitor.right-mi.rcMonitor.left,mi.rcMonitor.bottom-mi.rcMonitor.top,SWP_FRAMECHANGED);}else{SetWindowLongPtrW(mainWindow,GWL_STYLE,ShellStyle|WS_VISIBLE);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromRect(&windowPlacement.rcNormalPosition,MONITOR_DEFAULTTONEAREST),&mi);auto& r=windowPlacement.rcNormalPosition;if(r.right<mi.rcWork.left||r.left>mi.rcWork.right||r.bottom<mi.rcWork.top||r.top>mi.rcWork.bottom){OffsetRect(&r,mi.rcWork.left-r.left,mi.rcWork.top-r.top);}SetWindowPlacement(mainWindow,&windowPlacement);SetWindowPos(mainWindow,nullptr,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);}SetWindowTextW(GetDlgItem(mainWindow,Fullscreen),full?L"退出全屏":L"全屏 F11");SetCursor(LoadCursorW(nullptr,IDC_ARROW));layout();SetFocus(mainWindow);veyra::log::info("ui-fullscreen",std::format("enabled={} video-only viewport; transport auto-hides",full));}
+void toggleFullscreenLock(){if(!full)return;fullLocked=!fullLocked;fullControls=!fullLocked;pointerTick=GetTickCount64();layout();SetFocus(mainWindow);SetCursor(fullLocked?nullptr:LoadCursorW(nullptr,IDC_ARROW));veyra::log::info("ui-fullscreen",std::format("locked={} shortcut=Ctrl+L; Esc/F11 exit remains available",fullLocked));}
+void toggleFullscreen(){endTransition();fullLocked=false;full=!full;if(tooltips){SendMessageW(tooltips,TTM_POP,0,0);SendMessageW(tooltips,TTM_ACTIVATE,full?FALSE:TRUE,0);}DWORD corner=full?1:2;DwmSetWindowAttribute(mainWindow,33,&corner,sizeof(corner));fullControls=true;pointerTick=GetTickCount64();if(full){GetWindowPlacement(mainWindow,&windowPlacement);SetWindowLongPtrW(mainWindow,GWL_STYLE,WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromWindow(mainWindow,MONITOR_DEFAULTTONEAREST),&mi);SetWindowPos(mainWindow,HWND_TOP,mi.rcMonitor.left,mi.rcMonitor.top,mi.rcMonitor.right-mi.rcMonitor.left,mi.rcMonitor.bottom-mi.rcMonitor.top,SWP_FRAMECHANGED);}else{SetWindowLongPtrW(mainWindow,GWL_STYLE,ShellStyle|WS_VISIBLE);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromRect(&windowPlacement.rcNormalPosition,MONITOR_DEFAULTTONEAREST),&mi);auto& r=windowPlacement.rcNormalPosition;if(r.right<mi.rcWork.left||r.left>mi.rcWork.right||r.bottom<mi.rcWork.top||r.top>mi.rcWork.bottom){OffsetRect(&r,mi.rcWork.left-r.left,mi.rcWork.top-r.top);}SetWindowPlacement(mainWindow,&windowPlacement);SetWindowPos(mainWindow,nullptr,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);}SetWindowTextW(GetDlgItem(mainWindow,Fullscreen),full?L"退出全屏":L"全屏 F11");SetCursor(LoadCursorW(nullptr,IDC_ARROW));layout();SetFocus(mainWindow);veyra::log::info("ui-fullscreen",std::format("enabled={} video-only viewport; transport auto-hides",full));}
bool smokeProtection=false;int protectionStep=0;uint64_t protectionSession=0;bool protectionOverlayShown=false;
bool protectionArmed=false,protectionDragging=false;POINT protectionStart{};std::pair<float,float> protectionSourceStart;HWND protectionOverlay=nullptr;
void cancelProtection(){protectionArmed=protectionDragging=false;if(protectionOverlay)ShowWindow(protectionOverlay,SW_HIDE);if(video&&GetCapture()==video)ReleaseCapture();}
@@ -369,7 +370,7 @@ void layout(){
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;
pos(playbackBar,0,h-88,w,88,full&&fullControls);
pos(seekBar,full?16:pro?tx:g.left,barTop-(full?10:5),full?w-32:pro?tw:g.viewWidth,full?20:12,transport&&!target.capture&&!target.image&&!(pro&&showDiagnostics&&!full));surface(seekBar,pro&&!full?panel:cinemaPanel);
- const bool daily=!pro&&!full&&!transition.running;TransportLayout controls(tw,daily);
+ const bool daily=!pro&&!full&&!transition.running;TransportLayout controls(tw,daily,full);
const int timeWidth=std::min(240,std::max(0,(tw-154)/2));
put(TimeLabel,tx,barTop+10,timeWidth,20,transport);
// Settings messages live here now (the panel no longer draws its own line).
@@ -384,13 +385,13 @@ void layout(){
auto slot=[&](int id,TransportSlot item,int height=34,int offset=36){put(id,tx+item.x,barTop+offset,item.width,height,transport&&item.width>0);};
slot(Open,controls.open);slot(Capture,controls.capture);slot(Recent,controls.recent);if(!full&&pro)put(Recent,12,372,44,44);
if(daily)slot(Master,controls.master);slot(Sr,controls.sr);
- slot(Play,controls.play,44,30);slot(Stop,controls.stop);slot(Mute,controls.mute);slot(Volume,controls.volume,18,44);slot(Subtitle,controls.subtitle);slot(Fullscreen,controls.fullscreen);
+ slot(Play,controls.play,44,30);slot(Stop,controls.stop);slot(Mute,controls.mute);slot(Volume,controls.volume,18,44);slot(Subtitle,controls.subtitle);slot(Fullscreen,controls.fullscreen);slot(FullscreenLock,controls.lock);
if(daily){slot(ModeSwitch,controls.mode);slot(WindowMin,controls.minimize);slot(WindowClose,controls.close);}
else put(ModeSwitch,w-292,14,160,32,!full);
icon(GetDlgItem(mainWindow,Open),Icon::Video,controls.captions);icon(GetDlgItem(mainWindow,Capture),Icon::Capture,controls.captions);
icon(GetDlgItem(mainWindow,Master),Icon::Enhance,pro||controls.captions);icon(GetDlgItem(mainWindow,Sr),Icon::Upscale,true);
icon(GetDlgItem(mainWindow,ModeSwitch),pro?Icon::PanelClose:Icon::PanelOpen,pro||controls.captions);
-for(int id:std::initializer_list<int>{Open,Capture,Recent,Master,Save,Sr,Play,Stop,Mute,Volume,Subtitle,Fullscreen,TimeLabel,MediaTitle,FpsLabel,ColourStatus,ModeSwitch})surface(GetDlgItem(mainWindow,id),pro&&!full?panel:cinemaPanel);
+for(int id:std::initializer_list<int>{Open,Capture,Recent,Master,Save,Sr,Play,Stop,Mute,Volume,Subtitle,Fullscreen,FullscreenLock,TimeLabel,MediaTitle,FpsLabel,ColourStatus,ModeSwitch})surface(GetDlgItem(mainWindow,id),pro&&!full?panel:cinemaPanel);
put(OriginalHold,tx,barTop+160,96,32,!full&&pro);put(Split,tx+102,barTop+160,92,32,!full&&pro);put(CompareToggle,tx+200,barTop+160,96,32,!full&&pro&&tw>=600);
put(Reference,tx+(tw>=600?302:200),barTop+160,std::min(172,tw-(tw>=600?302:200)-88),180,!full&&pro&&tw>=500);
put(Details,tx+tw-76,barTop+160,76,32,!full&&pro);put(Info,12,h-66,44,44,!full&&pro);pos(metricLabel,tx,barTop+212,tw,120,!full&&pro&&uiState.diagnostics);
@@ -404,7 +405,7 @@ for(int id:std::initializer_list<int>{Open,Capture,Recent,Master,Save,Sr,Play,St
auto batch=BeginDeferWindowPos(int(placements.size()));for(const auto& p:placements){if(!batch)break;batch=DeferWindowPos(batch,p.child,nullptr,p.x,p.y,p.width,p.height,p.flags);}
if(batch)EndDeferWindowPos(batch);else for(const auto& p:placements)SetWindowPos(p.child,nullptr,p.x,p.y,p.width,p.height,p.flags);
auto front=[&](HWND child){if(child&&IsWindowVisible(child))SetWindowPos(child,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOREDRAW);};
- front(playbackBar);front(seekBar);front(GetDlgItem(mainWindow,RemotePlay));for(int id:{Open,Capture,Recent,Master,Save,Sr,Play,Stop,Mute,Volume,Subtitle,Fullscreen,WindowMin,WindowClose,TimeLabel,MediaTitle,FpsLabel,ModeSwitch,JobProgress,EmptyTitle,EmptyHint})front(GetDlgItem(mainWindow,id));front(inspector);front(subtitleLabel);if(showDiagnostics&&pro&&!full)front(diagnosticPanel);
+ front(playbackBar);front(seekBar);front(GetDlgItem(mainWindow,RemotePlay));for(int id:{Open,Capture,Recent,Master,Save,Sr,Play,Stop,Mute,Volume,Subtitle,Fullscreen,FullscreenLock,WindowMin,WindowClose,TimeLabel,MediaTitle,FpsLabel,ModeSwitch,JobProgress,EmptyTitle,EmptyHint})front(GetDlgItem(mainWindow,id));front(inspector);front(subtitleLabel);if(showDiagnostics&&pro&&!full)front(diagnosticPanel);
if(auto focused=GetFocus();focused&&IsChild(mainWindow,focused)&&!IsWindowVisible(focused))SetFocus(mainWindow);
RedrawWindow(mainWindow,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN);
if(smokeDual)veyra::log::info("ui-layout-timing",std::format("frameMs={:.3f} animation={}",std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-layoutBegin).count(),transition.running));
@@ -469,8 +470,8 @@ void subtitleMenu(){
add(SubtitleSize,L"字号、位置与延时…",Icon::Type,false,[]{
const bool valid=subtitlePrimary>=0&&size_t(subtitlePrimary)<subtitleTracks.size();
const int initialOffset=valid?subtitleTracks[subtitlePrimary].offsetMs:0;
- showSubtitleSettings(mainWindow,{subtitlePixels,uiState.subtitleMargin,initialOffset,uiPreferences.subtitleLines,uiState.subtitleFont,uiState.subtitleOutline,uiState.subtitleBackground},[lastOffset=initialOffset](const SubtitleSettings& s) mutable {
- subtitlePixels=s.pixels;uiState.subtitleMargin=s.margin;uiPreferences.subtitleLines=s.lines;
+ showSubtitleSettings(mainWindow,{subtitlePixels,uiState.subtitleMargin,initialOffset,uiPreferences.subtitleLines,uiState.subtitleFont,uiState.subtitleOutline,uiState.subtitleBackground,uiPreferences.subtitleFitToLines},[lastOffset=initialOffset](const SubtitleSettings& s) mutable {
+ subtitlePixels=s.pixels;uiState.subtitleMargin=s.margin;uiPreferences.subtitleLines=s.lines;uiPreferences.subtitleFitToLines=s.fitToLines;
uiState.subtitleFont=s.font;uiState.subtitleOutline=s.outline;uiState.subtitleBackground=s.background;
if(s.offset!=lastOffset&&subtitlePrimary>=0&&size_t(subtitlePrimary)<subtitleTracks.size())subtitleTracks[subtitlePrimary].offsetMs=s.offset;
lastOffset=s.offset;
@@ -577,7 +578,9 @@ control(L"STATIC",L"",ColourStatus,SS_RIGHT|SS_ENDELLIPSIS,0,0,440,20);
control(L"STATIC",L"开始观看",EmptyTitle,SS_CENTER,0,0,500,48);emptyFont=veyra::ui::makeFont(hwnd,26,FW_NORMAL);SendDlgItemMessageW(hwnd,EmptyTitle,WM_SETFONT,WPARAM(emptyFont),TRUE);control(L"STATIC",L"打开本地视频,或连接采集卡\n精细调整与原生导出在专业模式中",EmptyHint,SS_CENTER,0,0,500,68);
control(L"BUTTON",L"性能 ▾",Details,BS_PUSHBUTTON,0,0,112,32);control(L"BUTTON",L"",JobProgress,BS_PUSHBUTTON,0,0,280,32);metricLabel=control(L"STATIC",L"",0,SS_LEFT,0,0,500,132);
control(L"BUTTON",L"最小化",WindowMin,BS_PUSHBUTTON,0,0,32,32);control(L"BUTTON",L"最大化",WindowMax,BS_PUSHBUTTON,0,0,32,32);control(L"BUTTON",L"关闭窗口",WindowClose,BS_PUSHBUTTON,0,0,32,32);
-using veyra::ui::Icon;veyra::ui::icon(GetDlgItem(hwnd,WindowMin),Icon::Minimize);veyra::ui::icon(GetDlgItem(hwnd,WindowMax),Icon::Maximize);veyra::ui::icon(GetDlgItem(hwnd,WindowClose),Icon::Close);
+control(L"BUTTON",L"锁定全屏 · Ctrl+L 解锁",FullscreenLock,BS_PUSHBUTTON,0,0,32,32);
+using veyra::ui::Icon;veyra::ui::icon(GetDlgItem(hwnd,FullscreenLock),Icon::Lock);veyra::ui::ghost(GetDlgItem(hwnd,FullscreenLock));SetPropW(GetDlgItem(hwnd,FullscreenLock),L"veyra.tip",HANDLE(L"锁定后鼠标移动不显示控制栏;Ctrl+L 解锁,Esc 退出全屏"));
+veyra::ui::icon(GetDlgItem(hwnd,WindowMin),Icon::Minimize);veyra::ui::icon(GetDlgItem(hwnd,WindowMax),Icon::Maximize);veyra::ui::icon(GetDlgItem(hwnd,WindowClose),Icon::Close);
veyra::ui::icon(GetDlgItem(hwnd,Play),Icon::Play);veyra::ui::icon(GetDlgItem(hwnd,Stop),Icon::Stop);veyra::ui::icon(GetDlgItem(hwnd,Mute),Icon::Volume);veyra::ui::icon(GetDlgItem(hwnd,Subtitle),Icon::Subtitle);veyra::ui::icon(GetDlgItem(hwnd,Fullscreen),Icon::Fullscreen);
veyra::ui::icon(GetDlgItem(hwnd,ProRailVideo),Icon::Video);veyra::ui::icon(GetDlgItem(hwnd,ProRailCapture),Icon::Capture);veyra::ui::icon(GetDlgItem(hwnd,ImageOpen),Icon::Image);veyra::ui::icon(GetDlgItem(hwnd,Info),Icon::Subtitle);
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);
@@ -666,7 +669,8 @@ if(id==Multiplier&&HIWORD(wp)==CBN_SELCHANGE&&changed.multiplier>1)changed.multi
engine.requestSettings(changed);break;}
case Fullscreen:toggleFullscreen();break;
-case VideoSurface:if(HIWORD(wp)==STN_DBLCLK)toggleFullscreen();break;
+case FullscreenLock:toggleFullscreenLock();break;
+case VideoSurface:if(!fullLocked&&HIWORD(wp)==STN_DBLCLK)toggleFullscreen();break;
case CompareToggle:compareMode=compareMode==1?0:1;updateComparison();break;
case Split:compareMode=compareMode==2?0:2;updateComparison();break;
case Reference:referenceBase=SendDlgItemMessageW(hwnd,Reference,CB_GETCURSEL,0,0)==1;updateComparison();break;
@@ -752,7 +756,7 @@ if(screenFill&&currentFile.starts_with(L"screen:")&&s.running){
view.outline=uiState.subtitleOutline;
view.background=uiState.subtitleBackground;
view.bottomMargin=uiState.subtitleMargin;
- view.targetLines=uiPreferences.subtitleLines;
+ view.targetLines=uiPreferences.subtitleLines;view.fitToLines=uiPreferences.subtitleFitToLines;
if(full&&fullControls)view.bottomMargin+=84;
view.preview=engine.previewView();
view.videoWidth=s.metrics.resolution.output.width;
@@ -1288,6 +1292,7 @@ if(!editing&&(!adjustingSlider||full)&&!veyra::ui::popupSelectorOpen()&&msg.mess
if(full)pointerActivity();continue;
}
}
+if(full&&!editing&&msg.message==WM_KEYDOWN&&(GetKeyState(VK_CONTROL)&0x8000)&&msg.wParam=='L'){if(!(msg.lParam&(1LL<<30)))toggleFullscreenLock();continue;}
if(!editing&&msg.message==WM_KEYDOWN&&(GetKeyState(VK_CONTROL)&0x8000)&&msg.wParam=='O'){SendMessageW(hwnd,WM_COMMAND,Open,0);continue;}
if(!editing&&msg.message==WM_KEYDOWN&&(GetKeyState(VK_CONTROL)&0x8000)&&msg.wParam=='E'){if(uiState.mode==veyra::ui::Mode::Daily)switchMode();selectInspector(3);continue;}
const bool key=(!editing)&&(msg.wParam==VK_F11||msg.wParam==VK_ESCAPE||(msg.wParam==VK_SPACE&&(GetFocus()==hwnd||GetFocus()==video))||msg.wParam=='V'||(msg.wParam==VK_RETURN&&msg.message==WM_SYSKEYDOWN));if(key){SendMessageW(hwnd,msg.message,msg.wParam,msg.lParam);continue;}}
diff --git a/apps/veyra/ui/LucideIcons.h b/apps/veyra/ui/LucideIcons.h
index 6366a60f..75f20973 100644
--- a/apps/veyra/ui/LucideIcons.h
+++ b/apps/veyra/ui/LucideIcons.h
@@ -3,7 +3,7 @@
#pragma once
#include "GlassMaterial.h"
namespace veyra::ui {
-enum class Icon { None,Play,Pause,Stop,Volume,Muted,Fullscreen,Video,Capture,Image,Subtitle,Minimize,Maximize,Close,Back,Settings,Recent,Enhance,Upscale,PanelOpen,PanelClose,Check,Chevron,Load,Type,ScreenCapture,Reset };
+enum class Icon { None,Play,Pause,Stop,Volume,Muted,Fullscreen,Video,Capture,Image,Subtitle,Minimize,Maximize,Close,Back,Settings,Recent,Enhance,Upscale,PanelOpen,PanelClose,Check,Chevron,Load,Type,ScreenCapture,Reset,Lock };
inline void drawIcon(HDC dc,Icon icon,float x,float y,float size,COLORREF c){
using namespace Gdiplus; AlphaGraphics drawing(dc);auto& g=drawing.get();
g.SetSmoothingMode(SmoothingModeAntiAlias);g.TranslateTransform(x-size/2,y-size/2);g.ScaleTransform(size/24,size/24);
@@ -413,6 +413,29 @@ p.StartFigure();
p.AddLine(3.0000000f,3.0000000f,3.0000000f,8.0000000f);
p.AddLine(3.0000000f,8.0000000f,8.0000000f,8.0000000f);
break;
+case Icon::Lock: // lock-keyhole.svg
+p.StartFigure();
+p.AddBezier(11.0000000f,16.0000000f,11.0000000f,16.5522847f,11.4477153f,17.0000000f,12.0000000f,17.0000000f);
+p.AddBezier(12.0000000f,17.0000000f,12.5522847f,17.0000000f,13.0000000f,16.5522847f,13.0000000f,16.0000000f);
+p.AddBezier(13.0000000f,16.0000000f,13.0000000f,15.4477153f,12.5522847f,15.0000000f,12.0000000f,15.0000000f);
+p.AddBezier(12.0000000f,15.0000000f,11.4477153f,15.0000000f,11.0000000f,15.4477153f,11.0000000f,16.0000000f);
+p.CloseFigure();
+p.StartFigure();
+p.AddLine(5.0000000f,10.0000000f,19.0000000f,10.0000000f);
+p.AddBezier(19.0000000f,10.0000000f,20.1045695f,10.0000000f,21.0000000f,10.8954305f,21.0000000f,12.0000000f);
+p.AddLine(21.0000000f,12.0000000f,21.0000000f,20.0000000f);
+p.AddBezier(21.0000000f,20.0000000f,21.0000000f,21.1045695f,20.1045695f,22.0000000f,19.0000000f,22.0000000f);
+p.AddLine(19.0000000f,22.0000000f,5.0000000f,22.0000000f);
+p.AddBezier(5.0000000f,22.0000000f,3.8954305f,22.0000000f,3.0000000f,21.1045695f,3.0000000f,20.0000000f);
+p.AddLine(3.0000000f,20.0000000f,3.0000000f,12.0000000f);
+p.AddBezier(3.0000000f,12.0000000f,3.0000000f,10.8954305f,3.8954305f,10.0000000f,5.0000000f,10.0000000f);
+p.CloseFigure();
+p.StartFigure();
+p.AddLine(7.0000000f,10.0000000f,7.0000000f,7.0000000f);
+p.AddBezier(7.0000000f,7.0000000f,7.0000000f,4.2385763f,9.2385763f,2.0000000f,12.0000000f,2.0000000f);
+p.AddBezier(12.0000000f,2.0000000f,14.7614237f,2.0000000f,17.0000000f,4.2385763f,17.0000000f,7.0000000f);
+p.AddLine(17.0000000f,7.0000000f,17.0000000f,10.0000000f);
+break;
default: return;}g.DrawPath(&pen,&p);
}
}
diff --git a/apps/veyra/ui/SubtitleOverlay.cpp b/apps/veyra/ui/SubtitleOverlay.cpp
index f6d8dc1f..95c9dc30 100644
--- a/apps/veyra/ui/SubtitleOverlay.cpp
+++ b/apps/veyra/ui/SubtitleOverlay.cpp
@@ -39,7 +39,7 @@ std::wstring signatureOf(const std::vector<SubtitleLine>& lines,const SubtitleVi
signature+=std::format(L"{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|",s.back,s.outlineWidth,s.shadow,s.marginL,s.marginR,s.marginV,s.bold,s.italic,s.background,s.font.size());
}
signature+=std::format(L"#{}|{}:{}|{}|{}|{}|{}",view.scale,view.fontOverride.size(),view.fontOverride,view.outline?1:0,view.background?1:0,view.bottomMargin,view.blockGap);
- signature+=std::format(L"/{}x{}/{}",rect.right,rect.bottom,view.targetLines);
+ signature+=std::format(L"/{}x{}/{}/{}",rect.right,rect.bottom,view.targetLines,view.fitToLines);
signature+=std::format(L"/{}/{}/{}/{}/{}",view.preview.zoom,view.preview.centerX,view.preview.centerY,view.videoWidth,view.videoHeight);
return signature;
}
@@ -125,7 +125,7 @@ void updateSubtitleOverlay(HWND h,const std::vector<SubtitleLine>& lines,const S
// rectangle can silently omit the end of a long cue before fitting.
auto measure=[&](float size){Font font(use,size,toFontStyle(line.style.bold,line.style.italic),UnitPixel);RectF bounds;
graphics.MeasureString(text.c_str(),int(text.size()),&font,RectF(0,0,availableWidth,1e7f),&format,&bounds);return bounds;};
- if(!positioned&&view.targetLines>0){
+ if(!positioned&&view.fitToLines&&view.targetLines>0){
const float minimum=float(dip(h,12));
for(int attempt=0;attempt<24&&fontPixels>minimum;++attempt){
Font font(use,fontPixels,toFontStyle(line.style.bold,line.style.italic),UnitPixel);
diff --git a/apps/veyra/ui/SubtitleOverlay.h b/apps/veyra/ui/SubtitleOverlay.h
index ef234194..eda6e2d7 100644
--- a/apps/veyra/ui/SubtitleOverlay.h
+++ b/apps/veyra/ui/SubtitleOverlay.h
@@ -28,7 +28,8 @@ struct SubtitleView {
bool background=false;
int bottomMargin=0; // extra logical pixels above the bar
int blockGap=6; // gap between the two languages
- int targetLines=2; // ordinary text only; 0 keeps automatic wrapping
+ int targetLines=2; // used only by the explicit fit-to-lines option
+ bool fitToLines=false; // otherwise preserve authored/user font size
engine::PreviewView preview;
double videoWidth=0,videoHeight=0;
};
diff --git a/apps/veyra/ui/SubtitleSettingsPanel.h b/apps/veyra/ui/SubtitleSettingsPanel.h
index 611b7541..afa78cad 100644
--- a/apps/veyra/ui/SubtitleSettingsPanel.h
+++ b/apps/veyra/ui/SubtitleSettingsPanel.h
@@ -6,7 +6,7 @@
namespace veyra::ui {
struct SubtitleSettings {
int pixels=22,margin=0,offset=0,lines=2,font=0;
- bool outline=true,background=false;
+ bool outline=true,background=false,fitToLines=false;
};
namespace subtitlePanel {
inline HWND window=nullptr;
@@ -37,7 +37,7 @@ inline LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM w,LPARAM l){
number(L"字号",101,16,s->settings.pixels,16,56);
number(L"底部距离",102,58,s->settings.margin,0,240);
number(L"主字幕延时 (ms)",103,100,s->settings.offset,-30000,30000);
- number(L"目标行数 (0 = 自动)",104,142,s->settings.lines,0,8);
+ number(L"缩放目标行数 (0 = 自动)",104,142,s->settings.lines,0,8);
HWND outline=control(L"BUTTON",L"描边",105,BS_AUTOCHECKBOX|WS_TABSTOP,16,188,124,30);
HWND background=control(L"BUTTON",L"背景条",106,BS_AUTOCHECKBOX|WS_TABSTOP,160,188,138,30);
SendMessageW(outline,BM_SETCHECK,s->settings.outline?BST_CHECKED:BST_UNCHECKED,0);
@@ -46,6 +46,9 @@ inline LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM w,LPARAM l){
HWND font=control(L"COMBOBOX",L"",107,CBS_DROPDOWNLIST|WS_TABSTOP|WS_VSCROLL,100,232,198,220);
for(const auto* name:{L"字幕原字体",L"SimHei",L"SimSun",L"DengXian",L"Arial",L"Segoe UI"})SendMessageW(font,CB_ADDSTRING,0,LPARAM(name));
SendMessageW(font,CB_SETCURSEL,s->settings.font,0);
+ HWND fit=control(L"BUTTON",L"自动缩小字号以适应目标行数",108,BS_AUTOCHECKBOX|WS_TABSTOP,16,274,282,30);
+ SendMessageW(fit,BM_SETCHECK,s->settings.fitToLines?BST_CHECKED:BST_UNCHECKED,0);
+ EnableWindow(GetDlgItem(h,104),s->settings.fitToLines);EnableWindow(GetDlgItem(h,124),s->settings.fitToLines);
s->populating=false;return 0;
}
if(msg==WM_DPICHANGED){
@@ -73,6 +76,7 @@ inline LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM w,LPARAM l){
}else if((id==105||id==106)&&notification==BN_CLICKED){
(id==105?s->settings.outline:s->settings.background)=IsDlgButtonChecked(h,id)==BST_CHECKED;changed=true;
}else if(id==107&&notification==CBN_SELCHANGE){s->settings.font=int(SendDlgItemMessageW(h,id,CB_GETCURSEL,0,0));changed=true;}
+ else if(id==108&&notification==BN_CLICKED){s->settings.fitToLines=IsDlgButtonChecked(h,id)==BST_CHECKED;EnableWindow(GetDlgItem(h,104),s->settings.fitToLines);EnableWindow(GetDlgItem(h,124),s->settings.fitToLines);changed=true;}
if(changed&&s->changed)s->changed(s->settings);
return 0;
}
@@ -86,7 +90,7 @@ inline void showSubtitleSettings(HWND owner,SubtitleSettings settings,std::funct
if(subtitlePanel::window){ShowWindow(subtitlePanel::window,SW_SHOWNORMAL);SetForegroundWindow(subtitlePanel::window);return;}
WNDCLASSW wc{};wc.lpfnWndProc=subtitlePanel::proc;wc.hInstance=GetModuleHandleW(nullptr);wc.lpszClassName=L"VeyraSubtitleSettings";wc.hbrBackground=panelBrush();wc.hCursor=LoadCursorW(nullptr,IDC_ARROW);RegisterClassW(&wc);
auto* state=new subtitlePanel::State;state->settings=settings;state->changed=std::move(changed);
- RECT r{0,0,dip(owner,314),dip(owner,282)};AdjustWindowRectExForDpi(&r,WS_CAPTION|WS_SYSMENU,FALSE,WS_EX_TOOLWINDOW,layoutDpi(owner));
+ RECT r{0,0,dip(owner,314),dip(owner,322)};AdjustWindowRectExForDpi(&r,WS_CAPTION|WS_SYSMENU,FALSE,WS_EX_TOOLWINDOW,layoutDpi(owner));
RECT p{};GetWindowRect(owner,&p);
MONITORINFO monitor{sizeof(monitor)};GetMonitorInfoW(MonitorFromWindow(owner,MONITOR_DEFAULTTONEAREST),&monitor);
const int width=r.right-r.left,height=r.bottom-r.top;
diff --git a/apps/veyra/ui/TransportLayout.h b/apps/veyra/ui/TransportLayout.h
index 5d27332d..d0d70922 100644
--- a/apps/veyra/ui/TransportLayout.h
+++ b/apps/veyra/ui/TransportLayout.h
@@ -3,9 +3,9 @@
namespace veyra::ui {
struct TransportSlot {int x=0,width=0;};
struct TransportLayout {
- TransportSlot open,capture,recent,master,sr,stop,play,mute,volume,subtitle,fullscreen,mode,minimize,close;
+ TransportSlot open,capture,recent,master,sr,stop,play,mute,volume,subtitle,fullscreen,lock,mode,minimize,close;
bool captions;
- TransportLayout(int width,bool daily):captions(daily&&width>=1040){
+ TransportLayout(int width,bool daily,bool fullscreenMode=false):captions(daily&&width>=1040){
int left=0,right=width;
auto takeLeft=[&](int size){TransportSlot result{left,size};left+=size+4;return result;};
auto takeRight=[&](int size){right-=size;TransportSlot result{right,size};right-=4;return result;};
@@ -14,7 +14,7 @@ struct TransportLayout {
master=takeLeft(captions?114:36);sr=takeLeft(captions?70:60);
close=takeRight(26);minimize=takeRight(26);right-=8;mode=takeRight(captions?126:32);
}
- fullscreen=takeRight(32);subtitle=takeRight(32);right-=6;volume=takeRight(captions?76:48);mute=takeRight(32);
+ fullscreen=takeRight(32);if(fullscreenMode)lock=takeRight(32);subtitle=takeRight(32);right-=6;volume=takeRight(captions?76:48);mute=takeRight(32);
int center=width/2;play={center-22,44};stop={center-62,32};
if(!daily&&width<480){play={0,44};stop={48,32};}
}
diff --git a/apps/veyra/ui/UiPreferenceStore.h b/apps/veyra/ui/UiPreferenceStore.h
index b1f72bd9..b2682b55 100644
--- a/apps/veyra/ui/UiPreferenceStore.h
+++ b/apps/veyra/ui/UiPreferenceStore.h
@@ -19,6 +19,7 @@ struct UiPreferences {
bool subtitleOutline=true,subtitleBackground=false,subtitleSecondLanguage=false;
int subtitleMargin=0,subtitleFont=0;
int subtitleLines=2;
+ bool subtitleFitToLines=false;
// v4: colour-page accordion fold mask (one bit per section).
uint32_t colourFoldMask=0;
// -1 migrates v1-v4 by deriving the master switch from the saved effects.
@@ -34,7 +35,7 @@ public:
// 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>7)||!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(!(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>9)||!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;
@@ -48,14 +49,15 @@ public:
// it must be read here - reading it earlier shifted every following field.
if(version>=4&&!(file>>read.colourFoldMask)){corrupt_=true;return result;}
if(version>=5&&(!(file>>read.enhancementEnabled)||read.enhancementEnabled< -1||read.enhancementEnabled>1)){corrupt_=true;return result;}
- if(version>=6){int enabled=0,mode=0,display=0;if(!(file>>enabled>>mode>>display)||enabled<0||enabled>1||mode<0||mode>2||display<0||display>2){corrupt_=true;return result;}read.presentation={enabled!=0,engine::PacingMode(mode),engine::DisplaySync(display)};}
+ if(version>=6){int enabled=0,mode=0,display=0;if(!(file>>enabled>>mode>>display)||enabled<0||enabled>1||mode<0||mode>2||display<0||display>2){corrupt_=true;return result;}read.presentation={enabled!=0,engine::PacingMode(mode),engine::DisplaySync(display)};read.presentation.outputRate=engine::OutputRateMode::FollowDisplay;}
if(version>=7&&(!(file>>read.subtitleLines)||read.subtitleLines<0||read.subtitleLines>8)){corrupt_=true;return result;}
+ if(version>=8){int fit=0;if(!(file>>fit)||fit<0||fit>1){corrupt_=true;return result;}read.subtitleFitToLines=fit!=0;} if(version>=9){int rate=0;if(!(file>>rate>>read.presentation.customFps)||rate<0||rate>2||!std::isfinite(read.presentation.customFps)){corrupt_=true;return result;}read.presentation.outputRate=static_cast<engine::OutputRateMode>(rate);}
file>>std::ws;if(!file.eof()){corrupt_=true;return result;}read.muted=mute;read.subtitles=sub;read.positioned=pos;return read;
}
engine::EnhancementSettings startup(engine::EnhancementSettings fallback){engine::PresetStore last(folder_/"last-applied.v1");if(!last.load()||last.entries().empty())return fallback;return last.entries().front().settings;}
bool save(const UiPreferences& p,const engine::EnhancementSettings* applied){
bool ok=true;std::filesystem::create_directories(folder_);if(applied){engine::PresetStore last(folder_/"last-applied.v1");ok=last.load()&&last.put(L"Last applied",*applied,true);}
- if(corrupt_)return false;std::ostringstream out;out<<"VEYRA_UI 7\n"<<p.volume<<' '<<p.muted<<' '<<p.subtitles<<' '<<p.width<<' '<<p.height<<' '<<p.x<<' '<<p.y<<' '<<p.positioned<<' '<<p.inspector<<' '<<p.subtitleSize<<' '<<p.inspectorWidth<<' '<<p.subtitleOutline<<' '<<p.subtitleBackground<<' '<<p.subtitleSecondLanguage<<' '<<p.subtitleMargin<<' '<<p.subtitleFont<<' '<<p.colourFoldMask<<' '<<p.enhancementEnabled<<' '<<p.presentation.enabled<<' '<<unsigned(p.presentation.mode)<<' '<<unsigned(p.presentation.display)<<' '<<p.subtitleLines<<'\n';
+ if(corrupt_)return false;std::ostringstream out;out<<"VEYRA_UI 9\n"<<p.volume<<' '<<p.muted<<' '<<p.subtitles<<' '<<p.width<<' '<<p.height<<' '<<p.x<<' '<<p.y<<' '<<p.positioned<<' '<<p.inspector<<' '<<p.subtitleSize<<' '<<p.inspectorWidth<<' '<<p.subtitleOutline<<' '<<p.subtitleBackground<<' '<<p.subtitleSecondLanguage<<' '<<p.subtitleMargin<<' '<<p.subtitleFont<<' '<<p.colourFoldMask<<' '<<p.enhancementEnabled<<' '<<p.presentation.enabled<<' '<<unsigned(p.presentation.mode)<<' '<<unsigned(p.presentation.display)<<' '<<p.subtitleLines<<' '<<p.subtitleFitToLines<<' '<<unsigned(p.presentation.outputRate)<<' '<<p.presentation.customFps<<'\n';
auto target=folder_/"ui-preferences.v1",tmp=folder_/(L"ui-preferences.tmp-"+std::to_wstring(GetCurrentProcessId()));auto data=out.str();HANDLE file=CreateFileW(tmp.c_str(),GENERIC_WRITE,0,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);if(file==INVALID_HANDLE_VALUE)return false;DWORD written=0;bool saved=WriteFile(file,data.data(),DWORD(data.size()),&written,nullptr)&&written==data.size()&&FlushFileBuffers(file);CloseHandle(file);if(saved)saved=MoveFileExW(tmp.c_str(),target.c_str(),MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH)!=FALSE;return ok&&saved;
}
};
diff --git a/assets/icons/lucide/lock-keyhole.svg b/assets/icons/lucide/lock-keyhole.svg
new file mode 100644
index 00000000..97fcbd18
--- /dev/null
+++ b/assets/icons/lucide/lock-keyhole.svg
@@ -0,0 +1,15 @@
+<svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+>
+ <circle cx="12" cy="16" r="1" />
+ <rect x="3" y="10" width="18" height="12" rx="2" />
+ <path d="M7 10V7a5 5 0 0 1 10 0v3" />
+</svg>
diff --git a/assets/icons/lucide/manifest.json b/assets/icons/lucide/manifest.json
index da0be103..7d9d95f1 100644
--- a/assets/icons/lucide/manifest.json
+++ b/assets/icons/lucide/manifest.json
@@ -13,6 +13,7 @@
"file-plus.svg": "bbcf862a2a4425baa8a5bda39c7f16ec1d283816a3db77baf84f2e8766dd223e",
"folder-open.svg": "ee57452b40e71df310214091dd9da1941a397c83197b8ff8d7ae66dd4242578b",
"image.svg": "619c9db58c879dce6250376ba67d9c9102ca6dbb3b1efb9294c9f180e22273a5",
+ "lock-keyhole.svg": "fc0b8b7590d1d9e9bb0112c5c2e15a78ade0bfeca6d6f8c79fbbe149236d74be",
"maximize.svg": "1f790856b0de805ab62e871609f1990b89d227d472022e57a11fde015aad4826",
"minus.svg": "a0c743ab6dbf545d8a6e19ef3874f48ede686ce68d25e231bd81f540d97b1f19",
"monitor.svg": "d1a443233345724859de8e4fb48968ba91e885e12ddbd710701548bd91b39428",
diff --git a/docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md b/docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md
index d9c44b1d..ba8554db 100644
--- a/docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md
+++ b/docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md
@@ -197,3 +197,34 @@ build and relevant regression results. No automatic FG downshift, fixed latency
cushion, NR multipass default, runtime substitution or global color adjustment is
part of this proposal. User hardware acceptance remains separate from local tests.
This audit performed no application build or functional acceptance test.
+
+## Implementation status in codex/playback-nr-20260920
+
+The user subsequently authorized implementation. The current isolated worktree
+contains the first reversible slice:
+
+- Subtitles now preserve the selected font size by default. The old fit loop is
+ behind an explicit `自动缩小字号以适应目标行数` option and is covered by the
+ overlay/panel tests.
+- Fullscreen has an explicit lock button and Ctrl+L toggle. Mouse activity is
+ ignored while locked; Esc/F11 remain exit paths. The lock does not alter HDR
+ state or rebuild the graph.
+- Presentation settings now persist an independent output-rate mode and custom
+ FPS (the default is Follow-display). The custom cap is enforced in the existing cadence owner, without a
+ fixed latency cushion. Follow-display resolves the active Windows monitor
+ mode and uses that same cap; generated candidates that are already stale are
+ skipped to prevent queue growth. XeSS/FSR provider-owned swapchains report
+ the cap as unsupported instead of throttling their real-frame input.
+- NR has an opt-in temporal residual stabilization switch. It keeps a bounded
+ two-texture history, reprojects it with the existing motion field, rejects
+ inconsistent 3x3 patches and resets on discontinuity. It is a small Veyra
+ integration adapted from Magpie's open motion route, not a claim of
+ source-identical behavior. It is not enabled by default and has no real RTX
+ image-quality acceptance yet.
+
+Not implemented in this slice: Dolby Vision P5/RPU reconstruction and a proven
+XeSS jelly reduction. The current code already supports compatible DV base-layer
+routes; P5 requires the separate metadata/color reconstruction project above.
+XeSS remains at the controlled-A/B stage because changing sharpening or flow
+without evidence would risk worsening the 30/40/50-series paths. No runtime DLL
+was replaced or added.
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index e1f7d7c4..1cc66733 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,47 @@
# Veyra 工作记录
+## 2026-09-20 Playback/NR implementation slice
+
+On isolated branch `codex/playback-nr-20260920` from checkpoint commit
+`ed00218`, implemented the authorized first slice from
+`docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md`:
+
+- Subtitle default now preserves glyph size across one/two-line cues; fitting is
+ explicit and persisted.
+- Fullscreen lock button plus Ctrl+L hides/ignores incidental mouse activity;
+ Esc/F11 exit paths remain.
+- Presentation settings persist Off/Follow-display/Custom output-rate mode and
+ default to Follow-display; a validated 1..1000 FPS custom cap is also
+ available. Follow-display resolves the active
+ monitor's Windows mode and feeds the same cap. Generated candidates that are
+ already one cap slot stale are discarded so they cannot accumulate behind a
+ slower output. The cap uses the existing cadence owner; no extra fixed delay
+ or second pacing loop was added. XeSS/FSR provider-owned swapchains report
+ the cap as unsupported rather than throttling their real-frame input.
+- Added default-off NR temporal residual stabilization with bounded two-texture
+ history, motion-vector reprojection, patch consistency rejection, reset
+ invalidation and explicit UI/config/preset persistence. This is a Veyra
+ implementation adapted from Magpie's GPLv3 motion route, with source
+ provenance retained in the audit plan; it is not yet a hardware quality gate.
+- Added the exact Magpie commit/license attribution to `THIRD_PARTY_NOTICES.md`;
+ no Magpie binary or runtime was copied.
+
+Build command (successful): CMake/Ninja target `veyra veyra_repair_shader_tests`
+with the Visual Studio x64 environment; log
+`E:/项目/Veyra/logs/playback-nr-20260920/build-temporal-env.txt`.
+`veyra_ui_contract_tests`, `veyra_subtitle_overlay_tests`,
+`veyra_subtitle_panel_tests` and `veyra_repair_shader_tests` all exited 0;
+logs are under `E:/项目/Veyra/logs/playback-nr-20260920/`.
+
+The raw fullscreen process test initially lacked app-local runtime DLLs. A
+staged copy using the existing 1.4.3 test package's app-local dependencies then
+passed `scripts/acceptance/fullscreen-lock.py`; evidence is
+`E:/项目/Veyra/tests/playback-nr-20260920/fullscreen-run-current/result.json`.
+The test did not exercise HDR output. No physical Dolby Vision, XeSS controlled
+A/B, projector refresh or affected RTX hardware test was run. No package,
+release or push was performed; the isolated build itself still does not contain
+app-local FFmpeg DLLs.
+
## 2026-09-20 Six playback/NR requests: investigation only
User requested investigation and proposals, explicitly no implementation.
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index ec9e9c30..1e8755f8 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -106,6 +106,7 @@ struct EnhancementSettings {
bool nr=false,sr=false;
bool lowLatency=false; // preview only: NR before SR, opt-in
NrRuntime nrRuntime=NrRuntime::Original;
+ bool nrTemporal=false; // optional motion-reprojected residual stabilization
bool captureCompatible=false;
// Capture audio ingress; requires a reconnect to take effect (the media type
// is negotiated when the graph is built).
diff --git a/include/veyra/engine/PresentationSettings.h b/include/veyra/engine/PresentationSettings.h
index c44596d1..b947f0ff 100644
--- a/include/veyra/engine/PresentationSettings.h
+++ b/include/veyra/engine/PresentationSettings.h
@@ -1,15 +1,19 @@
#pragma once
#include <algorithm>
#include <cstdint>
+#include <cmath>
namespace veyra::engine {
enum class PacingMode : unsigned { LowQueue, Even, Reflex };
enum class DisplaySync : unsigned { Tearing, Vsync, Automatic };
+enum class OutputRateMode : unsigned { Off, FollowDisplay, Custom };
struct PresentationSettings {
bool enabled=false;
PacingMode mode=PacingMode::LowQueue;
DisplaySync display=DisplaySync::Tearing;
+ OutputRateMode outputRate=OutputRateMode::FollowDisplay;
+ double customFps=60.0;
bool operator==(const PresentationSettings&) const = default;
- bool valid()const{return unsigned(mode)<=2&&unsigned(display)<=2;}
+ bool valid()const{return unsigned(mode)<=2&&unsigned(display)<=2&&unsigned(outputRate)<=2&&std::isfinite(customFps)&&customFps>=1.0&&customFps<=1000.0;}
};
// Media time remains the authority. Spacing adds at most one interval from
// the current decision; stale generated frames are discarded by the caller.
@@ -27,5 +31,6 @@ public:
return std::max(mediaDeadline,last_+outputInterval-recovery);
}
void submitted(int64_t now){last_=now;}
+ int64_t rateDue(int64_t now,int64_t interval)const{return !last_||interval<=0?now:last_+interval;}
};
}
diff --git a/include/veyra/gfx/PresentSink.h b/include/veyra/gfx/PresentSink.h
index e73d0e70..22fcd740 100644
--- a/include/veyra/gfx/PresentSink.h
+++ b/include/veyra/gfx/PresentSink.h
@@ -26,6 +26,7 @@ using ComPtr = Microsoft::WRL::ComPtr<T>;
class PresentSink {
public:
static bool hdrDisplayActive(HWND);
+ static double displayRefreshFps(HWND);
PresentSink() = default;
~PresentSink();
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index e3758eda..35d943aa 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -1,6 +1,7 @@
#pragma once
#include "veyra/engine/BackendRecovery.h"
#include "veyra/pipeline/ColorGradeTables.h"
+#include "veyra/pipeline/NrTemporalPass.h"
// EnhanceGraph - the real unified processing graph (Playbook R3.2).
// Chains, per real frame:
@@ -75,6 +76,7 @@ struct EnhanceGraphDesc {
bool enableNr = true;
bool nrBeforeSr = false;
engine::NrRuntime nrRuntime=engine::NrRuntime::Original;
+ bool nrTemporal=false;
bool enableFg = true;
bool validateMotion = true; // disable only in isolated legacy A/B diagnostics
bool enableNvofStandalone = false; // run NVOF+densify per frame without FG (quality core)
@@ -352,6 +354,7 @@ private:
ComPtr<ID3D12Resource> videoSrInput_,videoSrOutput_;
ComPtr<ID3D12Resource> videoHdrInput_,videoHdrOutput_;
ComPtr<ID3D12Resource> nrInput_,residualRgba_,nrFlow_,baseFlow_;
+ NrTemporalPass nrTemporal_;
ComPtr<ID3D12Resource> presentMotion_[2];
bool presentMotionValid_[2]={};
uint64_t motionPreviousSource_[2]={},previousSource_=0;
diff --git a/include/veyra/pipeline/NrTemporalPass.h b/include/veyra/pipeline/NrTemporalPass.h
new file mode 100644
index 00000000..b7333958
--- /dev/null
+++ b/include/veyra/pipeline/NrTemporalPass.h
@@ -0,0 +1,22 @@
+#pragma once
+#include "veyra/pipeline/GpuPassUtils.h"
+#include <array>
+
+namespace veyra::pipeline {
+// Residual history stays on the graph's ordered GPU queue. Descriptor sets are
+// immutable; neither CPU waits nor descriptor rewrites occur per frame.
+class NrTemporalPass {
+public:
+ bool initialize(ID3D12Device*,ID3D12Resource* base,ID3D12Resource* motion,ID3D12Resource* output);
+ ID3D12Resource* raw()const{return raw_.Get();}
+ void run(ID3D12GraphicsCommandList*,StateTracker&,bool reset,bool haveMotion,double frameMs);
+ void reset(){valid_=false;}
+ void close();
+private:
+ ComputePass pass_;
+ ComPtr<ID3D12Resource> raw_,history_[2],guide_[2];
+ ID3D12Resource* base_=nullptr;ID3D12Resource* motion_=nullptr;ID3D12Resource* output_=nullptr;
+ unsigned width_=0,height_=0,index_=0;
+ bool valid_=false;
+};
+}
diff --git a/scripts/acceptance/fullscreen-lock.py b/scripts/acceptance/fullscreen-lock.py
new file mode 100644
index 00000000..ca57e322
--- /dev/null
+++ b/scripts/acceptance/fullscreen-lock.py
@@ -0,0 +1,84 @@
+"""Exercise the real app's fullscreen controls, without a media/driver dependency."""
+import ctypes as c
+import ctypes.wintypes as w
+import json
+import os
+from pathlib import Path
+import subprocess
+import sys
+import time
+
+exe, out = Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve()
+out.mkdir(parents=True, exist_ok=True)
+u = c.WinDLL('user32', use_last_error=True)
+visit_type = c.WINFUNCTYPE(w.BOOL, w.HWND, w.LPARAM)
+u.GetWindowThreadProcessId.argtypes = [w.HWND, c.POINTER(w.DWORD)]
+u.GetClassNameW.argtypes = [w.HWND, w.LPWSTR, c.c_int]
+u.GetWindowTextW.argtypes = [w.HWND, w.LPWSTR, c.c_int]
+u.GetDlgCtrlID.argtypes = [w.HWND]
+u.IsWindowVisible.argtypes = [w.HWND]
+u.SendMessageTimeoutW.argtypes = [w.HWND, w.UINT, w.WPARAM, w.LPARAM, w.UINT, w.UINT, c.POINTER(c.c_size_t)]
+u.PostMessageW.argtypes = [w.HWND, w.UINT, w.WPARAM, w.LPARAM]
+result = {'passed': False, 'hdrDisplayTested': False}
+env = os.environ.copy()
+env['VEYRA_LOG_FILE'] = str(out / 'app.log')
+with (out / 'stdout.txt').open('w') as stdout, (out / 'stderr.txt').open('w') as stderr:
+ process = subprocess.Popen([str(exe), '--smoke-empty', '--smoke-view', 'pro', '--smoke-seconds', '30'], env=env, stdout=stdout, stderr=stderr)
+ try:
+ found = []
+ @visit_type
+ def visit(hwnd, unused):
+ pid = w.DWORD()
+ u.GetWindowThreadProcessId(hwnd, c.byref(pid))
+ name = c.create_unicode_buffer(128)
+ u.GetClassNameW(hwnd, name, 128)
+ if pid.value == process.pid and name.value == 'VeyraApp':
+ found.append(hwnd)
+ return True
+ until = time.monotonic() + 10
+ while not found and time.monotonic() < until:
+ u.EnumWindows(visit, 0)
+ time.sleep(.1)
+ assert found, 'main window missing'
+ main = found[0]
+ def send(msg, wp=0, lp=0):
+ reply = c.c_size_t()
+ assert u.SendMessageTimeoutW(main, msg, wp, lp, 2, 2000, c.byref(reply)), 'UI timeout'
+ lock = []
+ @visit_type
+ def child(hwnd, unused):
+ text = c.create_unicode_buffer(256)
+ u.GetWindowTextW(hwnd, text, 256)
+ if 'Ctrl+L' in text.value:
+ lock.append(hwnd)
+ return True
+ u.EnumChildWindows(main, child, 0)
+ assert len(lock) == 1, 'lock control missing'
+ button = lock[0]
+ assert not u.IsWindowVisible(button), 'lock visible outside fullscreen'
+ send(0x100, 0x7A) # F11
+ assert u.IsWindowVisible(button), 'lock not available in fullscreen'
+ send(0x111, u.GetDlgCtrlID(button))
+ assert not u.IsWindowVisible(button), 'locking did not hide controls'
+ # Delivered through the normal message loop so pointerActivity runs.
+ for i in range(5):
+ u.PostMessageW(main, 0x200, 0, (80+i) | (80 << 16))
+ time.sleep(.06)
+ send(0)
+ assert not u.IsWindowVisible(button), 'mouse motion unlocked controls'
+ send(0x111, u.GetDlgCtrlID(button))
+ assert u.IsWindowVisible(button), 'unlock did not restore controls'
+ send(0x111, u.GetDlgCtrlID(button))
+ send(0x100, 0x1B) # Esc must exit even while locked.
+ send(0x100, 0x7A)
+ assert u.IsWindowVisible(button), 'fullscreen retained stale lock after exit'
+ send(0x100, 0x1B)
+ send(0x10)
+ assert process.wait(timeout=8) == 0
+ result['passed'] = True
+ finally:
+ if process.poll() is None:
+ process.kill()
+ process.wait(timeout=5)
+ result['exitCode'] = process.returncode
+ (out / 'result.json').write_text(json.dumps(result, indent=2), encoding='utf-8')
diff --git a/scripts/generate-lucide-icons.py b/scripts/generate-lucide-icons.py
index 6799abd4..8111cf85 100644
--- a/scripts/generate-lucide-icons.py
+++ b/scripts/generate-lucide-icons.py
@@ -20,7 +20,7 @@ ICONS = dict(Play="play", Pause="pause", Stop="square", Volume="volume-2",
Settings="sliders-horizontal", Recent="clock", Enhance="sparkles",
Upscale="scan", PanelOpen="panel-right-open", PanelClose="panel-right-close",
Check="check", Chevron="chevron-down", Load="file-plus", Type="type",
- ScreenCapture="app-window", Reset="rotate-ccw")
+ ScreenCapture="app-window", Reset="rotate-ccw", Lock="lock-keyhole")
DEST = ROOT / "assets/icons/lucide"
DEST.mkdir(parents=True, exist_ok=True)
manifest = {"repository": "https://github.com/lucide-icons/lucide", "revision": REVISION,
diff --git a/shaders/NrTemporal.hlsl b/shaders/NrTemporal.hlsl
new file mode 100644
index 00000000..59d70f9d
--- /dev/null
+++ b/shaders/NrTemporal.hlsl
@@ -0,0 +1,54 @@
+// Adapted from SAOG0721/Magpie, GPL-3.0, commit
+// 3841698348bfb246623d4acf791984c8b68a577b
+// src/Magpie.Core/DLSSNRTemporalShader.h (motion route 2).
+// Veyra: D3D12 Load-based bilinear sampling, source-flow extent conversion,
+// linear signed HDR guide, reset via zero weight, post-protection residual.
+Texture2D<float4> Base:register(t0);
+Texture2D<float4> Raw:register(t1);
+Texture2D<float4> History:register(t2);
+Texture2D<float4> PreviousGuide:register(t3);
+Texture2D<float2> Motion:register(t4);
+RWTexture2D<float4> Output:register(u0);
+RWTexture2D<float4> NextHistory:register(u1);
+RWTexture2D<float4> NextGuide:register(u2);
+cbuffer Settings:register(b0){uint2 Size;float HistoryWeight;float pad;float4 reserved;}
+float3 Guide(float3 c){return c/(1+abs(c));}
+bool Inside(int2 p){return all(p>=0)&&all(p<int2(Size));}
+float4 Bilinear(Texture2D<float4> tex,float2 p){
+ int2 a=int2(floor(p));float2 f=frac(p);int2 b=min(a+1,int2(Size)-1);
+ return lerp(lerp(tex[a],tex[int2(b.x,a.y)],f.x),lerp(tex[int2(a.x,b.y)],tex[b],f.x),f.y);
+}
+bool PreviousPosition(int2 p,out float2 previous){
+ previous=p;if(!Inside(p))return false;
+ uint w,h;Motion.GetDimensions(w,h);
+ float2 at=(float2(p)+.5)*float2(w,h)/Size-.5;
+ int2 a=int2(floor(at));float2 f=frac(at);int2 hi=int2(w,h)-1;
+ float2 mv=lerp(lerp(Motion[clamp(a,0,hi)],Motion[clamp(a+int2(1,0),0,hi)],f.x),lerp(Motion[clamp(a+int2(0,1),0,hi)],Motion[clamp(a+1,0,hi)],f.x),f.y)*float2(Size)/float2(w,h);
+ if(!all(isfinite(mv)))return false;previous+=mv;
+ return all(previous>=0)&&all(previous<=float2(Size)-1);
+}
+[numthreads(8,8,1)]void main(uint3 id:SV_DispatchThreadID){
+ int2 p=id.xy;if(any(id.xy>=Size))return;
+ float4 base=Base[p],raw=Raw[p];bool finite=all(isfinite(base))&&all(isfinite(raw));
+ NextGuide[p]=all(isfinite(base))?float4(Guide(base.rgb),1):0;
+ if(!finite){NextHistory[p]=0;Output[p]=all(isfinite(base))?base:float4(0,0,0,1);return;}
+ float3 current=raw.rgb-base.rgb,result=current;float2 previous;
+ // Preserve exact bypass/protection pixels; never revive a masked residual.
+ if(HistoryWeight>0&&any(abs(current)>1e-7)&&PreviousPosition(p,previous)){
+ float error=0,maximumError=0;bool valid=true;float3 lo=current,hi=current;
+ [unroll]for(int y=-1;y<=1;++y)[unroll]for(int x=-1;x<=1;++x){
+ int2 n=p+int2(x,y);float2 previousN;
+ if(!PreviousPosition(n,previousN)){valid=false;continue;}
+ if(any(abs((previousN-n)-(previous-p))>2)){valid=false;continue;}
+ float4 inputN=Base[n],old=Bilinear(PreviousGuide,previousN);
+ float3 residualN=Raw[n].rgb-inputN.rgb;
+ if(!all(isfinite(inputN))||!all(isfinite(old))||old.a<.999||!all(isfinite(residualN))){valid=false;continue;}
+ float3 delta=abs(Guide(inputN.rgb)-old.rgb);float e=max(delta.r,max(delta.g,delta.b));error+=e/9;maximumError=max(maximumError,e);lo=min(lo,residualN);hi=max(hi,residualN);
+ }
+ float q=(1-smoothstep(.008,.04,error))*(1-smoothstep(.025,.10,maximumError));
+ if(valid&&q>0){float4 old=Bilinear(History,previous);if(all(isfinite(old))&&old.a>=.999){float3 margin=.02+q*abs(old.rgb);result=lerp(current,clamp(old.rgb,lo-margin,hi+margin),HistoryWeight*q);}}
+ }
+ NextHistory[p]=float4(clamp(result,-65504,65504),1);
+ // Preserve signed wide-gamut/HDR working components (no SDR saturate).
+ Output[p]=float4(clamp(base.rgb+result,-65504,65504),raw.a);
+}
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index ae836954..3947a23b 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -290,7 +290,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
gd.workWidth=resolution.base.width;gd.workHeight=resolution.base.height;gd.nrWidth=resolution.nr.width;gd.nrHeight=resolution.nr.height;gd.flowWidth=resolution.flow.width;gd.flowHeight=resolution.flow.height;
const bool nvidiaAdapter=ctx.adapter().isNvidia;
const bool xessFg=presentSinkFrameGeneration(options.settings.frameGenerationBackend);
- gd.nrBeforeSr=!isImage&&options.settings.lowLatency&&options.nr&&resolution.srApplied;gd.enableSr=resolution.srApplied&&(nvidiaAdapter||options.settings.videoSrQuality==kVideoSrFsr);gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr&&nvidiaAdapter;gd.nrRuntime=options.settings.nrRuntime;gd.enableFg=options.fg&&(nvidiaAdapter||xessFg);gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=gd.enableNr;
+ gd.nrBeforeSr=!isImage&&options.settings.lowLatency&&options.nr&&resolution.srApplied;gd.enableSr=resolution.srApplied&&(nvidiaAdapter||options.settings.videoSrQuality==kVideoSrFsr);gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr&&nvidiaAdapter;gd.nrRuntime=options.settings.nrRuntime;gd.nrTemporal=options.settings.nrTemporal;gd.enableFg=options.fg&&(nvidiaAdapter||xessFg);gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=gd.enableNr;
gd.noFeatures=false;gd.model=options.settings.model;gd.residual=options.settings.residual;gd.protection=options.settings.protection;gd.color=options.settings.color;gd.settingsRevision=options.settings.revision;gd.flowQuality=options.settings.flow;gd.contentRate=options.settings.content;
gd.opticalFlowBackend=options.settings.opticalFlowBackend;gd.amdFlowHalfResolution=options.settings.amdFlowHalfResolution;
gd.videoHdr=options.settings.videoHdr;
@@ -800,11 +800,11 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const bool nvidiaAdapter=ctx.adapter().isNvidia;
const bool xessFg=presentSinkFrameGeneration(next.settings.frameGenerationBackend);
nextDesc.nrBeforeSr=!isImage&&requested.lowLatency&&requested.nr&&plan.srApplied;nextDesc.enableSr=plan.srApplied&&(nvidiaAdapter||next.settings.videoSrQuality==kVideoSrFsr);nextDesc.videoSrQuality=next.settings.videoSrQuality;nextDesc.enableNr=next.nr&&nvidiaAdapter;nextDesc.nrRuntime=next.settings.nrRuntime;nextDesc.enableFg=next.fg&&(nvidiaAdapter||xessFg);nextDesc.fgMultiplier=next.fgMultiplier;nextDesc.frameGenerationBackend=next.settings.frameGenerationBackend;nextDesc.enableNvofStandalone=nextDesc.enableNr;
- nextDesc.model=requested.model;nextDesc.residual=requested.residual;nextDesc.protection=requested.protection;nextDesc.color=requested.color;nextDesc.settingsRevision=requested.revision;nextDesc.flowQuality=requested.flow;nextDesc.contentRate=requested.content;
+ nextDesc.model=requested.model;nextDesc.nrTemporal=requested.nrTemporal;nextDesc.residual=requested.residual;nextDesc.protection=requested.protection;nextDesc.color=requested.color;nextDesc.settingsRevision=requested.revision;nextDesc.flowQuality=requested.flow;nextDesc.contentRate=requested.content;
nextDesc.opticalFlowBackend=requested.opticalFlowBackend;nextDesc.amdFlowHalfResolution=requested.amdFlowHalfResolution;
nextDesc.videoHdr=requested.videoHdr;
nextDesc.hdrOutput=requested.useHdrPreview(nextDesc.hdrInput,gfx::PresentSink::hdrDisplayActive(window));
- const bool rebuild=gd.videoHdr.enabled!=nextDesc.videoHdr.enabled||(!nvidiaAdapter&&(next.nr||next.sr||(next.fg&&!xessFg)))||gd.hdrOutput!=nextDesc.hdrOutput||previous.captureCompatible!=requested.captureCompatible||gd.nrRuntime!=nextDesc.nrRuntime||gd.opticalFlowBackend!=nextDesc.opticalFlowBackend||gd.amdFlowHalfResolution!=nextDesc.amdFlowHalfResolution||gd.enableNr!=nextDesc.enableNr||gd.color.enabled!=nextDesc.color.enabled||gd.color.lutNameString()!=nextDesc.color.lutNameString()||gd.enableFg!=nextDesc.enableFg||gd.frameGenerationBackend!=nextDesc.frameGenerationBackend||gd.fgMultiplier!=nextDesc.fgMultiplier||gd.videoSrQuality!=nextDesc.videoSrQuality||gd.flowQuality!=nextDesc.flowQuality||gd.nrBeforeSr!=nextDesc.nrBeforeSr||gd.workWidth!=nextDesc.workWidth||gd.workHeight!=nextDesc.workHeight||gd.nrWidth!=nextDesc.nrWidth||gd.nrHeight!=nextDesc.nrHeight||gd.flowWidth!=nextDesc.flowWidth||gd.flowHeight!=nextDesc.flowHeight;
+ const bool rebuild=gd.videoHdr.enabled!=nextDesc.videoHdr.enabled||gd.nrTemporal!=nextDesc.nrTemporal||(!nvidiaAdapter&&(next.nr||next.sr||(next.fg&&!xessFg)))||gd.hdrOutput!=nextDesc.hdrOutput||previous.captureCompatible!=requested.captureCompatible||gd.nrRuntime!=nextDesc.nrRuntime||gd.opticalFlowBackend!=nextDesc.opticalFlowBackend||gd.amdFlowHalfResolution!=nextDesc.amdFlowHalfResolution||gd.enableNr!=nextDesc.enableNr||gd.color.enabled!=nextDesc.color.enabled||gd.color.lutNameString()!=nextDesc.color.lutNameString()||gd.enableFg!=nextDesc.enableFg||gd.frameGenerationBackend!=nextDesc.frameGenerationBackend||gd.fgMultiplier!=nextDesc.fgMultiplier||gd.videoSrQuality!=nextDesc.videoSrQuality||gd.flowQuality!=nextDesc.flowQuality||gd.nrBeforeSr!=nextDesc.nrBeforeSr||gd.workWidth!=nextDesc.workWidth||gd.workHeight!=nextDesc.workHeight||gd.nrWidth!=nextDesc.nrWidth||gd.nrHeight!=nextDesc.nrHeight||gd.flowWidth!=nextDesc.flowWidth||gd.flowHeight!=nextDesc.flowHeight;
bool accepted=ring.drainQueue();out={};hasOutput=false;
resetRecord->rebuilt=rebuild;
markResetStage(diagnostics::ResetStage::Drain);
@@ -1320,12 +1320,23 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const auto due=cadence.due(optionalNow+int64_t((itemPtsMs-nowMs())*10000),interval,20);
if(optionalNow<due)return {State::Pending,due};
}
- if(presentationEffective.enabled){
+ if(presentationEffective.enabled||presentationEffective.outputRate==OutputRateMode::Custom){
const auto interval=std::max<int64_t>(1,int64_t(sourceIntervalMs*10000)/std::max(1u,batch.batch.count));
const auto mediaDeadline=isCapture?timeline.deadline(item.pts100ns):fileAwaitingVideo?optionalNow:optionalNow+int64_t((itemPtsMs-nowMs())*10000);
const unsigned catchUpPercent=!isCapture&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?20:10;
- const auto due=presentationEffective.mode==PacingMode::Even?cadence.due(mediaDeadline,interval,catchUpPercent):mediaDeadline;
- if(generated&&presentationEffective.mode==PacingMode::Even&&due>mediaDeadline+interval){++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();continue;}
+ auto due=presentationEffective.enabled&&presentationEffective.mode==PacingMode::Even?cadence.due(mediaDeadline,interval,catchUpPercent):mediaDeadline;
+ int64_t capInterval=0;
+ if(presentationEffective.outputRate==OutputRateMode::Custom){
+ capInterval=std::max<int64_t>(1,int64_t(10000000.0/presentationEffective.customFps));
+ due=std::max(due,cadence.rateDue(optionalNow,capInterval));
+ }
+ // The cap selects displayed candidates, never
+ // changes processing/FG history or media time.
+ // If the next candidate is due before this
+ // slot, discard this stale display opportunity
+ // instead of accumulating latency.
+ if(capInterval>0&&due>=mediaDeadline+interval){++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();continue;}
+ if(generated&&presentationEffective.enabled&&presentationEffective.mode==PacingMode::Even&&due>mediaDeadline+interval){++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();continue;}
if(optionalNow<due)return {State::Pending,due};
if(!presenter.presentationReady())return {State::Pending,optionalNow+2000};
}
diff --git a/src/engine/EngineControllerImage.cpp b/src/engine/EngineControllerImage.cpp
index 12aa179a..34243563 100644
--- a/src/engine/EngineControllerImage.cpp
+++ b/src/engine/EngineControllerImage.cpp
@@ -65,7 +65,7 @@ void EngineController::runLargeImage(HWND window,const sink::RgbaImage& original
}
if(requested.revision!=applied.revision){
pipeline::EnhanceGraphDesc desc;desc.enableNr=requested.nr;desc.nrRuntime=requested.nrRuntime;desc.noFeatures=!requested.nr;
- desc.model=requested.model;desc.residual=requested.residual;desc.protection=requested.protection;desc.color=requested.color;desc.settingsRevision=requested.revision;
+ desc.model=requested.model;desc.nrTemporal=requested.nrTemporal;desc.residual=requested.residual;desc.protection=requested.protection;desc.color=requested.color;desc.settingsRevision=requested.revision;
desc.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
sink::RgbaImage candidate;TiledImageProcessor::Stats stats;
status(L"正在分块增强大图,保留完整输出尺寸…");
diff --git a/src/engine/PresetStore.cpp b/src/engine/PresetStore.cpp
index ac07963f..e558769d 100644
--- a/src/engine/PresetStore.cpp
+++ b/src/engine/PresetStore.cpp
@@ -13,12 +13,12 @@ bool nameOk(const std::wstring& s){return !s.empty()&&s.size()<=48&&s.front()!=L
std::wstring trim(std::wstring s){auto a=s.find_first_not_of(L" \t\r\n");if(a==s.npos)return {};auto b=s.find_last_not_of(L" \t\r\n");return s.substr(a,b-a+1);}
}
std::string PresetStore::serialize()const{
- std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS 20\n"<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';
- for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<' '<<int(s.frameGenerationBackend)<<' '<<int(s.srTarget)<<' '<<int(s.opticalFlowBackend)<<' '<<s.amdFlowHalfResolution<<' '<<int(s.audioSync)<<' '<<s.audioOffsetMs<<' '<<int(s.nrRuntime)<<' '<<s.captureCompatible<<' '<<s.lowLatency<<' '<<s.forceSdrPreview<<' '<<int(s.captureAudio)<<' '<<s.exportBitrateMbps<<' '<<s.captureFlipVertical<<' '<<int(s.captureBuffer)<<' ';writeColorSettings(o,s.color,utf8(s.color.lutNameString()));o<<' '<<s.videoHdr.enabled<<' '<<s.videoHdr.contrast<<' '<<s.videoHdr.saturation<<' '<<s.videoHdr.middleGray<<' '<<s.videoHdr.peakNits<<'\n';}return o.str();
+ std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS 21\n"<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';
+ for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<' '<<int(s.frameGenerationBackend)<<' '<<int(s.srTarget)<<' '<<int(s.opticalFlowBackend)<<' '<<s.amdFlowHalfResolution<<' '<<int(s.audioSync)<<' '<<s.audioOffsetMs<<' '<<int(s.nrRuntime)<<' '<<s.captureCompatible<<' '<<s.lowLatency<<' '<<s.forceSdrPreview<<' '<<int(s.captureAudio)<<' '<<s.exportBitrateMbps<<' '<<s.captureFlipVertical<<' '<<int(s.captureBuffer)<<' ';writeColorSettings(o,s.color,utf8(s.color.lutNameString()));o<<' '<<s.videoHdr.enabled<<' '<<s.videoHdr.contrast<<' '<<s.videoHdr.saturation<<' '<<s.videoHdr.middleGray<<' '<<s.videoHdr.peakNits<<' '<<s.nrTemporal<<'\n';}return o.str();
}
bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,std::wstring& def){
if(data.size()>65536)return false;std::istringstream in(data);in.imbue(std::locale::classic());std::string magic,d;int version=0;size_t count=0;
- if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version<1||version>20)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;
+ if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version<1||version>21)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;
for(size_t i=0;i<count;++i){UserPreset p;std::string n;int policy,flow,content,nr,sr;auto& s=p.settings;auto& m=s.model;auto& r=s.residual;
if(!(in>>std::quoted(n)>>m.intensity>>m.tone>>m.structure>>m.skin>>m.style>>m.autoMask>>m.uiCorrection>>r.total>>r.darken>>r.brighten>>r.color>>r.luminance>>nr>>sr>>s.multiplier>>policy>>flow>>content))return false;
if(version>=2){int enabled;if(!(in>>enabled>>s.protection.featherPixels)||enabled<0||enabled>1)return false;s.protection.enabled=enabled!=0;
@@ -47,7 +47,7 @@ bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,std
if(version>=17){int buffer;if(!(in>>buffer)||buffer<0||buffer>2)return false;s.captureBuffer=static_cast<veyra::source::CaptureBufferMode>(buffer);}
// v18 appends the full colour grade block (see ColorSettings.h).
if(version>=18){std::string lut;if(!readColorSettings(in,s.color,lut,version))return false;if(!lut.empty()&&!s.color.setLutName(wide(lut)))return false;}
- if(version>=20){int enabled;if(!(in>>enabled>>s.videoHdr.contrast>>s.videoHdr.saturation>>s.videoHdr.middleGray>>s.videoHdr.peakNits)||enabled<0||enabled>1)return false;s.videoHdr.enabled=enabled!=0;}
+ if(version>=20){int enabled;if(!(in>>enabled>>s.videoHdr.contrast>>s.videoHdr.saturation>>s.videoHdr.middleGray>>s.videoHdr.peakNits)||enabled<0||enabled>1)return false;s.videoHdr.enabled=enabled!=0;} if(version>=21){int temporal=0;if(!(in>>temporal)||temporal<0||temporal>1)return false;s.nrTemporal=temporal!=0;}
p.name=wide(n);if(!nameOk(p.name)||std::any_of(out.begin(),out.end(),[&](auto& a){return a.name==p.name;})||nr<0||nr>1||sr<0||sr>1)return false;
s.nr=nr;s.sr=sr;s.nrPolicy=static_cast<pipeline::NrSizePolicy>(policy);s.flow=static_cast<FlowQuality>(flow);s.content=static_cast<ContentRate>(content);
if(!s.validate().empty())return false;out.push_back(std::move(p));
diff --git a/src/engine/VideoExportJob.cpp b/src/engine/VideoExportJob.cpp
index 8c8bf9e6..c7167aae 100644
--- a/src/engine/VideoExportJob.cpp
+++ b/src/engine/VideoExportJob.cpp
@@ -91,7 +91,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOpti
if(options.nr&&!nvidiaFeatures)fgNote+=fgNote.empty()?L"当前显卡不能使用 DLSS NR,本次导出自动关闭 NR":L";当前显卡不能使用 DLSS NR,本次导出自动关闭 NR";
if(options.sr&&!srAvailable)fgNote+=fgNote.empty()?L"当前显卡不能使用所选超分,本次导出关闭超分":L";当前显卡不能使用所选超分,本次导出关闭超分";
if(!nvidiaFeatures&&srAvailable)fgNote+=fgNote.empty()?L"本次导出使用 AMD FSR 超分":L";本次导出使用 AMD FSR 超分";
- gd.sourceWidth=info.width;gd.sourceHeight=info.height;gd.workWidth=resolution.base.width;gd.workHeight=resolution.base.height;gd.nrWidth=resolution.nr.width;gd.nrHeight=resolution.nr.height;gd.flowWidth=resolution.flow.width;gd.flowHeight=resolution.flow.height;gd.enableSr=srAvailable;gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr&&nvidiaFeatures;gd.nrRuntime=options.settings.nrRuntime;gd.enableFg=options.fg&&nvidiaFeatures;gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=options.nr&&nvidiaFeatures;gd.model=options.settings.model;gd.residual=options.settings.residual;gd.protection=options.settings.protection;gd.color=options.settings.color;gd.settingsRevision=options.settings.revision;gd.flowQuality=options.settings.flow;gd.opticalFlowBackend=options.settings.opticalFlowBackend;gd.amdFlowHalfResolution=options.settings.amdFlowHalfResolution;gd.contentRate=options.settings.content;gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
+ gd.sourceWidth=info.width;gd.sourceHeight=info.height;gd.workWidth=resolution.base.width;gd.workHeight=resolution.base.height;gd.nrWidth=resolution.nr.width;gd.nrHeight=resolution.nr.height;gd.flowWidth=resolution.flow.width;gd.flowHeight=resolution.flow.height;gd.enableSr=srAvailable;gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr&&nvidiaFeatures;gd.nrRuntime=options.settings.nrRuntime;gd.nrTemporal=options.settings.nrTemporal;gd.enableFg=options.fg&&nvidiaFeatures;gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=options.nr&&nvidiaFeatures;gd.model=options.settings.model;gd.residual=options.settings.residual;gd.protection=options.settings.protection;gd.color=options.settings.color;gd.settingsRevision=options.settings.revision;gd.flowQuality=options.settings.flow;gd.opticalFlowBackend=options.settings.opticalFlowBackend;gd.amdFlowHalfResolution=options.settings.amdFlowHalfResolution;gd.contentRate=options.settings.content;gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
// Keep the requested multiplier. Changing it after initialization fails
// would produce a successful-looking file with different settings.
bool graphReady=false,fgFailure=false;
diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cpp
index 4adcf9e3..8db1b5e4 100644
--- a/src/engine/VideoPresenter.cpp
+++ b/src/engine/VideoPresenter.cpp
@@ -255,9 +255,22 @@ void VideoPresenter::close(){
}
PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceContext& ctx,PresentationSettings requested,bool fg,std::wstring& status){
const bool reflexDisabled=reflex_.disable();reflexFrame_=0;
+ const bool followDisplay=requested.outputRate==OutputRateMode::FollowDisplay;
+ if(followDisplay){
+ const double hz=gfx::PresentSink::displayRefreshFps(sink_.hwnd());
+ if(hz>=1.0&&std::isfinite(hz)){requested.outputRate=OutputRateMode::Custom;requested.customFps=hz;}
+ else requested.outputRate=OutputRateMode::Off;
+ }
auto effective=requested;
+ std::wstring capNotice;
+ if((xessActive()||fsrActive())&&requested.outputRate!=OutputRateMode::Off){
+ // Provider owns generated Present calls. Capping our real-frame input
+ // would change the source cadence, not cap its final output.
+ effective.outputRate=OutputRateMode::Off;
+ capNotice=L" · 此补帧提供方暂不支持独立输出限帧;已保留设置";
+ }
if(!reflexDisabled){effective.enabled=false;sink_.configurePacing(false,false);status=L"Reflex 驱动状态撤销失败;应用等待已停用,请关闭视频后重试";return effective;}
- if(!requested.enabled){const bool restored=sink_.configurePacing(false,false);status=restored?L"帧同步已关闭":L"应用等待已关闭,但显示队列恢复失败;请关闭视频后重试";return effective;}
+ if(!requested.enabled){const bool restored=sink_.configurePacing(false,false);status=restored?L"帧同步已关闭":L"应用等待已关闭,但显示队列恢复失败;请关闭视频后重试";if(effective.outputRate==OutputRateMode::Custom)status+=std::format(L" · 输出上限 {:.3f} FPS",effective.customFps);status+=capNotice;return effective;}
if(xessActive()||fsrActive()){
effective.enabled=false;
const bool vsync=xessActive()&&requested.display!=DisplaySync::Tearing;
@@ -265,6 +278,7 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConte
if(fsrActive()){effective.display=DisplaySync::Tearing;status=L"FSR 提供方调度;显示同步暂不支持";}
else status=vsync?L"XeSS 提供方调度 · 垂直同步":L"XeSS 提供方调度 · 允许撕裂";
if(xessActive()&&requested.display==DisplaySync::Automatic)status+=L"(自动;VRR 状态未知)";
+ status+=capNotice;
return effective;
}
if(!sink_.configurePacing(true,requested.display!=DisplaySync::Tearing)){effective.enabled=false;status=L"显示队列控制不可用,已回退原呈现方式";return effective;}
@@ -273,6 +287,8 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConte
if(fg||!reflex_.enable(ctx.device())){effective.mode=PacingMode::LowQueue;status=fg?L"补帧运行:Reflex 暂用低排队(保留补帧倍率)":L"Reflex 初始化失败,已回退低排队";return effective;}
}
status=effective.mode==PacingMode::Reflex?L"NVIDIA Reflex · 实验":effective.mode==PacingMode::Even?L"均匀呈现":L"低排队";
+ if(followDisplay)status+=std::format(L" · 输出跟随显示器 ({:.0f} Hz)",requested.customFps);
+ else if(requested.outputRate==OutputRateMode::Custom)status+=std::format(L" · 输出上限 {:.3f} FPS",requested.customFps);
if(requested.display==DisplaySync::Automatic)status+=L" · 自动:垂直同步(VRR 状态未知)";
else if(requested.display==DisplaySync::Vsync)status+=L" · 垂直同步";
else status+=L" · 允许撕裂";
diff --git a/src/gfx/PresentSink.cpp b/src/gfx/PresentSink.cpp
index cd4a1c82..2dc96ac2 100644
--- a/src/gfx/PresentSink.cpp
+++ b/src/gfx/PresentSink.cpp
@@ -6,6 +6,7 @@
#include <format>
#include <chrono>
+#include <vector>
#include "veyra/Log.h"
#include "veyra/diagnostics/CpuStallTrace.h"
@@ -30,6 +31,28 @@ bool PresentSink::hdrDisplayActive(HWND window){
}return false;
}
+double PresentSink::displayRefreshFps(HWND window){
+ MONITORINFOEXW mi{};mi.cbSize=sizeof(mi);
+ const auto monitor=MonitorFromWindow(window,MONITOR_DEFAULTTONEAREST);
+ if(!monitor||!GetMonitorInfoW(monitor,&mi))return 0;
+ UINT32 pathCount=0,modeCount=0;
+ if(GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS,&pathCount,&modeCount)==ERROR_SUCCESS){
+ std::vector<DISPLAYCONFIG_PATH_INFO> paths(pathCount);
+ std::vector<DISPLAYCONFIG_MODE_INFO> modes(modeCount);
+ if(QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS,&pathCount,paths.data(),&modeCount,modes.data(),nullptr)==ERROR_SUCCESS){
+ for(UINT32 i=0;i<pathCount;++i){const auto& path=paths[i];
+ DISPLAYCONFIG_SOURCE_DEVICE_NAME name{};name.header.type=DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME;name.header.size=sizeof(name);name.header.adapterId=path.sourceInfo.adapterId;name.header.id=path.sourceInfo.id;
+ if(DisplayConfigGetDeviceInfo(&name.header)==ERROR_SUCCESS&&wcscmp(name.viewGdiDeviceName,mi.szDevice)==0&&path.targetInfo.refreshRate.Denominator&&path.targetInfo.refreshRate.Numerator)
+ return double(path.targetInfo.refreshRate.Numerator)/path.targetInfo.refreshRate.Denominator;
+ }
+ }
+ }
+ DEVMODEW mode{};mode.dmSize=sizeof(mode);
+ if(!EnumDisplaySettingsExW(mi.szDevice,ENUM_CURRENT_SETTINGS,&mode,0)||mode.dmDisplayFrequency==0)return 0;
+ // Older/remote drivers may expose only the integer fallback.
+ return double(mode.dmDisplayFrequency);
+}
+
PresentSink::~PresentSink()
{
shutdown();
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index c368cca8..964137ba 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -1145,7 +1145,8 @@ bool EnhanceGraph::createViews()
stagedSrv(desc_.nrBeforeSr?srcRgba_.Get():workRgba_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,residualPass_,0);
stagedSrv(nrInput_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,residualPass_,1);
stagedSrv(finalRgba_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,residualPass_,2);
- makeUav(context_.device(),residualRgba_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,cpu(residualPass_,3));
+ if(desc_.nrTemporal&&!nrTemporal_.initialize(context_.device(),desc_.nrBeforeSr?srcRgba_.Get():workRgba_.Get(),flowTex_.Get(),residualRgba_.Get()))return false;
+ makeUav(context_.device(),desc_.nrTemporal?nrTemporal_.raw():residualRgba_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,cpu(residualPass_,3));
stagedSrv(flowTex_.Get(),DXGI_FORMAT_R16G16_FLOAT,flowAdaptPass_,0);
makeUav(context_.device(),nrFlow_.Get(),DXGI_FORMAT_R16G16_FLOAT,cpu(flowAdaptPass_,1));
makeUav(context_.device(),baseFlow_.Get(),DXGI_FORMAT_R16G16_FLOAT,cpu(flowAdaptPass_,2));
@@ -1837,11 +1838,14 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
if(nrEnabled_&&nrHandle_){
gpuTimer_.mark(list,GpuStage::Residual);
- tracker_.transition(list,residualRgba_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ auto* raw=desc_.nrTemporal?nrTemporal_.raw():residualRgba_.Get();
+ tracker_.transition(list,raw,D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
const auto& r=desc_.residual;float c[24]={r.total,r.darken,r.brighten,r.color,r.luminance,desc_.protection.enabled?1.0f:0.0f,desc_.protection.featherPixels,desc_.hdrWorking()?1.0f:0.0f};
for(size_t i=0;i<4;++i){const auto q=desc_.protection.regions[i];c[8+i*4]=q.left;c[9+i*4]=q.top;c[10+i*4]=q.right;c[11+i*4]=q.bottom;}
residualPass_.bind(list,c,gpuHandleOf(residualPass_,0).ptr,gpuHandleOf(residualPass_,3).ptr);
- list->Dispatch(((desc_.nrBeforeSr?srcW_:workW_)+15)/16,((desc_.nrBeforeSr?srcH_:workH_)+15)/16,1);tracker_.uavBarrier(list,residualRgba_.Get());tracker_.transition(list,residualRgba_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);gpuTimer_.mark(list,GpuStage::Residual,true);
+ list->Dispatch(((desc_.nrBeforeSr?srcW_:workW_)+15)/16,((desc_.nrBeforeSr?srcH_:workH_)+15)/16,1);tracker_.uavBarrier(list,raw);tracker_.transition(list,raw,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ if(desc_.nrTemporal)nrTemporal_.run(list,tracker_,reset,haveFlow,ptsMs-prevPtsMs_);
+ gpuTimer_.mark(list,GpuStage::Residual,true);
}
if(desc_.nrBeforeSr&&!runSr())return false;
@@ -2022,6 +2026,8 @@ bool EnhanceGraph::resolveGeneration(FrameOutputs& out)
}
bool EnhanceGraph::applySettings(const engine::EnhancementSettings& s){
+ if(s.nrTemporal!=desc_.nrTemporal)return false;
+ nrTemporal_.reset(); // settings/protection changes must not revive old corrections
// A non-NVIDIA adapter keeps the user's requested NR setting in the UI
// but has this NGX-only stage explicitly disabled in the graph. Do not
// reject unrelated live settings in that degraded, playable state.
@@ -2158,7 +2164,7 @@ void EnhanceGraph::shutdown()
rgbPass_={};rgbTex_.Reset();
for(unsigned i=0;i<2;++i){if(upRgb_[i]&&mappedRgb_[i])upRgb_[i]->Unmap(0,nullptr);mappedRgb_[i]=nullptr;upRgb_[i].Reset();}
downsamplePass_={};residualPass_={};flowAdaptPass_={};
- nrInput_.Reset();residualRgba_.Reset();nrFlow_.Reset();baseFlow_.Reset();
+ nrTemporal_.close();nrInput_.Reset();residualRgba_.Reset();nrFlow_.Reset();baseFlow_.Reset();
for(unsigned i=0;i<kGeneratedPoolSlots;++i){fgDisable_[i].Reset();fgDisableReadback_[i].Reset();generatedLeases_[i].reset();genFrame_[i].Reset();}for(auto& lease:realLeases_)lease.reset();fgDisableInit_.Reset();
encPass_ = ComputePass{};
blitPass_ = ComputePass{};hdrVideoSrPass_={};
diff --git a/src/pipeline/NrTemporalPass.cpp b/src/pipeline/NrTemporalPass.cpp
new file mode 100644
index 00000000..d49ee671
--- /dev/null
+++ b/src/pipeline/NrTemporalPass.cpp
@@ -0,0 +1,39 @@
+#include "veyra/pipeline/NrTemporalPass.h"
+#include <bit>
+#include <cmath>
+#include <algorithm>
+namespace veyra::pipeline {
+bool NrTemporalPass::initialize(ID3D12Device* device,ID3D12Resource* base,ID3D12Resource* motion,ID3D12Resource* output){
+ close();base_=base;motion_=motion;output_=output;
+ if(!base||!motion||!output)return false;
+ auto desc=base->GetDesc();width_=unsigned(desc.Width);height_=desc.Height;
+ raw_=makeTexture(device,width_,height_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);
+ for(unsigned i=0;i<2;++i){history_[i]=makeTexture(device,width_,height_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);guide_[i]=makeTexture(device,width_,height_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);if(!history_[i]||!guide_[i])return false;}
+ std::vector<uint8_t> shader;if(!raw_||!pass_.loadShader("NrTemporal.dxil",shader)||!pass_.create(device,shader,16,5,3,8))return false;
+ DescriptorStager staging;if(!staging.initialize(device,10))return false;
+ for(unsigned i=0;i<2;++i){
+ ID3D12Resource* sources[]={base,raw_.Get(),history_[1-i].Get(),guide_[1-i].Get(),motion};
+ for(unsigned j=0;j<5;++j)staging.stageSrv(sources[j],nullptr,pass_.heap.Get(),i*8+j);
+ makeUav(device,output,DXGI_FORMAT_R16G16B16A16_FLOAT,cpuHandleOf(pass_,i*8+5));
+ makeUav(device,history_[i].Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,cpuHandleOf(pass_,i*8+6));
+ makeUav(device,guide_[i].Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,cpuHandleOf(pass_,i*8+7));
+ }return true;
+}
+void NrTemporalPass::run(ID3D12GraphicsCommandList* list,StateTracker& tracker,bool reset,bool haveMotion,double frameMs){
+ const auto i=index_;const bool useHistory=valid_&&!reset&&haveMotion;
+ tracker.transition(list,raw_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker.transition(list,base_,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker.transition(list,motion_,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker.transition(list,history_[1-i].Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker.transition(list,guide_[1-i].Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ for(auto* r:{output_,history_[i].Get(),guide_[i].Get()})tracker.transition(list,r,D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ // 80 ms past-history EMA; no future frames or presentation holdback.
+ const float weight=useHistory?float(std::exp(-std::clamp(frameMs,1.0,250.0)/80.0)):0.f;
+ const float c[8]={std::bit_cast<float>(width_),std::bit_cast<float>(height_),weight,0,0,0,0,0};
+ pass_.bind(list,c,gpuHandleOf(pass_,i*8).ptr,gpuHandleOf(pass_,i*8+5).ptr);
+ list->Dispatch((width_+7)/8,(height_+7)/8,1);
+ for(auto* r:{output_,history_[i].Get(),guide_[i].Get()}){tracker.uavBarrier(list,r);tracker.transition(list,r,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);}
+ valid_=true;index_=1-i;
+}
+void NrTemporalPass::close(){pass_={};raw_.Reset();for(auto& r:history_)r.Reset();for(auto& r:guide_)r.Reset();base_=motion_=output_=nullptr;width_=height_=index_=0;valid_=false;}
+}
diff --git a/tests/integration/SubtitleOverlayTests.cpp b/tests/integration/SubtitleOverlayTests.cpp
index 1d05b4bd..92b4513c 100644
--- a/tests/integration/SubtitleOverlayTests.cpp
+++ b/tests/integration/SubtitleOverlayTests.cpp
@@ -41,6 +41,16 @@ int main(){
std::cout<<"alignment="<<alignment<<" extent="<<imageWidth<<'x'<<imageHeight<<" red="<<r0<<','<<r1<<" green="<<g0<<','<<g1<<'\n';
if(alignment==5)check(std::abs((std::min(r0,g0)+std::max(r1,g1))/2-240)<12,"middle group is centered");
}
+ // Compare real glyph raster heights, not just the setting used by the renderer.
+ SubtitleLine stable;stable.text=L"HHHH";stable.style.size=28;stable.style.shadow=0;
+ view.targetLines=1;
+ auto inkBands=[&](){std::vector<int> heights;int run=0;for(int y=0;y<imageHeight;++y){bool ink=false;for(int x=0;x<imageWidth;++x)ink|=(pixels[size_t(y)*imageWidth+x]>>24)>30;if(ink)++run;else if(run){heights.push_back(run);run=0;}}if(run)heights.push_back(run);return heights;};
+ updateSubtitleOverlay(overlay,{stable},view);const auto one=inkBands();
+ stable.text=L"HHHH\nHHHH";updateSubtitleOverlay(overlay,{stable},view);const auto two=inkBands();
+ check(one.size()==1&&two.size()==2&&std::abs(one[0]-two[0])<=1&&std::abs(one[0]-two[1])<=1,"two-line cue preserves one-line glyph size even with target one");
+ view.fitToLines=true;updateSubtitleOverlay(overlay,{stable},view);const auto fitted=inkBands();
+ check(fitted.size()==2&&fitted[0]<two[0],"explicit fit-to-lines still shrinks text");
+ view.fitToLines=false;
RECT rect{0,0,640,480};
const auto original=signatureOf({red},view,rect);
auto changes=[&](auto change){auto copy=red;change(copy.style);check(signatureOf({copy},view,rect)!=original,"style mutation invalidates cache");};
diff --git a/tests/integration/SubtitlePanelTests.cpp b/tests/integration/SubtitlePanelTests.cpp
index 581e5d22..ffecea45 100644
--- a/tests/integration/SubtitlePanelTests.cpp
+++ b/tests/integration/SubtitlePanelTests.cpp
@@ -8,6 +8,10 @@ int wmain(){
auto check=[&](bool ok,const char* message){std::cout<<(ok?"PASS ":"FAIL ")<<message<<'\n';failures+=!ok;};
showSubtitleSettings(owner,{},[&](const auto& settings){current=settings;++updates;});
const HWND panel=subtitlePanel::window,edit=GetDlgItem(panel,101);SetFocus(edit);
+ check(!current.fitToLines&&!IsWindowEnabled(GetDlgItem(panel,104)),"fixed font is default; fit target disabled");
+ SendDlgItemMessageW(panel,108,BM_CLICK,0,0);
+ check(current.fitToLines&&IsWindowEnabled(GetDlgItem(panel,104)),"fit-to-lines is explicit and enables target");
+ SetFocus(edit); // BM_CLICK intentionally focused the checkbox, as a real click would.
for(int i=0;i<20;++i){SetWindowTextW(edit,std::to_wstring(20+i).c_str());check(IsWindow(panel)&&GetFocus()==edit&&current.pixels==20+i,"continuous edit retains panel and focus");}
SetWindowTextW(edit,L"-");check(current.pixels==39,"intermediate invalid text does not apply");
SendMessageW(panel,WM_COMMAND,MAKEWPARAM(101,EN_KILLFOCUS),LPARAM(edit));
diff --git a/tests/unit/UiContractTests.cpp b/tests/unit/UiContractTests.cpp
index b567b846..2f42ce66 100644
--- a/tests/unit/UiContractTests.cpp
+++ b/tests/unit/UiContractTests.cpp
@@ -124,10 +124,10 @@ int wmain(int argc,wchar_t** argv){try{
// 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");
- for(int enabled:{0,1}){p.enhancementEnabled=enabled;before.nr=true;before.nrRuntime=engine::NrRuntime::Community;require(prefs.save(p,&before),"master and runtime save");ui::UiPreferenceStore restart(dir);require(restart.load().enhancementEnabled==enabled,"master state survives restart");auto restoredSettings=restart.startup({});require(restoredSettings.nr&&restoredSettings.nrRuntime==before.nrRuntime,"bypassed effects and runtime survive restart");}
- for(bool enabled:{false,true})for(unsigned mode=0;mode<3;++mode)for(unsigned sync=0;sync<3;++sync){p.presentation={enabled,engine::PacingMode(mode),engine::DisplaySync(sync)};require(prefs.save(p,nullptr),"presentation atomic save");ui::UiPreferenceStore restart(dir);require(restart.load().presentation==p.presentation,"all presentation combinations survive restart");}
+ for(int enabled:{0,1}){p.enhancementEnabled=enabled;before.nr=true;before.nrRuntime=engine::NrRuntime::Community;before.nrTemporal=true;require(prefs.save(p,&before),"master and runtime save");ui::UiPreferenceStore restart(dir);require(restart.load().enhancementEnabled==enabled,"master state survives restart");auto restoredSettings=restart.startup({});require(restoredSettings.nr&&restoredSettings.nrRuntime==before.nrRuntime&&restoredSettings.nrTemporal,"bypassed effects, runtime and temporal NR survive restart");}
+ for(bool enabled:{false,true})for(unsigned mode=0;mode<3;++mode)for(unsigned sync=0;sync<3;++sync)for(unsigned rate=0;rate<3;++rate){p.presentation={enabled,engine::PacingMode(mode),engine::DisplaySync(sync),engine::OutputRateMode(rate),rate==2?119.88:60.0};require(prefs.save(p,nullptr),"presentation atomic save");ui::UiPreferenceStore restart(dir);require(restart.load().presentation==p.presentation,"all presentation combinations and output caps survive restart");}
auto path=dir/"ui-preferences.v1";
- for(int lines:{0,1,2,8}){p.subtitleLines=lines;require(prefs.save(p,nullptr),"subtitle lines save");ui::UiPreferenceStore restart(dir);require(restart.load().subtitleLines==lines,"subtitle lines survive restart");}
+ for(int lines:{0,1,2,8})for(bool fit:{false,true}){p.subtitleLines=lines;p.subtitleFitToLines=fit;require(prefs.save(p,nullptr),"subtitle layout save");ui::UiPreferenceStore restart(dir);auto back=restart.load();require(back.subtitleLines==lines&&back.subtitleFitToLines==fit,"subtitle lines and explicit fitting survive restart");}
{std::ofstream legacy(path);legacy<<"VEYRA_UI 6\n0.45 1 1 1280 800 0 0 0 4 22 392 1 0 1 16 3 0 1 1 2 1\n";legacy.close();ui::UiPreferenceStore migration(dir);auto old=migration.load();require(old.subtitleLines==2&&old.presentation.enabled&&old.presentation.mode==engine::PacingMode::Reflex&&old.subtitleMargin==16&&old.inspector==4,"v6 migrates subtitle layout without losing settings");require(migration.save(old,nullptr),"v6 remains writable");}
for(int version=1;version<=5;++version){std::ofstream legacy(path);legacy<<"VEYRA_UI "<<version<<"\n1 0 1 1280 800 0 0 0 1 22";if(version>=2)legacy<<" 392";if(version>=3)legacy<<" 1 0 0 0 0";if(version>=4)legacy<<" 0";if(version>=5)legacy<<" 1";legacy.close();ui::UiPreferenceStore migration(dir);require(!migration.load().presentation.enabled,"old preferences default pacing off");require(migration.save({},nullptr),"old preferences migrate without corrupt lock");}
{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");}