Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

fix: align node viewport and rotate playback with explicit BMD inputs

Veyra Goal Agent5f15a663e100
diff --git a/AGENTS.md b/AGENTS.md
index f8ef8611..1c53a7ef 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,7 @@
# Veyra 项目 Agent 执行规则
+> **2026-10-13 issues36/37 与 BMD 日志53**:用户将延迟工作交给Claude,要求检查issues37/36并继续修复BMD原生仍黑屏。按docs/ISSUES_36_37_BMD_PLAN_2026-10-13.md从main7571919在codex/issues36-37-bmd-20261013隔离修改对应节点布局、文件旋转/呈现运动与BMD明确输入选择、协商/保存及必要构建回归接点,覆盖这些范围旧冻结。73旧树head/status及原始输入独立保护;不修改同步/队列/XeLL延迟策略,不派Agent、不改驱动持久配置/EDID/运行库模型/用户真实配置,不盲切端口。产物全E盘,测试≤300秒/构建≤900秒,无main合并/push/发布/交付包/关机。BMD无实卡不能宣称现场恢复。
+
> **2026-10-13 2.0.7正式发布授权**:用户明确直接采用已验2.0.7-test-r2两个包发布GitHub、六群原图替换、README/Release加知识库、完整说明2.0.6以来变化。按docs/RELEASE_2.0.7_PLAN_2026-10-13.md,只改发布文档/图片和外部文件名,ZIP/EXE/运行组件逐字节保持。允许本地main合入、普通push nrvideo/main与两个标签、主v2.0.7两资产及独立非latest源码归档;保留原赞助/Discord/Ko-fi/width220。69旧树/509脏文件、旧包和旧Release保护,全产物E盘;无子Agent/代发/关机。不伪称包内test标识被去掉,不把混合模型取舍或合成误差包装成普遍画质/提速,也不宣称NV显存/BMD/HDR现场已根治。
> **2026-10-12 用户确认 Claude 内容节奏修复实机通过并授权合并重打 2.0.7**:从 main05bc4b5 隔离合入 claude/cadence-exact-20261012(60a93f3、8d11cad),按 docs/TEST_2.0.7_REFRESH_2026-10-12.md 重新构建、定向回归、本地 main 合并与 NVIDIA/AMD 完整测试包;显示2.0.7-test-r2。保护68旧树/509脏文件及已交付原包,全部研发产物在E盘新任务目录。不改用户正在运行的播放器/配置、UI频率/默认GPU优先级/运行库/模型,无新push/Release/关机或子Agent授权。
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index df059dbe..b6f550d8 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -809,6 +809,12 @@ source timestamps and HDR metadata, and reuses its bounded upload mailbox and
audio session. Device selection uses persistent/topological IDs plus subdevice
identity. No OBS binary, driver, EDID writes or VideoProcessor code is included.
+The 2026-10-13 follow-up also follows OBS's explicit input-connection selection
+(`IDeckLinkConfiguration::SetInt` before enabling capture). Veyra exposes only
+driver-reported connectors as stable saved identities, verifies the selected
+connector, and restores its temporary selection on close when still owned.
+It does not call `WriteConfigurationToPreferences` or scan physical inputs.
+
Build-time COM declarations come from the unmodified Blackmagic DeckLink SDK
12.0 Win IDL files supplied by OBS 31.0.3, pinned to
[fcd1910bf5116b69404a6ecdda6efedd1d00ebdf](https://github.com/obsproject/obs-studio/tree/fcd1910bf5116b69404a6ecdda6efedd1d00ebdf/plugins/decklink/win/decklink-sdk).
diff --git a/docs/ISSUES_36_37_BMD_PLAN_2026-10-13.md b/docs/ISSUES_36_37_BMD_PLAN_2026-10-13.md
new file mode 100644
index 00000000..bf930b1e
--- /dev/null
+++ b/docs/ISSUES_36_37_BMD_PLAN_2026-10-13.md
@@ -0,0 +1,11 @@
+# Issues 36/37 与 BMD 日志53修复计划
+
+用户已将延迟排查交给Claude;本轮不修改显示同步、帧队列、XeLL或延迟策略。用户要求检查GitHub issues36/37与BMD依旧黑屏,允许在独立codex/issues36-37-bmd-20261013修复相应QML布局、文件方向/呈现运动映射、BMD输入协商及必要构建/测试接点。这些具体范围覆盖旧UI冻结,不推进其它增强算法。
+
+基线main7571919;73旧工作树head/status、源码bundle、原始日志53与两issue正文/评论已固定在E:/项目/Veyra/archives/issues36-37-bmd-20261013。旧树/main/Claude延迟工作保持,不派Agent,不改用户配置、驱动、运行库/模型,不合并/push/Release/打交付包或关机。研发产物按用途全部在E:/项目/Veyra/<用途>/issues36-37-bmd-20261013,单测试≤300秒/构建≤900秒。
+
+1. #37:节点统计条实际高度随紧凑布局/状态文本增长,但Main仍固定减40。改为和专业页一致的实际viewport绑定,检查分隔条拖动、窗口尺寸、语言、DPI及D3D12/软件UI的真实视频HWND边界。不新增绘制Timer,不提高33ms/250ms节奏。
+2. #36:文件Display Matrix已解析成顺时针rotationDegrees,但像素未旋转。将方向纳入共享PreviewView映射,最终blit应用相同UV变换、原图对照也旋转;XeSS送入的运动须同步旋转,不能只转颜色。保持图内原始坐标、真实PTS、NR/补帧算法及原输出编码合同;离线导出方向另核对实际行为并如实报告。本轮用四象限视频/真实GPU抓图验证0/90/180/270及SAR/缩放/对照,不能只查源码。
+3. BMD:日志53原生接口成功,反复locked=0/noInput=true,connection=0x1;SDK明确定义1为SDI、2为HDMI。OBS源码显式SetInt输入连接,Veyra只跟随驱动、没有选择入口。这是软件配置能力差异,不是判断用户线接错。补上真实支持端口的明确选择与保存(稳定设备身份扩展、旧路径兼容),启用时设置并校验选中连接;不扫口/盲切、不写驱动持久偏好/EDID。自动/手动制式明确保留,不偷偷换用户格式。检查超时错误、实际模式/锁定及无输入诊断,杜绝失败仍显示成功。
+
+先真实复现布局/旋转失败,再最小修复。BMD控制通过实际产品状态机与驱动注入验证,未持受影响BMD卡,不能宣称现场恢复;普通USB与既有格式/保存回归。完成后写WORKLOG和报告,列明实际构建、测试、失败/修复、证据路径及未验范围,保护旧输入/旧树并提交独立分支。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 4abca2f6..64e62bce 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -9345,3 +9345,13 @@ ZIP/EXE原字节晋级,仅外部下载名去test-r2;包内显示原标识在
v2.0.7 ID 410800361,published_at 2026-10-12T16:24:59Z,latest/非草稿/非预发布通过;两个运行资产服务器SHA/size等于原test-r2。v2.0.7-sources ID 410800322,两源资产、非latest,未变依赖源保留v2.0.6。main/tag6ede5a7普通atomic推送成功,产品与67ab696相同,后续只补回执文档。remote.py draft/upload/verify-draft/publish/verify-public均通过;public-check.py final全部公开文档/双QR/Ko-fi/Release/下载200,六群原图SHA吻合,飞书带Cookie匿名GET200。最初无Cookie404/循环证据保留,不把它写成知识库本身失效。
旧v2.0.6Release完整稳定字段不变,68其它树/509脏文件/全部原包保护通过。详细docs/RELEASE_2.0.7_REPORT_2026-10-13.md;外部reports/logs回执固定远端正文/资产digest。只读发布辅助检查曾因utf8-sig别名和依赖回执尚未完成失败,原错误说明保留,改编码/顺序后原检查通过,未重发或改资产。原扩展NR+DLSS热切换失败和NV显存/BMD/HDR/AMD实卡限制保留,没有新性能或全硬件通过声明。群公告632字符仅保存给用户,无代发/关机。
+
+## 2026-10-13 issues36/37与BMD日志53开工及实现
+
+用户将延迟工作交Claude,要求检查issues37/36并继续修复BMD黑屏。隔离codex/issues36-37-bmd-20261013,从main7571919起;73旧树head/status、input log53 SHA和副本、两issue正文/评论、source-before.bundle固定在archives/issues36-37-bmd-20261013。计划docs/ISSUES_36_37_BMD_PLAN_2026-10-13.md;不改显示同步/队列/XeLL策略,避免干扰Claude。产物全E盘,不派Agent,不改驱动持久偏好/EDID/运行组件或用户真实配置,无合并/push/发布/交付包/关机。
+
+原r2实际GUI负对照:pro-video-geometry-test.py before --page node --task issues36-37-bmd-20261013 --baseline-ref7571919 --donor-app<原r2> --media<GTA4K>,9场完成,其中8场被视频HWND遮24–77DIP;全屏不遮。原因Main固定扣40但节点状态/紧凑条实际64–117。改NodePage响应式viewport并由Main绑定,不加Timer、不改33/250ms;同EXE只换QML后9场全部边界一致。原始日志/receipt在本轮before-d3d12-1-20261013-222518与after-d3d12-1-20261013-222847。
+
+旋转:PreviewView纳入容器顺时针方向、原生尺寸/SAR/选区逆映射;Engine读取SourceInfo的现成方向,UI重置保留元数据;PresentBlit和XeSS PresentMotion共享UV旋转,对照和运动也旋转。新增CPU坐标/GPU四象限与运动方向回归。图内NR/光流仍为原编码坐标,没有增加像素回读/额外旋转pass;离线导出合同不在本修复中改变。现有ExperimentalBackend的显示运动测试仍向新版shader传旧版zoom常量,已按当前16常量合同修正并增加独立present-motion入口,后续需真实GPU验证。
+
+BMD日志53:6次原生尝试均SDI连接0x1、locked0/noInput,另外DirectShow亦黑;不据此断言用户线接错,具体物理口尚未确认。对照固定OBS e7f0b0d输入SetInt与SDK枚举1SDI/2HDMI,Veyra此前只有读取默认口。增加设备实际支持的各输入口稳定选择,旧Driver身份兼容;启用前设置/读回,按端口过滤SDK可用模式,关闭时仅在仍持有该设置时恢复原输入,不写持久偏好、不扫描端口。追加路径/租用控制失败及恢复回归;没有BMD实卡不宣称现场已恢复。8条新增提示三语追加、原2243键保持;首轮保护校验因旧catalog存在重复键而误失败且未写文件,改按完整原列表比较后通过。构建/后续回归尚未完成。
diff --git a/i18n/catalog.json b/i18n/catalog.json
index 4a7a569f..918c31da 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -15716,6 +15716,62 @@
"zh-TW": "{} {}X 補幀初始化失敗,未替換後端或降低倍率;請查看工作診斷日誌",
"en": "{} {}X frame generation could not initialize. The backend and multiplier were retained; see the task diagnostic log.",
"ja": "{} {}X フレーム生成を初期化できませんでした。バックエンドと倍率は維持されています。タスク診断ログを確認してください。"
+ },
+ {
+ "zh": "保存的 BMD 输入口无效,请重新选择设备和 HDMI/SDI 输入",
+ "src": "src/source/DeckLinkDriver.cpp",
+ "zh-TW": "儲存的 BMD 輸入埠無效,請重新選擇裝置及 HDMI/SDI 輸入",
+ "en": "The saved BMD input connection is invalid. Select the device and HDMI/SDI input again.",
+ "ja": "保存された BMD 入力端子が無効です。デバイスと HDMI/SDI 入力を選び直してください。"
+ },
+ {
+ "zh": "这张 BMD 卡当前不提供所选输入口,请刷新并重新选择设备输入",
+ "src": "src/source/DeckLinkDriver.cpp",
+ "zh-TW": "這張 BMD 卡目前不提供所選輸入埠,請重新整理並選擇裝置輸入",
+ "en": "This BMD card does not currently expose the selected connector. Refresh and select an available input.",
+ "ja": "この BMD カードは現在、選択した入力端子を提供していません。更新して入力を選び直してください。"
+ },
+ {
+ "zh": "BMD 原生设备当前不可用,请确认设备连接和 Desktop Video 状态,然后刷新设备列表",
+ "src": "src/source/DeckLinkDriver.cpp",
+ "zh-TW": "BMD 原生裝置目前不可用,請確認裝置連線與 Desktop Video 狀態,再重新整理裝置清單",
+ "en": "The native BMD device is unavailable. Check its connection and Desktop Video status, then refresh the device list.",
+ "ja": "BMD ネイティブデバイスが利用できません。接続と Desktop Video の状態を確認してデバイス一覧を更新してください。"
+ },
+ {
+ "zh": "BMD 所选输入口不可用,或驱动未应用该输入口;请重新选择 HDMI/SDI 输入",
+ "src": "src/source/DeckLinkDriver.cpp",
+ "zh-TW": "所選 BMD 輸入埠不可用,或驅動程式未套用該輸入埠;請重新選擇 HDMI/SDI 輸入",
+ "en": "The selected BMD connector is unavailable or the driver did not apply it. Select the HDMI/SDI input again.",
+ "ja": "選択した BMD 入力端子が利用できないか、ドライバーが設定を適用していません。HDMI/SDI 入力を選び直してください。"
+ },
+ {
+ "zh": "请在视频输入设备列表选择这张 BMD 卡对应的 HDMI/SDI 输入口,再选择自动检测或匹配信号的手动制式。Driver 条目保留驱动当前输入。",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "請在視訊輸入裝置清單選擇這張 BMD 卡對應的 HDMI/SDI 輸入埠,再選擇自動偵測或符合訊號的手動制式。Driver 項目保留驅動程式目前輸入。",
+ "en": "Select this BMD card’s HDMI/SDI connector in the video device list, then choose automatic detection or the matching manual signal mode. Driver keeps the current driver input.",
+ "ja": "映像入力デバイス一覧で BMD カードの HDMI/SDI 入力端子を選択し、自動検出または信号に合う手動モードを選んでください。Driver は現在のドライバー入力を維持します。"
+ },
+ {
+ "zh": "BMD 未在 {} 输入检测到有效信号。请在设备列表选择与 OBS 一致的 HDMI/SDI 输入口,并选择自动检测或匹配实际信号的手动制式。",
+ "src": "src/source/DeckLinkCapture.cpp",
+ "zh-TW": "BMD 未在 {} 輸入偵測到有效訊號。請在裝置清單選擇與 OBS 相同的 HDMI/SDI 輸入埠,再選擇自動偵測或符合實際訊號的手動制式。",
+ "en": "BMD detected no valid signal on the {} input. Select the same HDMI/SDI connector as OBS, then choose automatic detection or the matching manual signal mode.",
+ "ja": "BMD は {} 入力で有効な信号を検出できませんでした。OBS と同じ HDMI/SDI 端子を選択し、自動検出または実際の信号に合う手動モードを選んでください。"
+ },
+ {
+ "zh": "请在设备列表选择对应的 HDMI/SDI 输入口;Driver 保留驱动当前输入。支持自动检测的卡建议选择自动,信号未锁定时会明确提示。",
+ "src": "qml/Veyra/DialogHost.qml",
+ "zh-TW": "請在裝置清單選擇對應的 HDMI/SDI 輸入埠;Driver 保留驅動程式目前輸入。支援自動偵測的卡建議選擇自動,訊號未鎖定時會明確提示。",
+ "en": "Select the matching HDMI/SDI connector in the device list. Driver keeps the current driver input. Use Auto on cards supporting signal detection; an unlocked signal is reported explicitly.",
+ "ja": "デバイス一覧で該当する HDMI/SDI 入力を選択してください。Driver は現在のドライバー入力を維持します。対応カードでは自動検出を推奨し、信号がロックされない場合は明示します。"
+ },
+ {
+ "zh": "原生采集先确认有效信号;请在设备列表选择对应的 HDMI/SDI 输入,支持自动检测的卡建议选择自动。Driver 保留驱动当前输入。",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "原生擷取會先確認有效訊號;請在裝置清單選擇對應的 HDMI/SDI 輸入,支援自動偵測的卡建議選擇自動。Driver 保留驅動程式目前輸入。",
+ "en": "Native capture first verifies a valid signal. Select the matching HDMI/SDI connector and use Auto when supported. Driver keeps the current driver input.",
+ "ja": "ネイティブキャプチャは最初に有効な信号を確認します。該当する HDMI/SDI 入力を選択し、対応カードでは自動検出を使用してください。Driver は現在のドライバー入力を維持します。"
}
]
}
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index c8078f84..5d2946b8 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -181,7 +181,7 @@ public:
void pause(bool p);
bool setPlaybackRate(double rate);
void setFullscreenMemoryProtection(bool enabled);
- void previewView(PreviewView view){if(!std::isfinite(view.zoom)||!std::isfinite(view.centerX)||!std::isfinite(view.centerY)||!std::isfinite(view.displayAspect)||view.displayAspect<0||view.mode<0||view.mode>6)return;std::lock_guard lock(mutex_);view.zoom=std::clamp(view.zoom,.05f,64.0f);if(view.displayAspect==0)view.displayAspect=previewView_.displayAspect;previewView_=view;}
+ void previewView(PreviewView view){if(!std::isfinite(view.zoom)||!std::isfinite(view.centerX)||!std::isfinite(view.centerY)||!std::isfinite(view.displayAspect)||view.displayAspect<0||view.mode<0||view.mode>6)return;std::lock_guard lock(mutex_);view.zoom=std::clamp(view.zoom,.05f,64.0f);if(view.displayAspect==0)view.displayAspect=previewView_.displayAspect;view.rotationDegrees=previewView_.rotationDegrees;previewView_=view;}
PreviewView previewView()const{std::lock_guard lock(mutex_);return previewView_;}
void setVolume(float gain,bool mute);
bool selectAudioTrack(uint64_t sessionId,int streamIndex);
diff --git a/include/veyra/engine/PreviewView.h b/include/veyra/engine/PreviewView.h
index 247b2c14..9427e207 100644
--- a/include/veyra/engine/PreviewView.h
+++ b/include/veyra/engine/PreviewView.h
@@ -8,23 +8,42 @@ struct PreviewView {
// Preserve UI IDs 0=fit, 1=native pixels, 2=fill; append stretch/ratios.
int mode=0;
double displayAspect=0;
+ // Container display rotation, clockwise. View centers live in the oriented
+ // picture; processing/protection and estimated motion keep coded coordinates.
+ int rotationDegrees=0;
+ unsigned quarterTurns()const {
+ const int angle=((rotationDegrees%360)+360)%360;
+ return angle%90==0?unsigned(angle/90):0;
+ }
+ std::pair<float,float> sourceUv(float u,float v)const {
+ switch(quarterTurns()){
+ case 1:return {v,1-u};case 2:return {1-u,1-v};case 3:return {1-v,u};default:return {u,v};
+ }
+ }
+ std::pair<float,float> displayUv(float u,float v)const {
+ switch(quarterTurns()){
+ case 1:return {1-v,u};case 2:return {1-u,1-v};case 3:return {v,1-u};default:return {u,v};
+ }
+ }
bool operator==(const PreviewView&)const=default;
double aspect(float iw,float ih)const{
if(mode==4)return 16.0/9;if(mode==5)return 4.0/3;if(mode==6)return 21.0/9;
+ if(quarterTurns()&1)std::swap(iw,ih);
return mode!=1&&std::isfinite(displayAspect)&&displayAspect>0?displayAspect:ih>0?double(iw)/ih:0;
}
std::pair<float,float> renderedSize(float cw,float ch,float iw,float ih)const{
if(cw<=0||ch<=0||iw<=0||ih<=0)return {0,0};
- if(mode==1)return {iw*zoom,ih*zoom};
+ const float orientedH=(quarterTurns()&1)?iw:ih;
+ if(mode==1)return {(quarterTurns()&1?ih:iw)*zoom,orientedH*zoom};
if(mode==3)return {cw*zoom,ch*zoom};
- const float virtualW=float(aspect(iw,ih))*ih;
- const float scale=(mode==2?std::max(cw/virtualW,ch/ih):std::min(cw/virtualW,ch/ih))*zoom;
- return {virtualW*scale,ih*scale};
+ const float virtualW=float(aspect(iw,ih))*orientedH;
+ const float scale=(mode==2?std::max(cw/virtualW,ch/orientedH):std::min(cw/virtualW,ch/orientedH))*zoom;
+ return {virtualW*scale,orientedH*scale};
}
std::pair<float,float> sourcePoint(float x,float y,float cw,float ch,float iw,float ih)const{
if(cw<=0||ch<=0||iw<=0||ih<=0)return {-1.0f,-1.0f};
const auto [rw,rh]=renderedSize(cw,ch,iw,ih);
- return {centerX+(x-cw*.5f)/rw,centerY+(y-ch*.5f)/rh};
+ return sourceUv(centerX+(x-cw*.5f)/rw,centerY+(y-ch*.5f)/rh);
}
void wheel(float steps,float x,float y,float clientW,float clientH,float imageW,float imageH){
if(clientW<=0||clientH<=0||imageW<=0||imageH<=0||!std::isfinite(steps))return;
diff --git a/include/veyra/source/DeckLinkInputConnection.h b/include/veyra/source/DeckLinkInputConnection.h
new file mode 100644
index 00000000..29878c15
--- /dev/null
+++ b/include/veyra/source/DeckLinkInputConnection.h
@@ -0,0 +1,65 @@
+#pragma once
+#include <array>
+#include <cstdint>
+#include <format>
+#include <string>
+#include <string_view>
+
+namespace veyra::source::decklink {
+// Stable SDK values, without putting SDK headers in the public/source tree.
+inline constexpr std::array<uint32_t,6> inputConnections{1,2,4,8,16,32};
+inline bool knownInputConnection(uint32_t value){
+ for(auto port:inputConnections)if(value==port)return true;
+ return false;
+}
+inline std::wstring_view inputConnectionName(uint32_t value){
+ switch(value){case 1:return L"SDI";case 2:return L"HDMI";case 4:return L"Optical SDI";
+ case 8:return L"Component";case 16:return L"Composite";case 32:return L"S-Video";default:return L"Driver";}
+}
+inline std::wstring inputConnectionPath(std::wstring_view base,uint32_t connection){
+ return knownInputConnection(connection)?std::format(L"{}:input={:08x}",base,connection):std::wstring{};
+}
+struct InputConnectionSelection {std::wstring_view device;uint32_t connection=0;bool valid=false;};
+inline InputConnectionSelection inputConnectionSelection(std::wstring_view path){
+ if(!path.starts_with(L"decklink-native:"))return {};
+ const auto at=path.find(L":input=");
+ if(at==path.npos)return {path,0,true}; // exact legacy device identity
+ const auto value=path.substr(at+7);
+ if(value.size()!=8)return {};
+ uint32_t port=0;
+ for(auto c:value){
+ const unsigned nibble=c>=L'0'&&c<=L'9'?c-L'0':c>=L'a'&&c<=L'f'?c-L'a'+10:c>=L'A'&&c<=L'F'?c-L'A'+10:16;
+ if(nibble>15)return {};port=(port<<4)|nibble;
+ }
+ return knownInputConnection(port)?InputConnectionSelection{path.substr(0,at),port,true}:InputConnectionSelection{};
+}
+
+// The owner thread changes only an explicit user selection. It does not write
+// driver preferences. On close, restore only if nobody else changed the port.
+// Read/write callbacks are the same control path exercised by driver tests.
+class InputConnectionLease {
+ uint32_t original_=0,selected_=0;
+ bool changed_=false;
+public:
+ template<class Read,class Write>
+ bool apply(uint32_t requested,uint32_t supported,Read read,Write write){
+ if(!requested)return true;
+ if(changed_){uint32_t actual=0;return requested==selected_&&read(actual)&&actual==selected_;}
+ if(!knownInputConnection(requested)||(supported&requested)==0||!read(original_))return false;
+ selected_=requested;
+ if(original_==selected_)return true;
+ changed_=true;
+ if(!write(selected_))return false;
+ uint32_t actual=0;return read(actual)&&actual==selected_;
+ }
+ template<class Read,class Write>
+ bool restore(Read read,Write write){
+ if(!changed_)return true;
+ uint32_t actual=0;
+ if(!read(actual))return false;
+ if(actual!=selected_){changed_=false;return true;}
+ if(!write(original_)||!read(actual)||actual!=original_)return false;
+ changed_=false;return true;
+ }
+};
+}
diff --git a/qml/Veyra/DialogHost.qml b/qml/Veyra/DialogHost.qml
index 8a6f657e..d2763a31 100644
--- a/qml/Veyra/DialogHost.qml
+++ b/qml/Veyra/DialogHost.qml
@@ -375,7 +375,7 @@ Item {
hint: captureDialog.live ? qsTr("先断开采集,再配置驱动")
: veyra.captureBlackmagicDevice
? (veyra.preferences.blackmagicNativeCapture === true
- ? qsTr("原生采集跟随 Desktop Video Setup 的 HDMI/SDI 输入。支持自动检测的卡建议选择自动;信号未锁定时会明确提示。")
+ ? qsTr("请在设备列表选择对应的 HDMI/SDI 输入口;Driver 保留驱动当前输入。支持自动检测的卡建议选择自动,信号未锁定时会明确提示。")
: qsTr("Blackmagic 两个条目可能属于同一张卡。DirectShow 黑屏可尝试下方原生采集开关;手动格式须匹配实际信号。"))
: qsTr("配置驱动公开的输入与视频属性;其他采集应用占用设备时请先关闭")
RowLayout {
diff --git a/qml/Veyra/Main.qml b/qml/Veyra/Main.qml
index 6db286c2..9902e34a 100644
--- a/qml/Veyra/Main.qml
+++ b/qml/Veyra/Main.qml
@@ -220,9 +220,7 @@ Window {
// A second fixed-height formula let the HWND cover the playback bar.
return proPage.videoViewport
case "node":
- // .nodeview padding 14; .nv-top (330px by default, the splitter under
- // it resizes it) minus its 40px bar.
- return { x: 14, y: 14, width: Math.max(1, width - 28), height: root.nodeVideoHeight - 40 }
+ return nodePage.videoViewport
case "exp":
return ExportLayout.calculate(width, height, exportPage.compactTab).video
default:
@@ -266,6 +264,7 @@ Window {
id: nodePage
pageId: "node"
dragStripHeight: 14
+ onVideoViewportChanged: if (root.page === "node" && !root.fullscreen) videoHost.syncRect()
home: pages
videoHeight: root.nodeVideoHeight
onVideoHeightEdited: h => { root.nodeVideoHeight = h; videoHost.syncRect() }
diff --git a/qml/Veyra/NodePage.qml b/qml/Veyra/NodePage.qml
index 9db73aaf..5b34438f 100644
--- a/qml/Veyra/NodePage.qml
+++ b/qml/Veyra/NodePage.qml
@@ -31,6 +31,12 @@ VPage {
// native video window in step).
property real videoHeight: 330
signal videoHeightEdited(real height)
+ // The status summary can wrap and the transport gains a row on narrow
+ // windows. The native video host must use this same responsive geometry.
+ readonly property real videoCardHeight: Math.max(statsBar.height + 1,
+ Math.min(root.videoHeight, Math.max(180, root.height - 28 - 10 - 200)))
+ readonly property rect videoViewport: Qt.rect(14, 14, Math.max(1, root.width - 28),
+ Math.max(1, root.videoCardHeight - statsBar.height))
// Where a node picked from the add menu lands (world coordinates).
property var addAt: null
readonly property real cardWidth: 236
@@ -340,7 +346,9 @@ VPage {
Rectangle {
id: nvTop
Layout.fillWidth: true
- Layout.preferredHeight: root.videoHeight
+ Layout.preferredHeight: root.videoCardHeight
+ Layout.minimumHeight: root.videoCardHeight
+ Layout.maximumHeight: root.videoCardHeight
radius: Theme.rCard
color: Theme.videoBlack
border.width: 1
diff --git a/scripts/acceptance/node-video-geometry-probe.qml b/scripts/acceptance/node-video-geometry-probe.qml
new file mode 100644
index 00000000..158d62d7
--- /dev/null
+++ b/scripts/acceptance/node-video-geometry-probe.qml
@@ -0,0 +1,75 @@
+// Drives the real node page and compares its laid-out video area to the HWND.
+import QtQuick
+Item {
+ id: probe
+ property var appWindow: Window.window
+ property var cases: []
+ property int index: -1
+ property int ticks: 0
+ property bool recorded: false
+ property string media: ""
+ function find(item, name) {
+ if (!item) return null
+ if (item.objectName === name) return item
+ for (const child of (item.children || [])) {
+ const hit = find(child, name)
+ if (hit) return hit
+ }
+ return null
+ }
+ function rect(item) {
+ const p = item.mapToItem(appWindow.contentItem, 0, 0)
+ return { x: p.x, y: p.y, w: item.width, h: item.height }
+ }
+ function apply(c) {
+ if (appWindow.fullscreen) appWindow.toggleFullscreen()
+ appWindow.page = "node"
+ appWindow.width = c.width; appWindow.height = c.height
+ appWindow.nodeVideoHeight = c.pictureHeight || 330
+ veyra.setPreference("language", c.language || "zh-CN")
+ veyra.contentRate = c.options ? 1 : 0
+ veyra.displaySync = c.options ? 1 : 0
+ veyra.outputCustomFps = 30
+ veyra.outputRateMode = c.options ? 2 : 0
+ if (c.fullscreen) appWindow.toggleFullscreen()
+ }
+ function record(c) {
+ const content = appWindow.contentItem
+ const host = find(content, "videoHost")
+ const area = find(content, "videoArea")
+ const stats = find(content, "node-stats-scroll")
+ if (!host || !area || !stats || !veyra.hasSource || veyra.failed) throw new Error("source/node layout unavailable")
+ const bar = stats.parent.parent
+ const row = { name: c.name, index: index, page: appWindow.page, qtDpr: Screen.devicePixelRatio,
+ fullscreen: appWindow.fullscreen, window: {w: appWindow.width,h: appWindow.height},
+ host: rect(host), options: veyra.runOptions, submitFps: veyra.submitFps, applying: veyra.applying }
+ if (!appWindow.fullscreen) { row.area = rect(area); row.bar = rect(bar) }
+ console.log("PRO_GEOMETRY " + JSON.stringify(row))
+ }
+ Timer {
+ interval: 100; running: true; repeat: true
+ onTriggered: {
+ try {
+ ++probe.ticks
+ if (probe.index < 0) {
+ if (probe.ticks < 3) return
+ veyra.setPreference("reducedMotion", true)
+ veyra.nodeMode = 1; veyra.muted = true
+ veyra.nrEnabled = false; veyra.srEnabled = false; veyra.fgEnabled = false
+ veyra.videoHdr = false; veyra.colorEnabled = false
+ probe.index = 0; probe.apply(probe.cases[0]); veyra.openPath(probe.media)
+ probe.ticks = 0; return
+ }
+ if (probe.ticks > 180) throw new Error("timeout at " + probe.index)
+ if (!probe.recorded) {
+ if (probe.ticks < 12 || !veyra.running || veyra.applying) return
+ probe.record(probe.cases[probe.index]); probe.recorded = true; probe.ticks = 0
+ } else if (probe.ticks >= 5) {
+ ++probe.index
+ if (probe.index >= probe.cases.length) { console.log("PRO_GEOMETRY_DONE"); veyra.stopPlayback(); Qt.quit(); return }
+ probe.apply(probe.cases[probe.index]); probe.recorded = false; probe.ticks = 0
+ }
+ } catch(e) { console.error("PRO_GEOMETRY_FAIL " + e.message); Qt.exit(3) }
+ }
+ }
+}
diff --git a/scripts/acceptance/pro-video-geometry-test.py b/scripts/acceptance/pro-video-geometry-test.py
index c6798529..7245e20b 100644
--- a/scripts/acceptance/pro-video-geometry-test.py
+++ b/scripts/acceptance/pro-video-geometry-test.py
@@ -18,6 +18,7 @@ p.add_argument('--donor-app',type=Path,required=True)
p.add_argument('--media',required=True)
p.add_argument('--baseline-ref')
p.add_argument('--case',action='append',dest='selected_cases',help='Run only these named layout cases')
+p.add_argument('--page',choices=('pro','node'),default='pro')
opts=p.parse_args()
assert re.fullmatch(r'[a-z0-9-]+',opts.task),'unsafe artifact directory name'
assert opts.variant!='before' or opts.baseline_ref,'negative control requires an explicit Git reference'
@@ -57,12 +58,22 @@ cases=[dict(name='wide-no-policy',width=1900,height=900),dict(name='wide-active-
dict(name='traditional',width=1400,height=900,options=True,language='zh-TW'),dict(name='cinema-switch',width=1280,height=800,page='min'),
dict(name='professional-return',width=1400,height=900,options=True),dict(name='fullscreen',width=1400,height=900,options=True,fullscreen=True),
dict(name='fullscreen-return',width=1400,height=900,options=True)]
+if opts.page=='node':
+ cases=[dict(name='node-wide',width=1900,height=900),
+ dict(name='node-compact',width=960,height=800,options=True),
+ dict(name='node-english',width=1400,height=900,options=True,language='en'),
+ dict(name='node-minimum',width=720,height=700,options=True,language='ja'),
+ dict(name='node-tall-picture',width=1400,height=900,pictureHeight=600,options=True),
+ dict(name='node-shrink-window',width=960,height=650,pictureHeight=600,options=True),
+ dict(name='node-short-picture',width=1400,height=900,pictureHeight=180,options=True),
+ dict(name='node-fullscreen',width=1400,height=900,fullscreen=True),
+ dict(name='node-fullscreen-return',width=1400,height=900,options=True)]
if opts.selected_cases:
selected=set(opts.selected_cases)
assert selected.issubset({c['name'] for c in cases}),selected
cases=[c for c in cases if c['name'] in selected]
MAIN=APP/'qml/Veyra/Main.qml';original=MAIN.read_bytes();driver=APP/'qml/Veyra/ProGeometryProbe.qml'
-write(driver,(R/'scripts/acceptance/pro-video-geometry-probe.qml').read_bytes())
+write(driver,(R/'scripts/acceptance'/('node-video-geometry-probe.qml' if opts.page=='node' else 'pro-video-geometry-probe.qml')).read_bytes())
text=original.decode('utf8');at=text.rfind('}')
loader='\n Loader { source:"ProGeometryProbe.qml"; onLoaded: { item.cases='+json.dumps(cases)+'; item.media='+json.dumps(opts.media,ensure_ascii=False)+' } }\n'
write(MAIN,(text[:at]+loader+text[at:]).encode('utf8'))
@@ -98,6 +109,7 @@ try:
with console.open('wb') as stream:
command=[str(APP/'veyra_qml_ui.exe'),'--data-dir',str(PROFILE),'--page','home','--size','1400x900','--exit-after','70000']
if MODE=='software':command.append('--obs-game-capture')
+ if MODE=='software':command.append('--obs-game-capture')
proc=subprocess.Popen(command,cwd=APP,env=env,stdout=stream,stderr=subprocess.STDOUT)
while proc.poll() is None:
if time.monotonic()-start>80:proc.kill();raise TimeoutError('GUI timeout')
@@ -124,6 +136,7 @@ finally:
driver.unlink(missing_ok=True)
logs=console.read_text('utf8',errors='replace')+'\n'+(O/'engine.log').read_text('utf8',errors='replace')
errors=[l for l in logs.splitlines() if re.search(r'PRO_GEOMETRY_FAIL|TypeError:|ReferenceError:|Binding loop|Cannot assign|D3D12 ERROR|D3D12 CORRUPTION|failed to load component|no root object',l)]
+if 'interface renderer='+MODE not in logs:errors.append('Requested UI renderer was not observed')
completed=rc==0 and not errors and 'PRO_GEOMETRY_DONE' in logs and len(rows)==len(cases)
result=dict(variant=VARIANT,mode=MODE,scale=SCALE,exit=rc,seconds=round(time.monotonic()-start,2),errors=errors,rows=rows,
passed=completed and all(r['passed'] for r in rows),completed=completed,
diff --git a/scripts/acceptance/test-2.0.7-build.py b/scripts/acceptance/test-2.0.7-build.py
index 2c8defcc..0f5156ec 100644
--- a/scripts/acceptance/test-2.0.7-build.py
+++ b/scripts/acceptance/test-2.0.7-build.py
@@ -6,6 +6,7 @@ import argparse,hashlib,json,os,re,subprocess,time
parser=argparse.ArgumentParser()
parser.add_argument('--task',default='test-2.0.7-20261012')
parser.add_argument('--label',default='2.0.7-test')
+parser.add_argument('--extra-target',action='append',default=[])
args=parser.parse_args()
assert re.fullmatch(r'[a-z0-9][a-z0-9.-]{0,79}',args.task)
assert re.fullmatch(r'2\.0\.7-[A-Za-z0-9.-]+',args.label)
@@ -56,6 +57,8 @@ targets=['veyra_qml_ui','veyra_xess_motion_contract_tests','veyra_xess_motion_qu
'veyra_present_sink_lifecycle_tests','veyra_decklink_tests','veyra_capture_format_selection_tests',
'veyra_capture_color_tests','veyra_vfg_gpu_tests','veyra_fsr_dispatch_tests','veyra_qml_quick_tests',
'veyra_playlist_tests','veyra_qml_data_tests','veyra_bitmap_subtitle_tests','veyra_subtitle_format_tests','veyra_capture_tests']
+assert all(re.fullmatch(r'veyra_[a-z0-9_]+',target) for target in args.extra_target)
+targets=list(dict.fromkeys(targets+args.extra_target))
inputs={p.relative_to(ROOT).as_posix():sha(p) for folder in ('include','src','apps','shaders','qml','tests','cmake','i18n') for p in (ROOT/folder).rglob('*') if p.is_file()}
inputs['CMakeLists.txt']=sha(ROOT/'CMakeLists.txt');commands=[];start=time.monotonic()
configure=[cmake,'-S',str(ROOT),'-B',str(BUILD),'-G','Ninja','-DCMAKE_BUILD_TYPE=Release']+['-D'+k+'='+v for k,v in options.items()]
diff --git a/shaders/PresentBlit.hlsl b/shaders/PresentBlit.hlsl
index f4f6fd71..5b3836be 100644
--- a/shaders/PresentBlit.hlsl
+++ b/shaders/PresentBlit.hlsl
@@ -4,6 +4,7 @@
// triangle sample instead of a compute write.
#include "HdrColor.hlsli"
+#include "PresentationRotation.hlsli"
Texture2D<float4> sourceTex : register(t0);
cbuffer PresentBlitConstants : register(b0)
@@ -114,6 +115,7 @@ float4 psMain(VSOut input) : SV_Target
if(any(uv<0)||any(uv>1))return float4(0,0,0,1);
}
uint flags=uint(srcDims.z+0.5);
+ uv=PresentationSourceUv(uv,(flags>>6)&3);
float4 color=(flags&2)?FineSample(uv):sourceTex.SampleLevel(linearClamp,uv,0);
if(flags&32)color.rgb=HdrDecodePq(color.rgb);
if(flags&8)color.rgb*=203.0/80.0; // SDR comparison white in an HDR output.
diff --git a/shaders/PresentMotion.hlsl b/shaders/PresentMotion.hlsl
index 7e628125..994028c3 100644
--- a/shaders/PresentMotion.hlsl
+++ b/shaders/PresentMotion.hlsl
@@ -1,10 +1,11 @@
// Same contain/zoom/pan mapping as PresentBlit, with current->previous motion.
+#include "PresentationRotation.hlsli"
Texture2D<float2> sourceMotion : register(t0);
RWTexture2D<float2> outputMotion : register(u0);
cbuffer Mapping : register(b0) {
float4 extent; // source extent, current client extent
float4 currentView; // current rendered width, center x/y, reset
- float4 previousView; // current rendered height, previous center x/y, unused
+ float4 previousView; // current rendered height, previous center x/y, clockwise quarter turns
float4 previousClient; // previous client width/height, rendered width/height
};
[numthreads(8,8,1)]
@@ -13,13 +14,15 @@ void main(uint3 tid : SV_DispatchThreadID) {
if(any(tid.xy>=size))return;
float2 displayUv=(float2(tid.xy)+.5)/float2(size);
float2 sourceUv=(displayUv-.5)*extent.zw/float2(currentView.x,previousView.x)+currentView.yz;
+ const uint turns=uint(previousView.w+.5)&3;
+ sourceUv=PresentationSourceUv(sourceUv,turns);
if(currentView.w!=0||any(sourceUv<0)||any(sourceUv>=1)) {
outputMotion[tid.xy]=0;return;
}
uint2 motionSize;sourceMotion.GetDimensions(motionSize.x,motionSize.y);
int2 samplePixel=min(int2(sourceUv*motionSize),int2(motionSize)-1);
float2 previousUv=sourceUv+sourceMotion.Load(int3(samplePixel,0))/extent.xy;
- float2 previousDisplay=.5+(previousUv-previousView.yz)*previousClient.zw/previousClient.xy;
+ float2 previousDisplay=.5+(PresentationDisplayUv(previousUv,turns)-previousView.yz)*previousClient.zw/previousClient.xy;
outputMotion[tid.xy]=(any(previousUv<0)||any(previousUv>=1)||any(previousDisplay<0)||any(previousDisplay>=1))?
float2(0,0):(previousDisplay-displayUv)*float2(size);
}
diff --git a/shaders/PresentationRotation.hlsli b/shaders/PresentationRotation.hlsli
new file mode 100644
index 00000000..941c36d7
--- /dev/null
+++ b/shaders/PresentationRotation.hlsli
@@ -0,0 +1,13 @@
+// Container rotation is clockwise. Color and provider motion share this mapping.
+float2 PresentationSourceUv(float2 uv,uint turns) {
+ if(turns==1)return float2(uv.y,1-uv.x);
+ if(turns==2)return 1-uv;
+ if(turns==3)return float2(1-uv.y,uv.x);
+ return uv;
+}
+float2 PresentationDisplayUv(float2 uv,uint turns) {
+ if(turns==1)return float2(1-uv.y,uv.x);
+ if(turns==2)return 1-uv;
+ if(turns==3)return float2(uv.y,1-uv.x);
+ return uv;
+}
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index e87c4444..fcd9f578 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -553,6 +553,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const auto& si=activeSource->info();
snapshot_.sourceWidth=si.width;snapshot_.sourceHeight=si.height;
snapshot_.sourceDisplayAspect=si.displayAspect;
+ previewView_.rotationDegrees=si.rotationDegrees;
if(si.width&&si.height&&std::isfinite(si.displayAspect)&&si.displayAspect>0&&std::abs(si.displayAspect-double(si.width)/si.height)>.001)
previewView_.displayAspect=si.displayAspect;
snapshot_.sourceRotationDegrees=si.rotationDegrees;
diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cpp
index dc3c8f3e..b46e27a7 100644
--- a/src/engine/VideoPresenter.cpp
+++ b/src/engine/VideoPresenter.cpp
@@ -252,7 +252,8 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
D3D12_VIEWPORT viewport{0,0,float(sink_.bufferWidth()),float(sink_.bufferHeight()),0,1};
D3D12_RECT rect{0,0,LONG(sink_.bufferWidth()),LONG(sink_.bufferHeight())};list->RSSetViewports(1,&viewport);list->RSSetScissorRects(1,&rect);
ID3D12DescriptorHeap* heaps[]={pass_.heap.Get()};list->SetDescriptorHeaps(1,heaps);list->SetGraphicsRootSignature(pass_.rootSig.Get());list->SetPipelineState(pass_.pso.Get());
- const float samplingFlags=graph.highQualityPresentation()?2.0f:0.0f;
+ const float rotationFlags=float(view.quarterTurns()<<6);
+ const float samplingFlags=(graph.highQualityPresentation()?2.0f:0.0f)+rotationFlags;
// PresentBlit uses a contain mapping. Cancel its fit so these dimensions
// express the exact shared display transform, including stretch/SAR/fill.
const float inverseFit=1.0f/std::min(float(rc.right)/renderW,float(rc.bottom)/renderH);
@@ -313,7 +314,7 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
// zero motion in this case. Keep the current color in XeSS history so
// the next continuous frame can interpolate without another warmup.
const bool enabled=regionVisible&&!generated&&!comparison&&graph.presentMotion(slot)&&graph.presentDepth()&&identity.sourceFrameId!=lastXessIdentity_.sourceFrameId&&!xessGenerationSuppressed_;
- const bool reset=!graph.presentMotionValid(slot)||!xessWasEnabled_||identity.epoch!=lastXessIdentity_.epoch||identity.settingsRevision!=lastXessIdentity_.settingsRevision||graph.motionPreviousSource(slot)!=lastXessIdentity_.sourceFrameId;
+ const bool reset=!graph.presentMotionValid(slot)||!xessWasEnabled_||identity.epoch!=lastXessIdentity_.epoch||identity.settingsRevision!=lastXessIdentity_.settingsRevision||graph.motionPreviousSource(slot)!=lastXessIdentity_.sourceFrameId||view.quarterTurns()!=previousXessView_.quarterTurns();
// frameRenderTime is the provider's only independent period estimate on
// non-Intel GPUs. Feeding present-to-present time back would include the
// provider's own wait and lengthen the next burst (measured 2026-09-21).
@@ -347,7 +348,7 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
const auto [prevRenderW,prevRenderH]=previous.renderedSize(float(reset?rc.right:previousXessWidth_),float(reset?rc.bottom:previousXessHeight_),float(graph.workWidth()),float(graph.workHeight()));
const float mapping[16]={float(graph.workWidth()),float(graph.workHeight()),float(rc.right),float(rc.bottom),
renderW,view.centerX,view.centerY,reset?1.0f:0.0f,
- renderH,previous.centerX,previous.centerY,0,
+ renderH,previous.centerX,previous.centerY,float(view.quarterTurns()),
float(reset?rc.right:previousXessWidth_),float(reset?rc.bottom:previousXessHeight_),prevRenderW,prevRenderH};
const auto heap=presentMotionPass_.heap->GetGPUDescriptorHandleForHeapStart().ptr;
presentMotionPass_.bind(list,mapping,heap+size_t(slot*2)*presentMotionPass_.increment,heap+size_t(slot*2+1)*presentMotionPass_.increment);
diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cpp
index dad3fa04..3fd3c27e 100644
--- a/src/source/CaptureCardSource.cpp
+++ b/src/source/CaptureCardSource.cpp
@@ -834,7 +834,7 @@ std::vector<CaptureFormat> CaptureCardSource::formatsByPath(std::wstring_view de
}
bool CaptureCardSource::showDeviceProperties(std::wstring_view devicePath,uintptr_t owner,bool inputSelector,std::wstring& error,std::wstring* changedFormatKey){
error.clear();if(changedFormatKey)changedFormatKey->clear();
- if(decklink::isPath(devicePath)){error=L"BMD 原生入口跟随 Desktop Video Setup 的 HDMI/SDI 输入设置;请在该程序选择输入口,再使用自动检测或手动制式。";return false;}
+ if(decklink::isPath(devicePath)){error=L"请在视频输入设备列表选择这张 BMD 卡对应的 HDMI/SDI 输入口,再选择自动检测或匹配信号的手动制式。Driver 条目保留驱动当前输入。";return false;}
ComPtr<IGraphBuilder> graph;ComPtr<ICaptureGraphBuilder2> builder;ComPtr<IBaseFilter> device;ComPtr<IAMStreamConfig> config;
if(!configuration(devicePath,graph,builder,device,config)){error=L"无法打开驱动设置;请先断开采集并关闭占用设备的应用。";return false;}
AM_MEDIA_TYPE* before=nullptr;const HRESULT beforeHr=config->GetFormat(&before);
diff --git a/src/source/DeckLinkCapture.cpp b/src/source/DeckLinkCapture.cpp
index ae84c773..86fad73d 100644
--- a/src/source/DeckLinkCapture.cpp
+++ b/src/source/DeckLinkCapture.cpp
@@ -1,4 +1,5 @@
#include "veyra/source/DeckLinkCapture.h"
+#include "veyra/source/DeckLinkInputConnection.h"
#include "veyra/Log.h"
#include <algorithm>
#include <chrono>
@@ -133,7 +134,7 @@ bool Capture::configure(std::wstring_view path,std::wstring_view key,bool audio,
{std::lock_guard lock(p.mutex);p.probing=false;if(p.reopen||p.pending)ok=false;}
if(!ok){
{std::lock_guard lock(p.mutex);if(why.empty())why=p.error;}
- if(why.empty())why=L"BMD 未检测到有效输入。请关闭占用采集卡的应用,并在 Desktop Video Setup 核对 HDMI/SDI 和制式;也可选择手动制式";
+ if(why.empty())why=std::format(L"BMD 未在 {} 输入检测到有效信号。请在设备列表选择与 OBS 一致的 HDMI/SDI 输入口,并选择自动检测或匹配实际信号的手动制式。",inputConnectionName(inputConnectionSelection(path).connection));
return failed(why);
}
if(!p.driver->flush(why))return failed(why);
diff --git a/src/source/DeckLinkDriver.cpp b/src/source/DeckLinkDriver.cpp
index 80a1d5b9..653c8084 100644
--- a/src/source/DeckLinkDriver.cpp
+++ b/src/source/DeckLinkDriver.cpp
@@ -3,6 +3,7 @@
// Veyra uses owner-thread negotiation, stable IDs, explicit metadata and its
// existing upload mailbox. SDK headers are generated externally, never vendored.
#include "veyra/source/DeckLinkCapture.h"
+#include "veyra/source/DeckLinkInputConnection.h"
#include "veyra/Log.h"
#include <algorithm>
#include <format>
@@ -26,7 +27,8 @@ bool checked(HRESULT hr,const char* operation,std::wstring* error=nullptr){
return SUCCEEDED(hr);
}
std::wstring take(BSTR value){std::wstring s=value?std::wstring(value,SysStringLen(value)):L"";SysFreeString(value);return s;}
-struct Row {ComPtr<IDeckLink> device;ComPtr<IDeckLinkInput> input;Device details;};
+static_assert(bmdVideoConnectionSDI==1&&bmdVideoConnectionHDMI==2&&bmdVideoConnectionSVideo==32);
+struct Row {ComPtr<IDeckLink> device;ComPtr<IDeckLinkInput> input;Device details;std::wstring name;uint32_t supportedConnections=0,requestedConnection=0;};
std::vector<Row> enumerate(){
std::vector<Row> out;ComPtr<IDeckLinkIterator> iterator;
const HRESULT hr=CoCreateInstance(__uuidof(CDeckLinkIterator),nullptr,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&iterator));
@@ -42,13 +44,16 @@ std::vector<Row> enumerate(){
const auto subHr=attributes->GetInt(BMDDeckLinkSubDeviceIndex,&sub);
BSTR name=nullptr;const auto nameHr=device->GetDisplayName(&name);
row.details.name=take(name);if(FAILED(nameHr)||row.details.name.empty())row.details.name=L"Blackmagic DeckLink";
+ row.name=row.details.name;
row.details.path=std::format(L"decklink-native:{}:{:016x}:{:x}",persistent?L"p":L"t",uint64_t(id),uint64_t(sub));
BOOL automatic=FALSE;const auto detectHr=attributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection,&automatic);
row.details.autoDetection=SUCCEEDED(detectHr)&&automatic;
ComPtr<IDeckLinkConfiguration> config;LONGLONG port=0;
if(SUCCEEDED(device.As(&config)))checked(config->GetInt(bmdDeckLinkConfigVideoInputConnection,&port),"GetInputConnection");
- row.details.name=std::format(L"[原生] {} · {}",row.details.name,port==bmdVideoConnectionHDMI?L"HDMI":port==bmdVideoConnectionSDI?L"SDI":L"跟随驱动输入");
- log::info("decklink-device",std::format("stableKind={} id=0x{:016X} sub={} subHr=0x{:08X} autoDetect={} detectHr=0x{:08X} connection=0x{:X}",persistent?"persistent":"topological",uint64_t(id),sub,uint32_t(subHr),row.details.autoDetection,uint32_t(detectHr),uint64_t(port)));
+ LONGLONG supported=0;const auto portsHr=attributes->GetInt(BMDDeckLinkVideoInputConnections,&supported);
+ if(portsHr==S_OK&&supported>=0&&supported<=UINT32_MAX)row.supportedConnections=uint32_t(supported);
+ row.details.name=std::format(L"[原生] {} · Driver ({})",row.name,inputConnectionName(uint32_t(port)));
+ log::info("decklink-device",std::format("stableKind={} id=0x{:016X} sub={} subHr=0x{:08X} autoDetect={} detectHr=0x{:08X} connection=0x{:X} supportedConnections=0x{:X} portsHr=0x{:08X}",persistent?"persistent":"topological",uint64_t(id),sub,uint32_t(subHr),row.details.autoDetection,uint32_t(detectHr),uint64_t(port),row.supportedConnections,uint32_t(portsHr)));
out.push_back(std::move(row));device.Reset();
}
// A driver without unique sub-device IDs must never make two physical
@@ -57,7 +62,17 @@ std::vector<Row> enumerate(){
for(const auto& row:out)if(std::count_if(out.begin(),out.end(),[&](const Row& other){return other.details.path==row.details.path;})>1)ambiguous.push_back(row.details.path);
if(!ambiguous.empty())log::warn("decklink-device","Duplicate stable input IDs; refusing ambiguous endpoints");
std::erase_if(out,[&](const Row& row){return std::find(ambiguous.begin(),ambiguous.end(),row.details.path)!=ambiguous.end();});
- return out;
+ std::vector<Row> choices;
+ for(const auto& row:out){
+ choices.push_back(row); // preserve saved legacy identities
+ for(auto connection:inputConnections)if(row.supportedConnections&connection){
+ auto choice=row;choice.requestedConnection=connection;
+ choice.details.path=inputConnectionPath(row.details.path,connection);
+ choice.details.name=std::format(L"[原生] {} · {}",row.name,inputConnectionName(connection));
+ choices.push_back(std::move(choice));
+ }
+ }
+ return choices;
}
Mode describe(IDeckLinkDisplayMode* mode){
Mode out;out.id=mode->GetDisplayMode();out.width=mode->GetWidth();out.height=mode->GetHeight();
@@ -75,12 +90,22 @@ Mode describe(IDeckLinkDisplayMode* mode){
else{c.matrix=out.height>576?YuvMatrix::BT709:YuvMatrix::BT601;c.primaries=out.height>576?ColorPrimaries::BT709:out.height==576?ColorPrimaries::BT601_625:ColorPrimaries::BT601_525;c.matrixAssumed=c.primariesAssumed=(flags&bmdDisplayModeColorspaceRec601)==0;}
return out;
}
-std::vector<Mode> readModes(IDeckLinkInput* input){
+std::vector<Mode> readModes(IDeckLinkInput* input,uint32_t connection=0){
std::vector<Mode> out;ComPtr<IDeckLinkDisplayModeIterator> iterator;
if(!checked(input->GetDisplayModeIterator(&iterator),"GetDisplayModeIterator"))return out;
ComPtr<IDeckLinkDisplayMode> mode;
while(iterator->Next(&mode)==S_OK){auto m=describe(mode.Get());
- if(m.width>=2&&m.height&&m.duration>0&&m.scale>0)out.push_back(std::move(m));mode.Reset();}
+ if(m.width>=2&&m.height&&m.duration>0&&m.scale>0){
+ bool usable=false;
+ for(auto format:{bmdFormat10BitYUV,bmdFormat8BitYUV,bmdFormat10BitRGBXLE,bmdFormat8BitBGRA}){
+ BOOL supported=FALSE;BMDDisplayMode actual=bmdModeUnknown;
+ const HRESULT hr=input->DoesSupportVideoMode(BMDVideoConnection(connection),BMDDisplayMode(m.id),format,bmdNoVideoInputConversion,bmdSupportedVideoModeDefault,&actual,&supported);
+ if(FAILED(hr))checked(hr,"DoesSupportVideoMode(enumerate)");
+ if(hr==S_OK&&supported&&uint32_t(actual)==m.id){usable=true;break;}
+ }
+ if(usable)out.push_back(std::move(m));
+ }
+ mode.Reset();}
// A conservative seed only. The format-change callback, not this order,
// selects the real automatic mode before any frame can be published.
std::stable_sort(out.begin(),out.end(),[](const Mode& a,const Mode& b){const auto seed=[](const Mode& m){return m.width==1920&&m.height==1080&&!m.interlaced&&m.scale==m.duration*60;};return seed(a)&&!seed(b);});
@@ -168,7 +193,23 @@ public:
};
class ComDriver final:public Driver {
ComPtr<IDeckLink> device_;ComPtr<IDeckLinkInput> input_;ComPtr<Callback> callback_;
+ ComPtr<IDeckLinkConfiguration> configuration_;
+ InputConnectionLease connectionLease_;
+ uint32_t requestedConnection_=0,supportedConnections_=0;
+ bool connectionConfigured_=false;
bool auto_=false,videoEnabled_=false,audioEnabled_=false;
+ bool readConnection(uint32_t& value){
+ if(!configuration_)return false;LONGLONG actual=0;
+ const auto hr=configuration_->GetInt(bmdDeckLinkConfigVideoInputConnection,&actual);
+ checked(hr,"ReadInputConnection");
+ if(hr!=S_OK||actual<0||actual>UINT32_MAX)return false;
+ value=uint32_t(actual);return true;
+ }
+ bool writeConnection(uint32_t value){
+ if(!configuration_)return false;
+ const auto hr=configuration_->SetInt(bmdDeckLinkConfigVideoInputConnection,value);
+ checked(hr,"SetInputConnection");return hr==S_OK;
+ }
void logStatus(){ComPtr<IDeckLinkStatus> status;if(FAILED(device_.As(&status)))return;
BOOL locked=FALSE;LONGLONG detected=0,flags=0,current=0;
const auto a=status->GetFlag(bmdDeckLinkStatusVideoInputSignalLocked,&locked),b=status->GetInt(bmdDeckLinkStatusDetectedVideoInputMode,&detected),c=status->GetInt(bmdDeckLinkStatusDetectedVideoInputFormatFlags,&flags),d=status->GetInt(bmdDeckLinkStatusCurrentVideoInputMode,&current);
@@ -176,17 +217,31 @@ class ComDriver final:public Driver {
public:
~ComDriver(){stop();}
bool open(std::wstring_view path,DriverSink& sink,std::wstring& error)override{
- stop();for(auto& row:enumerate())if(row.details.path==path){device_=row.device;input_=row.input;auto_=row.details.autoDetection;break;}
- if(!input_){error=L"未找到该 BMD 原生设备,请安装 Desktop Video 驱动并刷新设备列表";return false;}
+ stop();const auto selection=inputConnectionSelection(path);
+ if(!selection.valid){error=L"保存的 BMD 输入口无效,请重新选择设备和 HDMI/SDI 输入";return false;}
+ bool physicalFound=false;
+ for(auto& row:enumerate()){
+ if(row.details.path==selection.device)physicalFound=true;
+ if(row.details.path==path){device_=row.device;input_=row.input;auto_=row.details.autoDetection;requestedConnection_=row.requestedConnection;supportedConnections_=row.supportedConnections;break;}
+ }
+ if(!input_){error=physicalFound?L"这张 BMD 卡当前不提供所选输入口,请刷新并重新选择设备输入":L"BMD 原生设备当前不可用,请确认设备连接和 Desktop Video 状态,然后刷新设备列表";return false;}
+ device_.As(&configuration_);
callback_.Attach(new Callback(sink));
if(!checked(input_->SetCallback(callback_.Get()),"SetCallback",&error)){stop();return false;}
logStatus();return true;
}
- std::vector<Mode> modes()override{return input_?readModes(input_.Get()):std::vector<Mode>{};}
+ std::vector<Mode> modes()override{return input_?readModes(input_.Get(),requestedConnection_):std::vector<Mode>{};}
bool autoDetection()const override{return auto_;}
bool enable(const Mode& mode,Pixel p,bool automatic,bool audio,std::wstring& error)override{
if(!input_)return false;BOOL supported=FALSE;BMDDisplayMode actual=bmdModeUnknown;
- const auto hr=input_->DoesSupportVideoMode(bmdVideoConnectionUnspecified,BMDDisplayMode(mode.id),sdkPixel(p),bmdNoVideoInputConversion,bmdSupportedVideoModeDefault,&actual,&supported);
+ if(!connectionConfigured_){
+ const bool selected=connectionLease_.apply(requestedConnection_,supportedConnections_,[&](uint32_t& value){return readConnection(value);},[&](uint32_t value){return writeConnection(value);});
+ uint32_t actualConnection=0;const bool read=readConnection(actualConnection);
+ log::info("decklink-connection",std::format("requested=0x{:X} actual=0x{:X} verified={} read={} supported=0x{:X} persistentWrite=0",requestedConnection_,actualConnection,selected,read,supportedConnections_));
+ if(!selected){error=L"BMD 所选输入口不可用,或驱动未应用该输入口;请重新选择 HDMI/SDI 输入";return false;}
+ connectionConfigured_=true;
+ }
+ const auto hr=input_->DoesSupportVideoMode(BMDVideoConnection(requestedConnection_),BMDDisplayMode(mode.id),sdkPixel(p),bmdNoVideoInputConversion,bmdSupportedVideoModeDefault,&actual,&supported);
checked(hr,"DoesSupportVideoMode",&error);
log::info("decklink-negotiate",std::format("mode=0x{:08X} actual=0x{:08X} pixel=0x{:08X} supported={} automatic={}",mode.id,unsigned(actual),unsigned(sdkPixel(p)),supported,automatic));
if(FAILED(hr)||!supported||uint32_t(actual)!=mode.id){if(error.empty())error=L"BMD 输入不支持所选制式/像素格式";return false;}
@@ -204,12 +259,14 @@ public:
if(callback_)callback_->wait();
if(input_&&audioEnabled_)checked(input_->DisableAudioInput(),"DisableAudioInput");
if(input_&&videoEnabled_)checked(input_->DisableVideoInput(),"DisableVideoInput");
+ if(configuration_&&!connectionLease_.restore([&](uint32_t& value){return readConnection(value);},[&](uint32_t value){return writeConnection(value);}))log::warn("decklink-connection","Unable to restore the prior input connection; no persistent preferences were written");
+ connectionLease_={};configuration_.Reset();requestedConnection_=supportedConnections_=0;connectionConfigured_=false;
callback_.Reset();input_.Reset();device_.Reset();videoEnabled_=audioEnabled_=false;
}
};
}
std::vector<Device> devices(){std::vector<Device> out;for(auto& row:enumerate())out.push_back(std::move(row.details));return out;}
-std::vector<Mode> modes(std::wstring_view path){for(auto& row:enumerate())if(row.details.path==path)return readModes(row.input.Get());return {};}
+std::vector<Mode> modes(std::wstring_view path){for(auto& row:enumerate())if(row.details.path==path)return readModes(row.input.Get(),row.requestedConnection);return {};}
std::unique_ptr<Driver> makeDriver(){return std::make_unique<ComDriver>();}
}
#else
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index e6bd74a4..04f89d5f 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -2364,7 +2364,7 @@ void QmlPlayerBridge::tickCapture() {
i.captureStatus = i.captureFormatList.empty() ? tr("未读到设备上报的采集格式,或设备正被其他应用占用。")
: i.captureFormatKey.empty() ? (!i.capturePrefs.formatKey.empty()?tr("此采集卡无此格式,请重新选择分辨率、帧率和像素格式。"):tr("先选择分辨率,再选择该分辨率支持的帧率和像素格式"))
: q.kind == 3 ? tr("驱动设置已关闭。请核对所选格式与设备帧率,再连接。")
- : source::decklink::isPath(i.captureDevice) ? tr("原生采集先确认有效信号;支持自动检测的卡建议选择自动。HDMI/SDI 跟随 Desktop Video Setup。")
+ : source::decklink::isPath(i.captureDevice) ? tr("原生采集先确认有效信号;请在设备列表选择对应的 HDMI/SDI 输入,支持自动检测的卡建议选择自动。Driver 保留驱动当前输入。")
: captureBlackmagicDevice() ? tr("请选择与输入信号一致的格式。驱动默认格式不代表检测到的信号。")
: tr("连接后使用当前增强设置。格式与音频变更需要重新连接。");
veyra::log::info("capture-ui", std::format("formats={} selected={}", i.captureFormatList.size(), !i.captureFormatKey.empty()));
diff --git a/tests/integration/ExperimentalBackendTests.cpp b/tests/integration/ExperimentalBackendTests.cpp
index d5c8cd16..e8d6f305 100644
--- a/tests/integration/ExperimentalBackendTests.cpp
+++ b/tests/integration/ExperimentalBackendTests.cpp
@@ -138,7 +138,7 @@ bool checkDisplayMotion(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring)
D3D12_DESCRIPTOR_HEAP_DESC hd{};hd.Type=D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;hd.NumDescriptors=1;
if(FAILED(ctx.device()->CreateDescriptorHeap(&hd,IID_PPV_ARGS(&clearHeap))))return false;
pipeline::makeUav(ctx.device(),source.Get(),DXGI_FORMAT_R16G16_FLOAT,clearHeap->GetCPUDescriptorHandleForHeapStart());
- for(unsigned test=0;test<4;++test){
+ for(unsigned test=0;test<8;++test){
Status st;uint32_t slot=0;auto* list=ring.acquireNext(slot,st);if(!list)return false;
pipeline::StateTracker states;
states.transition(list,source.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
@@ -149,8 +149,10 @@ bool checkDisplayMotion(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring)
states.transition(list,output.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
// Identity; 2X zoom; view shifted 10% right; explicit history reset.
const float zoom=test==1?2.0f:1.0f;
- const float map[16]={640,360,960,540,zoom,test==2?.6f:.5f,.5f,test==3?1.0f:0.0f,
- zoom,.5f,.5f,0,960,540,0,0};
+ const unsigned turns=test>=4&&test<=6?test-3:test==7?1:0;
+ const float renderW=test==7?303.75f:960*zoom,renderH=540*zoom;
+ const float map[16]={640,360,960,540,renderW,test==2?.6f:.5f,.5f,test==3?1.0f:0.0f,
+ renderH,.5f,.5f,float(turns),960,540,renderW,renderH};
pass.bind(list,map,gpu.ptr,gpu.ptr+pass.increment);list->Dispatch(w/8,h/8,1);
states.transition(list,source.Get(),D3D12_RESOURCE_STATE_COMMON);
states.transition(list,output.Get(),D3D12_RESOURCE_STATE_COMMON);
@@ -160,8 +162,8 @@ bool checkDisplayMotion(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring)
readStates.transition(list,output.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
if(!ring.submitAndSignal(slot))return false;
FlowSample sample;if(!readCanonicalFlow(ctx,ring,output.Get(),sample))return false;
- const float expectedX=test==3?0:test==2?62:-2*zoom;
- const float expectedY=test==3?0:zoom;
+ const float expectedX=test==3?0:test==2?62:turns==1?-renderW/540.0f:turns==2?2:turns==3?960.0f/540.0f:-2*zoom;
+ const float expectedY=test==3?0:turns==1?-1.125f:turns==2?-1:turns==3?1.125f:zoom;
const bool ok=std::abs(sample.x-expectedX)<.08f&&std::abs(sample.y-expectedY)<.08f;
std::cout<<"DISPLAY_MOTION case="<<test<<" actual="<<sample.x<<","<<sample.y<<" expected="<<expectedX<<","<<expectedY<<" pass="<<ok<<std::endl;
list=ring.acquireNext(slot,st);if(!list)return false;
@@ -177,6 +179,13 @@ bool checkDisplayMotion(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring)
int wmain(int argc,wchar_t** argv){
if(argc!=3)return 2;
+ if(wcscmp(argv[1],L"present-motion")==0){
+ CoInitializeEx(nullptr,COINIT_MULTITHREADED);
+ gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status;
+ const bool initialized=ctx.initialize({},status)&&ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,status);
+ const bool ok=initialized&&checkDisplayMotion(ctx,ring);
+ if(initialized)ring.drainQueue();ring.shutdown();ctx.shutdown();CoUninitialize();return ok?0:1;
+ }
const bool dis=std::wstring(argv[1]).find(L"dis")==0;
const bool pan=wcscmp(argv[1],L"xess-pan2")==0||wcscmp(argv[1],L"xess-pan4")==0;
const bool recovery=wcscmp(argv[1],L"xess-recovery2")==0||wcscmp(argv[1],L"xess-recovery3")==0||wcscmp(argv[1],L"xess-recovery4")==0||wcscmp(argv[1],L"xess-resize4")==0;
diff --git a/tests/integration/PreviewGeometryTests.cpp b/tests/integration/PreviewGeometryTests.cpp
index 00ff3992..1e83f0b1 100644
--- a/tests/integration/PreviewGeometryTests.cpp
+++ b/tests/integration/PreviewGeometryTests.cpp
@@ -38,6 +38,19 @@ int wmain(int argc,wchar_t** argv){
if(ok)ok=test("pan",{2,.25f,.5f},0,{{280,60,255,0,0},{280,200,255,0,255}});
if(ok)ok=test("reference",{2,.5f,.5f},1,{{40,10,255,0,0},{280,10,0,255,0}});
if(ok)ok=test("reset",{},0,{{160,10,0,0,0},{280,80,0,255,0}});
+ if(ok){
+ engine::PreviewView rotated;rotated.rotationDegrees=90;
+ ok=test("rotate90",rotated,0,{{40,120,0,0,0},{130,60,255,0,255},{190,60,255,0,0},{130,180,255,255,255},{190,180,0,255,0}});
+ if(ok)ok=test("rotate90-reference",rotated,1,{{130,60,255,0,255},{190,60,255,0,0},{190,180,0,255,0}});
+ rotated.rotationDegrees=270;
+ if(ok)ok=test("rotate270",rotated,0,{{130,60,0,255,0},{190,60,255,255,255},{130,180,255,0,0},{190,180,255,0,255}});
+ rotated.rotationDegrees=180;
+ if(ok)ok=test("rotate180",rotated,0,{{40,80,255,255,255},{280,80,255,0,255},{40,160,0,255,0},{280,160,255,0,0}});
+ rotated.rotationDegrees=90;rotated.mode=3;
+ if(ok)ok=test("rotate90-stretch",rotated,0,{{40,80,255,0,255},{280,80,255,0,0},{40,160,255,255,255},{280,160,0,255,0}});
+ rotated.mode=1;
+ if(ok)ok=test("rotate90-native",rotated,0,{{152,104,255,0,255},{168,104,255,0,0},{152,136,255,255,255},{168,136,0,255,0}});
+ }
if(ok)ok=test("dar-4-3",{1,.5f,.5f,0,4.0/3},0,{{40,10,255,0,0},{280,10,0,255,0},{40,230,255,0,255}});
if(ok)ok=test("stretch",{1,.5f,.5f,3},0,{{40,10,255,0,0},{280,10,0,255,0},{280,230,255,255,255}});
if(ok)ok=test("forced-16-9",{1,.5f,.5f,4},0,{{160,10,0,0,0},{40,40,255,0,0},{280,200,255,255,255}});
diff --git a/tests/unit/DeckLinkCaptureTests.cpp b/tests/unit/DeckLinkCaptureTests.cpp
index 640faa67..596a4341 100644
--- a/tests/unit/DeckLinkCaptureTests.cpp
+++ b/tests/unit/DeckLinkCaptureTests.cpp
@@ -1,4 +1,5 @@
#include "veyra/source/DeckLinkCapture.h"
+#include "veyra/source/DeckLinkInputConnection.h"
#include <windows.h>
#include <atomic>
#include <chrono>
@@ -46,6 +47,33 @@ int main(){
int failures=0;auto check=[&](bool value,const char* name){printf("%s %s\n",value?"PASS":"FAIL",name);if(!value)++failures;};
auto fixture=[](){auto driver=std::make_unique<FakeDriver>();auto* raw=driver.get();return std::pair{std::move(driver),raw};};
constexpr auto path=L"decklink-native:p:0000000000000123:0";
+ {
+ const auto hdmi=inputConnectionPath(path,2),sdi=inputConnectionPath(path,1);
+ check(inputConnectionSelection(path).valid&&inputConnectionSelection(path).connection==0,"old device identity still follows driver");
+ check(hdmi!=sdi&&inputConnectionSelection(hdmi).device==path&&inputConnectionSelection(hdmi).connection==2,"HDMI and SDI have separate stable saved identities");
+ for(auto bad:{L"decklink-native:p:123:0:input=00000000",L"decklink-native:p:123:0:input=00000003",L"decklink-native:p:123:0:input=00000002extra",L"decklink-native:p:123:0:input=zzzzzzzz"})
+ check(!inputConnectionSelection(bad).valid,"malformed or combined port cannot silently select another input");
+ uint32_t port=1;unsigned writes=0;
+ auto read=[&](uint32_t& value){value=port;return true;};
+ auto write=[&](uint32_t value){port=value;++writes;return true;};
+ InputConnectionLease lease;
+ check(lease.apply(2,3,read,write)&&port==2&&writes==1,"explicit HDMI overrides driver SDI and verifies actual value");
+ check(lease.apply(2,3,read,write)&&writes==1,"repeated pixel negotiation does not rewrite selected port");
+ check(lease.restore(read,write)&&port==1&&writes==2,"close restores previous driver input without persistent preferences");
+ InputConnectionLease external;
+ check(external.apply(2,3,read,write),"second input lease applies");port=8;const auto before=writes;
+ check(external.restore(read,write)&&port==8&&writes==before,"close never overwrites another application's changed input");
+ InputConnectionLease unsupported;
+ check(!unsupported.apply(2,1,read,write)&&writes==before,"unsupported connector fails without changing driver");
+ InputConnectionLease ignored;port=1;
+ check(!ignored.apply(2,3,read,[&](uint32_t){return true;})&&port==1,"successful Set call with ignored port is rejected by readback");
+ InputConnectionLease readFailure;port=1;unsigned reads=0;
+ auto intermittent=[&](uint32_t& value){value=port;return ++reads!=2;};
+ check(!readFailure.apply(2,3,intermittent,write)&&port==2,"readback failure is not reported as successful input selection");
+ check(readFailure.apply(2,3,read,write)&&readFailure.restore(read,write)&&port==1,"retry preserves original SDI for rollback after failed readback");
+ InputConnectionLease follow;const auto unchanged=writes;
+ check(follow.apply(0,3,read,write)&&follow.restore(read,write)&&writes==unchanged,"legacy follow-driver selection never switches ports");
+ }
{
auto [driver,fake]=fixture();fake->oversizedFirst=true;Capture capture(std::move(driver));
check(capture.configure(path,L"decklink:auto",false,50)&&capture.mode().id==1,"all driver modes retained without choosing an unsupported automatic seed");
diff --git a/tests/unit/UiContractTests.cpp b/tests/unit/UiContractTests.cpp
index e088eac3..ab1e3be1 100644
--- a/tests/unit/UiContractTests.cpp
+++ b/tests/unit/UiContractTests.cpp
@@ -124,6 +124,14 @@ int wmain(int argc,wchar_t** argv){try{
const float anchored=(800-500)/(1920.0f*(1000.0f/1920)*v.zoom)+v.centerX;require(std::abs(anchored-.8f)<.0001f,"pointer anchor fixed");
v.wheel(-3,800,300,1000,600,1920,1080);require(std::abs(v.zoom-1)<.0001f&&std::abs(v.centerX-.5f)<.0001f,"inverse wheel returns same view");
v.pan(100,0,1000,600,1920,1080);require(std::abs(v.centerX-.4f)<.0001f,"pan measured in displayed pixels");}
+ {engine::PreviewView v;v.rotationDegrees=90;
+ const auto size=v.renderedSize(320,240,64,32);require(size.first==120&&size.second==240,"portrait contain uses rotated extent");
+ const auto source=v.sourcePoint(130,60,320,240,64,32);require(source.first==.25f&&source.second==.75f,"portrait protection maps display corner to coded source");
+ const auto display=v.displayUv(source.first,source.second);require(display.first==.25f&&display.second==.25f,"inverse source/display rotation agrees");
+ v.mode=1;const auto native=v.renderedSize(320,240,64,32);require(native.first==32&&native.second==64,"native-pixel view swaps dimensions for portrait");
+ v.mode=0;v.rotationDegrees=-90;const auto opposite=v.sourceUv(.25f,.25f);require(opposite.first==.75f&&opposite.second==.25f,"opposite display matrix rotates the other way");
+ v.rotationDegrees=180;const auto upsideDown=v.sourceUv(.25f,.25f);require(upsideDown.first==.75f&&upsideDown.second==.75f,"upside-down display matrix maps both axes");
+ v.rotationDegrees=90;v.displayAspect=.75;require(std::abs(v.aspect(64,32)-.75)<.00001,"already-oriented SAR is not inverted twice");}
ui::UiSessionState state;require(!state.enhanced&&!state.configured.nr&&!state.configured.sr&&state.configured.multiplier==1,"fresh startup effects disabled");state.configured.forceSdrPreview=true;state.enhanced=true;state.configured.nr=true;state.configured.multiplier=4;state.configured.sr=true;state.configured.model.intensity=.37f;state.configured.residual.color=1.4f;
auto before=state.effective();require(state.mode==ui::Mode::Daily,"startup Daily");state.mode=ui::Mode::Professional;require(state.effective()==before,"mode cannot alter settings");state.enhanced=false;auto bypass=state.effective();require(!bypass.nr&&!bypass.sr&&bypass.multiplier==1,"true full bypass");require(bypass.forceSdrPreview,"master bypass retains SDR display choice");state.enhanced=true;require(state.effective()==before,"restore all settings");
for(bool input:{false,true})for(bool display:{false,true})for(bool force:{false,true}){engine::EnhancementSettings s;s.forceSdrPreview=force;require(s.useHdrPreview(input,display)==(input&&display&&!force),"HDR output policy");}