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(capture-audio): manual audio ingress selector (auto / PCM only / bitstream first)
Veyra Goal Agent2ffb5c7d8550
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex a7605b8c..e2fd2e70 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -413,7 +413,7 @@ case RemotePlay:veyra::ui::showRemotePlayPanel(hwnd,[](veyra::source::RemotePlay}return result;},[]{engine.stop();},[]{return remoteController.calibrate();});break;#endif-case Capture:case ProRailCapture:veyra::ui::showCapturePanel(hwnd,[](const std::wstring& path){openFile(path);layout();},[]{return (uiState.enhanced?engine.snapshot().desired:uiState.configured).forceSdrPreview;},[](bool enabled){auto s=uiState.enhanced?engine.snapshot().desired:uiState.configured;s.forceSdrPreview=enabled;return applySettings(s);});break;+case Capture:case ProRailCapture:veyra::ui::showCapturePanel(hwnd,[](const std::wstring& path){openFile(path);layout();},[]{return (uiState.enhanced?engine.snapshot().desired:uiState.configured).forceSdrPreview;},[](bool enabled){auto s=uiState.enhanced?engine.snapshot().desired:uiState.configured;s.forceSdrPreview=enabled;return applySettings(s);},[]{return int((uiState.enhanced?engine.snapshot().desired:uiState.configured).captureAudio);},[](int mode){auto s=uiState.enhanced?engine.snapshot().desired:uiState.configured;s.captureAudio=static_cast<veyra::engine::CaptureAudioIngress>(std::clamp(mode,0,2));return applySettings(s);});break;case Export:if(uiState.mode==veyra::ui::Mode::Professional)startVideoExport(false);break;case Info:showDiagnostics=!showDiagnostics;layout();break;}return 0;@@ -559,7 +559,7 @@ SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);INITCOCoInitializeEx(nullptr,COINIT_APARTMENTTHREADED);initialOptions=veyra::engine::PlayerOptions::from(veyra::ui::defaultSettings());-int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-fg-only")smokeFgOnly=true;else if(arg==L"--smoke-transport")smokeTransport=true;else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--flow-amd")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::AmdFidelityFx;else if(arg==L"--flow-gpudis")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::GpuDis;else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,5);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);+int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-fg-only")smokeFgOnly=true;else if(arg==L"--smoke-transport")smokeTransport=true;else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--capture-audio"&&i+1<argc)initialOptions.settings.captureAudio=static_cast<veyra::engine::CaptureAudioIngress>(std::clamp(_wtoi(argv[++i]),0,2));else if(arg==L"--flow-amd")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::AmdFidelityFx;else if(arg==L"--flow-gpudis")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::GpuDis;else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,5);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);// The legacy argument clamp caps --fg-multiplier at 4X. Re-read the flag here so// 6X (and 2X/3X/4X) can be exercised from the command line for diagnostics and// smoke tests; the interactive UI uses the capability-driven list instead.diff --git a/apps/veyra/ui/CapturePanel.cpp b/apps/veyra/ui/CapturePanel.cppindex ae0136d6..838469c4 100644--- a/apps/veyra/ui/CapturePanel.cpp+++ b/apps/veyra/ui/CapturePanel.cpp@@ -15,7 +15,7 @@ std::future<Query> pending;bool busy=false,refreshAfterQuery=false;int queriedDestd::vector<source::CaptureFormat> formats;std::vector<source::CaptureDevice> videoDevices,audioDevices;CapturePreferences remembered;-std::function<bool()> readSdr;std::function<bool(bool)> setSdr;+std::function<bool()> readSdr;std::function<bool(bool)> setSdr;std::function<int()> readAudioIngress;std::function<bool(int)> setAudioIngress;void rebuildAudioList(HWND h,int device){SendDlgItemMessageW(h,3,CB_RESETCONTENT,0,0);SendDlgItemMessageW(h,3,CB_ADDSTRING,0,LPARAM(L"不监听音频"));const bool videoSelected=device>=0&&size_t(device)<videoDevices.size();@@ -42,7 +42,7 @@ void query(int device){if(busy)return;busy=true;queriedDevice=device;queryStarteconst std::wstring videoPath=device>=0&&size_t(device)<videoDevices.size()?videoDevices[size_t(device)].path:L"";pending=std::async(std::launch::async,[device,videoPath]{CoInitializeEx(nullptr,COINIT_MULTITHREADED);Query result;result.device=device;try{if(device<0){result.video=source::CaptureCardSource::deviceDetails();result.audio=source::CaptureCardSource::deviceDetails(true);}else result.formats=videoPath.empty()?source::CaptureCardSource::formats(unsigned(device)):source::CaptureCardSource::formatsByPath(videoPath);}catch(...){}CoUninitialize();return result;});}-void arrange(){RECT r{};GetClientRect(window,&r);const int width=MulDiv(r.right,96,veyra::ui::layoutDpi(window));const int ys[]={0,44,114,184,412,412,14,84,344,154,254,224,294};for(int id=1;id<=12;++id){int x=id==5?width-152:16;int w=id==4?width-184:id==5?136:width-32;MoveWindow(GetDlgItem(window,id),dip(window,x),dip(window,ys[id]),dip(window,w),dip(window,(id<=3||id==10)?180:id==8?56:id==4||id==5?36:24),TRUE);}}+void arrange(){RECT r{};GetClientRect(window,&r);const int width=MulDiv(r.right,96,veyra::ui::layoutDpi(window));const int ys[]={0,44,114,184,412,412,14,84,344,154,254,224,294,478,448};for(int id=1;id<=14;++id){int x=id==5?width-152:16;int w=id==4?width-184:id==5?136:width-32;MoveWindow(GetDlgItem(window,id),dip(window,x),dip(window,ys[id]),dip(window,w),dip(window,(id<=3||id==10||id==13)?180:id==8?56:id==4||id==5?36:24),TRUE);}}LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){switch(msg){case WM_CREATE:{window=h;font=makeFont(h);titleTheme(h);auto add=[&](const wchar_t* cls,const wchar_t* label,int id,DWORD style){auto c=CreateWindowExW(0,cls,label,WS_CHILD|WS_VISIBLE|style,0,0,1,1,h,HMENU(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(c,WM_SETFONT,WPARAM(font),TRUE);themeControl(c);};remembered=CapturePreferenceStore(runtime::localDataDirectory()).load();@@ -51,9 +51,12 @@ case WM_CREATE:{window=h;font=makeFont(h);titleTheme(h);auto add=[&](const wcharadd(L"COMBOBOX",L"",10,CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP);add(L"STATIC",L"输入颜色(变更需重连)",11,0);for(auto name:{L"自动识别 SDR / HDR · 设备元数据",L"手动 HDR10 / PQ · BT.2020",L"手动 HLG · BT.2020 / 1000nit参考"})SendDlgItemMessageW(h,10,CB_ADDSTRING,0,LPARAM(name));SendDlgItemMessageW(h,10,CB_SETCURSEL,0,0);add(L"BUTTON",L"转为 SDR 显示(所有预览,立即生效)",12,BS_AUTOCHECKBOX|WS_TABSTOP);SendDlgItemMessageW(h,12,BM_SETCHECK,readSdr()?BST_CHECKED:BST_UNCHECKED,0);+ add(L"COMBOBOX",L"",13,CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP);add(L"STATIC",L"采集音频(变更需重连)",14,0);+ for(auto name:{L"自动:优先线性 PCM,必要时 Dolby/DTS 位流解码",L"强制线性 PCM(不接受 Dolby/DTS 位流)",L"位流优先:Dolby/DTS 直通并解码为 PCM"})SendDlgItemMessageW(h,13,CB_ADDSTRING,0,LPARAM(name));+ SendDlgItemMessageW(h,13,CB_SETCURSEL,WPARAM(std::clamp(readAudioIngress?readAudioIngress():0,0,2)),0);add(L"BUTTON",L"连接并开始观看",4,BS_PUSHBUTTON|WS_TABSTOP);marked(GetDlgItem(h,4));add(L"BUTTON",L"刷新设备",5,BS_PUSHBUTTON|WS_TABSTOP);add(L"STATIC",L"视频输入设备",6,0);add(L"STATIC",L"设备实际支持的格式",7,0);add(L"STATIC",L"",8,0);add(L"STATIC",L"音频监听(仅采集所选输入,默认关闭)",9,0);- installDialogHelp(h,{{12,L"收到HDR也转成SDR显示,不用改PS5或Windows。增强照常用;只改预览,视频导出不受影响。切换会短暂停顿,截图跟随当前画面。关闭后跟随显示器。"},{10,L"设备没报HDR信息时手动指定,需选P010/P016。P010也可能装SDR,别给普通画面强戴HDR帽子。"},{1,L"选采集卡的视频设备。别把摄像头误请来直播PS5。"},{2,L"选设备真实提供的分辨率、帧率和像素格式。清晰度、带宽和延迟都受它影响。"},{3,L"如果设备自带 HDMI 音频,会显示“使用视频设备内置音频”;否则选择独立音频设备,也可不采声音。"},{4,L"按当前格式连接采集卡,并应用当前增强设置。"},{5,L"重新扫描设备和格式。设备被其他软件占用时,刷新不一定能抢回来。"}});+ installDialogHelp(h,{{13,L"采集卡把 Dolby Atmos / Dolby Audio / DTS 以位流送来时,这里决定用哪条路。设备本身的音频格式不受影响;改这个要重新连接采集卡。自动优先 PCM,PCM 不可用时才走位流解码;位流优先则反过来,适合 PS5 已设成 Dolby 输出、但设备同时提供 PCM 的情况。"},{12,L"收到HDR也转成SDR显示,不用改PS5或Windows。增强照常用;只改预览,视频导出不受影响。切换会短暂停顿,截图跟随当前画面。关闭后跟随显示器。"},{10,L"设备没报HDR信息时手动指定,需选P010/P016。P010也可能装SDR,别给普通画面强戴HDR帽子。"},{1,L"选采集卡的视频设备。别把摄像头误请来直播PS5。"},{2,L"选设备真实提供的分辨率、帧率和像素格式。清晰度、带宽和延迟都受它影响。"},{3,L"如果设备自带 HDMI 音频,会显示“使用视频设备内置音频”;否则选择独立音频设备,也可不采声音。"},{4,L"按当前格式连接采集卡,并应用当前增强设置。"},{5,L"重新扫描设备和格式。设备被其他软件占用时,刷新不一定能抢回来。"}});EnableWindow(GetDlgItem(h,4),FALSE);arrange();SetTimer(h,1,100,nullptr);if(!busy)query(-1);return 0;}case WM_TIMER:SendDlgItemMessageW(h,12,BM_SETCHECK,readSdr()?BST_CHECKED:BST_UNCHECKED,0);@@ -93,6 +96,10 @@ case WM_COMMAND:const bool enabled=SendDlgItemMessageW(h,12,BM_GETCHECK,0,0)==BST_CHECKED;if(!setSdr(enabled))SetDlgItemTextW(h,8,L"当前正在切换增强,请稍后再试。");SendDlgItemMessageW(h,12,BM_SETCHECK,readSdr()?BST_CHECKED:BST_UNCHECKED,0);+ }else if(LOWORD(wp)==13&&HIWORD(wp)==CBN_SELCHANGE){+ const int mode=int(SendDlgItemMessageW(h,13,CB_GETCURSEL,0,0));+ if(mode>=0&&setAudioIngress&&!setAudioIngress(mode))SetDlgItemTextW(h,8,L"当前正在切换增强或采集;请稍后再试。");+ if(readAudioIngress)SendDlgItemMessageW(h,13,CB_SETCURSEL,WPARAM(std::clamp(readAudioIngress(),0,2)),0);}else if(LOWORD(wp)==1&&HIWORD(wp)==CBN_SELCHANGE){const int device=int(SendDlgItemMessageW(h,1,CB_GETCURSEL,0,0));rebuildAudioList(h,device);query(device);}else if((LOWORD(wp)==2||LOWORD(wp)==3)&&HIWORD(wp)==CBN_SELCHANGE){@@ -123,5 +130,5 @@ case WM_CLOSE:DestroyWindow(h);return 0;case WM_DESTROY:KillTimer(h,1);DeleteObject(font);window=nullptr;return 0;}return DefWindowProcW(h,msg,wp,lp);}}-void showCapturePanel(HWND parent,std::function<void(const std::wstring&)> callback,std::function<bool()> read,std::function<bool(bool)> write){start=std::move(callback);readSdr=std::move(read);setSdr=std::move(write);if(window){SetForegroundWindow(window);return;}WNDCLASSW wc{};wc.lpfnWndProc=proc;wc.hInstance=GetModuleHandleW(nullptr);wc.lpszClassName=L"VeyraCaptureSetup";wc.hbrBackground=panelBrush();wc.hCursor=LoadCursorW(nullptr,IDC_ARROW);RegisterClassW(&wc);CreateWindowExW(WS_EX_TOOLWINDOW,wc.lpszClassName,L"采集卡 · 连接设置",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,dip(parent,560),dip(parent,514),parent,nullptr,wc.hInstance,nullptr);}+void showCapturePanel(HWND parent,std::function<void(const std::wstring&)> callback,std::function<bool()> read,std::function<bool(bool)> write,std::function<int()> readIngress,std::function<bool(int)> writeIngress){start=std::move(callback);readSdr=std::move(read);setSdr=std::move(write);readAudioIngress=std::move(readIngress);setAudioIngress=std::move(writeIngress);if(window){SetForegroundWindow(window);return;}WNDCLASSW wc{};wc.lpfnWndProc=proc;wc.hInstance=GetModuleHandleW(nullptr);wc.lpszClassName=L"VeyraCaptureSetup";wc.hbrBackground=panelBrush();wc.hCursor=LoadCursorW(nullptr,IDC_ARROW);RegisterClassW(&wc);CreateWindowExW(WS_EX_TOOLWINDOW,wc.lpszClassName,L"采集卡 · 连接设置",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,dip(parent,560),dip(parent,562),parent,nullptr,wc.hInstance,nullptr);}}diff --git a/apps/veyra/ui/CapturePanel.h b/apps/veyra/ui/CapturePanel.hindex 5b830595..4c54c386 100644--- a/apps/veyra/ui/CapturePanel.h+++ b/apps/veyra/ui/CapturePanel.h@@ -2,4 +2,10 @@#include <windows.h>#include <string>#include <functional>-namespace veyra::ui {void showCapturePanel(HWND,std::function<void(const std::wstring&)>,std::function<bool()> readSdr,std::function<bool(bool)> setSdr);}+namespace veyra::ui {+// readAudioIngress/setAudioIngress use engine::CaptureAudioIngress values+// (0 automatic, 1 PCM only, 2 bitstream preferred). The mode needs a reconnect+// because the audio media type is negotiated when the capture graph is built.+void showCapturePanel(HWND,std::function<void(const std::wstring&)>,std::function<bool()> readSdr,std::function<bool(bool)> setSdr,+ std::function<int()> readAudioIngress,std::function<bool(int)> setAudioIngress);+}diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 03451bad..d78298a0 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -2347,6 +2347,27 @@ DLSSG 能力门控没有排除 FSR,导致 FSR 会话下任何就地设置变### 2026-09-16 杜比/DTS 位流解码兜底(G-2)实现 + 本地解码验证+### 2026-09-16 采集音频改为可手动指定(用户反馈自动识别不好用)++用户反馈"自动识别并不好用",要求在采集面板里像 HDR 那样手动选。已加:++- 采集面板新增下拉框「采集音频(变更需重连)」:**自动**(优先线性 PCM,PCM 不可用时位流解码)、+ **强制线性 PCM**(不接受 Dolby/DTS 位流)、**位流优先**(Dolby/DTS 直通解码为 PCM,+ 适合 PS5 已设成 Dolby 输出但设备同时提供 PCM 的情况),并带与 HDR 那两项同风格的说明文本。+- 设置持久化:`EnhancementSettings::captureAudio`(`engine::CaptureAudioIngress`),+ 预设 schema 升到 **v14**(旧版本读入默认"自动"),UI 走 `applySettings` 与 HDR 选项同一条路。+- 采集端按模式执行:`CaptureCardSource::setAudioIngress` + `configureAudio()` 里+ `位流优先` 先试压缩类型、失败再回退 PCM;`强制 PCM` 完全忽略位流类型并写日志说明。+ 命令行测试开关 `--capture-audio 0|1|2`。+- **修掉一个真 bug**:`setAudioIngress` 原先在采集源 `configure()` 之后才调用,+ 第一次连接不会生效;现在移到配置之前(日志顺序 `capture-audio-ingress` →+ `device bitstream types` → `selected media type` 即为证)。+- 本机参考采集卡三种模式实测(本身无位流类型):mode0/1/2 均 exit 0、330–335 帧、60fps、+ 选中 48kHz/2ch PCM(`logs/fsr/capture-audio-mode{0,1,2}.log`)。**位流优先的"真的优先"分支+ 只能靠有 Dolby 输出的设备验收**,本机无法触发。+- 回归:契约测试 165 项 0 失败;预设 66 组迁移 + 全字段往返(含新模式)通过;+ delivery 短测 PASS(`logs/delivery/72b1dec41e0540f7ae5fa6856f8a18b7/result.json`)。+新增 `include/veyra/sink/BitstreamAudio.h` + `src/sink/BitstreamAudio.cpp`(FFmpeg libavcodec/libswresample):按 KSDATAFORMAT/WAVE subtype 分类 AC-3 / E-AC-3(含 DD+ Atmos 载体) / TrueHD-MLP / DTS / DTS-HD/DTS:X,S/PDIF 的 IEC 61937 突发自动解框,解码为交错 float PCM 并给出真实声道数与采样率。diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.hindex ececf784..d7507ed6 100644--- a/include/veyra/engine/EnhancementSettings.h+++ b/include/veyra/engine/EnhancementSettings.h@@ -19,6 +19,19 @@ inline constexpr size_t kFgMultiplierChoiceCount=sizeof(kFgMultiplierChoices)/si// videoSrQuality values: 0 = DLSS SR, 1..4 = RTX video SR quality steps,// 5 = AMD FSR upscaling (vendor neutral; verified on an NVIDIA adapter).inline constexpr uint32_t kVideoSrFsr=5;+// Capture audio ingress policy. Automatic is what the pipeline did before the+// manual selector existed; the other two exist because Dolby/DTS passthrough+// negotiation depends on the device and the console, and users reported that+// "let the capture card decide" is not reliable in practice.+enum class CaptureAudioIngress { Auto, PcmOnly, BitstreamPreferred };+constexpr std::wstring_view captureAudioIngressName(CaptureAudioIngress mode) {+ switch(mode) {+ case CaptureAudioIngress::PcmOnly: return L"强制线性 PCM";+ case CaptureAudioIngress::BitstreamPreferred: return L"位流优先(Dolby/DTS 直通解码)";+ case CaptureAudioIngress::Auto: break;+ }+ return L"自动(优先 PCM,必要时位流解码)";+}enum class NrRuntime { Original, Community, Ampere };constexpr std::string_view nrRuntimeName(NrRuntime runtime) {switch(runtime) {@@ -83,6 +96,9 @@ struct EnhancementSettings {bool lowLatency=false; // preview only: NR before SR, opt-inNrRuntime nrRuntime=NrRuntime::Original;bool captureCompatible=false;+ // Capture audio ingress; requires a reconnect to take effect (the media type+ // is negotiated when the graph is built).+ CaptureAudioIngress captureAudio=CaptureAudioIngress::Auto;bool forceSdrPreview=false; // display only; retain actual HDR source metadatabool useHdrPreview(bool hdrInput,bool hdrDisplayActive)const{return hdrInput&&hdrDisplayActive&&!forceSdrPreview;}pipeline::SrTarget srTarget=pipeline::SrTarget::Uhd4K;@@ -117,6 +133,7 @@ struct EnhancementSettings {if(auto error=protection.validate();!error.empty())return error;if(!revision)return "settingsRevision must be nonzero";if(nrRuntime!=NrRuntime::Original&&nrRuntime!=NrRuntime::Community&&nrRuntime!=NrRuntime::Ampere)return "invalid NR runtime";+ if(captureAudio<CaptureAudioIngress::Auto||captureAudio>CaptureAudioIngress::BitstreamPreferred)return "invalid capture audio ingress mode";if(audioSync<AudioSyncMode::Automatic||audioSync>AudioSyncMode::Off||audioOffsetMs<-250||audioOffsetMs>250)return "invalid audio sync setting";if(!range(model.intensity,1)||!range(model.tone,1)||!range(model.structure,1))return "model parameter out of range";if(model.skin!=-1&&!range(model.skin,2))return "skin parameter out of range";diff --git a/include/veyra/source/CaptureCardSource.h b/include/veyra/source/CaptureCardSource.hindex e4c4f968..b9cfe3cb 100644--- a/include/veyra/source/CaptureCardSource.h+++ b/include/veyra/source/CaptureCardSource.h@@ -42,6 +42,9 @@ public:// Owner-thread recovery of DirectShow audio pins; same video filter retained.void recoverAudio(float gain,unsigned syncMode,int offsetMs);bool setAudioGain(float); // call on the graph owner thread; never system volume+ // 0 automatic, 1 PCM only, 2 bitstream preferred. Takes effect on the next+ // connect/reconnect because the audio media type is negotiated there.+ void setAudioIngress(unsigned mode);CaptureMetrics metrics()const;void videoPresented(double ptsMs,int64_t host100ns,int64_t arrival100ns);void videoReset(bool resetAudio=true);diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 34faa75c..96176978 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -212,6 +212,10 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(stop_||!cachedFrame)break;}else#endif+ // Audio ingress policy has to be in place before the capture+ // graph negotiates its media type, otherwise the first connect+ // silently uses the previous mode.+ if(physicalCapture)captureSource.setAudioIngress(unsigned(options.settings.captureAudio));if(!(physicalCapture?captureSource.configure(od):activeSource->open(od))){status(!isCapture&&!source.errorMessage().empty()?source.errorMessage():L"无法打开视频,请查看诊断",true);break;}// A file's actual decoded pixel format and HDR VUI are only// reliable on AVFrame. Prime one frame before constructing@@ -354,6 +358,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(graph.xessEnabled()&&!presenter.xessActive())snapshot_.backendWarning=L"XeSS 初始化失败;当前为普通呈现";}captureSource.setAudioSync(unsigned(options.settings.audioSync),options.settings.audioOffsetMs);+ captureSource.setAudioIngress(unsigned(options.settings.captureAudio));if(physicalCapture&&!captureSource.start()){status(L"无法启动采集,请查看诊断",true);break;}{std::lock_guard lock(mutex_);snapshot_.duration=duration;snapshot_.nominalSourceFps=isImage?0:activeSource->info().averageFps;snapshot_.running=true;snapshot_.transport=TransportState::Playing;snapshot_.image=isImage;snapshot_.capture=isCapture;snapshot_.applied=options.snapshot();snapshot_.desired=desired_;}status(isImage?L"图片已增强,可保存PNG/JPEG":std::format(L"{} | 输入 {}×{} / 底图 {}×{} / NR {}×{} / 光流 {}×{} / FG与输出 {}×{} | {}",isRemote?L"PS5 串流":isCapture?L"实时采集":L"播放",width,height,gd.workWidth,gd.workHeight,gd.nrWidth,gd.nrHeight,gd.flowWidth,gd.flowHeight,gd.workWidth,gd.workHeight,gd.nrBeforeSr?L"低延迟 · NR先行后超分":gd.nrWidth<gd.workWidth?L"实时内部处理并回填":L"原生NR(性能成本较高)"));@@ -571,6 +576,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s++captureRetries;{std::lock_guard lock(mutex_);snapshot_.captureReconnectAttempts=captureRetries;}status(std::format(L"采集信号中断,正在重连原设备(第 {} 次)",captureRetries));+ captureSource.setAudioIngress(unsigned(options.settings.captureAudio));if(captureSource.reconnect(muted_?0.0f:volume_.load(),unsigned(options.settings.audioSync),options.settings.audioOffsetMs)){captureRecovering=false;reset=true;pendingResetCause=pipeline::ResetReason::DeviceLost;captureSampler.reset();{std::lock_guard lock(mutex_);snapshot_.captureRecovering=false;}@@ -609,6 +615,14 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(requested.revision==options.settings.revision&&requested!=options.settings){options.settings.audioSync=requested.audioSync;options.settings.audioOffsetMs=requested.audioOffsetMs;captureSource.setAudioSync(unsigned(requested.audioSync),requested.audioOffsetMs);+ // Audio ingress is negotiated when the capture graph is+ // built: record it now and tell the user a reconnect applies+ // it instead of pretending it is already live.+ if(requested.captureAudio!=options.settings.captureAudio){+ options.settings.captureAudio=requested.captureAudio;+ captureSource.setAudioIngress(unsigned(requested.captureAudio));+ status(L"采集音频模式已记录;重新连接采集卡后生效",false);+ }std::lock_guard lock(mutex_);snapshot_.applied=options.snapshot();snapshot_.applying=desired_!=snapshot_.applied;veyra::log::info("settings",std::format("Audio applied videoRevision={} mode={} offsetMs={} (video history retained)",requested.revision,unsigned(requested.audioSync),requested.audioOffsetMs));}diff --git a/src/engine/PresetStore.cpp b/src/engine/PresetStore.cppindex d0e8cd89..d295a252 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()!=Lstd::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 13\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<<'\n';}return o.str();+ std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS 14\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)<<'\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>13)||!(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>14)||!(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;@@ -36,6 +36,7 @@ bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,stdif(version>=10){int capture;if(!(in>>capture)||capture<0||capture>1)return false;s.captureCompatible=capture!=0;}if(version>=11){int low;if(!(in>>low)||low<0||low>1)return false;s.lowLatency=low!=0;}if(version>=12){int sdr;if(!(in>>sdr)||sdr<0||sdr>1)return false;s.forceSdrPreview=sdr!=0;}+ if(version>=14){int ingress;if(!(in>>ingress)||ingress<0||ingress>2)return false;s.captureAudio=static_cast<CaptureAudioIngress>(ingress);}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/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cppindex 00e44e3b..e2c2cf1a 100644--- a/src/source/CaptureCardSource.cpp+++ b/src/source/CaptureCardSource.cpp@@ -132,6 +132,9 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {std::shared_ptr<sink::BitstreamDecoder> audioBitstream;bool audioSessionDeferred=false;std::wstring audioBitstreamKind;+ // 0 automatic, 1 PCM only, 2 bitstream preferred (see+ // engine::CaptureAudioIngress). Read when the audio graph is built.+ unsigned audioIngressMode=0;std::unique_ptr<WasapiAudioInput> wasapi;std::wstring audioError;AudioInputRecovery audioRecovery;@@ -214,6 +217,14 @@ std::vector<CaptureFormat> enumerateFormats(IAMStreamConfig* config){std::vector<CaptureFormat> CaptureCardSource::formats(unsigned device){ComPtr<IGraphBuilder> g;ComPtr<ICaptureGraphBuilder2>b;ComPtr<IBaseFilter>f;ComPtr<IAMStreamConfig>c;if(!configuration(device,g,b,f,c))return {};return enumerateFormats(c.Get());}std::vector<CaptureFormat> CaptureCardSource::formatsByPath(std::wstring_view devicePath){ComPtr<IGraphBuilder> g;ComPtr<ICaptureGraphBuilder2>b;ComPtr<IBaseFilter>f;ComPtr<IAMStreamConfig>c;if(!configuration(devicePath,g,b,f,c))return {};return enumerateFormats(c.Get());}const SourceInfo& CaptureCardSource::info()const{return p_->info;}+void CaptureCardSource::setAudioIngress(unsigned mode){+ auto& p=*p_;+ const unsigned clamped=mode>2?0:mode;+ if(p.audioIngressMode==clamped)return;+ p.audioIngressMode=clamped;+ log::info("capture-audio-ingress",std::format("mode={} ({}) takes effect on the next connect",clamped,+ clamped==1?"PCM only":clamped==2?"bitstream preferred":"automatic"));+}bool CaptureCardSource::setAudioGain(float gain){if(p_->wasapi){p_->wasapi->setGain(gain);return p_->wasapi->snapshot().available;}auto& p=*p_;if(p.audioSession){p.audioSession->setGain(gain);return p.audioSession->snapshot().available;}if(!p.graph||!p.audioFilter)return false;@@ -375,13 +386,19 @@ if(name){else if(bitstreamName(type->subtype))bitstreamTypes.push_back(std::move(owned));}log::info("capture-audio-bitstream",std::format("device bitstream types={} [{}] pcmTypes={}",bitstreamTypeCount,bitstreamSummary.empty()?"none":bitstreamSummary,audioTypes.size()));-if(audioTypes.empty()){log::warn("capture-audio","audio pin has no supported PCM media type");return false;}+const bool wantBitstreamFirst=p.audioIngressMode==2;+const bool allowBitstream=p.audioIngressMode!=1;+if(p.audioIngressMode==1&&bitstreamTypeCount>0)log::info("capture-audio-ingress","manual PCM-only selected: bitstream types are ignored even though the device offers them");+if(audioTypes.empty()&&(!allowBitstream||bitstreamTypes.empty())){log::warn("capture-audio","audio pin has no usable media type for the selected ingress mode");return false;}std::stable_sort(audioTypes.begin(),audioTypes.end(),[](const auto& a,const auto& b){sink::WavePcmFormat lhs{},rhs{};if(!sink::parseWavePcm(a->pbFormat,a->cbFormat,lhs)||!sink::parseWavePcm(b->pbFormat,b->cbFormat,rhs))return false;return sink::preferCaptureAudioFormat(lhs,rhs);});bool connectedAudio=false;+ // PCM attempt as a lambda so the bitstream-preferred mode can try it after+ // the compressed types instead of before them.+ auto connectPcm=[&]()->bool{for(const auto& owned:audioTypes){auto* type=owned.get();auto session=std::make_unique<sink::CaptureAudioSession>();ComPtr<IBaseFilter> candidate;ComPtr<IPin> terminal;@@ -403,12 +420,15 @@ if(audioTypes.empty()){log::warn("capture-audio","audio pin has no supported PCMelse if(candidate)p.graph->RemoveFilter(candidate.Get());log::info("capture-audio",std::format("PCM ConnectDirect hr=0x{:X}",unsigned(hr)));}- if(connectedAudio)break;+ if(connectedAudio)return true;}+ return false;+ };+ if(!wantBitstreamFirst)connectedAudio=connectPcm();// Dolby/DTS passthrough fallback: no PCM type connected, so take the best// compressed type the device offers and decode it back to PCM. This is the// path a PS5 feeding Dolby Atmos / Dolby Audio / DTS needs.- if(!connectedAudio&&!bitstreamTypes.empty()){+ if(!connectedAudio&&allowBitstream&&!bitstreamTypes.empty()){std::stable_sort(bitstreamTypes.begin(),bitstreamTypes.end(),[](const auto& a,const auto& b){return sink::bitstreamPreferenceOrder(sink::classifyBitstreamSubtype(a->subtype.Data1))>sink::bitstreamPreferenceOrder(sink::classifyBitstreamSubtype(b->subtype.Data1));@@ -470,6 +490,7 @@ if(audioTypes.empty()){log::warn("capture-audio","audio pin has no supported PCMif(connectedAudio)break;}}+ if(!connectedAudio&&wantBitstreamFirst)connectedAudio=connectPcm();return connectedAudio;}bool CaptureCardSource::start(){diff --git a/tests/unit/RepairContractTests.cpp b/tests/unit/RepairContractTests.cppindex 640a4d41..66849cbc 100644--- a/tests/unit/RepairContractTests.cpp+++ b/tests/unit/RepairContractTests.cpp@@ -202,6 +202,16 @@ int main(){settings.videoSrQuality=0;check(settings.validate().empty(),"DLSS SR quality remains valid");}+ {+ engine::EnhancementSettings settings;+ check(settings.captureAudio==engine::CaptureAudioIngress::Auto,"capture audio ingress defaults to automatic");+ for(auto mode:{engine::CaptureAudioIngress::Auto,engine::CaptureAudioIngress::PcmOnly,engine::CaptureAudioIngress::BitstreamPreferred}){+ settings.captureAudio=mode;+ check(settings.validate().empty(),"capture audio ingress modes validate");+ }+ settings.captureAudio=static_cast<engine::CaptureAudioIngress>(3);+ check(!settings.validate().empty(),"capture audio ingress outside the enum is rejected");+ }check(engine::opticalFlowBackendName(engine::OpticalFlowBackend::Nvidia)=="NVIDIA_NVOF"&&engine::opticalFlowBackendName(engine::OpticalFlowBackend::AmdFidelityFx)=="AMD_FIDELITYFX_OF","optical-flow backend names identify every backend");s.model.intensity=std::numeric_limits<float>::quiet_NaN();check(!s.validate().empty(),"reject NaN transaction");s={};s.multiplier=5;check(s.validate().empty(),"5X multiplier accepted by the API guard (6X ceiling)");diff --git a/tests/unit/RepairPresetTests.cpp b/tests/unit/RepairPresetTests.cppindex 7e24b982..aa5cccce 100644--- a/tests/unit/RepairPresetTests.cpp+++ b/tests/unit/RepairPresetTests.cpp@@ -7,7 +7,7 @@ namespace {bool legacyBackends(const std::filesystem::path& path) {using namespace veyra::engine;unsigned checks=0;- for(int version=4;version<=13;++version)for(int backend=0;backend<=2;++backend)for(int multiplier:{2,4}){+ for(int version=4;version<=14;++version)for(int backend=0;backend<=2;++backend)for(int multiplier:{2,4}){std::ostringstream fixture;fixture<<"VEYRA_PRESETS "<<version<<"\n\"legacy\" 1\n\"legacy\" 1 1 1 -1 0 0 0 1 1 1 1 1 1 0 "<<multiplier<<" 0 1 0";fixture<<" 0 0";@@ -20,6 +20,7 @@ bool legacyBackends(const std::filesystem::path& path) {if(version>=10)fixture<<" 1";if(version>=11)fixture<<" 0";if(version>=12)fixture<<" 0";+ if(version>=14)fixture<<" 0";fixture<<'\n';{std::ofstream file(path);file<<fixture.str();}const bool xess=version<8?backend==2:backend==1;@@ -41,7 +42,7 @@ bool legacyBackends(const std::filesystem::path& path) {if(version>=7&&(value.audioSync!=AudioSyncMode::Manual||value.audioOffsetMs!=137))return false;if(!store.put(L"legacy",value,true))return false;std::ifstream file(path);std::string magic;int savedVersion=0;file>>magic>>savedVersion;- if(magic!="VEYRA_PRESETS"||savedVersion!=13)return false;+ if(magic!="VEYRA_PRESETS"||savedVersion!=14)return false;PresetStore reloaded(path);if(!reloaded.load()||reloaded.defaultSettings()!=value)return false;}else{@@ -93,6 +94,13 @@ ok=ok&&a.put(L"test",s)&&a.setDefault(0)&&!a.put(L"test",s);PresetStore b(p);ok=auto badSr=s;badSr.videoSrQuality=veyra::engine::kVideoSrFsr+1;ok=ok&&!b.put(L"invalid video SR",badSr);auto invalid=s;invalid.model.tone=9;ok=ok&&!b.put(L"bad",invalid)&&b.entries().size()==1&&b.erase(0)&&b.entries().empty();auto badRegion=s;badRegion.protection.regions[0].left=2;ok=ok&&!b.put(L"invalid region",badRegion);+ // Capture audio ingress: the manual Dolby/DTS selector round-trips and an+ // out-of-range value is refused.+ // The store is empty here (the invalid-settings block erased the last entry),+ // so the round-tripped preset lands at index 0.+ auto ingress=s;ingress.captureAudio=CaptureAudioIngress::BitstreamPreferred;ok=ok&&b.put(L"audio bitstream",ingress);+ PresetStore ingressReload(p);ok=ok&&ingressReload.load()&&ingressReload.entries().size()==1&&ingressReload.entries().back().settings.captureAudio==CaptureAudioIngress::BitstreamPreferred&&b.erase(0);+ auto badIngress=s;badIngress.captureAudio=static_cast<CaptureAudioIngress>(3);ok=ok&&!b.put(L"invalid ingress",badIngress);{std::ofstream legacy(p);legacy<<"VEYRA_PRESETS 1\n\"legacy\" 1\n\"legacy\" 1 1 1 -1 0 0 0 1 1 1 1 1 1 0 1 0 1 0\n";}PresetStore old(p);ok=ok&&old.load()&&!old.defaultSettings().protection.enabled&&old.defaultSettings().srTarget==veyra::pipeline::SrTarget::Uhd4K&&old.put(L"v2",s);PresetStore upgraded(p);ok=ok&&upgraded.load()&&upgraded.entries().size()==2&&upgraded.entries()[1].settings==s;