Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
fix: PS5 remote-play first-frame abort and RGB24 capture orientation
Veyra Goal Agent015f8a4eaa66
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex ceb4291b..9f42128d 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -60,7 +60,7 @@ std::wstring smokeView;bool smokeViewApplied=false;std::wstring smokeDualOutput;bool smokeEmpty=false;DWORD modeGdiStart=0,modeHandlesStart=0;SIZE_T modePrivateStart=0;bool smokeDual=false,smokeDualPause=false,smokeMaster=false,smokeMasterReject=false,smokeAudio=false,smokeJob=false,smokeJobCancel=false,smokeJobExit=false;int dualStep=0,masterStep=0,audioStep=0,jobStep=0;double pausedPosition=-1,jobPosition=0;uint64_t pausedFrames=0;ULONGLONG jobPauseTick=0;HANDLE workerMapping=nullptr;void switchMode();void selectInspector(int);void refreshDailyPresets();-bool applySettings(veyra::engine::EnhancementSettings s){if(masterPendingRevision)return false;uiState.configured=s;if(uiState.enhanced)engine.requestSettings(s);else {auto effective=engine.snapshot().desired;if(effective.captureCompatible!=s.captureCompatible||effective.forceSdrPreview!=s.forceSdrPreview){effective.captureCompatible=s.captureCompatible;effective.forceSdrPreview=s.forceSdrPreview;engine.requestSettings(effective);}veyra::log::info("ui-settings","enhancement off: draft saved; presentation setting applied independently");}veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);return true;}+bool applySettings(veyra::engine::EnhancementSettings s){if(masterPendingRevision)return false;uiState.configured=s;if(uiState.enhanced)engine.requestSettings(s);else {auto effective=engine.snapshot().desired;if(effective.captureCompatible!=s.captureCompatible||effective.forceSdrPreview!=s.forceSdrPreview||effective.captureFlipVertical!=s.captureFlipVertical){effective.captureCompatible=s.captureCompatible;effective.forceSdrPreview=s.forceSdrPreview;effective.captureFlipVertical=s.captureFlipVertical;engine.requestSettings(effective);}veyra::log::info("ui-settings","enhancement off: draft saved; presentation setting applied independently");}veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);return true;}struct ToolbarItem{HWND hwnd;int width;};std::vector<ToolbarItem> toolbar;bool full=false,holdOriginal=false,referenceBase=false;int compareMode=0;float compareSplit=.5f;WINDOWPLACEMENT windowPlacement{sizeof(windowPlacement)};@@ -587,7 +587,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);},[]{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 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);},[]{return (uiState.enhanced?engine.snapshot().desired:uiState.configured).captureFlipVertical;},[](bool enabled){auto s=uiState.enhanced?engine.snapshot().desired:uiState.configured;s.captureFlipVertical=enabled;return applySettings(s);});break;case Export:if(uiState.mode==veyra::ui::Mode::Professional)startVideoExport(false);break;case Info:showDiagnostics=!showDiagnostics;layout();break;}return 0;@@ -788,6 +788,9 @@ int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<a// every value-taking flag known, so --fg-xess / --fg-fsr / --fg-dlss work// anywhere on the command line instead of only at the end.{+ // --capture-flip: diagnostics/smoke only; the interactive path uses the+ // capture panel checkbox and persists captureFlipVertical with presets.+ {int flipArgc=0;auto flipArgv=CommandLineToArgvW(GetCommandLineW(),&flipArgc);for(int i=1;i<flipArgc;++i)if(!_wcsicmp(flipArgv[i],L"--capture-flip"))initialOptions.settings.captureFlipVertical=true;LocalFree(flipArgv);}int positionalArgc=0;auto positionalArgv=CommandLineToArgvW(GetCommandLineW(),&positionalArgc);std::wstring positional;const wchar_t* valueFlags[]={L"--export-worker",L"--smoke-view",L"--smoke-dual-export",L"--smoke-seconds",L"--export-out",L"--max-frames",L"--cancel-after-ms",L"--smoke-save",L"--fg-multiplier",L"--capture-audio",L"--video-sr",L"--bitrate-mbps",L"--subtitle-primary",L"--subtitle-secondary",L"--subtitle-offset-ms",L"--subtitle-font-size"};for(int i=1;i<positionalArgc;++i){const std::wstring a=positionalArgv[i];diff --git a/apps/veyra/ui/CapturePanel.cpp b/apps/veyra/ui/CapturePanel.cppindex 35442396..0cea3a32 100644--- a/apps/veyra/ui/CapturePanel.cpp+++ b/apps/veyra/ui/CapturePanel.cpp@@ -16,6 +16,7 @@ std::vector<source::CaptureFormat> formats;std::vector<source::CaptureDevice> videoDevices,audioDevices;CapturePreferences remembered;std::function<bool()> readSdr;std::function<bool(bool)> setSdr;std::function<int()> readAudioIngress;std::function<bool(int)> setAudioIngress;+std::function<bool()> readFlip;std::function<bool(bool)> setFlip;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 +43,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,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);}}+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,512};for(int id=1;id<=15;++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();@@ -54,12 +55,14 @@ case WM_CREATE:{window=h;font=makeFont(h);titleTheme(h);auto add=[&](const wcharadd(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"位流优先:优先直通给功放(无直通时解码为 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"画面上下翻转(采集画面倒置时勾选,立即生效)",15,BS_AUTOCHECKBOX|WS_TABSTOP);SendDlgItemMessageW(h,15,BM_SETCHECK,readFlip&&readFlip()?BST_CHECKED:BST_UNCHECKED,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,{{13,L"采集卡把 Dolby Atmos / Dolby Audio / DTS 以位流送来时,这里决定用哪条路。设备本身的音频格式不受影响;改这个要重新连接采集卡。自动优先 PCM,PCM 不可用时才走位流解码;位流优先则反过来:先尝试把位流原样直通给功放/回音壁(独占输出,卡不经过软件解码,只有接收端才能解出 Atmos/DTS:X 的对象声场;需要输出设备支持,探测见日志 bitstream-out),没有支持的输出端点时自动回退到解码。适合 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"重新扫描设备和格式。设备被其他软件占用时,刷新不一定能抢回来。"}});+ installDialogHelp(h,{{15,L"给方向声明和实际画面不一致的采集卡用:常见于某些 RGB24 格式——设备在媒体类型里写的是底行在前,实际送来的却是顶行在前,于是画面上下颠倒。勾选后把采集画面上下翻转一次,立即生效;只影响本机采集预览、截图和从这里导出的画面,不改设备也不动其他格式。画面正常时不要勾选;换成不颠倒的格式后记得取消。"},{13,L"采集卡把 Dolby Atmos / Dolby Audio / DTS 以位流送来时,这里决定用哪条路。设备本身的音频格式不受影响;改这个要重新连接采集卡。自动优先 PCM,PCM 不可用时才走位流解码;位流优先则反过来:先尝试把位流原样直通给功放/回音壁(独占输出,卡不经过软件解码,只有接收端才能解出 Atmos/DTS:X 的对象声场;需要输出设备支持,探测见日志 bitstream-out),没有支持的输出端点时自动回退到解码。适合 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);+ if(readFlip)SendDlgItemMessageW(h,15,BM_SETCHECK,readFlip()?BST_CHECKED:BST_UNCHECKED,0);if(busy&&pending.wait_for(std::chrono::seconds(0))==std::future_status::ready){auto result=pending.get();busy=false;EnableWindow(GetDlgItem(h,5),TRUE);EnableWindow(GetDlgItem(h,1),TRUE);if(refreshAfterQuery){refreshAfterQuery=false;query(-1);return 0;}@@ -96,6 +99,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)==15&&HIWORD(wp)==BN_CLICKED){+ const bool enabled=SendDlgItemMessageW(h,15,BM_GETCHECK,0,0)==BST_CHECKED;+ if(!setFlip||!setFlip(enabled))SetDlgItemTextW(h,8,L"当前正在切换增强,请稍后再试。");+ if(readFlip)SendDlgItemMessageW(h,15,BM_SETCHECK,readFlip()?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"当前正在切换增强或采集;请稍后再试。");@@ -130,5 +137,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,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);}+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,std::function<bool()> readFlipped,std::function<bool(bool)> writeFlipped){start=std::move(callback);readSdr=std::move(read);setSdr=std::move(write);readAudioIngress=std::move(readIngress);setAudioIngress=std::move(writeIngress);readFlip=std::move(readFlipped);setFlip=std::move(writeFlipped);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,600),parent,nullptr,wc.hInstance,nullptr);}}diff --git a/apps/veyra/ui/CapturePanel.h b/apps/veyra/ui/CapturePanel.hindex 4c54c386..47f29b50 100644--- a/apps/veyra/ui/CapturePanel.h+++ b/apps/veyra/ui/CapturePanel.h@@ -6,6 +6,9 @@ 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.+// readFlip/setFlip toggle the manual vertical ingest flip for devices whose+// declared DIB orientation does not match their samples (RGB24 upside down).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);+ std::function<int()> readAudioIngress,std::function<bool(int)> setAudioIngress,+ std::function<bool()> readFlip,std::function<bool(bool)> setFlip);}diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 4a81973e..0ab0e129 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,43 @@# 2026-09-11 继续修复目标模式执行中+## 2026-09-16 RGB24 采集倒像:直连 top-down 协商 + 手动上下翻转(用户选 A+B,不做强制转换 C)++用户反馈部分设备用 RGB24 时画面上下颠倒,其他格式正常、其他软件正常。判定:全链路只有 `captureMediaLayout` 按 DIB 的 `biHeight` 符号决定是否翻转(`copyCaptureSample`),YUV 一律按 top-down 读、不看符号;这些设备的 RGB24 媒体类型声明方向与实际样本不一致。RGB24 自 1.1.0 起是原生直连(1.0.x 走系统 RGB32 转换),因此只有该格式暴露该矛盾。旧测试是自证式(单元用例用同一公式算期望)或用等值横条纹(GPU 用例),方向没有任何断言。++**A. 直连 RGB DIB 先协商 top-down**(`src/source/CaptureCardSource.cpp`):对 Bgr32/Bgra32/Bgr24/RGB555/565 且 `biHeight>0` 的 caps 类型,先把 `biHeight` 取负再 `SetFormat`;成功则重新 `GetFormat` 并按实际连接类型解析(负高度→不翻转),失败则恢复原符号、保持按符号翻转。新增日志 `[capture] DIB top-down request hr=0x… accepted=0/1 bottomUp=…`。诚实的 bottom-up 设备两种结果都保持正确。++**B. 采集面板"画面上下翻转"开关**(立即生效):新增 `EnhancementSettings::captureFlipVertical`(默认关;加入 `sameVideoConfiguration` 的实时字段,切换不重建图);`CaptureCardSource::setVerticalFlip`(原子标志,DirectShow 回调按样本生效,RGB 与 YUV 都支持,YUV 连色度行一起翻转;`copyCaptureSample` 增加可选 flip 参数);引擎在 configure 前、start 前、重连、每帧与实时设置块同步;采集面板新增 checkbox 15 与帮助文本,AppShell 接线;`--capture-flip` 仅作诊断/烟测。预设 schema v15→v16(行尾追加 bool;v1–v15 旧文件仍可读,老版本读到 v16 会拒绝并保留原文件)。++**验证**:++- `veyra_capture_color_tests.exe`:failures=0;新增方向断言全部 PASS(bottom-up RGB24 读最后一行、top-down 直通、手动翻转对两种输入都反相、NV12 色度行跟随翻转)。+- `veyra_repair_contract_tests.exe`:181 checks 0 failures(含 "capture vertical flip defaults off")。+- `veyra_repair_preset_tests.exe <tmp>`:66 组 v4–v14 迁移 + 全字段往返(含 v16 翻转字段)通过,exit 0;测试内的 schema 版本断言同步改为 16。+- `cmd.exe /c out\build\veyra-build-x64-release.cmd` exit 0(93/93)。+- 实卡烟测:`veyra.exe "capture:0:0:-1:0" --smoke-seconds 10 --no-nr --no-sr --no-fg --capture-flip` exit 0、`frames=573`、`failed=false`、`captureDropped=0`,日志 `[capture-flip] manual vertical flip=1`(YUY2 路径翻转后仍稳定);最终构建再复测 8 秒 exit 0。+- 总开关关闭时也立即生效:`applySettings` 的 enhancement-off 分支改为与 `forceSdrPreview` 一起转发 `captureFlipVertical`(否则首次默认"全关"状态下勾选不会下发)。+- delivery 短测 PASS,42.84 秒,`logs/delivery/3f749a7819ae4ae6842eab73ed04e235/result.json`,最终 EXE SHA256 `D7539CBC7CC8D5728DAE559175912181375E1FF62FE0C9F1D15A937FAC93098A`(gate 自身仍标 `capture=awaiting_user_capture_test`)。++**未执行(如实记录)**:本机没有 RGB24 设备,"A 的 top-down 协商在问题卡上是否被接受"仍须受影响用户实机验证;若驱动拒绝协商,B 的开关可立即救场。未打包、未发布、未提交/推送。++## 2026-09-16 PS5 串流"无法打开视频"回归修复(音频入口插入语句改坏 else 绑定)++用户反馈 1.2 能串流、1.3.1beta 测试包不行,面板提示"无法打开视频,请查看诊断"。++**根因(代码与日志双向确认)**:`2ffb5c7`(2026-09-16 10:40 采集音频手动入口)在 `EngineController::run()` 的 `#ifdef VEYRA_ENABLE_REMOTEPLAY … }else` 与"打开源"检查之间插入 `if(physicalCapture)captureSource.setAudioIngress(...)`。C++ 的 `else` 只绑定紧随其后的单条语句,这一插入把原本绑定 open 检查的 `else` 静默改绑到新语句上,导致 **PS5 串流也执行 `activeSource->open(od)`**;`RemotePlaySessionSource::open()` 固定返回 false → `status("无法打开视频,请查看诊断",true)` → break。因为 remote 分支先阻塞等待第一帧,失败固定发生在解码器产出第一帧后 3~5ms:日志只见 `teardown begin … cancelled=true`,没有任何 graph/present 行。失败包为 `E:\App\Veyra-1.3.1beta-win64-portable`(= `final-30x86-r4`,EXE SHA256 `2DF130AC…`),日志 `E:\App\Veyra-1.3.1beta-win64-portable\logs\veyra-app.log`(三次尝试 10:49:57 / 10:50:16 / 10:50:29,另 11:18–11:19 两次干净进程复现)。++**版本对照(git 验证)**:v1.2.0 与 v1.3.0 tag 的 `}else` 直接绑定 open 检查(结构正常;1.2.0 桌面测试版本机 18:51 实测串流可用,仓库 `logs\veyra-app.log` 10:51:49–10:56:11 段);含 `2ffb5c7` 的 r2/r3/r4 与 `final/` 1.3.1beta 包全部中招。文件/采集卡不受影响(它们的路径本来就要走这条检查)。++**修复**(`src/engine/EngineController.cpp`,+11/-5):把 `setAudioIngress` 移到 `#ifdef` 分支链之前(仍早于 `captureSource.configure`,采集语义不变),并给 `}else{ … }` 补大括号,防止以后再次插入语句改变绑定。++**验证**:++- `cmd.exe /c out\build\veyra-build-x64-release.cmd` exit 0(增量 23/23,RemotePlay ON,patched FFmpeg/dav1d 保持)。+- `scripts/gates/delivery.ps1 -Root . -BuildDirectory out/build/audio-continuity-repair-20260915` PASS,46.98 秒,`logs/delivery/206a0c5ffe7f4e2eb4f72f42146455f3/result.json`,EXE SHA256 `91A7116F78A3ACE3105C20894A3E9332A04C3CDA4E997FB6E897955297E5B6D1`(gate 自身仍标 `capture=awaiting_user_capture_test`)。+- 实机采集卡烟测 `veyra.exe "capture:0:0:-1:0" --smoke-seconds 12 --no-nr --no-sr --no-fg`:exit 0、`frames=694`、`failed=false`、`captureDropped=0`,音频入口调用顺序未回归。++**未执行(如实记录)**:真实 PS5 串流复测(需要主机;修复后第一次连接须由实机确认能到 `display-color`/图初始化);未重打 1.3.1beta 测试包(等实机确认后再打包替换)。工作区改动未提交、未推送。+## 2026-09-16 帧生成 / FSR / 杜比:隔离分支夜间施工(未合并 main)用户要求"开工前创建 GIT 存档、建立隔离区分支、所有操作在隔离区进行、人工验收合格前不允许合并 main"。已建 tag `checkpoint/pre-framegen-fsr-dolby-2026-09-16`(main `693db07`)与分支 `codex/framegen-fsr-dolby-20260916`。diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.hindex 5cebc21b..dde112b4 100644--- a/include/veyra/engine/EnhancementSettings.h+++ b/include/veyra/engine/EnhancementSettings.h@@ -105,6 +105,12 @@ struct EnhancementSettings {// Capture audio ingress; requires a reconnect to take effect (the media type// is negotiated when the graph is built).CaptureAudioIngress captureAudio=CaptureAudioIngress::Auto;+ // Capture ingest only: flip the incoming frame vertically. Exists because+ // some devices declare a DIB orientation that does not match their samples+ // (RGB24 upside-down reports); the capture source asks for top-down first,+ // this is the manual fallback when a driver still misreports. Applies to+ // the next sample, so it is a live edit, not a graph rebuild.+ bool captureFlipVertical=false;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;@@ -128,6 +134,9 @@ struct EnhancementSettings {video.revision=other.revision;video.audioSync=other.audioSync;video.audioOffsetMs=other.audioOffsetMs;+ // Capture flip is applied per sample on the source's callback thread;+ // toggling it must not rebuild the graph.+ video.captureFlipVertical=other.captureFlipVertical;// Export-only fields: changing the bitrate must never invalidate the// running preview graph (the controller would otherwise rebuild it).video.exportBitrateMbps=other.exportBitrateMbps;diff --git a/include/veyra/source/CaptureCardSource.h b/include/veyra/source/CaptureCardSource.hindex b9cfe3cb..502de936 100644--- a/include/veyra/source/CaptureCardSource.h+++ b/include/veyra/source/CaptureCardSource.h@@ -45,6 +45,10 @@ public:// 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);+ // Manual ingest flip for devices whose declared DIB orientation does not+ // match the samples (RGB24 upside-down reports). Applies to the next+ // sample; works for RGB and YUV without touching the device.+ void setVerticalFlip(bool enabled);CaptureMetrics metrics()const;void videoPresented(double ptsMs,int64_t host100ns,int64_t arrival100ns);void videoReset(bool resetAudio=true);diff --git a/include/veyra/source/CaptureMediaType.h b/include/veyra/source/CaptureMediaType.hindex d9669cf2..d48345aa 100644--- a/include/veyra/source/CaptureMediaType.h+++ b/include/veyra/source/CaptureMediaType.h@@ -22,6 +22,20 @@ struct CaptureMediaLayout {unsigned planes=1,chromaStride=0,chromaRowBytes=0;size_t chromaOffset=0,secondChromaOffset=0;};+// Walk the AM_MEDIA_TYPE's format block without assuming VideoInfo vs+// VideoInfo2; used to read/rewrite the DIB orientation flag in place.+inline BITMAPINFOHEADER* captureBitmapHeader(AM_MEDIA_TYPE& type){+ if(!type.pbFormat)return nullptr;+ if(type.formattype==FORMAT_VideoInfo&&type.cbFormat>=sizeof(VIDEOINFOHEADER))return &reinterpret_cast<VIDEOINFOHEADER*>(type.pbFormat)->bmiHeader;+ if(type.formattype==FORMAT_VideoInfo2&&type.cbFormat>=sizeof(VIDEOINFOHEADER2))return &reinterpret_cast<VIDEOINFOHEADER2*>(type.pbFormat)->bmiHeader;+ return nullptr;+}+// RGB DIB packings are the only ones whose biHeight sign describes storage+// order; YUV formats are always top-down (see captureMediaLayout).+constexpr bool captureIsRgbDib(CapturePacking packing){+ return packing==CapturePacking::Bgr32||packing==CapturePacking::Bgra32||packing==CapturePacking::Bgr24||+ packing==CapturePacking::Rgb555||packing==CapturePacking::Rgb565;+}// Parse negotiated memory layout, not the UI's requested dimensions. YUV is// top-down for either sign of biHeight; only RGB DIBs use bottom-up storage.inline bool captureMediaLayout(const AM_MEDIA_TYPE& type,CaptureMediaLayout& out){@@ -97,13 +111,17 @@ inline bool captureMediaLayout(const AM_MEDIA_TYPE& type,CaptureMediaLayout& out}return true;}-inline bool copyCaptureSample(const CaptureMediaLayout& layout,const uint8_t* src,size_t bytes,AVFrame& dst){+// flipVertical is the manual capture override: it inverts whatever the DIB+// header claims (and reverses chroma rows for planar YUV), so a device whose+// declared orientation does not match its samples can still be watched.+inline bool copyCaptureSample(const CaptureMediaLayout& layout,const uint8_t* src,size_t bytes,AVFrame& dst,bool flipVertical=false){if(!src||bytes<layout.sampleBytes||dst.format!=layout.format||dst.width!=int(layout.width)||dst.height!=int(layout.height)||!dst.data[0]||dst.linesize[0]<int(layout.rowBytes))return false;if(layout.format==AV_PIX_FMT_BGR0&&dst.linesize[0]<int(layout.width*4))return false;if(layout.planes>1&&(!dst.data[1]||dst.linesize[1]<int(layout.chromaRowBytes)))return false;if(layout.planes>2&&(!dst.data[2]||dst.linesize[2]<int(layout.chromaRowBytes)))return false;+ const bool flip=layout.bottomUp!=flipVertical;for(unsigned y=0;y<layout.height;++y){- const auto* s=src+size_t(layout.bottomUp?layout.height-1-y:y)*layout.stride;auto* d=dst.data[0]+ptrdiff_t(y)*dst.linesize[0];+ const auto* s=src+size_t(flip?layout.height-1-y:y)*layout.stride;auto* d=dst.data[0]+ptrdiff_t(y)*dst.linesize[0];if(layout.packing==CapturePacking::Bgr24){for(unsigned x=0;x<layout.width;++x){d[x*4]=s[x*3];d[x*4+1]=s[x*3+1];d[x*4+2]=s[x*3+2];d[x*4+3]=255;}}else if(layout.packing==CapturePacking::Rgb555||layout.packing==CapturePacking::Rgb565){const bool six=layout.packing==CapturePacking::Rgb565;@@ -113,7 +131,7 @@ inline bool copyCaptureSample(const CaptureMediaLayout& layout,const uint8_t* sr}else std::memcpy(d,s,layout.rowBytes);}for(unsigned p=1;p<layout.planes;++p)for(unsigned y=0;y<layout.height/2;++y){- const auto* s=src+(p==1?layout.chromaOffset:layout.secondChromaOffset)+size_t(y)*layout.chromaStride;auto* d=dst.data[p]+ptrdiff_t(y)*dst.linesize[p];+ const auto* s=src+(p==1?layout.chromaOffset:layout.secondChromaOffset)+size_t(flip?layout.height/2-1-y:y)*layout.chromaStride;auto* d=dst.data[p]+ptrdiff_t(y)*dst.linesize[p];if(layout.packing==CapturePacking::Nv21){for(unsigned x=0;x<layout.chromaRowBytes;x+=2){d[x]=s[x+1];d[x+1]=s[x];}}else std::memcpy(d,s,layout.chromaRowBytes);}diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 4ac6ced9..8351e531 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -194,6 +194,14 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(!isCapture&&GetEnvironmentVariableW(L"VEYRA_TEST_FILE_HW_DECODE",nullptr,0)){od.preferHardwareDecode=true;od.d3d12Device=ctx.device();od.d3d12Queue=ctx.directQueue();}+ // 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. Kept above the branch chain:+ // inserting statements between `}else` and the open call+ // silently re-binds the `else` and made PS5 sessions fall+ // through to the file open check (fixed 2026-09-16).+ if(physicalCapture)captureSource.setAudioIngress(unsigned(options.settings.captureAudio));+ if(physicalCapture)captureSource.setVerticalFlip(options.settings.captureFlipVertical);#ifdef VEYRA_ENABLE_REMOTEPLAYif(remote){status(L"正在连接 PS5…");@@ -210,13 +218,12 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sstd::this_thread::sleep_for(std::chrono::milliseconds(2));}if(stop_||!cachedFrame)break;- }else+ }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;}+#ifdef VEYRA_ENABLE_REMOTEPLAY+ }+#endif// A file's actual decoded pixel format and HDR VUI are only// reliable on AVFrame. Prime one frame before constructing// the graph so AV1/MOV 10-bit and HDR inputs do not get an@@ -366,6 +373,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s}captureSource.setAudioSync(unsigned(options.settings.audioSync),options.settings.audioOffsetMs);captureSource.setAudioIngress(unsigned(options.settings.captureAudio));+ captureSource.setVerticalFlip(options.settings.captureFlipVertical);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(性能成本较高)"));@@ -590,6 +598,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s{std::lock_guard lock(mutex_);snapshot_.captureReconnectAttempts=captureRetries;}status(std::format(L"采集信号中断,正在重连原设备(第 {} 次)",captureRetries));captureSource.setAudioIngress(unsigned(options.settings.captureAudio));+ captureSource.setVerticalFlip(options.settings.captureFlipVertical);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;}@@ -611,6 +620,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sconst float gain=muted_?0.0f:volume_.load();audio.setGain(gain);if(physicalCapture)captureSource.recoverAudio(gain,unsigned(options.settings.audioSync),options.settings.audioOffsetMs);captureSource.setAudioSync(unsigned(options.settings.audioSync),options.settings.audioOffsetMs);+ captureSource.setVerticalFlip(options.settings.captureFlipVertical);if(physicalCapture){const bool available=captureSource.setAudioGain(gain);const auto audioState=captureSource.audioState();std::lock_guard lock(mutex_);snapshot_.audioAvailable=available;snapshot_.captureAudio=audioState;snapshot_.audioInputChannels=audioState.inputChannels;snapshot_.audioOutputChannels=audioState.outputChannels;}#ifdef VEYRA_ENABLE_REMOTEPLAYif(remote){remote->setAudioGain(gain);remote->setAudioSync(unsigned(options.settings.audioSync),options.settings.audioOffsetMs);@@ -636,6 +646,13 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,scaptureSource.setAudioIngress(unsigned(requested.captureAudio));status(L"采集音频模式已记录;重新连接采集卡后生效",false);}+ // The manual capture flip is applied per sample on the+ // DirectShow callback thread, so it is a live edit.+ if(requested.captureFlipVertical!=options.settings.captureFlipVertical){+ options.settings.captureFlipVertical=requested.captureFlipVertical;+ captureSource.setVerticalFlip(requested.captureFlipVertical);+ status(requested.captureFlipVertical?L"采集画面已上下翻转(仅影响本机采集画面)":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 1795b0c5..7bbedf2c 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 15\n"<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';- for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<' '<<int(s.frameGenerationBackend)<<' '<<int(s.srTarget)<<' '<<int(s.opticalFlowBackend)<<' '<<s.amdFlowHalfResolution<<' '<<int(s.audioSync)<<' '<<s.audioOffsetMs<<' '<<int(s.nrRuntime)<<' '<<s.captureCompatible<<' '<<s.lowLatency<<' '<<s.forceSdrPreview<<' '<<int(s.captureAudio)<<' '<<s.exportBitrateMbps<<'\n';}return o.str();+ std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS 16\n"<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';+ for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<' '<<int(s.frameGenerationBackend)<<' '<<int(s.srTarget)<<' '<<int(s.opticalFlowBackend)<<' '<<s.amdFlowHalfResolution<<' '<<int(s.audioSync)<<' '<<s.audioOffsetMs<<' '<<int(s.nrRuntime)<<' '<<s.captureCompatible<<' '<<s.lowLatency<<' '<<s.forceSdrPreview<<' '<<int(s.captureAudio)<<' '<<s.exportBitrateMbps<<' '<<s.captureFlipVertical<<'\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>15)||!(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>16)||!(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;@@ -39,6 +39,8 @@ bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,stdif(version>=14){int ingress;if(!(in>>ingress)||ingress<0||ingress>2)return false;s.captureAudio=static_cast<CaptureAudioIngress>(ingress);}// v15 appends the export bitrate to the line, so it must be read last.if(version>=15){if(!(in>>s.exportBitrateMbps))return false;}+ // v16 appends the manual capture vertical flip after the bitrate.+ if(version>=16){int flip;if(!(in>>flip)||flip<0||flip>1)return false;s.captureFlipVertical=flip!=0;}p.name=wide(n);if(!nameOk(p.name)||std::any_of(out.begin(),out.end(),[&](auto& a){return a.name==p.name;})||nr<0||nr>1||sr<0||sr>1)return false;s.nr=nr;s.sr=sr;s.nrPolicy=static_cast<pipeline::NrSizePolicy>(policy);s.flow=static_cast<FlowQuality>(flow);s.content=static_cast<ContentRate>(content);if(!s.validate().empty())return false;out.push_back(std::move(p));diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cppindex ccbc75b6..714cea8e 100644--- a/src/source/CaptureCardSource.cpp+++ b/src/source/CaptureCardSource.cpp@@ -141,6 +141,8 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {// 0 automatic, 1 PCM only, 2 bitstream preferred (see// engine::CaptureAudioIngress). Read when the audio graph is built.unsigned audioIngressMode=0;+ // Manual capture flip; read by the DirectShow callback thread.+ std::atomic<bool> verticalFlip{false};std::unique_ptr<WasapiAudioInput> wasapi;std::wstring audioError;AudioInputRecovery audioRecovery;@@ -159,7 +161,7 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {else {// Copy directly into our bounded mailbox; read() swaps frames// under this lock, so the frame consumed by the GPU is untouched.- if(!copyCaptureSample(layout,data,size_t(sample->GetActualDataLength()),*pendingFrame)){callbackError=true;wake.notify_one();return S_OK;}+ if(!copyCaptureSample(layout,data,size_t(sample->GetActualDataLength()),*pendingFrame,verticalFlip.load())){callbackError=true;wake.notify_one();return S_OK;}if(pending)++dropped;// Inspect consecutive callbacks, not consecutive mailbox reads.// Preserve a driver/clock break when its sample is overwritten.@@ -231,6 +233,11 @@ void CaptureCardSource::setAudioIngress(unsigned mode){log::info("capture-audio-ingress",std::format("mode={} ({}) takes effect on the next connect",clamped,clamped==1?"PCM only":clamped==2?"bitstream preferred":"automatic"));}+void CaptureCardSource::setVerticalFlip(bool enabled){+ auto& p=*p_;+ if(p.verticalFlip.exchange(enabled)==enabled)return;+ log::info("capture-flip",std::format("manual vertical flip={} (applies to the next sample; ingest only)",enabled?1:0));+}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;@@ -259,6 +266,28 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();p_->lastAuCaptureMediaLayout nativeLayout;const bool nativeSupported=captureMediaLayout(*native,nativeLayout);if(!nativeSupported&&capturePacking(native->subtype)!=CapturePacking::Unknown){log::error("capture","Known raw format has unsupported layout/color metadata; refusing implicit RGB conversion");freeType(native);return false;}if(nativeSupported&&(nativeLayout.format==AV_PIX_FMT_P010||nativeLayout.format==AV_PIX_FMT_P016)&&desc.legacyCaptureRgbForDiagnostic){log::error("capture","10/16-bit capture cannot use the legacy 8-bit RGB diagnostic converter");freeType(native);return false;}+ // Some drivers advertise a bottom-up DIB (biHeight>0) while their samples+ // actually arrive top-down, which users reported as "RGB24 captures upside+ // down". Ask for an explicit top-down connection first: an accepted request+ // normalizes the mismatch (connected type is then negative and no flip is+ // applied), a refusal keeps the driver-declared sign and the existing flip.+ // Truthful bottom-up devices stay correct in both cases.+ if(nativeSupported&&captureIsRgbDib(nativeLayout.packing)){+ if(auto* header=captureBitmapHeader(*native);header&&header->biHeight>0){+ const LONG advertised=header->biHeight;header->biHeight=-advertised;+ const HRESULT topDownHr=p.config->SetFormat(native);+ if(SUCCEEDED(topDownHr)){+ AM_MEDIA_TYPE* refreshed=nullptr;CaptureMediaLayout refreshedLayout;+ if(SUCCEEDED(p.config->GetFormat(&refreshed))&&refreshed&&captureMediaLayout(*refreshed,refreshedLayout)){+ freeType(native);native=refreshed;nativeLayout=refreshedLayout;+ }else freeType(refreshed);+ log::info("capture",std::format("DIB top-down request hr=0x{:08X} subtype=0x{:08X} accepted=1 bottomUp={}",uint32_t(topDownHr),native->subtype.Data1,nativeLayout.bottomUp));+ }else{+ header->biHeight=advertised;+ log::info("capture",std::format("DIB top-down request hr=0x{:08X} subtype=0x{:08X} accepted=0 bottomUp={} (keeping driver-declared orientation)",uint32_t(topDownHr),native->subtype.Data1,nativeLayout.bottomUp));+ }+ }+ }const bool direct=nativeSupported&&!desc.legacyCaptureRgbForDiagnostic;AM_MEDIA_TYPE connected{};if(direct){diff --git a/tests/unit/CaptureFormatCases.h b/tests/unit/CaptureFormatCases.hindex 7d74790f..4b5989a4 100644--- a/tests/unit/CaptureFormatCases.h+++ b/tests/unit/CaptureFormatCases.h@@ -50,6 +50,28 @@ template<class Check> void captureFormatCases(Check check){for(unsigned y=0;y<4;++y){raw[y*l.stride]=0;raw[y*l.stride+1]=id==MEDIASUBTYPE_RGB565?0xf8:0x7c;}check(copyCaptureSample(l,raw.data(),raw.size(),*f)&&f->data[0][0]==0&&f->data[0][1]==0&&f->data[0][2]==255,"RGB555/565 red channel masks");av_frame_free(&f);}+ // Orientation contract: the DIB sign decides whether ingest flips, the+ // manual override inverts that decision, and planar chroma follows luma.+ {+ vi.bmiHeader.biWidth=4;vi.bmiHeader.biHeight=4;vi.bmiHeader.biSizeImage=0;t.subtype=MEDIASUBTYPE_RGB24;CaptureMediaLayout rgb;+ check(captureMediaLayout(t,rgb),"RGB24 bottom-up layout for the orientation cases");+ std::vector<uint8_t> raw(rgb.sampleBytes,0);+ for(unsigned y=0;y<4;++y)raw[size_t(y)*rgb.stride]=uint8_t(y+1);+ AVFrame* f=av_frame_alloc();f->width=4;f->height=4;f->format=rgb.format;av_frame_get_buffer(f,32);+ check(rgb.bottomUp&©CaptureSample(rgb,raw.data(),raw.size(),*f)&&f->data[0][0]==4,"bottom-up RGB24 ingest reads the last memory row first");+ check(copyCaptureSample(rgb,raw.data(),raw.size(),*f,true)&&f->data[0][0]==1,"manual flip inverts bottom-up RGB24 ingest");+ vi.bmiHeader.biHeight=-4;+ check(captureMediaLayout(t,rgb)&&!rgb.bottomUp&©CaptureSample(rgb,raw.data(),raw.size(),*f)&&f->data[0][0]==1,"top-down RGB24 ingest passes rows through");+ check(copyCaptureSample(rgb,raw.data(),raw.size(),*f,true)&&f->data[0][0]==4,"manual flip inverts top-down RGB24 ingest");+ av_frame_free(&f);+ t.subtype=fourcc("NV12");vi.bmiHeader.biWidth=4;vi.bmiHeader.biHeight=4;vi.bmiHeader.biSizeImage=0;CaptureMediaLayout yuv;+ check(captureMediaLayout(t,yuv),"NV12 layout for the chroma flip case");+ std::vector<uint8_t> plane(yuv.sampleBytes,0);plane[yuv.chromaOffset]=10;plane[yuv.chromaOffset+yuv.chromaStride]=11;+ AVFrame* g=av_frame_alloc();g->width=4;g->height=4;g->format=yuv.format;av_frame_get_buffer(g,32);+ check(copyCaptureSample(yuv,plane.data(),plane.size(),*g)&&g->data[1][0]==10,"YUV ingest stays top-down without the override");+ check(copyCaptureSample(yuv,plane.data(),plane.size(),*g,true)&&g->data[1][0]==11,"manual flip reverses chroma rows too");+ av_frame_free(&g);+ }t.subtype=fourcc("P010");DXVA2_ExtendedFormat ext{};ext.VideoTransferFunction=16;vi.dwControlFlags=ext.value|AMCONTROL_COLORINFO_PRESENT;check(captureMediaLayout(t,l)&&l.color.transfer==veyra::pipeline::TransferFunction::HLG&&!l.color.transferAssumed,"capture HLG metadata is retained, never silently interpreted as SDR");vi.dwControlFlags=0;t.subtype=fourcc("ABCD");check(capturePixelName(t.subtype)==L"ABCD"&&!captureMediaLayout(t,l),"unknown FourCC readable but not advertised as native");diff --git a/tests/unit/RepairContractTests.cpp b/tests/unit/RepairContractTests.cppindex 1fef4d8e..1130dca0 100644--- a/tests/unit/RepairContractTests.cpp+++ b/tests/unit/RepairContractTests.cpp@@ -206,6 +206,7 @@ int main(){{engine::EnhancementSettings settings;check(settings.captureAudio==engine::CaptureAudioIngress::Auto,"capture audio ingress defaults to automatic");+ check(!settings.captureFlipVertical,"capture vertical flip defaults off");for(auto mode:{engine::CaptureAudioIngress::Auto,engine::CaptureAudioIngress::PcmOnly,engine::CaptureAudioIngress::BitstreamPreferred}){settings.captureAudio=mode;check(settings.validate().empty(),"capture audio ingress modes validate");diff --git a/tests/unit/RepairPresetTests.cpp b/tests/unit/RepairPresetTests.cppindex 01be60e7..0de202d2 100644--- a/tests/unit/RepairPresetTests.cpp+++ b/tests/unit/RepairPresetTests.cpp@@ -42,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!=15)return false;+ if(magic!="VEYRA_PRESETS"||savedVersion!=16)return false;PresetStore reloaded(path);if(!reloaded.load()||reloaded.defaultSettings()!=value)return false;}else{@@ -106,6 +106,9 @@ ok=ok&&a.put(L"test",s)&&a.setDefault(0)&&!a.put(L"test",s);PresetStore b(p);ok=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);+ // Manual capture vertical flip (v16) round-trips with the rest of the preset.+ auto flipped=s;flipped.captureFlipVertical=true;ok=ok&&b.put(L"capture flip",flipped);+ PresetStore flipReload(p);ok=ok&&flipReload.load()&&flipReload.entries().size()==1&&flipReload.entries().back().settings.captureFlipVertical&&b.erase(0);{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;