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++
Checkpoint capture UI and synchronization repairs before scheduling fixes
Veyra Goal Agent5a1931ba5437
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 9b58c6be..34191306 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -549,6 +549,9 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformadd_executable(veyra_repair_contract_tests tests/unit/RepairContractTests.cpp)add_executable(veyra_subtitle_loading_tests tests/integration/SubtitleLoadingTests.cpp)+ add_executable(veyra_screenshot_combination_tests tests/integration/ScreenshotCombinationTests.cpp)+ target_link_libraries(veyra_screenshot_combination_tests PRIVATE veyra_engine)+ target_compile_features(veyra_screenshot_combination_tests PRIVATE cxx_std_20)add_executable(veyra_bitmap_subtitle_tests tests/integration/BitmapSubtitleTests.cpp)target_link_libraries(veyra_bitmap_subtitle_tests PRIVATE veyra_engine)target_compile_features(veyra_bitmap_subtitle_tests PRIVATE cxx_std_20)@@ -794,6 +797,11 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformtarget_compile_definitions(veyra_ui_contract_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)target_include_directories(veyra_ui_contract_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)add_executable(veyra_popup_selector_tests tests/integration/PopupSelectorTests.cpp)+ add_executable(veyra_subtitle_panel_tests tests/integration/SubtitlePanelTests.cpp)+ target_compile_features(veyra_subtitle_panel_tests PRIVATE cxx_std_20)+ target_compile_options(veyra_subtitle_panel_tests PRIVATE /utf-8)+ target_compile_definitions(veyra_subtitle_panel_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN UNICODE _UNICODE)+ target_link_libraries(veyra_subtitle_panel_tests PRIVATE veyra_base comctl32)target_compile_features(veyra_popup_selector_tests PRIVATE cxx_std_20)target_compile_options(veyra_popup_selector_tests PRIVATE /utf-8)target_compile_definitions(veyra_popup_selector_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN UNICODE _UNICODE)diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cppindex 5d024519..1312059d 100644--- a/apps/veyra/SettingsWindow.cpp+++ b/apps/veyra/SettingsWindow.cpp@@ -1601,9 +1601,9 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.}}setText(item(1103),L"光流与补帧");- add(L"BUTTON",L"帧同步",240,BS_AUTOCHECKBOX|WS_TABSTOP,1,12,550,-1,32);+ 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"自动"});+ 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);}button(L"Smooth Motion · 开启方法 ▾",221,1,12,358);diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex 770e2a60..9ab6d10e 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -17,6 +17,7 @@#include "veyra/remoteplay/ControllerInput.h"#endif#include "SubtitleOverlay.h"+#include "SubtitleSettingsPanel.h"#include "ProtectionOverlay.h"#include "SourceTitle.h"#include "veyra/engine/ExportJobManager.h"@@ -132,6 +133,7 @@ bool subtitleIsChinese(const veyra::engine::SubtitleTrack& track){return false;}void refreshSubtitleTracks(const std::wstring& media){+ veyra::ui::closeSubtitleSettings();subtitleTracks.clear();subtitlePrimary=-1;subtitleSecondary=-1;subtitleStatus.clear();subtitlePrimaryChosen=subtitleSecondaryChosen=false;subtitleLoadedTracks=0;@@ -182,6 +184,7 @@ void setSubtitleOffset(int deltaMs){veyra::log::info("subtitle",std::format("offset track={} offsetMs={}",narrow(track.name),track.offsetMs));}void cycleSubtitleTrack(bool secondary){+ if(!secondary)veyra::ui::closeSubtitleSettings();if(subtitleTracks.empty())return;(secondary?subtitleSecondaryChosen:subtitlePrimaryChosen)=true;int& slot=secondary?subtitleSecondary:subtitlePrimary;@@ -427,6 +430,7 @@ void audioTrackMenu(){}void subtitleMenu(){using namespace veyra::ui;+ closeSubtitleSettings();std::vector<PopupOption> options;std::vector<std::function<void()>> actions;auto add=[&](int command,std::wstring label,Icon icon,bool checked,std::function<void()> action){options.push_back({command,std::move(label),icon,checked});actions.push_back(std::move(action));};add(Subtitle,L"音轨…",Icon::None,false,[]{audioTrackMenu();});@@ -448,21 +452,17 @@ void subtitleMenu(){uiState.subtitles=true;subtitleStatus=std::format(L"已载入 {}",subtitleTracks.back().name);layout();});add(SubtitleLoad,L"重新扫描内嵌字幕轨",Icon::Load,false,[&]{refreshSubtitleTracks(currentFile);layout();});- add(0,L"── 时间(作用于主字幕)──",Icon::None,false,[]{});- add(SubtitleSize,L"延时 -1 秒",Icon::Type,false,[&]{setSubtitleOffset(-1000);});- add(SubtitleSize,L"延时 -50 毫秒",Icon::Type,false,[&]{setSubtitleOffset(-50);});- add(SubtitleSize,L"延时归零",Icon::Type,false,[&]{if(subtitlePrimary>=0&&size_t(subtitlePrimary)<subtitleTracks.size())subtitleTracks[size_t(subtitlePrimary)].offsetMs=0;subtitleStatus=L"字幕延时已归零";});- add(SubtitleSize,L"延时 +50 毫秒",Icon::Type,false,[&]{setSubtitleOffset(50);});- add(SubtitleSize,L"延时 +1 秒",Icon::Type,false,[&]{setSubtitleOffset(1000);});+ 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;+ 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;+ });+ });add(SubtitleSize,L"自动对齐到音轨(实验)",Icon::Type,false,[]{startSubtitleAutoAlign();});- add(0,L"── 样式 ──",Icon::None,false,[]{});- add(SubtitleSize,std::format(L"字号 - (当前 {:.0f})",subtitleScale()*22),Icon::Type,false,[&]{subtitlePixels=std::clamp(subtitlePixels-2,16,56);});- add(SubtitleSize,std::format(L"字号 + (当前 {:.0f})",subtitleScale()*22),Icon::Type,false,[&]{subtitlePixels=std::clamp(subtitlePixels+2,16,56);});- add(SubtitleSize,uiState.subtitleOutline?L"描边 · 开":L"描边 · 关",Icon::Type,uiState.subtitleOutline,[&]{uiState.subtitleOutline=!uiState.subtitleOutline;});- add(SubtitleSize,uiState.subtitleBackground?L"背景条 · 开":L"背景条 · 关",Icon::Type,uiState.subtitleBackground,[&]{uiState.subtitleBackground=!uiState.subtitleBackground;});- add(SubtitleSize,L"位置上移",Icon::Type,false,[&]{uiState.subtitleMargin=std::clamp(uiState.subtitleMargin+4,0,240);});- add(SubtitleSize,L"位置下移",Icon::Type,false,[&]{uiState.subtitleMargin=std::clamp(uiState.subtitleMargin-4,0,240);});- add(SubtitleSize,std::format(L"字体:{}",subtitleFontName()),Icon::Type,false,[&]{uiState.subtitleFont=(uiState.subtitleFont+1)%kSubtitleFontCount;subtitleStatus=std::format(L"字幕字体:{}",subtitleFontName());});menuOpen=true;const int selected=popupSelector(GetDlgItem(mainWindow,Subtitle),options,0,true,L"字幕与音轨");menuOpen=false;if(selected>=0&&size_t(selected)<actions.size()&&actions[size_t(selected)])actions[size_t(selected)]();pointerActivity();@@ -743,6 +743,7 @@ if(screenFill&¤tFile.starts_with(L"screen:")&&s.running){view.outline=uiState.subtitleOutline;view.background=uiState.subtitleBackground;view.bottomMargin=uiState.subtitleMargin;+ view.targetLines=uiPreferences.subtitleLines;if(full&&fullControls)view.bottomMargin+=84;view.preview=engine.previewView();view.videoWidth=s.metrics.resolution.output.width;@@ -794,6 +795,7 @@ CheckDlgButton(hwnd,Sr,(uiState.enhanced&&s.desired.sr)?BST_CHECKED:BST_UNCHECKEveyra::ui::icon(GetDlgItem(hwnd,Play),s.transport==veyra::engine::TransportState::Playing?veyra::ui::Icon::Pause:veyra::ui::Icon::Play);veyra::ui::icon(GetDlgItem(hwnd,Mute),s.muted?veyra::ui::Icon::Muted:veyra::ui::Icon::Volume);setText(GetDlgItem(hwnd,Play),s.transport==veyra::engine::TransportState::Playing?L"暂停":L"播放");setText(GetDlgItem(hwnd,Mute),!s.audioAvailable?L"无音轨":s.muted?L"静音":L"音量");EnableWindow(GetDlgItem(hwnd,Volume),s.audioAvailable);EnableWindow(GetDlgItem(hwnd,Mute),s.audioAvailable);+if(GetCapture()!=GetDlgItem(hwnd,Volume))SendDlgItemMessageW(hwnd,Volume,TBM_SETPOS,TRUE,int(std::lround(s.volume*100)));EnableWindow(seekBar,s.running&&!s.capture&&!s.image&&s.duration>0);ShowWindow(seekBar,(!full||fullControls)&&!s.capture&&!s.image&&!(showDiagnostics&&uiState.mode==veyra::ui::Mode::Professional&&!full)?SW_SHOW:SW_HIDE);EnableWindow(GetDlgItem(hwnd,Play),!currentFile.empty()&&!s.capture&&!s.image);EnableWindow(GetDlgItem(hwnd,Stop),s.running);setText(GetDlgItem(hwnd,MediaTitle),currentFile.empty()?L"尚未打开媒体":s.remotePlay?L"PS5 · LIVE":s.capture?L"采集卡 · LIVE":std::filesystem::path(currentFile).filename().wstring());auto stamp=[](double v){int seconds=std::max(0,int(v));return std::format(L"{:02}:{:02}:{:02}",seconds/3600,seconds/60%60,seconds%60);};@@ -1172,6 +1174,9 @@ RegisterClassExW(&wc);auto hwnd=CreateWindowExW(0,wc.lpszClassName,L"Veyra — 本地实验版",ShellStyle,CW_USEDEFAULT,CW_USEDEFAULT,std::min(MulDiv(uiPreferences.width,GetDpiForSystem(),96),GetSystemMetrics(SM_CXSCREEN)),std::min(MulDiv(uiPreferences.height,GetDpiForSystem(),96),GetSystemMetrics(SM_CYSCREEN)-40),nullptr,nullptr,instance,nullptr);if(!hwnd)return 1;if(uiPreferences.positioned&&smokeSeconds<=0){RECT target{uiPreferences.x,uiPreferences.y,uiPreferences.x+MulDiv(uiPreferences.width,GetDpiForSystem(),96),uiPreferences.y+MulDiv(uiPreferences.height,GetDpiForSystem(),96)};MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromRect(&target,MONITOR_DEFAULTTONEAREST),&mi);int width=std::min(target.right-target.left,mi.rcWork.right-mi.rcWork.left),height=std::min(target.bottom-target.top,mi.rcWork.bottom-mi.rcWork.top);SetWindowPos(hwnd,nullptr,std::clamp(target.left,mi.rcWork.left,mi.rcWork.right-width),std::clamp(target.top,mi.rcWork.top,mi.rcWork.bottom-height),width,height,SWP_NOZORDER|SWP_NOACTIVATE);}CheckDlgButton(hwnd,Nr,initialOptions.nr?BST_CHECKED:BST_UNCHECKED);CheckDlgButton(hwnd,Sr,initialOptions.sr?BST_CHECKED:BST_UNCHECKED);CheckDlgButton(hwnd,Fg,initialOptions.fg?BST_CHECKED:BST_UNCHECKED);CheckDlgButton(hwnd,Realtime,initialOptions.realtime?BST_CHECKED:BST_UNCHECKED);ShowWindow(hwnd,show);MSG msg{};while(GetMessageW(&msg,nullptr,0,0)>0){if(full&&GetAncestor(msg.hwnd,GA_ROOT)==hwnd&&(msg.message==WM_MOUSEMOVE||msg.message==WM_LBUTTONDOWN||msg.message==WM_KEYDOWN)){static POINT previous{-9999,-9999};POINT now{};GetCursorPos(&now);if(msg.message!=WM_MOUSEMOVE||now.x!=previous.x||now.y!=previous.y)pointerActivity();previous=now;}if(GetAncestor(msg.hwnd,GA_ROOT)==hwnd&&(msg.message==WM_KEYDOWN||msg.message==WM_KEYUP||msg.message==WM_SYSKEYDOWN)){wchar_t focusedClass[32]{};GetClassNameW(GetFocus(),focusedClass,32);const bool editing=_wcsicmp(focusedClass,L"Edit")==0||_wcsicmp(focusedClass,L"ComboBox")==0;const bool adjustingSlider=_wcsicmp(focusedClass,TRACKBAR_CLASSW)==0&&GetFocus()!=seekBar;+if(!editing&&!adjustingSlider&&_wcsicmp(focusedClass,L"ListBox")!=0&&!veyra::ui::popupSelectorOpen()&&msg.message==WM_KEYDOWN&&(msg.wParam==VK_UP||msg.wParam==VK_DOWN)&&!(GetKeyState(VK_CONTROL)&0x8000)&&!(GetKeyState(VK_MENU)&0x8000)){+ const auto state=engine.snapshot();engine.setVolume(std::clamp(state.volume+(msg.wParam==VK_UP?.05f:-.05f),0.0f,1.0f),false);continue;+}if(!editing&&!veyra::ui::popupSelectorOpen()&&msg.message==WM_KEYDOWN&&!(GetKeyState(VK_CONTROL)&0x8000)&&!(GetKeyState(VK_MENU)&0x8000)){const bool shift=(GetKeyState(VK_SHIFT)&0x8000)!=0;switch(msg.wParam){@@ -1197,6 +1202,13 @@ if(!editing&&(!adjustingSlider||full)&&!veyra::ui::popupSelectorOpen()&&msg.messif(!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;}}-if(msg.message==WM_MOUSEWHEEL&&uiState.mode==veyra::ui::Mode::Professional&&GetAncestor(msg.hwnd,GA_ROOT)==hwnd){POINT p{GET_X_LPARAM(msg.lParam),GET_Y_LPARAM(msg.lParam)};if(WindowFromPoint(p)==video){SendMessageW(video,msg.message,msg.wParam,msg.lParam);continue;}}-if(veyra::ui::screenCaptureDialogMessage(msg)||IsDialogMessageW(hwnd,&msg))continue;TranslateMessage(&msg);DispatchMessageW(&msg);}CoUninitialize();return int(msg.wParam);+if(msg.message==WM_MOUSEWHEEL&&GetAncestor(msg.hwnd,GA_ROOT)==hwnd&&!veyra::ui::popupSelectorOpen()){+ POINT p{GET_X_LPARAM(msg.lParam),GET_Y_LPARAM(msg.lParam)};const HWND hovered=WindowFromPoint(p);+ if(hovered==video&&uiState.mode==veyra::ui::Mode::Professional){SendMessageW(video,msg.message,msg.wParam,msg.lParam);continue;}+ if(hovered==video||hovered==GetDlgItem(hwnd,Volume)){+ static int wheelRemainder=0;wheelRemainder+=GET_WHEEL_DELTA_WPARAM(msg.wParam);const int steps=wheelRemainder/WHEEL_DELTA;wheelRemainder%=WHEEL_DELTA;+ if(steps){const auto state=engine.snapshot();engine.setVolume(std::clamp(state.volume+steps*.05f,0.0f,1.0f),false);}continue;+ }+}+if(veyra::ui::subtitleSettingsDialogMessage(msg)||veyra::ui::screenCaptureDialogMessage(msg)||IsDialogMessageW(hwnd,&msg))continue;TranslateMessage(&msg);DispatchMessageW(&msg);}CoUninitialize();return int(msg.wParam);}diff --git a/apps/veyra/ui/SubtitleOverlay.cpp b/apps/veyra/ui/SubtitleOverlay.cppindex 36964391..0ae9b4ad 100644--- a/apps/veyra/ui/SubtitleOverlay.cpp+++ b/apps/veyra/ui/SubtitleOverlay.cpp@@ -37,7 +37,7 @@ std::wstring signatureOf(const std::vector<SubtitleLine>& lines,const SubtitleVisignature+=std::format(L"{}:{:.4f}:{:.4f}|",reinterpret_cast<uintptr_t>(line.bitmap.get()),line.posX,line.posY);}signature+=std::format(L"#{:.2f}|{}|{}|{}|{}|{}",view.scale,view.fontOverride,view.outline?1:0,view.background?1:0,view.bottomMargin,view.blockGap);- signature+=std::format(L"/{}x{}",rect.right,rect.bottom);+ signature+=std::format(L"/{}x{}/{}",rect.right,rect.bottom,view.targetLines);signature+=std::format(L"/{}/{}/{}/{}/{}",view.preview.zoom,view.preview.centerX,view.preview.centerY,view.videoWidth,view.videoHeight);return signature;}@@ -114,7 +114,23 @@ void updateSubtitleOverlay(HWND h,const std::vector<SubtitleLine>& lines,const Sformat.SetLineAlignment(StringAlignmentNear);format.SetFormatFlags(StringFormatFlagsNoClip|StringFormatFlagsMeasureTrailingSpaces);const auto& text=line.text;- entry.path->AddString(text.c_str(),int(text.size()),use,toFontStyle(line.style.bold,line.style.italic),float(dip(h,logicalSize)),RectF(0,0,layoutWidth,float(height)*2),&format);+ const bool positioned=line.posX>=0&&line.posY>=0;+ const float availableWidth=positioned?layoutWidth:std::max(1.0f,layoutWidth-float(dip(h,std::max(0.0,line.style.marginL)+std::max(0.0,line.style.marginR))));+ float fontPixels=float(dip(h,logicalSize));+ // Measure the complete cue without a height cap. A two-screen+ // 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){+ 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);+ if(measure(fontPixels).Height<=font.GetHeight(&graphics)*view.targetLines+1)break;+ fontPixels=std::max(minimum,fontPixels*.9f);+ }+ }+ const auto measured=measure(fontPixels);+ entry.path->AddString(text.c_str(),int(text.size()),use,toFontStyle(line.style.bold,line.style.italic),fontPixels,RectF(0,0,availableWidth,std::max(measured.Height+fontPixels*2,1.0f)),&format);entry.path->GetBounds(&entry.bounds);if(line.posX>=0&&line.posY>=0){entry.positioned=true;@@ -125,7 +141,13 @@ void updateSubtitleOverlay(HWND h,const std::vector<SubtitleLine>& lines,const S}// The caller passes secondary lines first, primary last: the loop below// lays them out bottom-up, so the primary cue ends up on the bottom.- float cursor=float(height)-padding-float(dip(h,view.bottomMargin));+ float cursor=std::max(padding+1,float(height)-padding-float(dip(h,view.bottomMargin)));+ float totalHeight=0;size_t stacked=0;+ for(const auto& entry:laid)if(!entry.positioned){totalHeight+=entry.bounds.Height;++stacked;}+ const float gap=stacked>1?std::min(float(dip(h,view.blockGap)),std::max(0.0f,(cursor-padding)/float(stacked*2))):0;+ const float space=std::max(1.0f,cursor-padding-gap*float(stacked?stacked-1:0));+ const float scale=totalHeight>space?space/totalHeight:1;+ if(scale<1)for(auto& entry:laid)if(!entry.positioned){Matrix shrink;shrink.Scale(scale,scale);entry.path->Transform(&shrink);entry.path->GetBounds(&entry.bounds);}for(size_t index=laid.size();index-->0;){auto& entry=laid[index];const int alignment=(entry.style.alignment>=1&&entry.style.alignment<=9)?entry.style.alignment:2;@@ -146,7 +168,7 @@ void updateSubtitleOverlay(HWND h,const std::vector<SubtitleLine>& lines,const Sconst float left=padding+marginL,right=float(width)-padding-marginR;const auto horizontal=horizontalOf(alignment);x=horizontal==StringAlignmentNear?left:horizontal==StringAlignmentFar?right-blockWidth:left+(right-left-blockWidth)/2;- if(vertical!=StringAlignmentNear)cursor=y-float(dip(h,view.blockGap));+ if(vertical!=StringAlignmentNear)cursor=y-gap;}Matrix translation;translation.Translate(x-entry.bounds.X,y-entry.bounds.Y);diff --git a/apps/veyra/ui/SubtitleOverlay.h b/apps/veyra/ui/SubtitleOverlay.hindex 96530d9a..ef234194 100644--- a/apps/veyra/ui/SubtitleOverlay.h+++ b/apps/veyra/ui/SubtitleOverlay.h@@ -28,6 +28,7 @@ struct SubtitleView {bool background=false;int bottomMargin=0; // extra logical pixels above the barint blockGap=6; // gap between the two languages+ int targetLines=2; // ordinary text only; 0 keeps automatic wrappingengine::PreviewView preview;double videoWidth=0,videoHeight=0;};diff --git a/apps/veyra/ui/SubtitleSettingsPanel.h b/apps/veyra/ui/SubtitleSettingsPanel.hnew file mode 100644index 00000000..2e80b723--- /dev/null+++ b/apps/veyra/ui/SubtitleSettingsPanel.h@@ -0,0 +1,100 @@+#pragma once+#include "Theme.h"+#include <functional>+#include <memory>++namespace veyra::ui {+struct SubtitleSettings {+ int pixels=22,margin=0,offset=0,lines=2,font=0;+ bool outline=true,background=false;+};+namespace subtitlePanel {+inline HWND window=nullptr;+struct State {+ HFONT font=nullptr;+ SubtitleSettings settings;+ std::function<void(const SubtitleSettings&)> changed;+ bool populating=true;+ UINT dpi=96;+};+inline LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM w,LPARAM l){+ auto* s=reinterpret_cast<State*>(GetWindowLongPtrW(h,GWLP_USERDATA));+ if(msg==WM_NCCREATE){s=static_cast<State*>(reinterpret_cast<CREATESTRUCTW*>(l)->lpCreateParams);SetWindowLongPtrW(h,GWLP_USERDATA,LONG_PTR(s));}+ if(!s)return DefWindowProcW(h,msg,w,l);+ if(msg==WM_CREATE){+ titleTheme(h);s->dpi=GetDpiForWindow(h);s->font=makeFont(h);+ auto control=[&](const wchar_t* cls,const wchar_t* text,int id,DWORD style,int x,int y,int width,int height){+ HWND c=CreateWindowExW(0,cls,text,WS_CHILD|WS_VISIBLE|style,dip(h,x),dip(h,y),dip(h,width),dip(h,height),h,HMENU(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);+ SendMessageW(c,WM_SETFONT,WPARAM(s->font),TRUE);themeControl(c);return c;+ };+ auto number=[&](const wchar_t* name,int id,int y,int value,int low,int high){+ control(L"STATIC",name,0,SS_CENTERIMAGE,16,y,174,30);+ HWND edit=control(L"EDIT",std::to_wstring(value).c_str(),id,WS_TABSTOP|ES_RIGHT|ES_AUTOHSCROLL,196,y,102,30);+ SendMessageW(edit,EM_SETLIMITTEXT,6,0);+ HWND spin=control(UPDOWN_CLASSW,L"",id+20,UDS_ALIGNRIGHT|UDS_ARROWKEYS|UDS_SETBUDDYINT|UDS_NOTHOUSANDS,0,0,0,0);+ SendMessageW(spin,UDM_SETBUDDY,WPARAM(edit),0);SendMessageW(spin,UDM_SETRANGE32,low,high);SendMessageW(spin,UDM_SETPOS32,0,value);+ };+ 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);+ 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);+ SendMessageW(background,BM_SETCHECK,s->settings.background?BST_CHECKED:BST_UNCHECKED,0);+ control(L"STATIC",L"字体",0,SS_CENTERIMAGE,16,232,80,30);+ 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);+ s->populating=false;return 0;+ }+ if(msg==WM_DPICHANGED){+ const UINT dpi=HIWORD(w);const auto* r=reinterpret_cast<const RECT*>(l);+ SetWindowPos(h,nullptr,r->left,r->top,r->right-r->left,r->bottom-r->top,SWP_NOZORDER|SWP_NOACTIVATE);+ HFONT font=makeFont(h);+ for(HWND child=GetWindow(h,GW_CHILD);child;child=GetWindow(child,GW_HWNDNEXT)){+ RECT bounds{};GetWindowRect(child,&bounds);MapWindowPoints(nullptr,h,reinterpret_cast<POINT*>(&bounds),2);+ SetWindowPos(child,nullptr,MulDiv(bounds.left,dpi,s->dpi),MulDiv(bounds.top,dpi,s->dpi),MulDiv(bounds.right-bounds.left,dpi,s->dpi),MulDiv(bounds.bottom-bounds.top,dpi,s->dpi),SWP_NOZORDER|SWP_NOACTIVATE);+ SendMessageW(child,WM_SETFONT,WPARAM(font),TRUE);+ }+ DeleteObject(s->font);s->font=font;s->dpi=dpi;return 0;+ }+ if(msg==WM_COMMAND&&!s->populating){+ const int id=LOWORD(w),notification=HIWORD(w);+ if(id==IDCANCEL){DestroyWindow(h);return 0;}+ bool changed=false;+ if(id>=101&&id<=104&¬ification==EN_CHANGE){+ wchar_t value[32]{};GetDlgItemTextW(h,id,value,32);wchar_t* end=nullptr;const long n=wcstol(value,&end,10);+ const int low=id==101?16:id==103?-30000:0,high=id==101?56:id==102?240:id==103?30000:8;+ if(end!=value&&!*end&&n>=low&&n<=high){int* field=id==101?&s->settings.pixels:id==102?&s->settings.margin:id==103?&s->settings.offset:&s->settings.lines;*field=int(n);changed=true;}+ }else if(id>=101&&id<=104&¬ification==EN_KILLFOCUS){+ const int value=id==101?s->settings.pixels:id==102?s->settings.margin:id==103?s->settings.offset:s->settings.lines;+ s->populating=true;SetDlgItemTextW(h,id,std::to_wstring(value).c_str());s->populating=false;+ }else if((id==105||id==106)&¬ification==BN_CLICKED){+ (id==105?s->settings.outline:s->settings.background)=IsDlgButtonChecked(h,id)==BST_CHECKED;changed=true;+ }else if(id==107&¬ification==CBN_SELCHANGE){s->settings.font=int(SendDlgItemMessageW(h,id,CB_GETCURSEL,0,0));changed=true;}+ if(changed&&s->changed)s->changed(s->settings);+ return 0;+ }+ if(msg==WM_CTLCOLORSTATIC||msg==WM_CTLCOLOREDIT||msg==WM_CTLCOLORBTN)return colors(msg,w,l);+ if(msg==WM_CLOSE){DestroyWindow(h);return 0;}+ if(msg==WM_NCDESTROY){DeleteObject(s->font);delete s;SetWindowLongPtrW(h,GWLP_USERDATA,0);window=nullptr;}+ return DefWindowProcW(h,msg,w,l);+}+}+inline void showSubtitleSettings(HWND owner,SubtitleSettings settings,std::function<void(const SubtitleSettings&)> changed){+ 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 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;+ const int x=std::clamp(p.left+dip(owner,40),int(monitor.rcWork.left),std::max(int(monitor.rcWork.left),int(monitor.rcWork.right)-width));+ const int y=std::clamp(p.top+dip(owner,80),int(monitor.rcWork.top),std::max(int(monitor.rcWork.top),int(monitor.rcWork.bottom)-height));+ subtitlePanel::window=CreateWindowExW(WS_EX_TOOLWINDOW,wc.lpszClassName,L"字幕设置",WS_CAPTION|WS_SYSMENU|WS_CLIPCHILDREN,x,y,width,height,owner,nullptr,wc.hInstance,state);+ if(subtitlePanel::window)ShowWindow(subtitlePanel::window,SW_SHOW);+}+inline bool subtitleSettingsDialogMessage(MSG& message){return subtitlePanel::window&&IsDialogMessageW(subtitlePanel::window,&message);}+inline void closeSubtitleSettings(){if(subtitlePanel::window)DestroyWindow(subtitlePanel::window);}+}diff --git a/apps/veyra/ui/UiPreferenceStore.h b/apps/veyra/ui/UiPreferenceStore.hindex ded89f33..b1f72bd9 100644--- a/apps/veyra/ui/UiPreferenceStore.h+++ b/apps/veyra/ui/UiPreferenceStore.h@@ -18,6 +18,7 @@ struct UiPreferences {// and the dual-language switch.bool subtitleOutline=true,subtitleBackground=false,subtitleSecondLanguage=false;int subtitleMargin=0,subtitleFont=0;+ int subtitleLines=2;// 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.@@ -33,7 +34,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>6)||!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>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(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,12 +49,13 @@ public: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>=7&&(!(file>>read.subtitleLines)||read.subtitleLines<0||read.subtitleLines>8)){corrupt_=true;return result;}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 6\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)<<'\n';+ 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';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/docs/CAPTURE_SCREENSHOT_SUBTITLE_SYNC_PLAN_2026-09-19.md b/docs/CAPTURE_SCREENSHOT_SUBTITLE_SYNC_PLAN_2026-09-19.mdindex 1dd8b03f..eba24cbb 100644--- a/docs/CAPTURE_SCREENSHOT_SUBTITLE_SYNC_PLAN_2026-09-19.md+++ b/docs/CAPTURE_SCREENSHOT_SUBTITLE_SYNC_PLAN_2026-09-19.md@@ -1,6 +1,6 @@# 采集、HDR截图、字幕与防撕裂修复方案-日期:2026-09-19。范围:本轮代码调查和施工方案,未修改产品实现,未构建或复现实卡问题。保留此前 XeSS 等未提交修改。用户报告的 573 暂按 GC573 理解,准确型号、分辨率、RGB24/32、音频及帧率日志待补充。+日期:2026-09-19。已在 `codex/capture-ui-sync-20260919` 实施并完成本机针对性构建与回归;开工前已有修复存档于 `7761f34`。用户确认圆刚设备且没有日志,本轮不以补日志为施工前提。实卡和物理显示验收未完成,结果以 `docs/CAPTURE_UI_SYNC_ACCEPTANCE_2026-09-19.md` 为准,下文保留原设计与验收目标。## 1. GC551 无音频diff --git a/docs/CAPTURE_UI_SYNC_ACCEPTANCE_2026-09-19.md b/docs/CAPTURE_UI_SYNC_ACCEPTANCE_2026-09-19.mdnew file mode 100644index 00000000..6e4d04f6--- /dev/null+++ b/docs/CAPTURE_UI_SYNC_ACCEPTANCE_2026-09-19.md@@ -0,0 +1,45 @@+# 采集、截图、字幕与显示同步修复记录++日期:2026-09-19。分支:`codex/capture-ui-sync-20260919`;前置存档 `7761f34`。++## 修复及证据++- 音频:PCM 与压缩音频回调原来因 GetTime 失败而拒绝有效数据。现在缺失时间戳时使用样本数连续计时,断点重新锚定,有真实时间戳时优先使用。六项时钟合同检查通过,WASAPI 抖动输入测试通过。+- 音频:确认 Dolby/DTS 的解码和直通入口误用只接收 PCM 的 NativeSink。新增独立压缩音频 sink,保持 codec/媒体类型变化必须重连,压缩包不套 PCM 对齐限制。回归包含无 WAVEFORMAT、无时间戳、奇数字节包、空包拒绝、codec 变化拒绝、未知类型拒绝及原 PCM/视频合同,退出 0。+- 音频:发现 pin 和选择格式时补读 IAMStreamConfig::GetFormat,兼容枚举失败但当前格式可用的驱动。没有按品牌随意绑定麦克风,没有给 GC551 套 GC553 私有开关。此驱动兼容分支通过编译与代码检查,尚无对应实卡证据。+- 采集:callbackFps 改为近两秒窗口,停止到帧一秒后归零;不再用启动以来的累计平均代表当前输入。记录回调到锁获取、到复制完成的耗时与字节数,保留设备协商及 mailbox 丢弃诊断。没有软件重复帧凑 60,也没有扩大队列。**尚不能认定 GC573 的 57fps 是读数问题或已修复真实掉帧。**+- HDR 截图:增加源格式、尺寸与各阶段 HRESULT;继续 FP16 scRGB JPEG XR 无损编码、解码完整性检查和原子落盘,不覆盖已有文件。生产路径撤掉逐位相同比较门禁,独立测试保留像素比对。真实视频 NR+HDR 直接处理图截图通过;真实引擎四组合各播放/暂停两次,共八张截图保存和重开通过。本机 SDR 显示器上的引擎组合测试走 SDR 输出,不能冒充 HDR 显示器验收。用户原始错误本机未复现,不能据此断言已经定位其根因。+- 字幕:轨道仍使用选择菜单;样式/延时使用常驻窗口,字号、底部距离、延时、目标行数、字体、描边、背景可连续调节。默认目标两行,0 为自动,1–8 自定义;完整测量文字后缩放布局,不通过丢弃第三行实现两行。偏好格式 v7,v6 迁移默认两行。连续 20 次编辑、无效输入、失焦恢复、延时、复开、关闭、宿主销毁测试通过。补充跨 DPI 调整和初始工作区定位;复杂 ASS/双语/PGS/多 DPI 视觉矩阵尚未全部验收。+- 音量:上下键每次 5%,支持重复;普通模式视频区域及音量条滚轮调整音量,高精度滚轮累计;调节解除静音。文本框、列表、其他滑杆、弹窗不抢键。专业模式视频滚轮继续缩放。音量条跟随引擎值刷新。未添加原方案的独立 OSD 或滚轮用途设置,本轮以用户要求的快捷调节为范围。+- 显示同步:区分帧节奏和显示同步。XeSS 保留 SDK 调度,只将所选 VSync 传给代理 swapchain,不叠加外部等待;完全关闭时 VSync 和应用等待均关闭。DLSS/普通 DXGI 的 VSync 不再依赖最大排队 API 成功。记录实际 Present interval/flags/HRESULT,计时不包括新增日志开销。自动模式明确 VRR 未知;FSR 仍明确显示同步未支持。++## 实际运行++构建入口:`scripts/build-isolated.ps1 -Root . -BuildDirectory E:/项目/Veyra/build/slider-reset-20260919 -DependencyCache E:/项目/Veyra/build/frame-pacing-20260918/CMakeCache.txt -TempDirectory E:/项目/Veyra/tmp/capture-ui-sync-20260919 -DisplayVersion 1.4.2 -Targets ...`。++测试统一使用 `scripts/run-short-test.ps1`,每次不超过 240 秒,GPU 用例顺序执行。日志目录 `E:/项目/Veyra/logs/capture-ui-sync-20260919/`,证据目录 `E:/项目/Veyra/tests/capture-ui-sync-20260919/`。++| 用例 | 实际结果/日志前缀 |+| --- | --- |+| PCM/压缩音频/视频 sink 合同 | 退出 0,capture-color-final |+| 音频抖动输入 | 退出 0,audio-jitter |+| UI 偏好迁移与时钟合同 | 退出 0,ui-contract-final |+| 字幕面板连续调节 | 退出 0,subtitle-panel-final |+| NR+HDR 真实视频图直接截图 | 退出 0,hdr-real |+| 引擎截图四组合×播放/暂停 | 退出 0,screenshots-final |+| HDR 高光、宽色域独立像素比对 | 退出 0,hdr-integrity |+| XeSS 4X+VSync,6秒 | 退出 0,xess4-vsync;Present sync=1 flags=0 |+| XeSS 2X+完全关闭,6秒 | 退出 0,xess2-off |+| DLSS 4X+VSync及生命周期 | 退出 0,dlss4-vsync-lifecycle |++测试素材 `E:/项目/Veyra/tests/1.4.2beta/visible-scene.mp4`。Pacing 参数依次为素材、证据目录、模式、显示策略、倍率、秒数、场景;上述三个用例分别为 `0 1 4 6 xess`、`-1 1 2 6 xess`、`0 1 4 6 lifecycle`。++过程失败如实保留:首次 UI 编译出现 std::max 类型不一致,修正后通过;一次构建指定不存在的 veyra_capture_source_tests,改用实际目标;截图矩阵首次错误地假定 SDR 显示器也生成 JXR,修正测试预期为实际输出合同后八项通过。这不是原用户 HDR 错误复现。++## 上游核对与限制++核对 OBS `obsproject/libdshowcapture` 固定提交 `c13d4b7b0c66979396ba0a9060c9aafc15bb7b22`,本地只读参考 `E:/项目/Veyra/deps/libdshowcapture-audit-20260919`。重点是 `source/device.cpp` 的 GetTime/SetupAudioCapture/GetFormat。没有复制其实现代码,也没有引入运行库。++本机未枚举到 GC551/GC573/VC-007PRO。不能宣称两张圆刚卡无声和掉帧已实测解决;后续实卡需比较请求/连接帧率、实际回调、复制耗时、处理 FPS、mailbox 丢弃及音频协商 HRESULT。不同显卡和驱动、HDR 显示器、VRR、物理屏幕撕裂与到眼延迟仍需独立验收。普通软件截图不能证明无撕裂。++本轮没有打包、推送或发布;构建程序位于 `E:/项目/Veyra/build/slider-reset-20260919/veyra.exe`。没有新增 SDK、模型或运行库到源码 Git。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 876d4fdf..586cde08 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -4603,3 +4603,46 @@ Blackwell 上会改变一条已经正常工作的路径,无法区分"补丁生4. `veyra_popup_selector_tests.exe` 退出 0,包含此前字幕弹窗鼠标/键盘案例;`scripts/run-short-test.ps1 ... --smoke-empty --smoke-seconds 5` 主程序退出 0。日志及截图:`E:/项目/Veyra/logs/slider-reset-20260919/`(final-build.log、reset-test.log、popup-test.log、app-smoke.log、reset-after-click.png)。临时文件:`E:/项目/Veyra/tmp/slider-reset-20260919/`。未打包。此次为设置 UI 修改,未执行 NVIDIA Create/Evaluate、视频画质或实卡补帧测试,不据此宣称处理链验收。++## 2026-09-19 采集音频、HDR 截图、字幕和显示同步++开工已有修改存档 `7761f34`,隔离分支 `codex/capture-ui-sync-20260919`。完整变更、执行命令、过程失败和未验收范围见 `docs/CAPTURE_UI_SYNC_ACCEPTANCE_2026-09-19.md`,施工方案状态已更新。++- CaptureCardSource/NativeCaptureSink:缺时间戳音频连续计时、驱动当前格式兜底、专用压缩音频接收端、近两秒输入 FPS、回调锁等待/复制耗时日志。已确认压缩音频错误连接 PCM 接收端;不能推断就是 GC551 用户的根因。+- ImageExportSink:各阶段错误诊断,撤掉生产截图逐位相同比较门禁,保留 FP16 无损编码和文件完整性;独立像素回归通过。NR+HDR 真实视频直接图截图通过,SDR 显示器引擎四组合八张截图通过;原用户故障未复现。+- SubtitleSettingsPanel/SubtitleOverlay/UiPreferenceStore/AppShell:常驻连续编辑、完整文本测量和目标行数、v7 偏好迁移、DPI/工作区处理、音量键/滚轮与滑杆反馈。+- VideoPresenter/PresentSink/SettingsWindow:XeSS VSync 交给提供方,完整关闭测试确认 `sync=0 flags=0x200`;XeSS 4X VSync 确认 `sync=1 flags=0`,DLSS 4X 生命周期回归通过。自动 VRR 未知、FSR 未支持如实提示。++构建复用 `E:/项目/Veyra/build/slider-reset-20260919`,依赖缓存 `E:/项目/Veyra/build/frame-pacing-20260918/CMakeCache.txt`;`scripts/build-isolated.ps1` 通过,日志 build-final.log/build-reviewed.log,最终增量构建 build-delivery.log。测试用 `scripts/run-short-test.ps1` 单次 60–240 秒:capture-color-final、audio-jitter、ui-contract-final、subtitle-panel-final、hdr-real、hdr-integrity、screenshots-final、xess4-vsync、xess2-off、dlss4-vsync-lifecycle 均退出 0。++日志目录 `E:/项目/Veyra/logs/capture-ui-sync-20260919/`,测试证据 `E:/项目/Veyra/tests/capture-ui-sync-20260919/`,进程 TEMP/TMP `E:/项目/Veyra/tmp/capture-ui-sync-20260919/`。OBS 只读参考源码 `E:/项目/Veyra/deps/libdshowcapture-audit-20260919`,固定提交记在验收报告,未复制上游实现。早期编译类型错误、错误构建目标、截图测试错误预期及修正均保留记录。++最终 build-delivery.log 构建退出 0;主程序 `--smoke-empty --smoke-seconds 5` 退出 0(app-final),工作目录设为本轮 E 盘测试目录。最终面板回归 subtitle-panel-delivery 退出 0。`git diff --check` 通过。未使用其他 Agent,审查为本人代码复查及上述回归,不冒充独立 Reviewer 验收。++用户确认圆刚且无日志,继续按代码证据修复;本机未连接 GC551/GC573,真实 57fps、实卡无声、HDR 显示器、物理撕裂和完整字幕视觉矩阵均未宣称通过。未打包、未推送、未发布,未加入 SDK/运行库/模型。++## 2026-09-19 三份用户日志联合诊断与修复方案++用户补充 GC573 RGB53fps、5080 采集 XeSS 卡顿和 5070 Ti PS5 串流 XeSS 卡顿日志,要求联合排查并写方案。本轮保留全部已有工作区改动,仅新增 `docs/XESS_GC573_LOG_REPAIR_PLAN_2026-09-19.md` 及本记录。++- 使用 `Get-FileHash`、`Select-String`、`rg`、`Get-Content` 和 `git diff` 核对日志、代码和本地 XeSS 3.0.2 返回码。原始文件路径、SHA256、时间及关键行号见方案;没有复制用户日志或新建运行产物。+- GC573 效果关闭区间 59.560 秒收到/处理 3186 帧,约 53.49fps,丢弃计数不变。确认不是仅 FPS 显示误差;驱动回调内 RGB 扩展和锁为待测风险,尚未证明唯一根因。+- PS5 接收/解码基本 60fps、队列为零,同期后级处理掉帧和历史重置增长,呈现调用 P95 约 17–18ms。方案优先追踪呈现反压和历史恢复,未将其归因于采集卡或整段网络无丢包。+- 旧 XeSS 路径强制清掉 VSync,已有工作区修复仍需提供方最终呈现及实屏验证。5080 日志主动 60->30 限帧与异常丢弃分开;SDK result=3 按头文件解释,不猜作性能不足。+- 本轮未新增产品修复、未构建或运行硬件测试、未打包发布。此前全软件审查问题保留为独立修复项。方案规定后续输出到 `E:/项目/Veyra/{build,tests,logs,tmp}/xess-gc573-20260919/`。++### 5080 功耗波动追加排查++用户指出主要症状是工作量不均与功耗起伏。重新按设置不变窗口计算 received/processed/generated/drop/reset 增量,并对照 engine-stall、present-cost、capture-age-stall、XeSS scheduler 及 EngineController/XessPresenter 代码,扩展方案第2.4节和XeSS施工优先级。++- 原生4K30、capture60To30=false 的11:27稳定段反复约69ms主循环长帧,其中调度/呈现约63ms,CPU图提交约3–4ms。11:22另有单次Present 60.573/55.485ms,图GPU span约14/13ms(不覆盖完整提供方)。主动限帧不能解释这些长帧。+- 12:58:11.738至12:58:12.743,固定revision下生成增量降为54、掉帧和重置各+6,NR P95仍14.346ms;随后恢复。说明存在超出主动限帧的工作连续性问题,但无功率曲线,不能宣称瓦数因果已测实。+- 检查输入、NR、预算、XeLL、媒体期限、提供方节奏、重置、日志/重建和显存等方向;方案要求区分GPU执行与CPU等待引起的供给空洞,不通过取消reset、忙等或无限排队取巧。+- 命令为PowerShell `Select-String`/正则键值解析和`rg`/`Get-Content`只读代码。初次时间排序使用DateTime发生本地时区转换,后改DateTimeOffset复核,文档统一使用原日志Z时间。未运行新构建或硬件测试,本轮仅更新方案与本记录。++### DLSS 4X/6X 受限追加排查++- 核对 EngineController、FgRecoveryBudget、LivePairLatency、FrameMetrics、EnhanceGraph 与现有 LiveGpuSchedulerTests。确认计算前整组拒绝、下一次完整暖机不输出的放大机制;Present成本只扣allocator等待,显示阻塞仍参与预算。未将这些机制直接宣布为所有用户唯一根因。+- PowerShell `Select-String`、正则字段摘取核对5080日志:87条admission采样均true,11:35:30至34累计拒绝固定9,但暖机/过期增长且中间有120fps提交。避免将累计拒绝误算为每秒新增,也避免把XeSS套用DLSS门禁。+- 方案新增2.5节:分离计算成本与显示反压、逐子帧期限、连续恢复、供给阻塞及对应测试矩阵。预算数值例子仅为算式推演,没有冒充实机结果。+- 本轮仅修改方案与WORKLOG,未改产品代码、未构建、未运行新单测或实卡测试、未生成包或发布;没有新增仓库外产物。diff --git a/docs/XESS_GC573_LOG_REPAIR_PLAN_2026-09-19.md b/docs/XESS_GC573_LOG_REPAIR_PLAN_2026-09-19.mdnew file mode 100644index 00000000..227d09cf--- /dev/null+++ b/docs/XESS_GC573_LOG_REPAIR_PLAN_2026-09-19.md@@ -0,0 +1,159 @@+# XeSS 撕裂、卡顿与 GC573 RGB 掉速:三份日志联合排查++日期:2026-09-19。状态:诊断与施工方案,尚未实施本方案新增修复。++当前分支 `codex/capture-ui-sync-20260919` 有上一轮未提交修复,保留原状。本轮不构建、不打包、不发布。已有修复的验收范围见 `CAPTURE_UI_SYNC_ACCEPTANCE_2026-09-19.md`,不能当作这三位用户通过的证据。++## 1. 输入与证据边界++原始日志均在 `C:/Users/123/Desktop/`;下文时间保留日志原始 Z 时间,不换算。文件分别为:++|编号|文件|主要来源|SHA256|+|---|---|---|---|+|A|画面撕裂,xess卡顿的,功率不稳定.log|RTX 5080,ASUS 4K PRO,P010/NV12 多次切换|EF8CC4897FF7D75751DF374D856509871412D19B1C6E9034A4B3A512BDDD6CF8|+|B|573 采集RGB60fps模式卡53fps.log|RTX 5090,GC573,多种采集模式|82AD479467D20CEDDEA77B61D39DCF963142631B0764CC85D4ED2B188200C8A4|+|C|画面撕裂 xess卡.log|RTX 5070 Ti,PS5 RemotePlay,1080p60 H.265|9DB419ACD30FD24FE86DBF2519A7F2D4384CAA9F3119AC369C64F0A0620128C8|++按会话、格式、设置 revision 和提供方分别分析。C 不是采集卡;其通用 capture-timing 日志 callbackFps=0 不代表无输入。没有功率采样或物理屏幕扫描证据,不能从这些日志测出瓦数波动原因或眼睛看到的延迟。++## 2. 已证实与尚待证明++### 2.1 GC573 确有约 53.49fps 的输入吞吐,不能仅修 FPS 显示++B 第 18034–18050 行:08:24:26,协商 3840x2160、60fps、RGB24,stride=11520,样本 24883200 字节;请求 3 个缓冲,实际返回 4 个。实际缓冲数量不等于已测得的排队延迟。++效果关闭后的稳定区间:++|时间|received|processed|dropped|处理 CPU P95|GPU ready P95|Present CPU P95|+|---|---:|---:|---:|---:|---:|---:|+|08:28:00.825,第19534行|11337|10348|7|2.092ms|0.769ms|0.390ms|+|08:29:00.385,第19921行|14523|13534|7|2.014ms|0.683ms|0.289ms|++59.560 秒内 received 和 processed 都增加 3186,即约 53.49fps,丢弃数未增长。NR/Flow/SR/FG 阶段耗时为零,残留的 NR 累计计数不能解释成仍在运行。问题在完成采集回调之前或回调自身,不是这一段增强渲染算不过来。++不能据此断言硬件只输出 53fps:`CaptureCardSource.cpp` 的 received 在复制后增长;`NativeCaptureSink::Receive` 持锁调用回调,回调再持采集锁执行 `copyCaptureSample`。`CaptureMediaType.h` 的 RGB24 路径逐像素扩展 BGR24 到 BGR0,发生在驱动送帧线程。软件回调反过来阻塞驱动是明确风险,但旧日志没有复制耗时,尚不能定为唯一根因。++### 2.2 XeSS 防撕裂存在独立的接入问题,当前工作区已有修复++C 第 166、944 行分别记录 requested=true/2/2、true/0/1,而 effective=false;旧实现 `VideoPresenter::configurePresentation` 和 `PresentSink::configurePacing` 在 XeSS 下直接清掉 vsync。选择了显示同步却被软件关闭,属于代码确认的缺陷。++当前未提交改动已经将 XeSS 的显示同步交给提供方,同时不启用应用层队列等待。上一轮验证的是外层 Present 参数 sync=1/flags=0,不是最终生成子帧扫描,也不证明用户屏幕已无撕裂。新实现 effective.enabled=false 仅表示应用节奏控制关闭,不能再把它单独解释为 VSync 关闭。必须补充提供方最终呈现的证据。++VSync 解决扫描时换帧导致的撕裂,不能自动解决输入不足、帧间隔不均或历史频繁失效。++### 2.3 PS5 日志把 XeSS 卡顿指向解码之后的链路++C 06:35:14–24 的 remoteplay-progress:接收/解码约 58–60fps,多数为 60,received=decoded、queue=0、errors=0。该窗口 transport/assembly errors=0,packetWindowLost=0;这些是窗口指标,不能推断整个文件从未丢包。++同段 capture-timing:06:35:15.565 至 06:35:24.660,received 从 214 到 756,processed 从 126 到 630,dropped 从 86 到 124,historyResets 从 11 到 49。对应输入约 59.59fps、处理约 55.42fps,新增 38 次丢弃和 38 次重置。Present CPU P95 多次约 17–18ms,GPU ready P95 约 20–21ms;这些分位数不能相加当作单帧总延迟。++代码 `EngineController.cpp` 对 Drop/预览跳帧触发 temporalBreak;XeSS 按 motion 前帧身份不连续等条件 reset。因此“后端等待拖慢消费 -> mailbox 覆盖 -> 历史重置 -> 补帧不连续”是优先验证的机制。日志数量相关与代码路径支持此方向,但还缺逐帧等待归属和 reset 原因,不能宣称完整因果已证明。不能通过取消必要 reset 掩盖掉帧,否则会把不连续运动信息用于插帧。++C 的 inBurst 间隔曾出现 0.385–7.476ms、0.608–11.406ms,60fps 4X 的名义间隔是 4.167ms。现有 inBurst 统计排除了批次边界,既不能代表完整输出均匀,也不是扫描间隔。++### 2.4 5080 功耗波动:调度长帧与生成量变化是主线,主动限帧仅是统计边界++用户追加说明:5080 的主要症状是功耗忽高忽低。此前强调最后一段主动限帧不足以解释这个症状。进一步检查发现,无主动限帧的原生 4K30 段也有持续调度长帧;不能将其归为正常 60->30 行为。++**原生 30fps、设置不变的证据:**++- 11:22:20.299(第833行),source=1846:增强图 GPU span=14.059ms,readyObservedAge=21.215ms,deadlineWait=12.168ms,present=60.573ms,callbackToReturn=93.955ms。11:22:21.994(第848行)另一次 present=55.485ms,图 GPU span=13.027ms。这里是单帧字段,不是把不同 P95 相加。GPU span 不包含完整 XeSS 内部工作,Present 也不是纯睡眠。+- 11:27:25–34,revision=11,反复出现 engine-stall 总计约 68–69ms,其中 scheduleAndPresent 约 62–64ms,graphSubmit CPU 约 3.4–4.0ms。第3541行确认 capture60To30=false、rateSkipped=0。不是用户切换设置期间一次初始化,也不是主动跳一半帧。+- 11:27:32.198 -> 11:27:33.228,输入约 30.1fps、处理约 27.2fps,生成帧增量约 61.2fps,新增 3 次 dropped 和 3 次 historyReset;NR P95 约 14.50ms。11:27:33.158 同期 SDK result=3、framesPresented=1。输入仍在,增强/生成/输出工作量不再均匀。+- 11:22 的 NR P95 多数约 13–14ms,Present P95 却从约 5–6ms 到 30ms 以上变化。P95 只支持窗口差异,不能反推每一帧或具体瓦数。++**即使在主动限帧段,也有额外异常:**++12:58:11.738 -> 12:58:12.743,received +60、processed +27、generated +54、dropped +6、historyResets +6;此前约一秒 generated +93。NR P95 两点都是 14.346ms,Present P95 从 1.966ms 到 24.590ms,设置 revision=5 不变。随后恢复到每秒约 90 个生成帧。该段主动限帧目标稳定在 30,不能解释生成量短暂跌到约 54;这些计数存在异步完成边界,短窗口比例不是逐对生成成功率。++**多方面核对结果:**++|方向|日志/代码事实|当前判断|+|---|---|---|+|输入突然断流|原生30段增量输入仍约30;capture-discontinuity 记录集中在每次连接的最初几帧|不能用开流约100ms缺口解释几分钟后的反复卡顿;短时到达抖动仍需逐帧验证|+|NR 每帧工作量大幅变动|所选异常窗口 NR P95 相对稳定,生成量与等待变化更明显|不支持把 NR 算力波动定为主因;没有完整单帧 GPU 序列,不能完全排除|+|补帧主动预算抑制|采集 XeSS 不走图内 FgRecoveryBudget admission;日志无 xess-fg-gate 事件|不能套用 DLSS 预算反复拒绝的旧诊断;enable/reset 的变化仍须检查|+|呈现拖住下一次增强|单 GPU owner 主循环同步调用 presenter.present;队列容量2,推进过程中 Present 返回前不能继续该线程的源处理|已确认代码耦合,且长帧主要在调度/呈现;是最高优先级机制|+|多层等待相互影响|当前路径有 XeLL beginInput sleep、采集时间线 deadline、提供方子帧 scheduler|各自有不同职责,不能仅数等待点就认定重复;需量出各自期限、用时及 GPU 空洞|+|提供方子帧节奏|11:22:02.424 inBurst min=0.615ms/max=8.879ms;11:22:06.438 min=0.664ms/max=8.344ms,名义目标8.333ms;refused/bypassed=0|有短间隔,且该段不是 fallback 所致;只覆盖批内,缺批间完整证据|+|场景/历史变化|掉帧、historyReset、AMD OF reset 与生成下降同段出现|需区分 Drop、scene cut、参数变更、ID不连续,不能一律取消reset|+|CPU日志/UI/重建|所选稳定长帧 periodicLogs/tail 很小;初始化及切换另有秒级stall|不能把切换重建计入稳态;没有证据表明日志写入是所选长帧主因|+|显存/驱动功率管理|初始化预算约15GiB,记录的图下限约1GiB,但不含全部SDK分配;无瓦数/频率/节流遥测|没有足够证据认定显存耗尽或降频;也不能据初始化预算排除运行时驻留问题|++最符合当前证据的解释是:调度/呈现长帧打断主循环供给,部分源帧被覆盖并触发历史重置,生成工作量随之下降,再恢复。它可以导致用户观察到的负载/功耗起伏,但功耗因果仍须同步遥测确认;不能把 Present 60ms 直接称为 GPU 空闲60ms。++A 最后一段输入约 59.95fps,但明确启用了 60 -> 30 的采集限帧。结束时 sourceAccepted=3190、sourceSkippedBeforeGraph=3189,约一半跳过与用户设置一致。需另查 mailbox 丢弃和重置,不能把 3189 全计入故障。++A 11:22:02.918 有 enabled=0/framesPresented=1,11:22:06.942 有 enabled=1/result=3/framesPresented=1,说明存在没有达到 4X 的时段。本地 XeSS 3.0.2 头文件将 3 定义为 WARNING_TOO_FEW_FRAMES,注释为 Frame ID should be over 0;不得误译为显卡性能不足。需要将它与 enable/reset/Frame ID 串联定位。++原生 P010/NV12/RGB 路径与此前审查发现的压缩采集包丢弃、EAGAIN、重排 PTS 问题不是同一条路径,不把后者强行当成这三份日志的根因。++## 2.5 DLSS 4X/6X 补帧受限追加审查++用户追加反馈多用户4X/6X受限。不能假设补帧成本恒小:当前 `src/pipeline/EnhanceGraph.cpp:1902` 对4X执行3次、6X执行5次 Evaluate,另有资源转换、状态读取和提交;实际成本须按分辨率、设备、倍率测量。GPU低利用率也可能是输入不足、显示反压或软件拒绝工作。++### 已确认的代码机制++1. `EngineController.cpp:1186` 的计算前拒绝更新 `lastFgRejected100ns`,界面在约1秒内标为受限。该标志不是GPU饱和判据。XeSS走呈现端,不使用此图内预算,必须分别诊断。+2. `EngineController.cpp:1289` 的 Present 服务样本只扣除 allocator 等待,仍包含 DXGI/驱动阻塞;`FgRecoveryBudget::admit` 再将其P95加到预计剩余工作。显示反压可以导致尚未计算的整组FG被拒绝。当前单测甚至明确覆盖“80ms Present导致拒绝”,但只验证样本过期恢复,未覆盖周期性显示阻塞与持续生成。+3. `EnhanceGraph.cpp:1892` 一次决定整组是否执行;拒绝置 `fgHistorySkipped_`。下一次获准会 reset 并执行全部子帧,但 `hasGenerated=false`,再下一对连续获准才可能输出。一次拒绝至少损失本组和随后暖机组的生成机会;交替拒绝/获准可以持续算暖机却没有有效补帧。不能直接删掉必要reset,否则历史错误会变为画面故障。+4. 预算使用最后一个子帧的期限,呈现按每个子帧期限另做过期淘汰(采集容差10ms)。所以“获准计算”不保证3/5个子帧全部赶得上。`LivePairLatency` 当前只允许比旧相位更早,不能超出“一源帧间隔+base成本上限”;需要检查其对较慢FG和6X首子帧是否足够,不能未经测量直接全局增加延迟。+5. 预算的 graph span 是同队列首尾GPU时间戳包络,包含依赖等待,并非各阶段纯执行耗时之和。CPU elapsed 也不等于GPU已完成量:admission前有条件提交点,但最后一段base在admission后才提交。必须拆开执行、依赖、供给空洞和显示等待,不能重复计费或把CPU忙碌当GPU进度。++算式示例(仅模型,不是实机测试):预算预测12ms、base进度抵扣2ms、剩余期限8ms,容差10ms时,无Present等待需要10ms,可获准;Present P95为17ms时需求变成27ms,被拒绝。它证明等待可触发受限,不证明17ms阻塞必然可以安全忽略;显示吞吐确实不足时仍需有界背压。++### 日志边界与反证++A的11:35:30.863至11:35:34.929,`fgSkippedBeforeEval`始终为9,是累计值,不能把每行9都算成持续新拒绝。11:35:31/32有约121/120fps提交;11:35:33跌至94,epoch100->102、暖机15->21、生成过期3->7,而计算前拒绝未增加。这次下降更符合历史重置/过期,不能全归预算门禁。A的87条节流admission日志均为true,但累计计数证明存在漏采的拒绝事件,现有每秒采样不能还原其当时成本。++另外检查桌面旧5060日志,未找到非零 `fgSkippedBeforeEval`,不能用它证明本次4X/6X预算根因;旧5090指定日志当前不存在。本轮没有覆盖所有反馈用户的6X失败现场,也没有新增硬件实测。++### 修复顺序与验收补充++1. 优先记录拒绝事件的原因和分项成本:预算、首/末子帧期限、显示等待、GPU阶段/依赖、来源间隔、倍率、暖机状态。按窗口聚合并保留首个状态转换,避免逐帧大量日志造成干扰。UI区分计算前拒绝、过期、暖机、SDK无效、显示吞吐上限。+2. 将必需计算成本和显示反压分开建模;保留有界显示队列。不能仅把Present项归零,也不能通过关闭预算一律猛算来宣称修复。基于首子帧就绪与后续子帧节奏校准期限,确认同一等待未被重复扣除。+3. 恢复策略必须能完成连续的暖机与有效生成,避免交替拒绝反复暖机;在真实源断点时仍reset。对所有子帧都过期、只有前几个过期和短暂显示阻塞分别验证,不制造假帧或修改FPS计数。+4. 检查单owner同步Present及上一批GPU完成等待是否阻断可安全准备的下一帧;先量化,再在现有资源所有权和有界队列内修复,与5080工作连续性排查共同推进。+5. 增加受控时间线回归:2X/4X/6X,30/59.94/60源,周期性17/33/80ms呈现阻塞,一次拒绝、交替拒绝、连续恢复、样本老化、真实GPU超预算和输入断点。断言有效生成恢复、每类丢帧原因、队列上限及历史正确性,而不是只断言admit返回值。再同参数120秒实机对照,分别报告FG执行耗时、有效生成、显示提交、过期和恢复时间;30/40/50系验收独立记录。++## 3. 施工顺序++### P0:把每次等待和丢帧归属测清++1. 在现有诊断中增加会话内增量:实际来源类型、输入到达、解码完成、图提交/完成、呈现入队、提供方调用开始/返回。绑定 source ID、epoch、revision;统计固定窗口 P50/P95/P99/max,不逐帧刷生产日志。+2. 区分输入 mailbox 覆盖、主动限帧、性能跳过、生成失败、显示淘汰;reset 记录原因与前后源帧身份。+3. 同步状态拆成用户请求、应用等待、提供方调度、实际 sync/tearing flags。提供方生成帧记录全序列间隔,包含批次边界,并解码 SDK 返回码。+4. 利用上一轮已有回调锁等待/复制指标,补齐回调入口/出口、驱动 PTS、协商格式和 allocator;确认诊断不会显著拉低吞吐。++### P1:XeSS 呈现与历史连续性++5080 优先做同输入三组120秒对照:NR only、XeSS4X only、NR+XeSS4X;固定原生4K30、画布和显示模式,排除主动限帧与参数切换。分别测增强图 GPU、XeSS 提供方 GPU、XeLL sleep、媒体 deadline、proxy Present 和最终子帧调度;同步采功率/核心频率/显存/利用率/节流原因,并用共同单调时钟对齐。无5080时本机只验证机制,不能代替该用户功耗验收。++必须用 GPU 时间线或等价可验证的队列证据区分“Present 在等 GPU 执行”和“CPU 等显示导致下一批 GPU 工作未提交”。如果确认后者,优先在现有有界调度器内调整准备/提交顺序,让允许独立的下一源帧准备利用等待时间;保留 XeSS tag->Present 期间同队列资源状态和消费者 fence 合同。不能直接把 Present 搬到另一个线程并同时复用纹理。若涉及独立队列/线程,另列资源所有权和GPU验证矩阵后实施。只在测量证实期限重复时合并等待,不能同时撤掉所有节奏控制或用忙等耗电“稳定功率”。验收目标是减少稳态长帧和异常生成缺口,不是强求瓦数恒定。++1. 基于现有 VSync 改动验证提供方最终 Present;完全关闭仍必须生效。低排队/Reflex 等应用等待不叠到 XeSS 调度器上,界面说明实际生效范围。+2. 分解 Present 内等待、GPU ready 和图线程被阻塞的位置。检查资源生命周期、共享 GPU 所有权及锁持有范围;有证据后缩短阻塞,不用无界队列换表面高 FPS。+3. 沿用已有 XeSS 原生 scheduler 接入、零 render-time 反馈修复;核对用户包是否包含这些修改。2X 与多帧路径分别验收,避免重新引入双重等待。+4. 核对 enable/reset/Frame ID:断点当前真实帧正确入历史,下一对连续帧恢复;重复重绘不生成。保留必要历史重置,不通过拖动/转身时停止生成、重复原帧或改计数掩盖问题。++### P1:GC573 RGB60 回调与协商++1. 同卡同信号,分别运行 OBS 与 Veyra,记录实际 AM_MEDIA_TYPE、AvgTimePerFrame、尺寸、subtype、stride、方向、allocator 和音频路径。不能只对比界面都显示“60”。比较 60 与 60000/1001 时使用真实有理数。+2. 先全效果关做入口测试,再单 NR、XeSS 4X、组合;音频开关仅作定位变量。检查 graph clock/交付节奏,而非直接移除时钟。+3. 若复制/锁确为瓶颈:将驱动回调压缩为有界的应用自有 packed RGB 复制,复用既有 GPU 解包路径;保留 top-down、翻转、stride、range/matrix 合同。必要 CPU 回退优先复用已有成熟矢量化实现并记录来源。+4. 不长期持有驱动样本,不复用消费者仍持有的帧,不增加无界排队;保持 latest-frame mailbox。不能通过强制换 NV12、重复帧或隐藏实际 FPS 作为 RGB60 修复。++### 独立审查项++此前全软件审查的压缩包队列/帧身份/EAGAIN/PTS、D3D11 context4 释放、字幕锚点重叠/缓存键遗漏,另行回归处理。它们是代码审查发现,不是三份日志全部症状的共同解释。++## 4. 验收与交付++- 修复前后使用同输入、同格式、同效果、同显示刷新率和驱动设置;每个稳定场景 120 秒,单次测试不超过 300 秒。过渡阶段单列,不能删掉失败窗口制造平均值。+- GC573:原生 RGB 4K60 全效果关闭,比较回调入口、复制完成和处理吞吐;目标为跟随真实输入 60/59.94,无持续 53fps 平台。以同条件 OBS/驱动 PTS 为基准,缺实卡则明确未验收。检查 RGB 方向、颜色、花屏和音画同步。+- XeSS:2X/3X/4X,60fps 与 30fps 来源,关闭/VSync 两类显示条件,静止、持续转身、平移、resize、设置切换、断点恢复;DLSS 2X/4X/6X 作回归对照。当前 XeSS 上限 4X,不把 DLSS 6X 误写为 XeSS 支持。+- 统计全输出序列的长短间隔、每秒有效生成量、掉帧/reset/警告及队列上限;独立检查显示事件和可见撕裂。提供方 submitted/presented 计数不替代物理屏幕刷新证据。+- 功率须另采带时间戳的硬件遥测,判断是否跟随工作断续;不能从利用率单独归因。屏幕端到端延迟须外部测量,软件日志只报告进程内指标。+- 构建、相关单元/集成测试、GPU debug layer 和真实来源回归后再写验收结论;无实卡或显示设备的场景列为待用户验证。不得用本机 RTX5070 替代 5070 Ti/5080/5090/GC573 全型号验收。++未来本方案产物统一写入 `E:/项目/Veyra/{build,tests,logs,tmp}/xess-gc573-20260919/`。本轮仅读取原日志与代码,新增本文并更新 WORKLOG;未运行性能测试,也未声称修复完成。diff --git a/include/veyra/source/CaptureAudioClock.h b/include/veyra/source/CaptureAudioClock.hnew file mode 100644index 00000000..5b9474f4--- /dev/null+++ b/include/veyra/source/CaptureAudioClock.h@@ -0,0 +1,16 @@+#pragma once+#include <optional>++namespace veyra::source {+// Untimed driver samples still contain real audio. Continue by decoded sample+// duration; arrival time is only an anchor after open or a discontinuity.+class CaptureAudioClock {+ double next_=0;+ bool anchored_=false;+public:+ double observe(std::optional<double> timestamp,double arrival,double duration,bool discontinuity){+ const double start=timestamp?*timestamp:(!anchored_||discontinuity?arrival:next_);+ next_=start+duration;anchored_=true;return start;+ }+};+}diff --git a/include/veyra/source/NativeCaptureSink.h b/include/veyra/source/NativeCaptureSink.hindex b9d552cd..75c3e6a2 100644--- a/include/veyra/source/NativeCaptureSink.h+++ b/include/veyra/source/NativeCaptureSink.h@@ -9,6 +9,7 @@ namespace veyra::source {// restriction, conversion filter or extra queue. Callback borrows the sample.HRESULT createNativeCaptureSink(const AM_MEDIA_TYPE&,std::function<HRESULT(IMediaSample*)>,Microsoft::WRL::ComPtr<IBaseFilter>&,Microsoft::WRL::ComPtr<IPin>&);HRESULT createNativeAudioSink(const AM_MEDIA_TYPE&,std::function<HRESULT(IMediaSample*)>,Microsoft::WRL::ComPtr<IBaseFilter>&,Microsoft::WRL::ComPtr<IPin>&);+HRESULT createBitstreamAudioSink(const AM_MEDIA_TYPE&,std::function<HRESULT(IMediaSample*)>,Microsoft::WRL::ComPtr<IBaseFilter>&,Microsoft::WRL::ComPtr<IPin>&);// Compressed (MJPEG/H.264/HEVC/...) variant: carries the driver payload without// a pixel-layout contract; decoding happens in our own backend.HRESULT createCompressedCaptureSink(const AM_MEDIA_TYPE&,std::function<HRESULT(IMediaSample*)>,Microsoft::WRL::ComPtr<IBaseFilter>&,Microsoft::WRL::ComPtr<IPin>&);diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cppindex dc73e002..f2f43f97 100644--- a/src/engine/VideoPresenter.cpp+++ b/src/engine/VideoPresenter.cpp@@ -256,7 +256,15 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConteauto effective=requested;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(xessActive()||fsrActive()){effective.enabled=false;sink_.configurePacing(false,false);status=L"当前由补帧提供方调度,帧同步选项暂不生效";return effective;}+ if(xessActive()||fsrActive()){+ effective.enabled=false;+ const bool vsync=xessActive()&&requested.display!=DisplaySync::Tearing;+ sink_.configurePacing(false,vsync);+ 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 状态未知)";+ return effective;+ }if(!sink_.configurePacing(true,requested.display!=DisplaySync::Tearing)){effective.enabled=false;status=L"显示队列控制不可用,已回退原呈现方式";return effective;}if(requested.mode==PacingMode::Reflex){// Generated outputs need separately validated out-of-band markers.diff --git a/src/gfx/PresentSink.cpp b/src/gfx/PresentSink.cppindex 893dd7c5..cd4a1c82 100644--- a/src/gfx/PresentSink.cpp+++ b/src/gfx/PresentSink.cpp@@ -321,6 +321,8 @@ bool PresentSink::present(Status& status)if(!beforeOk){xessFailed_=true;status=Status::WindowFailure;return false;}const HRESULT hr = swapChain_->Present(syncInterval, flags);presentTiming_.callMs=split();presentTiming_.result=hr;+ if(attemptedPresentCount_<=3||attemptedPresentCount_%120==0)+ log::info("present-contract",std::format("backend={} sync={} flags=0x{:X} hr=0x{:X}",xess_?"XeSS":fsr_?"FSR":"DXGI",syncInterval,flags,unsigned(hr)));if (SUCCEEDED(hr)) {++presentCount_;backBufferIndex_ = swapChain_->GetCurrentBackBufferIndex();@@ -374,10 +376,12 @@ bool PresentSink::present(Status& status)}bool PresentSink::configurePacing(bool enabled,bool vsync){- if(xess_||fsr_){pacing_=false;desc_.vsync=false;return !enabled;}+ // XeSS owns pacing, but its proxy accepts DXGI VSync independently.+ // Do not install another latency waiter on the provider swap chain.+ if(xess_||fsr_){pacing_=false;capacityAcquired_=false;desc_.vsync=xess_&&vsync;log::info("pacing",std::format("provider={} applicationWait=0 vsync={}",xess_?"XeSS":"FSR",desc_.vsync));return !enabled;}const HRESULT hr=latencyHandle_?swapChain_->SetMaximumFrameLatency(enabled?1:3):enabled?E_NOTIMPL:S_OK;- log::info("pacing",std::format("DXGI enabled={} maximumLatency={} vsync={} hr=0x{:X}",enabled,enabled?1:3,enabled&&vsync,unsigned(hr)));- pacing_=enabled&&SUCCEEDED(hr);desc_.vsync=pacing_&&vsync;capacityAcquired_=false;+ log::info("pacing",std::format("DXGI enabled={} maximumLatency={} vsync={} hr=0x{:X}",enabled,enabled?1:3,vsync,unsigned(hr)));+ pacing_=enabled&&SUCCEEDED(hr);desc_.vsync=vsync;capacityAcquired_=false;return SUCCEEDED(hr);}bool PresentSink::presentationReady(){diff --git a/src/sink/ImageExportSink.cpp b/src/sink/ImageExportSink.cppindex ace231fc..cefd1545 100644--- a/src/sink/ImageExportSink.cpp+++ b/src/sink/ImageExportSink.cpp@@ -9,6 +9,7 @@#include <limits>#include <DirectXPackedVector.h>#include <cmath>+#include <format>namespace veyra::sink {using Microsoft::WRL::ComPtr;static bool readPixels(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring,ID3D12Resource* tex,RgbaImage& img,unsigned bytesPerPixel) {@@ -40,10 +41,13 @@ bool readRgba8(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring,ID3D12Resreturn tex&&tex->GetDesc().Format==DXGI_FORMAT_R8G8B8A8_UNORM&&readPixels(ctx,ring,tex,img,4);}bool saveHdrScreenshot(const std::wstring& path,gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring,ID3D12Resource* texture){- if(!texture||std::filesystem::exists(path))return false;+ const auto check=[](HRESULT hr,const char* stage){if(SUCCEEDED(hr))return true;log::error("hdr-screenshot",std::format("stage={} hr=0x{:08X}",stage,unsigned(hr)));return false;};+ if(!texture)return check(E_POINTER,"source-texture");+ if(std::filesystem::exists(path))return check(HRESULT_FROM_WIN32(ERROR_FILE_EXISTS),"destination");const auto format=texture->GetDesc().Format;const bool pq=format==DXGI_FORMAT_R10G10B10A2_UNORM;- if(!pq&&format!=DXGI_FORMAT_R16G16B16A16_FLOAT)return false;- RgbaImage raw;if(!readPixels(ctx,ring,texture,raw,pq?4:8))return false;+ log::info("hdr-screenshot",std::format("source format={} extent={}x{}",unsigned(format),texture->GetDesc().Width,texture->GetDesc().Height));+ if(!pq&&format!=DXGI_FORMAT_R16G16B16A16_FLOAT)return check(E_INVALIDARG,"source-format");+ RgbaImage raw;if(!readPixels(ctx,ring,texture,raw,pq?4:8))return check(E_FAIL,"gpu-readback");const size_t count=size_t(raw.width)*raw.height;std::vector<uint16_t> pixels(count*4);if(!pq)memcpy(pixels.data(),raw.pixels.data(),count*8);else for(size_t i=0;i<count;++i){@@ -53,26 +57,29 @@ bool saveHdrScreenshot(const std::wstring& path,gfx::D3D12DeviceContext& ctx,gfxfor(unsigned c=0;c<3;++c)pixels[i*4+c]=DirectX::PackedVector::XMConvertFloatToHalf(float(matrix[c][0]*linear[0]+matrix[c][1]*linear[1]+matrix[c][2]*linear[2]));pixels[i*4+3]=DirectX::PackedVector::XMConvertFloatToHalf(1);}- const auto partial=path+L".partial";HANDLE file=CreateFileW(partial.c_str(),GENERIC_WRITE,0,nullptr,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,nullptr);if(file==INVALID_HANDLE_VALUE)return false;CloseHandle(file);+ const auto partial=path+L".partial";HANDLE file=CreateFileW(partial.c_str(),GENERIC_WRITE,0,nullptr,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,nullptr);if(file==INVALID_HANDLE_VALUE)return check(HRESULT_FROM_WIN32(GetLastError()),"create-partial");CloseHandle(file);struct Guard{std::wstring path;bool active=true;~Guard(){if(active)DeleteFileW(path.c_str());}} guard{partial};ComPtr<IWICImagingFactory> factory;ComPtr<IWICStream> stream;ComPtr<IWICBitmapEncoder> encoder;ComPtr<IWICBitmapFrameEncode> frame;ComPtr<IPropertyBag2> options;- if(FAILED(CoCreateInstance(CLSID_WICImagingFactory,nullptr,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&factory)))||FAILED(factory->CreateStream(&stream))||FAILED(stream->InitializeFromFilename(partial.c_str(),GENERIC_WRITE))||FAILED(factory->CreateEncoder(GUID_ContainerFormatWmp,nullptr,&encoder))||FAILED(encoder->Initialize(stream.Get(),WICBitmapEncoderNoCache))||FAILED(encoder->CreateNewFrame(&frame,&options)))return false;+ if(!check(CoCreateInstance(CLSID_WICImagingFactory,nullptr,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&factory)),"wic-factory")||!check(factory->CreateStream(&stream),"wic-stream")||!check(stream->InitializeFromFilename(partial.c_str(),GENERIC_WRITE),"open-stream")||!check(factory->CreateEncoder(GUID_ContainerFormatWmp,nullptr,&encoder),"create-jxr")||!check(encoder->Initialize(stream.Get(),WICBitmapEncoderNoCache),"init-encoder")||!check(encoder->CreateNewFrame(&frame,&options),"create-frame"))return false;PROPBAG2 property{};property.pstrName=const_cast<wchar_t*>(L"Lossless");VARIANT lossless{};lossless.vt=VT_BOOL;lossless.boolVal=VARIANT_TRUE;- if(FAILED(options->Write(1,&property,&lossless))||FAILED(frame->Initialize(options.Get()))||FAILED(frame->SetSize(raw.width,raw.height)))return false;+ if(!check(options->Write(1,&property,&lossless),"lossless-option")||!check(frame->Initialize(options.Get()),"init-frame")||!check(frame->SetSize(raw.width,raw.height),"frame-size"))return false;auto pixelFormat=GUID_WICPixelFormat64bppRGBAHalf;- if(FAILED(frame->SetPixelFormat(&pixelFormat))||pixelFormat!=GUID_WICPixelFormat64bppRGBAHalf||count>UINT_MAX/8)return false;- if(FAILED(frame->WritePixels(raw.height,raw.width*8,UINT(count*8),reinterpret_cast<BYTE*>(pixels.data())))||FAILED(frame->Commit())||FAILED(encoder->Commit()))return false;+ if(!check(frame->SetPixelFormat(&pixelFormat),"set-format"))return false;+ if(pixelFormat!=GUID_WICPixelFormat64bppRGBAHalf||count>UINT_MAX/8)return check(E_INVALIDARG,"negotiated-format-or-size");+ if(!check(frame->WritePixels(raw.height,raw.width*8,UINT(count*8),reinterpret_cast<BYTE*>(pixels.data())),"write-pixels")||!check(frame->Commit(),"frame-commit")||!check(encoder->Commit(),"encoder-commit"))return false;frame.Reset();encoder.Reset();stream.Reset();- // Verify lossless floating-point storage, not an 8-bit thumbnail decode.+ // Check file integrity and floating-point format. Pixel fidelity is tested+ // independently; representational differences must not discard a saved image.ComPtr<IWICBitmapDecoder> decoder;ComPtr<IWICBitmapFrameDecode> decoded;- if(FAILED(factory->CreateDecoderFromFilename(partial.c_str(),nullptr,GENERIC_READ,WICDecodeMetadataCacheOnLoad,&decoder))||FAILED(decoder->GetFrame(0,&decoded)))return false;+ if(!check(factory->CreateDecoderFromFilename(partial.c_str(),nullptr,GENERIC_READ,WICDecodeMetadataCacheOnLoad,&decoder),"reopen")||!check(decoder->GetFrame(0,&decoded),"decode-frame"))return false;WICPixelFormatGUID decodedFormat;UINT width=0,height=0;- if(FAILED(decoded->GetPixelFormat(&decodedFormat))||decodedFormat!=pixelFormat||FAILED(decoded->GetSize(&width,&height))||width!=raw.width||height!=raw.height)return false;+ if(!check(decoded->GetPixelFormat(&decodedFormat),"decoded-format")||!check(decoded->GetSize(&width,&height),"decoded-size"))return false;+ if(decodedFormat!=pixelFormat||width!=raw.width||height!=raw.height)return check(E_FAIL,"decoded-contract");std::vector<uint16_t> verify(count*4);- if(FAILED(decoded->CopyPixels(nullptr,width*8,UINT(count*8),reinterpret_cast<BYTE*>(verify.data())))||verify!=pixels)return false;+ if(!check(decoded->CopyPixels(nullptr,width*8,UINT(count*8),reinterpret_cast<BYTE*>(verify.data())),"decode-pixels"))return false;decoded.Reset();decoder.Reset();- if(!MoveFileExW(partial.c_str(),path.c_str(),MOVEFILE_WRITE_THROUGH))return false;guard.active=false;- log::info("hdr-screenshot","saved and lossless-verified scRGB FP16 JPEG XR; 1=80 nits, includes software processing only");return true;+ if(!MoveFileExW(partial.c_str(),path.c_str(),MOVEFILE_WRITE_THROUGH))return check(HRESULT_FROM_WIN32(GetLastError()),"publish-file");guard.active=false;+ log::info("hdr-screenshot","saved scRGB FP16 JPEG XR with lossless encoding and decode integrity check; 1=80 nits, includes software processing only");return true;}bool loadImage(const std::wstring& path,RgbaImage& img) {ComPtr<IWICImagingFactory> fac;ComPtr<IWICBitmapDecoder> dec;ComPtr<IWICBitmapFrameDecode> frame;ComPtr<IWICFormatConverter> conv;diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cppindex 5e018419..d289e3c8 100644--- a/src/source/CaptureCardSource.cpp+++ b/src/source/CaptureCardSource.cpp@@ -35,6 +35,7 @@ extern "C" {#include <atomic>#include <format>#include <chrono>+#include "veyra/source/CaptureAudioClock.h"#include <cmath>#include <string_view>extern "C" {@@ -143,6 +144,12 @@ std::wstring monikerPath(IMoniker* moniker){}bool audioOutputPin(IPin* pin){if(!pin)return false;PIN_DIRECTION direction{};if(FAILED(pin->QueryDirection(&direction))||direction!=PINDIR_OUTPUT)return false;+ ComPtr<IAMStreamConfig> config;+ if(SUCCEEDED(pin->QueryInterface(IID_PPV_ARGS(&config)))){+ AM_MEDIA_TYPE* type=nullptr;const auto hr=config->GetFormat(&type);+ const bool audio=SUCCEEDED(hr)&&type&&type->majortype==MEDIATYPE_Audio;+ if(type)freeType(type);if(audio)return true;+ }ComPtr<IEnumMediaTypes> types;if(FAILED(pin->EnumMediaTypes(&types)))return false;for(;;){AM_MEDIA_TYPE* type=nullptr;const HRESULT hr=types->Next(1,&type,nullptr);if(hr!=S_OK||!type)break;const bool audio=type->majortype==MEDIATYPE_Audio;freeType(type);if(audio)return true;}return false;@@ -224,6 +231,7 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {uint64_t received=0,dropped=0,lastDrop=0,sequence=0;uint64_t discontinuitySamples=0;Clock::time_point pendingArrival{},readArrival{},firstArrival{},latestArrival{};+ std::deque<Clock::time_point> recentArrivals;ComPtr<IGraphBuilder> graph;ComPtr<ICaptureGraphBuilder2> builder;ComPtr<IBaseFilter> device,grabFilter,nullFilter,audioFilter;ComPtr<IAMStreamConfig> config;ComPtr<ISampleGrabber> grab;ComPtr<IMediaControl> control;ComPtr<IMediaEvent> events;float lastAudioGain=-1;bool audioGainSupported=false;ComPtr<IBaseFilter> audioSink;ComPtr<IReferenceClock> referenceClock;@@ -353,9 +361,10 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {const bool sampleTime=sample&&sample->GetTime(&sampleStart,&sampleEnd)==S_OK;const bool valid=sample&&std::isfinite(time)&&SUCCEEDED(sample->GetPointer(&data))&&data&&(compressedPath?sample->GetActualDataLength()>0:sample->GetActualDataLength()>=LONG(layout.sampleBytes));- bool enqueued=false;uint64_t timingSequence=0;int64_t copied100ns=0;+ bool enqueued=false;uint64_t timingSequence=0;int64_t copied100ns=0;double lockWaitMs=0;{std::lock_guard lock(mutex);+ lockWaitMs=std::chrono::duration<double,std::milli>(Clock::now()-arrival).count();// The compressed path decodes in its own worker and keeps its own// frame pool, so the preallocated NV12 mailbox is legitimately// empty between reads; only the native path requires it here.@@ -396,10 +405,13 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {}if(!received)firstArrival=arrival;++received;latestArrival=arrival;+ recentArrivals.push_back(arrival);+ while(recentArrivals.size()>1&&(recentArrivals.size()>1024||arrival-recentArrivals.front()>std::chrono::seconds(2)))recentArrivals.pop_front();timingSequence=received;copied100ns=std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now().time_since_epoch()).count()/100;}}if(enqueued)decodeWake.notify_one();+ if(timingSequence&&(timingSequence%120==0||lockWaitMs>5))log::info("capture-callback",std::format("source={} entryToLockMs={:.3f} entryToCopiedMs={:.3f} bytes={} compressed={} (callback cost, not display latency)",timingSequence,lockWaitMs,(copied100ns-std::chrono::duration_cast<std::chrono::nanoseconds>(arrival.time_since_epoch()).count()/100)/10000.0,sample->GetActualDataLength(),compressedPath));if(log::verboseFrameLogs()&&timingSequence)log::info("capture-ingress-sample",std::format("source={} arrival={} copied={} compressed={}",timingSequence,std::chrono::duration_cast<std::chrono::nanoseconds>(arrival.time_since_epoch()).count()/100,copied100ns,compressedPath));wake.notify_one();return S_OK;}@@ -814,11 +826,20 @@ bool CaptureCardSource::connectDirectShowAudio(const SourceOpenDesc& desc){embedded?" (this video filter exposes no audio pin; select the separate audio device)":""));return false;}- ComPtr<IEnumMediaTypes> types;hr=audioPin->EnumMediaTypes(&types);if(FAILED(hr)){log::warn("capture-audio",std::format("EnumMediaTypes hr=0x{:08X}",uint32_t(hr)));return false;}+ ComPtr<IEnumMediaTypes> types;hr=audioPin->EnumMediaTypes(&types);if(FAILED(hr)){types.Reset();log::warn("capture-audio",std::format("EnumMediaTypes hr=0x{:08X}; trying current driver format",uint32_t(hr)));}// Preserve the device's actual speaker layout. Enumeration order is// commonly stereo first even when native 5.1 is available.auto releaseType=[](AM_MEDIA_TYPE* type){freeType(type);};using AudioType=std::unique_ptr<AM_MEDIA_TYPE,decltype(releaseType)>;+ std::vector<AudioType> candidates;+ ComPtr<IAMStreamConfig> audioConfig;+ if(SUCCEEDED(audioPin.As(&audioConfig))){+ AM_MEDIA_TYPE* current=nullptr;const auto currentHr=audioConfig->GetFormat(¤t);+ log::info("capture-audio",std::format("current driver format hr=0x{:08X}",uint32_t(currentHr)));+ if(SUCCEEDED(currentHr)&¤t)candidates.emplace_back(current,releaseType);else if(current)freeType(current);+ }+ while(types){AM_MEDIA_TYPE* type=nullptr;const auto next=types->Next(1,&type,nullptr);+ if(next!=S_OK||!type){if(type)freeType(type);break;}candidates.emplace_back(type,releaseType);}std::vector<AudioType> audioTypes;std::vector<AudioType> bitstreamTypes;unsigned typeIndex=0;// Dolby/DTS bitstream capability probe: the capture card may expose AC-3 /// E-AC-3 (Dolby Digital Plus, includes Atmos over DD+) / TrueHD / DTS instead@@ -840,8 +861,8 @@ auto bitstreamName=[](const GUID& subtype)->const char*{default:return nullptr;}};-for(;;){AM_MEDIA_TYPE* type=nullptr;if(types->Next(1,&type,nullptr)!=S_OK||!type)break;-AudioType owned(type,releaseType);sink::WavePcmFormat pcm;bool supported=false;+for(auto& owned:candidates){AM_MEDIA_TYPE* type=owned.get();if(type->majortype!=MEDIATYPE_Audio)continue;+sink::WavePcmFormat pcm;bool supported=false;if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat)supported=sink::parseWavePcm(type->pbFormat,type->cbFormat,pcm);if(!supported){const char* name=bitstreamName(type->subtype);@@ -878,11 +899,15 @@ if(audioTypes.empty()&&(!allowBitstream||bitstreamTypes.empty())){log::warn("capif(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat&&type->cbFormat>=sizeof(WAVEFORMATEX)&&sink::parseWavePcm(type->pbFormat,type->cbFormat,parsed)&&session->configure(parsed)){auto* target=session.get();auto probe=std::make_shared<sink::Iec61937Probe>();- hr=createNativeAudioSink(*type,[target,probe](IMediaSample* sample){+ hr=createNativeAudioSink(*type,[target,probe,clock=CaptureAudioClock{},rate=parsed.wave.nAvgBytesPerSec,warned=false](IMediaSample* sample) mutable {BYTE* bytes=nullptr;REFERENCE_TIME begin=0,end=0;- if(FAILED(sample->GetPointer(&bytes))||FAILED(sample->GetTime(&begin,&end)))return VFW_E_SAMPLE_TIME_NOT_SET;+ const auto pointerHr=sample->GetPointer(&bytes);if(FAILED(pointerHr))return pointerHr;+ const auto timeHr=sample->GetTime(&begin,&end);const bool timed=SUCCEEDED(timeHr);+ if(!timed&&!warned){log::warn("capture-audio",std::format("PCM timestamp missing hr=0x{:X}; using sample-count clock",unsigned(timeHr)));warned=true;}+ const double arrival=std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now().time_since_epoch()).count();+ const double pts=clock.observe(timed?std::optional<double>(double(begin)/10000):std::nullopt,arrival,1000.0*sample->GetActualDataLength()/rate,sample->IsDiscontinuity()==S_OK);probe->feed(bytes,size_t(sample->GetActualDataLength()));- return target->push(bytes,size_t(sample->GetActualDataLength()),double(begin)/10000,sample->IsDiscontinuity()==S_OK)?S_OK:E_FAIL;+ return target->push(bytes,size_t(sample->GetActualDataLength()),pts,sample->IsDiscontinuity()==S_OK)?S_OK:E_FAIL;},candidate,terminal);if(SUCCEEDED(hr))hr=p.graph->AddFilter(candidate.Get(),L"Veyra audio PCM");// Request small input blocks before connection; downstream@@ -938,7 +963,7 @@ if(audioTypes.empty()&&(!allowBitstream||bitstreamTypes.empty())){log::warn("capif(passthrough->open(*carrier,rate)){ComPtr<IBaseFilter> candidate;ComPtr<IPin> terminal;auto sink=passthrough;- hr=createNativeAudioSink(*type,[sink](IMediaSample* sample){+ hr=createBitstreamAudioSink(*type,[sink](IMediaSample* sample){BYTE* bytes=nullptr;if(FAILED(sample->GetPointer(&bytes)))return VFW_E_SAMPLE_TIME_NOT_SET;return sink->write(bytes,size_t(sample->GetActualDataLength()))?S_OK:E_FAIL;@@ -972,9 +997,11 @@ if(audioTypes.empty()&&(!allowBitstream||bitstreamTypes.empty())){log::warn("capauto started=std::make_shared<bool>(false);const std::string kindName=sink::bitstreamKindName(kind);const std::wstring kindWide(kindName.begin(),kindName.end());- hr=createNativeAudioSink(*type,[target,decoder,pcmBuffer,started,kindWide](IMediaSample* sample){+ hr=createBitstreamAudioSink(*type,[target,decoder,pcmBuffer,started,kindWide,clock=CaptureAudioClock{},warned=false](IMediaSample* sample) mutable {BYTE* bytes=nullptr;REFERENCE_TIME begin=0,end=0;- if(FAILED(sample->GetPointer(&bytes))||FAILED(sample->GetTime(&begin,&end)))return VFW_E_SAMPLE_TIME_NOT_SET;+ const auto pointerHr=sample->GetPointer(&bytes);if(FAILED(pointerHr))return pointerHr;+ const auto timeHr=sample->GetTime(&begin,&end);const bool timed=SUCCEEDED(timeHr);+ if(!timed&&!warned){log::warn("capture-audio",std::format("bitstream timestamp missing hr=0x{:X}; using decoded sample-count clock",unsigned(timeHr)));warned=true;}pcmBuffer->clear();if(!decoder->push(bytes,size_t(sample->GetActualDataLength()),*pcmBuffer))return S_OK;if(pcmBuffer->empty())return S_OK;@@ -998,7 +1025,9 @@ if(audioTypes.empty()&&(!allowBitstream||bitstreamTypes.empty())){log::warn("captarget->setInputBitstream(kindWide);*started=true;}- return target->push(pcmBuffer->data(),pcmBuffer->size()*sizeof(float),double(begin)/10000,sample->IsDiscontinuity()==S_OK)?S_OK:E_FAIL;+ const double arrival=std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now().time_since_epoch()).count();+ const double pts=clock.observe(timed?std::optional<double>(double(begin)/10000):std::nullopt,arrival,1000.0*pcmBuffer->size()/channels/rate,sample->IsDiscontinuity()==S_OK);+ return target->push(pcmBuffer->data(),pcmBuffer->size()*sizeof(float),pts,sample->IsDiscontinuity()==S_OK)?S_OK:E_FAIL;},candidate,terminal);if(SUCCEEDED(hr))hr=p.graph->AddFilter(candidate.Get(),L"Veyra audio bitstream");if(SUCCEEDED(hr))hr=p.graph->ConnectDirect(audioPin.Get(),terminal.Get(),type);@@ -1087,7 +1116,7 @@ bool CaptureCardSource::reconnect(float gain,unsigned syncMode,int offsetMs){CaptureMetrics CaptureCardSource::metrics()const{auto& p=*p_;std::lock_guard lock(p.mutex);CaptureMetrics m;m.received=receivedOffset_+p.received;m.delivered=deliveredOffset_+p.sequence;m.dropped=droppedOffset_+p.dropped;m.readAgeMs=p.readAgeMs;- if(p.received>1){const double elapsed=std::chrono::duration<double>(p.latestArrival-p.firstArrival).count();if(elapsed>0)m.callbackFps=(p.received-1)/elapsed;}+ if(p.recentArrivals.size()>1&&Impl::Clock::now()-p.latestArrival<std::chrono::seconds(1)){const double elapsed=std::chrono::duration<double>(p.recentArrivals.back()-p.recentArrivals.front()).count();if(elapsed>0)m.callbackFps=(p.recentArrivals.size()-1)/elapsed;}if(p.sequence)m.frameAgeMs=std::chrono::duration<double,std::milli>(Impl::Clock::now()-p.readArrival).count();return m;}SourceReadStatus CaptureCardSource::read(pipeline::FramePacket& packet,const AVFrame** frame){return readWithWait(packet,frame,30);}@@ -1160,5 +1189,6 @@ void CaptureCardSource::close()noexcept{p.pendingIsHardware=false;p.compressedPath=false;p.codec=CaptureCodec::None;p.compressedDecoded=p.compressedErrors=0;p.info={};p.sequence=p.received=p.dropped=p.lastDrop=0;p.pending=p.callbackError=p.configured=p.forceDiscontinuity=false;p.lastPts=p.readAgeMs=0;+ p.recentArrivals.clear();}}diff --git a/src/source/NativeCaptureSink.cpp b/src/source/NativeCaptureSink.cppindex 89aaa078..bf239346 100644--- a/src/source/NativeCaptureSink.cpp+++ b/src/source/NativeCaptureSink.cpp@@ -2,6 +2,7 @@#include "veyra/source/CaptureMediaType.h"#include "veyra/Log.h"#include "veyra/sink/AudioFormat.h"+#include "veyra/sink/BitstreamAudio.h"#include <format>#include <mmreg.h>#include <atomic>@@ -67,9 +68,9 @@ class NativeSink final:public IBaseFilter,public IPin,public IMemInputPin {bool compressed_=false;public:NativeSink(const AM_MEDIA_TYPE& type,std::function<HRESULT(IMediaSample*)> cb,bool compressed=false):callback_(std::move(cb)){- compressed_=compressed;audio_=audioType(type);+ compressed_=compressed;audio_=!compressed&&audioType(type);if(compressed_){- if(type.majortype!=MEDIATYPE_Video||FAILED(copyType(desired_,type)))throw std::bad_alloc();+ if(FAILED(copyType(desired_,type)))throw std::bad_alloc();}else{if((!audio_&&!captureMediaLayout(type,layout_))||FAILED(copyType(desired_,type)))throw std::bad_alloc();if(audio_)layout_.sampleBytes=reinterpret_cast<const WAVEFORMATEX*>(type.pbFormat)->nBlockAlign;@@ -205,4 +206,11 @@ HRESULT createNativeAudioSink(const AM_MEDIA_TYPE& type,std::function<HRESULT(IMfilter.Reset();pin.Reset();if(!audioType(type))return VFW_E_INVALIDMEDIATYPE;try{filter.Attach(new NativeSink(type,std::move(callback)));return filter.As(&pin);}catch(...){return E_OUTOFMEMORY;}}+HRESULT createBitstreamAudioSink(const AM_MEDIA_TYPE& type,std::function<HRESULT(IMediaSample*)> callback,ComPtr<IBaseFilter>& filter,ComPtr<IPin>& pin){+ filter.Reset();pin.Reset();+ if(type.majortype!=MEDIATYPE_Audio||sink::classifyBitstreamSubtype(type.subtype.Data1)==sink::BitstreamKind::None||+ (type.cbFormat&&!type.pbFormat))return VFW_E_INVALIDMEDIATYPE;+ // Compressed packets have no PCM sample stride or byte-rate contract.+ try{filter.Attach(new NativeSink(type,std::move(callback),true));return filter.As(&pin);}catch(...){return E_OUTOFMEMORY;}+}}diff --git a/tests/integration/ScreenshotCombinationTests.cpp b/tests/integration/ScreenshotCombinationTests.cppnew file mode 100644index 00000000..6fa7d2e8--- /dev/null+++ b/tests/integration/ScreenshotCombinationTests.cpp@@ -0,0 +1,35 @@+#include "veyra/engine/EngineController.h"+#include "veyra/Log.h"+#include "veyra/gfx/PresentSink.h"+#include "veyra/sink/ImageExportSink.h"+#include <filesystem>+#include <chrono>+#include <thread>+#include <iostream>+using namespace veyra::engine;+int wmain(int argc,wchar_t** argv){+ if(argc!=3)return 2;+ const std::filesystem::path dir=argv[2];std::filesystem::create_directories(dir);+ veyra::Logger::instance().openFile((dir/L"engine.log").wstring());+ if(FAILED(CoInitializeEx(nullptr,COINIT_MULTITHREADED)))return 2;+ HWND window=CreateWindowExW(0,L"STATIC",L"Screenshot combination regression",WS_OVERLAPPEDWINDOW|WS_VISIBLE,80,80,960,600,nullptr,nullptr,GetModuleHandleW(nullptr),nullptr);+ int failures=0;+ for(bool nr:{false,true})for(bool hdr:{false,true}){+ EngineController engine;engine.setVolume(0,true);EnhancementSettings settings;settings.nr=nr;settings.videoHdr.enabled=hdr;+ engine.open(window,argv[1],PlayerOptions::from(settings));+ auto wait=[&](auto predicate){const auto end=std::chrono::steady_clock::now()+std::chrono::seconds(20);+ while(std::chrono::steady_clock::now()<end){MSG m;while(PeekMessageW(&m,nullptr,0,0,PM_REMOVE)){TranslateMessage(&m);DispatchMessageW(&m);}const auto s=engine.snapshot();if(s.failed)return false;if(predicate(s))return true;std::this_thread::sleep_for(std::chrono::milliseconds(10));}return false;};+ bool ok=wait([&](const auto& s){return s.frames>=12&&(!nr||s.nrActive);});+ for(bool paused:{false,true}){+ if(paused){engine.pause(true);ok=wait([](const auto& s){return s.transport==TransportState::Paused;})&&ok;}+ const auto base=dir/(std::to_wstring(nr)+L"-"+std::to_wstring(hdr)+L"-"+std::to_wstring(paused)+L".png");+ auto actual=base;const bool hdrOutput=hdr&&veyra::gfx::PresentSink::hdrDisplayActive(window);if(hdrOutput)actual.replace_extension(L".jxr");+ engine.saveFrame(base.wstring());+ const bool saved=wait([&](const auto&){return std::filesystem::exists(actual)&&std::filesystem::file_size(actual)>100;});+ veyra::sink::RgbaImage decoded;const bool reopened=saved&&veyra::sink::loadImage(actual.wstring(),decoded)&&decoded.width>0&&decoded.height>0;+ std::cout<<"SCREENSHOT nr="<<nr<<" hdrRequested="<<hdr<<" hdrOutput="<<hdrOutput<<" paused="<<paused<<" saved="<<saved<<" reopened="<<reopened<<std::endl;ok=reopened&&ok;+ }+ failures+=!ok;engine.stop();+ }+ DestroyWindow(window);CoUninitialize();return failures?1:0;+}diff --git a/tests/integration/SubtitlePanelTests.cpp b/tests/integration/SubtitlePanelTests.cppnew file mode 100644index 00000000..581e5d22--- /dev/null+++ b/tests/integration/SubtitlePanelTests.cpp@@ -0,0 +1,23 @@+#include "../../apps/veyra/ui/SubtitleSettingsPanel.h"+#include <iostream>+int wmain(){+ using namespace veyra::ui;+ INITCOMMONCONTROLSEX controls{sizeof(controls),ICC_UPDOWN_CLASS};InitCommonControlsEx(&controls);+ HWND owner=CreateWindowExW(0,L"STATIC",L"Subtitle regression",WS_OVERLAPPEDWINDOW|WS_VISIBLE,100,100,600,500,nullptr,nullptr,GetModuleHandleW(nullptr),nullptr);+ int failures=0,updates=0;SubtitleSettings current;+ 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);+ for(int i=0;i<20;++i){SetWindowTextW(edit,std::to_wstring(20+i).c_str());check(IsWindow(panel)&&GetFocus()==edit&¤t.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));+ wchar_t value[32]{};GetWindowTextW(edit,value,32);check(std::wstring(value)==L"39","invalid text restored on blur");+ SetDlgItemTextW(panel,103,L"-500");SetDlgItemTextW(panel,104,L"0");+ check(current.offset==-500&¤t.lines==0,"signed delay and auto lines apply");+ SendDlgItemMessageW(panel,105,BM_CLICK,0,0);check(!current.outline,"checkbox applies without closing");+ showSubtitleSettings(owner,{},{});check(subtitlePanel::window==panel,"reopen focuses same panel");+ SendMessageW(panel,WM_COMMAND,IDCANCEL,0);check(!subtitlePanel::window,"cancel clears window lifetime");+ showSubtitleSettings(owner,current,{});check(subtitlePanel::window&&IsWindow(subtitlePanel::window),"panel recreates after close");+ DestroyWindow(owner);check(!subtitlePanel::window,"owner destruction releases panel");+ check(updates>=23,"live change notifications delivered");return failures?1:0;+}diff --git a/tests/integration/VideoHdrTests.cpp b/tests/integration/VideoHdrTests.cppindex c6d3a999..76fb54e9 100644--- a/tests/integration/VideoHdrTests.cpp+++ b/tests/integration/VideoHdrTests.cpp@@ -49,17 +49,24 @@ int wmain(int argc,wchar_t** argv){gd.videoHdr.enabled=true;gd.hdrOutput=true;gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();if(argc>1){const auto multiplier=unsigned(_wtoi(argv[1]));gd.fgMultiplier=std::max(2u,multiplier);gd.enableFg=multiplier>1;}if(argc>2){gd.enableNr=_wtoi(argv[2])!=0;gd.enableNvofStandalone=gd.enableNr;}- if(argc>3){gd.enableSr=true;gd.workWidth=1920;gd.workHeight=1080;gd.videoSrQuality=unsigned(_wtoi(argv[3]));}+ if(argc>3&&_wtoi(argv[3])>0){gd.enableSr=true;gd.workWidth=1920;gd.workHeight=1080;gd.videoSrQuality=unsigned(_wtoi(argv[3]));}+ source::MediaFileSource media;const AVFrame* decodedFrame=nullptr;FramePacket packet;+ if(argc>5){source::SourceOpenDesc input;input.path=argv[5];input.preferHardwareDecode=false;+ if(!media.open(input)||media.read(packet,&decodedFrame)!=source::SourceReadStatus::Frame)return 6;+ gd.sourceWidth=gd.workWidth=gd.nrWidth=decodedFrame->width;gd.sourceHeight=gd.workHeight=gd.nrHeight=decodedFrame->height;gd.rgbInput=false;+ }if(!graph.initialize(gd)||!graph.createViews()||!graph.videoHdrActive())return 3;AVFrame* frame=av_frame_alloc();frame->format=AV_PIX_FMT_BGRA;frame->width=1280;frame->height=720;frame->color_range=AVCOL_RANGE_JPEG;frame->color_primaries=AVCOL_PRI_BT709;frame->color_trc=AVCOL_TRC_IEC61966_2_1;if(av_frame_get_buffer(frame,32)<0)return 4;for(int y=0;y<720;++y)for(int x=0;x<1280;++x){auto* p=frame->data[0]+y*frame->linesize[0]+x*4;const uint8_t v=uint8_t(x*255/1279);p[0]=p[1]=p[2]=v;p[3]=255;}+ if(argc>4)for(int y=0;y<720;++y)for(int x=0;x<1280;++x){auto* p=frame->data[0]+y*frame->linesize[0]+x*4;p[0]=uint8_t(x*17+y*13);p[1]=uint8_t(x/5+y/3);p[2]=uint8_t((x^y)&255);p[3]=255;}bool ok=true;double peak=0,changed=0;std::vector<float> baseline;unsigned generated=0;for(unsigned n=0;n<12&&ok;++n){if(n==6){engine::EnhancementSettings s;s.nr=gd.enableNr;s.sr=gd.enableSr;s.multiplier=gd.enableFg?gd.fgMultiplier:1;s.videoSrQuality=gd.videoSrQuality;s.videoHdr=gd.videoHdr;s.videoHdr.peakNits=400;ok=graph.applySettings(s);}- EnhanceGraph::FrameOutputs out;ok=ok&&graph.process(frame,n*1000.0/30,n==0||n==8,out,n+1);+ if(argc>5&&n&&media.read(packet,&decodedFrame)!=source::SourceReadStatus::Frame){ok=false;break;}+ EnhanceGraph::FrameOutputs out;ok=ok&&graph.process(decodedFrame?decodedFrame:frame,n*1000.0/30,n==0||n==8,out,n+1);if(!ok)break;std::vector<float> data;ok=pixels(ctx,ring,graph.videoFrameResource(out.videoSlot),data);if(!ok)break;diff --git a/tests/unit/CaptureColorContractTests.cpp b/tests/unit/CaptureColorContractTests.cppindex 54c0c151..4a9406f7 100644--- a/tests/unit/CaptureColorContractTests.cpp+++ b/tests/unit/CaptureColorContractTests.cpp@@ -137,5 +137,30 @@ int main(){check(input->QueryAccept(&alternative)==S_FALSE,"side-to-back layout change requires reconnect even at identical byte stride");input->Disconnect();input.Reset();filter.Reset();output.Reset();}+ {+ AM_MEDIA_TYPE compressed{};compressed.majortype=MEDIATYPE_Audio;+ compressed.subtype={0x2000,0,0x10,{0x80,0,0,0xaa,0,0x38,0x9b,0x71}};+ compressed.formattype=FORMAT_None;+ unsigned packets=0;output.Attach(new OutputPin);+ check(source::createNativeAudioSink(compressed,[](IMediaSample*){return S_OK;},filter,input)==VFW_E_INVALIDMEDIATYPE,"PCM terminal rejects compressed packets");+ check(SUCCEEDED(source::createBitstreamAudioSink(compressed,[&](IMediaSample*){++packets;return S_OK;},filter,input)),"compressed audio terminal accepts AC3 without PCM WAVEFORMAT");+ if(filter&&input){+ check(input->ReceiveConnection(output.Get(),&compressed)==S_OK&&SUCCEEDED(filter.As(&memory)),"compressed audio connects directly");+ ALLOCATOR_PROPERTIES wanted{},actual{};memory->GetAllocatorRequirements(&wanted);+ const bool ready=memory->GetAllocator(&allocator)==S_OK&&allocator->SetProperties(&wanted,&actual)==S_OK&&allocator->Commit()==S_OK;+ check(ready,"compressed allocator initializes without PCM byte rate");+ if(ready){+ ComPtr<IMediaSample> sample;allocator->GetBuffer(&sample,nullptr,nullptr,0);filter->Run(0);+ sample->SetActualDataLength(101);check(memory->Receive(sample.Get())==S_OK&&packets==1,"odd-sized untimed compressed packet delivered");+ sample->SetActualDataLength(0);check(FAILED(memory->Receive(sample.Get()))&&packets==1,"empty compressed packet rejected");+ auto changed=compressed;changed.subtype.Data1=8;check(input->QueryAccept(&changed)==S_FALSE,"codec change requires reconnect");+ filter->Stop();sample.Reset();allocator->Decommit();+ }+ input->Disconnect();+ }+ memory.Reset();input.Reset();filter.Reset();output.Reset();allocator.Reset();+ compressed.subtype.Data1=0xdeadbeef;+ check(source::createBitstreamAudioSink(compressed,[](IMediaSample*){return S_OK;},filter,input)==VFW_E_INVALIDMEDIATYPE,"unknown codec rejected");+ }CoUninitialize();std::cout<<"failures="<<failures<<'\n';return failures?1:0;}diff --git a/tests/unit/UiContractTests.cpp b/tests/unit/UiContractTests.cppindex 6a674e36..d66e1e28 100644--- a/tests/unit/UiContractTests.cpp+++ b/tests/unit/UiContractTests.cpp@@ -9,12 +9,14 @@#include "../../apps/veyra/ui/LiveStatusHistory.h"#include "veyra/sink/AudioGain.h"#include "veyra/engine/PreviewView.h"+#include "veyra/source/CaptureAudioClock.h"#include <iostream>#include <vector>#include <stdexcept>void require(bool value,const char* why){if(!value)throw std::runtime_error(why);}int wmain(int argc,wchar_t** argv){try{using namespace veyra;+ {source::CaptureAudioClock c;require(c.observe({},100,10,false)==100,"untimed audio anchors to arrival");require(c.observe({},170,10,false)==110,"driver arrival jitter cannot stretch untimed PCM");require(c.observe(120,180,10,false)==120,"valid driver timestamp takes precedence");require(c.observe({},190,10,false)==130,"missing timestamps continue from valid samples");require(c.observe({},500,10,true)==500,"discontinuity reanchors untimed audio");require(c.observe(0,510,10,true)==0,"timestamp zero remains valid");}{ui::live_status::DashboardHistory history;engine::PlayerSnapshot s;s.running=s.capture=true;s.transport=engine::TransportState::Playing;s.sessionId=1;s.applied.revision=1;@@ -111,6 +113,8 @@ int wmain(int argc,wchar_t** argv){try{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");}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");}+ {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");}std::cout<<"PASS: mode/bypass, 384 layout cases at four DPI scales, actual PCM gain/mute, confirmed settings persistence/corruption\n";return 0;