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++
Require supported capture resolution and explicit pixel format without fallback
Veyra Goal Agent4a4952f4ef44
diff --git a/AGENTS.md b/AGENTS.mdindex 62dbb43b..d17e8a37 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,5 +1,7 @@# Veyra 项目 Agent 执行规则+> **2026-10-12 构建前采集格式追加授权**:用户要求分辨率先行、MJPEG 标红(不建议使用)、无效组合明确弹错且不自动路由其他格式。允许最小 UI/桥接/采集协商修复和有关回归,保留有效上次配置;与本轮整合一起本地合入 main 和 2.0.7 测试包。+> **2026-10-12 各分支整合与 2.0.7 测试包授权**:用户明确要求将 Claude 最新已验 XeSS 和各分支已完成修复合入 main 并构建 2.0.7 测试包。按 docs/TEST_2.0.7_PLAN_2026-10-12.md 从 main a167831 隔离整合 Claude e46bbdf 与 Codex d883216(含34f479e),必要冲突适配后构建、组合回归、本地 main 合并及 NVIDIA/AMD 完整便携测试包。66旧树/509脏文件及来源 tip 存档保护,不派 Agent,不改驱动/运行库/模型/真实配置;UI33ms/250ms、GPU默认优先级与已撤回负优化保持。产物全E盘,测试每进程≤300秒、构建≤900秒。此范围覆盖历史 no-merge/no-package;没有新 push/Release/上传/关机授权。> **2026-10-12 专业模式画面遮挡播放条**:用户反馈原生视频位置错误并要求追溯来源。按docs/PRO_VIDEO_GEOMETRY_PLAN_2026-10-12.md从已验34f479e隔离codex/pro-video-geometry-20261012,仅统一Main/ProPage响应式尺寸、加入实际HWND回归;不改引擎、33ms/250ms节奏、GPU优先级、运行库或真实配置,不派Agent。65旧树/509脏文件由本轮start/bundle保护;产物全E盘,每测试≤300秒。无main合并/push/打包/Release/关机。diff --git a/CMakeLists.txt b/CMakeLists.txtindex d274d4d2..a0005884 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -735,6 +735,7 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformadd_executable(veyra_capture_color_tests tests/unit/CaptureColorContractTests.cpp)add_executable(veyra_capture_format_selection_tests tests/unit/CaptureFormatSelectionTests.cpp)target_compile_features(veyra_capture_format_selection_tests PRIVATE cxx_std_20)+ target_compile_options(veyra_capture_format_selection_tests PRIVATE /utf-8)target_include_directories(veyra_capture_format_selection_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)target_compile_definitions(veyra_capture_format_selection_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)target_link_libraries(veyra_capture_format_selection_tests PRIVATE ole32 strmiids)diff --git a/docs/TEST_2.0.7_PLAN_2026-10-12.md b/docs/TEST_2.0.7_PLAN_2026-10-12.mdindex 40fc35cd..36a2fca5 100644--- a/docs/TEST_2.0.7_PLAN_2026-10-12.md+++ b/docs/TEST_2.0.7_PLAN_2026-10-12.md@@ -18,3 +18,7 @@5. 封存实测产品源码后本地 main --no-ff 合并,核对完整 Git 树及旧树/脏文件。制作 NVIDIA、AMD 两个完整便携测试包,审计 PE、全部文件、运行组件 manifest、许可证、源码/依赖源码及 ZIP 哈希,并使用最终包私有 data-dir 冷启动。产物统一 E:/项目/Veyra/{archives,build,tests,logs,tmp,reports,test-packages}/test-2.0.7-20261012。原测试包/正式包不覆盖。当前授权不包含 GitHub push、Release、上传或关机。未验证项和失败证据写入报告及 WORKLOG。++## 构建前追加的采集格式约束++用户要求先选分辨率再选格式,MJPEG 标红并括号“不建议使用”,实际不存在的组合弹错误而不换格式。首次新设备不默认选分辨率;有效历史设置继续恢复。分辨率/帧率改变清空具体格式,列表仅显示设备在所选两轴下提供的完整媒体身份。无效 key、驱动拒绝及连接失败均明确报错,压缩连接/解码失败不再自动转 RGB;显式诊断 RGB 入口保留。草稿两轴按设备写入现有 JSON,capture-preferences.v1 格式不升级。增加严格组合/MJPEG 单测、红色菜单 Qt 测试、新设备/草稿重启/无效选择/全格式可达及原保存/继续/自动恢复真实 GUI 回归。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 92b4914e..44f4fed7 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -9284,3 +9284,7 @@ audit.py核对测试/GUI/所有app原件、两份旧final、旧JSON和源码bund## 2026-10-12 2.0.7 本地整合测试包开工用户授权 main 合并与测试包。开工 main a167831,66旧树/509脏文件独立快照、增量 bundle verify;隔离 codex/test-2.0.7-20261012 合入 d883216 与 e46bbdf。三处冲突为 AGENTS/WORKLOG/catalog,保留双方记录和主线翻译,增加四条 Edge Aegis 翻译。其余旧分支以祖先/最终差异审核,不恢复旧实验。计划 docs/TEST_2.0.7_PLAN_2026-10-12.md;构建/验收尚未完成,不把来源分支通过冒充组合通过。实际产物 E:/项目/Veyra 的本轮 archives/build/tests/logs/tmp/reports/test-packages。++### 2026-10-12 2.0.7 构建前采集格式追加修复(待本轮回归)+- 用户追加先选分辨率、MJPEG 红色警示、不支持的格式不得自动路由。新增草稿两轴和严格像素 key 校验、联动选择禁用、无效格式错误通知;更改分辨率/帧率需重新确认像素格式。有效历史完整配置继续恢复,部分草稿存现有 JSON,不升级二进制配置。移除压缩格式连接/解码失败的隐式 RGB 重试,保留显式诊断开关;没有改采集缓冲、逐帧传输或 UI 刷新频率。+- 首轮完整配置暴露最新 FFmpeg staging 无 import LIB,按对应 DEF 在 E 盘构建目录生成;DLL 未改。随后完整编译在 capture_format_selection_tests 缺 MSVC /utf-8 失败(中文源被按本机代码页解析),给该目标明确 /utf-8。失败证据 logs/test-2.0.7-20261012/build-20261012-163711、build-20261012-163842 保留;尚未宣称通过。diff --git a/i18n/catalog.json b/i18n/catalog.jsonindex e43d4be8..008ce997 100644--- a/i18n/catalog.json+++ b/i18n/catalog.json@@ -15597,6 +15597,125 @@"zh-TW": "引擎未接受邊緣神盾,原設定保留","en": "The engine did not accept Edge Aegis; previous setting kept","ja": "エンジンがエッジイージスを受け付けなかったため、元の設定のままです"+ },+ {+ "zh": "(不建议使用)",+ "src": "src/ui/QmlPlayerBridge.cpp",+ "zh-TW": "(不建議使用)",+ "en": " (not recommended)",+ "ja": "(非推奨)"+ },+ {+ "zh": "先选择分辨率,再选择该分辨率支持的帧率和像素格式",+ "src": "src/ui/QmlPlayerBridge.cpp",+ "zh-TW": "先選擇解析度,再選擇該解析度支援的幀率和像素格式",+ "en": "Choose a resolution first, then a frame rate and pixel format supported at that resolution.",+ "ja": "先に解像度を選択し、その解像度で対応するフレームレートとピクセル形式を選択してください。"+ },+ {+ "zh": "请先选择分辨率",+ "src": "src/ui/QmlPlayerBridge.cpp",+ "zh-TW": "請先選擇解析度",+ "en": "Choose a resolution first",+ "ja": "先に解像度を選択してください"+ },+ {+ "zh": "请先选择分辨率和像素格式",+ "src": "src/ui/QmlPlayerBridge.cpp",+ "zh-TW": "請先選擇解析度和像素格式",+ "en": "Choose a resolution and pixel format first",+ "ja": "先に解像度とピクセル形式を選択してください"+ },+ {+ "zh": "此采集卡无此格式,请重新选择分辨率、帧率和像素格式。",+ "src": "src/ui/QmlPlayerBridge.cpp",+ "zh-TW": "此擷取卡無此格式,請重新選擇解析度、幀率和像素格式。",+ "en": "This capture card does not offer this format. Choose a supported resolution, frame rate and pixel format.",+ "ja": "このキャプチャカードにこの形式はありません。対応する解像度、フレームレート、ピクセル形式を選び直してください。"+ },+ {+ "zh": "此采集卡无此格式:拒绝 {:.3f} FPS(0x{:08X}),请改用设备支持的帧率,或填 0 沿用所选格式。",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "此擷取卡無此格式:拒絕 {:.3f} FPS(0x{:08X}),請改用裝置支援的幀率,或填 0 沿用所選格式。",+ "en": "This capture card rejected the requested format at {:.3f} FPS (0x{:08X}). Choose a supported rate, or enter 0 to use the selected format rate.",+ "ja": "キャプチャカードが {:.3f} FPS の指定形式を拒否しました(0x{:08X})。対応するレートを選ぶか、0 を入力して選択形式のレートを使用してください。"+ },+ {+ "zh": "此采集卡无此格式,驱动拒绝所选格式(0x{:08X}),请重新选择。",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "此擷取卡無此格式,驅動拒絕所選格式(0x{:08X}),請重新選擇。",+ "en": "This capture card rejected the selected format (0x{:08X}). Choose another supported format.",+ "ja": "キャプチャカードのドライバーが選択形式を拒否しました(0x{:08X})。対応する形式を選び直してください。"+ },+ {+ "zh": "采集卡返回的压缩格式尺寸无效,请重新选择采集格式。",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "擷取卡回傳的壓縮格式尺寸無效,請重新選擇擷取格式。",+ "en": "The capture card returned invalid compressed frame dimensions. Choose another capture format.",+ "ja": "キャプチャカードが無効な圧縮フレームサイズを返しました。キャプチャ形式を選び直してください。"+ },+ {+ "zh": "所选采集格式的解码器初始化失败,请选择其他格式。",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "所選擷取格式的解碼器初始化失敗,請選擇其他格式。",+ "en": "The decoder for the selected capture format could not initialize. Choose another format.",+ "ja": "選択したキャプチャ形式のデコーダーを初期化できませんでした。別の形式を選択してください。"+ },+ {+ "zh": "采集卡无法连接所选压缩格式(0x{:08X}),请重新选择。",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "擷取卡無法連接所選壓縮格式(0x{:08X}),請重新選擇。",+ "en": "The selected compressed capture format could not connect (0x{:08X}). Choose another format.",+ "ja": "選択した圧縮キャプチャ形式を接続できませんでした(0x{:08X})。形式を選び直してください。"+ },+ {+ "zh": "采集卡无法连接所选格式(0x{:08X}),请检查设备占用并重新选择。",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "擷取卡無法連接所選格式(0x{:08X}),請檢查裝置占用並重新選擇。",+ "en": "The selected capture format could not connect (0x{:08X}). Check whether another app is using the device and choose the format again.",+ "ja": "選択したキャプチャ形式を接続できませんでした(0x{:08X})。他のアプリによるデバイス使用を確認し、形式を選び直してください。"+ },+ {+ "zh": "HDR10 提示;系统或显示器可能忽略,让它的动态色调映射有依据。",+ "src": "qml/Veyra/ProPage.qml",+ "zh-TW": "HDR10 提示;系統或顯示器可能忽略,讓其動態色調映射有依據。",+ "en": "HDR10 hints for dynamic tone mapping; the system or display may ignore them.",+ "ja": "HDR10 のトーンマッピング用ヒントです。システムやディスプレイに無視される場合があります。"+ },+ {+ "zh": "导出任务通信协议不匹配",+ "src": "src/engine/ExportJobManager.cpp",+ "zh-TW": "匯出工作通訊協定不符",+ "en": "Export task protocol mismatch",+ "ja": "エクスポートタスクの通信プロトコルが一致しません"+ },+ {+ "zh": "导出任务的增强参数无效,请查看任务日志中的具体参数错误",+ "src": "src/engine/ExportJobManager.cpp",+ "zh-TW": "匯出工作的增強參數無效,請查看工作日誌中的具體參數錯誤",+ "en": "Invalid export enhancement settings. See the task log for the parameter error.",+ "ja": "エクスポートの補正設定が無効です。パラメーターエラーはタスクログで確認してください。"+ },+ {+ "zh": "导出任务的路径、剪辑、封装或轨道参数无效",+ "src": "src/engine/ExportJobManager.cpp",+ "zh-TW": "匯出工作的路徑、剪輯、封裝或軌道參數無效",+ "en": "Invalid export path, trim, container or track settings",+ "ja": "エクスポートのパス、トリミング、コンテナ、トラック設定が無効です"+ },+ {+ "zh": "导出任务的效果链与冻结参数不一致",+ "src": "src/engine/ExportJobManager.cpp",+ "zh-TW": "匯出工作的效果鏈與凍結參數不一致",+ "en": "The export effect chain does not match the frozen settings",+ "ja": "エクスポートのエフェクトチェーンが確定した設定と一致しません"+ },+ {+ "zh": "{} {}X 补帧初始化失败,未替换后端或降低倍率;请查看任务诊断日志",+ "src": "src/engine/ExportJobManager.cpp",+ "zh-TW": "{} {}X 補幀初始化失敗,未替換後端或降低倍率;請查看工作診斷日誌",+ "en": "{} {}X frame generation could not initialize. The backend and multiplier were retained; see the task diagnostic log.",+ "ja": "{} {}X フレーム生成を初期化できませんでした。バックエンドと倍率は維持されています。タスク診断ログを確認してください。"}]}diff --git a/include/veyra/source/CaptureFormatSelection.h b/include/veyra/source/CaptureFormatSelection.hindex 2145b8da..484c82d9 100644--- a/include/veyra/source/CaptureFormatSelection.h+++ b/include/veyra/source/CaptureFormatSelection.h@@ -12,7 +12,7 @@ namespace veyra::source {// persisted identity so an old combined selection still restores one type.struct CaptureFormat {int index=0;unsigned width=0,height=0;double fps=0;std::wstring label;std::wstring key;int rank=0;int tier=0;bool driverCurrent=false;std::wstring pixel;std::wstring scan;bool interlaced=false;int64_t interval100ns=0;bool supported=true;bool automatic=false;};enum class CaptureFormatAxis { Resolution, FrameRate };-struct CaptureFormatOption { std::wstring id, label; bool disabled=false; };+struct CaptureFormatOption { std::wstring id, label; bool disabled=false, discouraged=false; };inline const CaptureFormat* selectCaptureFormat(std::span<const CaptureFormat> formats,int legacyIndex,std::wstring_view key){for(const auto& format:formats)@@ -34,12 +34,35 @@ inline std::wstring captureResolutionId(const CaptureFormat& format){if(format.automatic)return L"auto";return std::format(L"{}x{}",format.width,format.height);}+// A draft resolution/rate may exist before the user has chosen a concrete+// pixel format. Representatives populate dependent menus; they are never a+// capture selection and must not silently replace a missing media identity.+inline const CaptureFormat* captureResolutionSample(std::span<const CaptureFormat> formats,std::wstring_view resolution){+ if(resolution.empty())return nullptr;+ for(const auto& f:formats)if(captureResolutionId(f)==resolution)return &f;+ return nullptr;+}inline std::wstring captureFrameRateId(const CaptureFormat& format){if(format.automatic)return L"auto";// Progressive and interlaced modes that share a numeric rate stay distinct.// Field order stays on the pixel list, so it does not create two identical fps rows.return std::format(L"{}|{}",format.interval100ns>0?format.interval100ns:format.fps>0?captureFrameInterval(format.fps):0,format.interlaced?1:0);}+inline const CaptureFormat* captureRateSample(std::span<const CaptureFormat> formats,std::wstring_view resolution,std::wstring_view rate){+ if(resolution.empty()||rate.empty())return nullptr;+ for(const auto& f:formats)if(captureResolutionId(f)==resolution&&captureFrameRateId(f)==rate)return &f;+ return nullptr;+}+inline const CaptureFormat* selectCapturePixelFormat(std::span<const CaptureFormat> formats,std::wstring_view resolution,std::wstring_view rate,std::wstring_view key){+ if(key.empty())return nullptr;+ const auto* f=selectCaptureFormat(formats,-1,key);+ return f&&!resolution.empty()&&!rate.empty()&&captureResolutionId(*f)==resolution&&captureFrameRateId(*f)==rate?f:nullptr;+}+inline bool captureMjpegFormat(const CaptureFormat& format){+ std::wstring pixel=format.pixel;+ for(auto& c:pixel)if(c>=L'a'&&c<=L'z')c-=L'a'-L'A';+ return pixel==L"MJPEG"||pixel==L"MJPG";+}inline std::wstring captureResolutionLabel(const CaptureFormat& format){if(format.automatic)return L"自动检测实际信号";return std::format(L"{} × {}",format.width,format.height);@@ -97,14 +120,14 @@ inline std::vector<CaptureFormatOption> capturePixelOptions(std::span<const Captint copies=0;for(const auto* other:matched)if(other->pixel==format->pixel)++copies;if(std::any_of(out.begin(),out.end(),[&](const CaptureFormatOption& option){return option.id==format->key;}))continue;- out.push_back({format->key,capturePixelLabel(*format,copies>1),!format->supported});+ out.push_back({format->key,capturePixelLabel(*format,copies>1),!format->supported,captureMjpegFormat(*format)});}return out;}// Keep the other two axes when the newly chosen resolution or frame rate still-// offers them. Otherwise take the first remaining media type in list order-// (driver-current, then lower latency). Never invent a triple the device did-// not enumerate.+// offers them. A missing pixel format must be selected explicitly; never route+// an existing choice to another pixel format. A null current is only a menu+// representative, not permission to connect that media type.inline const CaptureFormat* retargetCaptureFormat(std::span<const CaptureFormat> formats,const CaptureFormat* current,CaptureFormatAxis axis,std::wstring_view id){if(id.empty()||(axis==CaptureFormatAxis::FrameRate&&!current))return nullptr;const auto resolution=current?captureResolutionId(*current):std::wstring{};@@ -112,7 +135,6 @@ inline const CaptureFormat* retargetCaptureFormat(std::span<const CaptureFormat>const auto pixel=current?current->pixel:std::wstring{};const CaptureFormat* fallback=nullptr;const CaptureFormat* samePixel=nullptr;- const CaptureFormat* sameRate=nullptr;const CaptureFormat* sameBoth=nullptr;for(const auto& format:formats){const bool match=axis==CaptureFormatAxis::Resolution?captureResolutionId(format)==id@@ -123,11 +145,11 @@ inline const CaptureFormat* retargetCaptureFormat(std::span<const CaptureFormat>const bool rateMatch=captureFrameRateId(format)==rate;const bool pixelMatch=!pixel.empty()&&format.pixel==pixel;if(rateMatch&&pixelMatch){if(!sameBoth)sameBoth=&format;}- else if(rateMatch){if(!sameRate)sameRate=&format;}else if(pixelMatch){if(!samePixel)samePixel=&format;}}- if(axis==CaptureFormatAxis::FrameRate)return samePixel?samePixel:fallback;- return sameBoth?sameBoth:sameRate?sameRate:samePixel?samePixel:fallback;+ if(!current)return fallback;+ if(axis==CaptureFormatAxis::FrameRate)return samePixel;+ return sameBoth?sameBoth:samePixel;}inline std::wstring capturePathOptions(double fps,std::wstring_view encodedKey){diff --git a/qml/Veyra/DialogHost.qml b/qml/Veyra/DialogHost.qmlindex ecff09bc..8a6f657e 100644--- a/qml/Veyra/DialogHost.qml+++ b/qml/Veyra/DialogHost.qml@@ -331,9 +331,11 @@ Item {}VRow {label: qsTr("分辨率")- hint: qsTr("与帧率和像素格式一起决定采集媒体类型")+ hint: qsTr("先选择分辨率,再选择该分辨率支持的帧率和像素格式")VSelect {objectName: "capture-resolution"+ enabled: !veyra.captureQueryBusy+ opacity: enabled ? 1 : 0.5implicitWidth: 180value: captureDialog.labelOf(veyra.captureResolutionOptions, veyra.captureResolutionId, veyra.captureResolutionOptions.length ? qsTr("请选择分辨率") : "—")options: veyra.captureResolutionOptions@@ -345,6 +347,8 @@ Item {hint: qsTr("只列出当前分辨率下设备上报的帧率。设备帧率填 0 时,连接使用这里选中的帧率")VSelect {objectName: "capture-frame-rate"+ enabled: !veyra.captureQueryBusy && veyra.captureResolutionId.length > 0+ opacity: enabled ? 1 : 0.5implicitWidth: 280value: captureDialog.labelOf(veyra.captureFrameRateOptions, veyra.captureFrameRateId, veyra.captureFrameRateOptions.length ? qsTr("请选择帧率") : "—")options: veyra.captureFrameRateOptions@@ -356,8 +360,10 @@ Item {hint: { const f = veyra.captureFormats.find(x => x.id === veyra.captureFormatKey); return f && f.costHint ? qsTr("该格式比低延迟格式多一道处理环节,高分辨率/高帧率下建议优先低延迟格式") : qsTr("只列出当前分辨率和帧率下的像素格式") }VSelect {objectName: "capture-format"+ enabled: !veyra.captureQueryBusy && veyra.captureResolutionId.length > 0 && veyra.captureFrameRateId.length > 0+ opacity: enabled ? 1 : 0.5implicitWidth: 220- value: captureDialog.labelOf(veyra.capturePixelOptions, veyra.capturePixelId, veyra.capturePixelOptions.length ? qsTr("请选择像素格式") : "—")+ value: captureDialog.labelOf(veyra.capturePixelOptions, veyra.capturePixelId, veyra.captureResolutionId.length ? qsTr("请选择像素格式") : qsTr("请先选择分辨率"))options: veyra.capturePixelOptionsonPicked: id => veyra.capturePixelId = id}diff --git a/qml/Veyra/VMenu.qml b/qml/Veyra/VMenu.qmlindex d4cac1a4..37d479d5 100644--- a/qml/Veyra/VMenu.qml+++ b/qml/Veyra/VMenu.qml@@ -241,7 +241,7 @@ Popup {Layout.fillWidth: trueLayout.minimumWidth: 0text: row.modelData.label- color: Theme.t1+ color: row.modelData.danger === true ? Theme.err : Theme.t1font.family: Theme.fontUifont.pixelSize: Theme.fsBodyfont.weight: Font.Mediumdiff --git a/qml/Veyra/VSelect.qml b/qml/Veyra/VSelect.qmlindex e2d915e9..547d3451 100644--- a/qml/Veyra/VSelect.qml+++ b/qml/Veyra/VSelect.qml@@ -4,6 +4,7 @@ import QtQuick.LayoutsRectangle {id: selproperty string value: ""+ readonly property color valueColor: options.some(o => o.label === value && o.danger === true) ? Theme.err : Theme.t1property var options: [] // [{ id, label }]// .pop h6: the design titles a select's menu with the row label (core.js sel()).property string title: ""@@ -27,7 +28,7 @@ Rectangle {Layout.fillWidth: trueLayout.minimumWidth: 0text: sel.value- color: Theme.t1+ color: sel.valueColorfont.family: Theme.fontUifont.pixelSize: Theme.fsBodyfont.weight: Font.Medium@@ -49,7 +50,7 @@ Rectangle {if (p instanceof VRow) return p.labelreturn ""}- items: sel.options.map(o => ({ label: o.label, checked: o.label === sel.value, disabled: o.disabled === true, note: o.note || "" }))+ items: sel.options.map(o => ({ label: o.label, checked: o.label === sel.value, disabled: o.disabled === true, danger: o.danger === true, note: o.note || "" }))onPicked: (i, o) => sel.picked(sel.options[i].id)}}diff --git a/scripts/acceptance/capture-format-safety-probe.qml b/scripts/acceptance/capture-format-safety-probe.qmlnew file mode 100644index 00000000..18b1f130--- /dev/null+++ b/scripts/acceptance/capture-format-safety-probe.qml@@ -0,0 +1,80 @@+import QtQuick+Item {+ id: probe+ property var appWindow: Window.window+ property var dialogHost+ property string mode: "fresh"+ property string outputDir: ""+ property var expected: ({})+ property int ticks: 0+ property int state: 0+ property var messages: []+ function require(ok,why) { if(!ok) throw new Error(why) }+ 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 field(name) {const f=find(appWindow.contentItem,name);require(!!f,name);return f}+ function pass() {console.log("CAPTURE_SAFETY_PASS",mode,JSON.stringify({resolution:veyra.captureResolutionId,rate:veyra.captureFrameRateId,format:veyra.captureFormatKey}));Qt.quit()}+ Connections {target:veyra;function onNotice(message,error){if(error)probe.messages.push(String(message))}}+ Timer {+ interval:400;running:true;repeat:true+ onTriggered:{try{+ require(++ticks<100,"deadline")+ if(ticks<3)return+ if(state===0){veyra.setPreference("language","zh-CN");dialogHost.open("capture");state=1;return}+ if(veyra.captureQueryBusy||ticks<6)return+ const all=veyra.captureFormats.slice()+ require(all.length>0,"physical device formats present")+ if(mode==="draft-restore"){+ require(veyra.captureResolutionId.length>0&&veyra.captureFrameRateId.length>0,"partial draft axes restored")+ require(veyra.captureFormatKey.length===0&&veyra.capturePixelId.length===0,"partial draft does not invent a pixel format")+ require(!veyra.startCaptureSession()&&!veyra.running,"partial draft cannot open another format")+ pass();return+ }+ require(veyra.captureResolutionId.length===0&&veyra.captureFrameRateId.length===0,"new device has no implicit resolution/rate")+ require(!field("capture-frame-rate").enabled&&!field("capture-format").enabled,"dependent selectors disabled before resolution")+ require(veyra.capturePixelOptions.length===0,"no pixels offered before resolution")+ veyra.capturePixelId=all[0].id+ require(messages.some(x=>x.indexOf("请先选择分辨率")>=0),"premature pixel reports resolution requirement")+ const reached={}+ for(const resolution of veyra.captureResolutionOptions.slice()){+ field("capture-resolution").picked(resolution.id)+ require(veyra.captureFormatKey.length===0,"resolution change requires explicit pixel confirmation")+ for(const rate of veyra.captureFrameRateOptions.slice()){+ field("capture-frame-rate").picked(rate.id)+ for(const pixel of veyra.capturePixelOptions.slice()){+ require(all.some(f=>f.id===pixel.id),"pixel is an actual advertised media identity")+ reached[pixel.id]=true+ const format=all.find(f=>f.id===pixel.id)+ if(format.pixel.toUpperCase()==="MJPEG"||format.pixel.toUpperCase()==="MJPG"){+ require(pixel.danger&&pixel.label.indexOf("(不建议使用)")>=0,"MJPEG warning metadata")+ field("capture-format").picked(pixel.id)+ require(String(field("capture-format").valueColor)==="#ff5d5d","selected MJPEG remains red")+ }+ }+ }+ }+ require(Object.keys(reached).length===all.length,"all advertised formats remain reachable")+ const desired=all.find(f=>f.width===1920&&f.height===1080&&Math.abs(f.fps-30)<.005&&!f.interlaced&&f.pixel==="NV12")+ require(!!desired,"physical 1080p30 NV12 fixture")+ veyra.captureFormatKey=desired.id+ require(veyra.capturePixelId===desired.id,"full exact selection accepted")+ const resolution=veyra.captureResolutionOptions.find(r=>r.id!==veyra.captureResolutionId)+ require(!!resolution,"fixture offers multiple resolutions")+ veyra.captureResolutionId=resolution.id+ require(veyra.captureFormatKey.length===0,"stale media key cleared on size change")+ veyra.capturePixelId=desired.id+ require(veyra.capturePixelId.length===0&&!veyra.startCaptureSession()&&!veyra.running,"mismatched key cannot connect previous format")+ require(messages.some(x=>x.indexOf("此采集卡无此格式")>=0),"mismatched key emits visible format error")+ // Correcting the same formerly invalid identity must restore both axes.+ veyra.captureFormatKey=desired.id+ require(veyra.captureResolutionId==="1920x1080"&&veyra.capturePixelId===desired.id,"correction of invalid identity works")+ veyra.captureResolutionId=resolution.id+ console.log("CAPTURE_SAFETY_ENUM",all.length,Object.keys(reached).length)+ pass()+ }catch(e){console.error("CAPTURE_SAFETY_FAIL",e.message);Qt.exit(3)}}+ }+}diff --git a/scripts/acceptance/test-2.0.7-build.py b/scripts/acceptance/test-2.0.7-build.pyindex de4845e2..28c02cbb 100644--- a/scripts/acceptance/test-2.0.7-build.py+++ b/scripts/acceptance/test-2.0.7-build.py@@ -49,7 +49,7 @@ targets=['veyra_qml_ui','veyra_xess_motion_contract_tests','veyra_xess_motion_qu'veyra_hdr_color_tests','veyra_live_presentation_tests','veyra_settings_transaction_tests','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_playlist_tests','veyra_qml_data_tests','veyra_bitmap_subtitle_tests','veyra_subtitle_format_tests','veyra_capture_tests']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/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cppindex 8927a535..76610410 100644--- a/src/source/CaptureCardSource.cpp+++ b/src/source/CaptureCardSource.cpp@@ -883,7 +883,7 @@ bool CaptureCardSource::configureDeckLink(const SourceOpenDesc& desc){auto& p=*p_;CaptureSelection selection;if(!parseCapturePath(desc.path,selection))return false;const auto formats=formatsByPath(selection.videoPath);const auto* selected=selectCaptureFormat(formats,selection.format,selection.formatKey);- if(!selected){error_=L"保存的 BMD 制式已不可用,请刷新并重新选择";return false;}+ if(!selected){error_=L"此采集卡无此格式,请重新选择分辨率、帧率和像素格式。";return false;}p.decklink=std::make_unique<decklink::Capture>();if(!p.decklink->configure(selection.videoPath,selected->key,selection.audio==kCaptureAudioFromVideoDevice)){error_=p.decklink->error();p.decklink.reset();return false;@@ -937,7 +937,7 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cleComPtr<IPin> formatPin;p.builder->FindPin(p.device.Get(),PINDIR_OUTPUT,&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,FALSE,0,&formatPin);const auto available=enumerateFormats(p.config.Get(),false,p.device.Get(),formatPin.Get());const auto* chosen=selectCaptureFormat(available,format,selection.formatKey);- if(!selection.formatKey.empty()&&!chosen){error_=L"保存的采集格式已不可用,请重新选择分辨率、帧率和像素格式。";return false;}+ if(!chosen){error_=L"此采集卡无此格式,请重新选择分辨率、帧率和像素格式。";return false;}if(chosen)format=chosen->index;if(chosen&&!chosen->supported){error_=L"设备提供此格式,但当前播放器不支持其尺寸或像素布局,请选择其他格式";return false;}// Capture the advertised identity before SetFormat: some drivers mutate@@ -967,7 +967,7 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cleconfigureAverToneMap(p.device.Get(),devicePath,native->subtype.Data1==MAKEFOURCC('P','0','1','0')||native->subtype.Data1==MAKEFOURCC('P','0','1','6'));log::info("capture-device",std::format("path={} selectedFormat={} requestedFps={} nativeSubtype=0x{:X}",narrowForLog(devicePath),format,expectedFps,native->subtype.Data1));HRESULT hr=p.config->SetFormat(native);const GUID requestedSubtype=native->subtype;- log::info("capture",std::format("SetFormat device={} nativeIndex={} subtype=0x{:08X} hr=0x{:08X}",index,format,native->subtype.Data1,uint32_t(hr)));freeType(native);if(FAILED(hr)){if(selection.requestedFps>0)error_=std::format(L"采集卡拒绝 {:.3f} FPS(0x{:08X});请改用设备支持的帧率,或填 0 恢复默认。",selection.requestedFps,uint32_t(hr));return false;}+ log::info("capture",std::format("SetFormat device={} nativeIndex={} subtype=0x{:08X} hr=0x{:08X}",index,format,native->subtype.Data1,uint32_t(hr)));freeType(native);if(FAILED(hr)){error_=selection.requestedFps>0?std::format(L"此采集卡无此格式:拒绝 {:.3f} FPS(0x{:08X}),请改用设备支持的帧率,或填 0 沿用所选格式。",selection.requestedFps,uint32_t(hr)):std::format(L"此采集卡无此格式,驱动拒绝所选格式(0x{:08X}),请重新选择。",uint32_t(hr));return false;}// Read the driver-negotiated type back. Native YUY2/NV12/RGB32 connects// directly to our terminal filter: no intelligent-connect converter.native=nullptr;hr=p.config->GetFormat(&native);if(FAILED(hr)||!native){freeType(native);return false;}@@ -1006,7 +1006,8 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cleunsigned compressedWidth=0,compressedHeight=0;int64_t compressedDuration=0;// MPEG chain: every compressed subtype (MJPEG/H.264/HEVC/AV1/VP9) now// bypasses the system decoder stack; our own backend decodes it. Any- // failure below falls back to the RGB32 compatibility path.+ // failure below is explicit; a selected compressed format must never+ // silently open another format or an intelligent-connect RGB converter.const bool compressedPath=!direct&&!nativeSupported&&codec!=CaptureCodec::None&&!desc.legacyCaptureRgbForDiagnostic;if(compressedPath){p.compressedPath=true;p.codec=codec;}AM_MEDIA_TYPE connected{};@@ -1021,13 +1022,14 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cleif(SUCCEEDED(hr)){if(connected.formattype==FORMAT_VideoInfo2&&connected.cbFormat>=sizeof(VIDEOINFOHEADER2)){const auto& v=*reinterpret_cast<const VIDEOINFOHEADER2*>(connected.pbFormat);compressedWidth=unsigned(v.bmiHeader.biWidth);compressedHeight=unsigned(std::abs(int64_t(v.bmiHeader.biHeight)));compressedDuration=int64_t(v.AvgTimePerFrame);}else if(connected.formattype==FORMAT_VideoInfo&&connected.cbFormat>=sizeof(VIDEOINFOHEADER)){const auto& v=*reinterpret_cast<const VIDEOINFOHEADER*>(connected.pbFormat);compressedWidth=unsigned(v.bmiHeader.biWidth);compressedHeight=unsigned(std::abs(int64_t(v.bmiHeader.biHeight)));compressedDuration=int64_t(v.AvgTimePerFrame);}- if(!compressedWidth||!compressedHeight||compressedWidth%2||compressedHeight%2){log::warn("capture-decode","compressed dimensions unusable; falling back to the RGB32 compatibility path");hr=VFW_E_INVALIDMEDIATYPE;}+ if(!compressedWidth||!compressedHeight||compressedWidth%2||compressedHeight%2){log::error("capture-decode","compressed dimensions unusable; refusing implicit RGB conversion");error_=L"采集卡返回的压缩格式尺寸无效,请重新选择采集格式。";hr=VFW_E_INVALIDMEDIATYPE;}}if(SUCCEEDED(hr)){const auto extradata=captureCompressedExtradata(*native,codec);if(!p.compressedDecoder.open(codec,compressedWidth,compressedHeight,extradata.data(),extradata.size(),static_cast<ID3D12Device*>(desc.d3d12Device),static_cast<ID3D12CommandQueue*>(desc.d3d12Queue))){- log::warn("capture-decode",std::format("no usable decoder for codec={}; falling back to the RGB32 compatibility path",captureCodecKey(codec)));+ log::error("capture-decode",std::format("no usable decoder for codec={}; refusing implicit RGB conversion",captureCodecKey(codec)));+ error_=L"所选采集格式的解码器初始化失败,请选择其他格式。";hr=VFW_E_INVALIDMEDIATYPE;}else{// Keep the shared device/queue alive for the decode worker.@@ -1036,7 +1038,10 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cle}}log::info("capture-decode",std::format("compressed ConnectDirect codec={} subtype=0x{:08X} size={}x{} hr=0x{:08X}",captureCodecKey(codec),native->subtype.Data1,compressedWidth,compressedHeight,uint32_t(hr)));- if(FAILED(hr)){log::warn("capture-decode","compressed direct connect failed; retrying the RGB32 compatibility path");SourceOpenDesc retry=desc;retry.legacyCaptureRgbForDiagnostic=true;return configure(retry);}+ if(FAILED(hr)){+ if(error_.empty())error_=std::format(L"采集卡无法连接所选压缩格式(0x{:08X}),请重新选择。",uint32_t(hr));+ freeType(native);freeType(&connected,false);return false;+ }}else if(direct){// N4: suggest the video-pin allocator size before ConnectDirect. The// suggestion is advisory; a refusal keeps the driver's defaults and is@@ -1106,7 +1111,7 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cle}else{freeType(native);layoutValid=SUCCEEDED(hr)&&captureMediaLayout(connected,p.layout);freeType(&connected,false);}- if(!layoutValid){log::error("capture",std::format("unsupported negotiated layout/connect failure hr=0x{:08X}",uint32_t(hr)));return false;}+ if(!layoutValid){log::error("capture",std::format("unsupported negotiated layout/connect failure hr=0x{:08X}",uint32_t(hr)));if(error_.empty())error_=std::format(L"采集卡无法连接所选格式(0x{:08X}),请检查设备占用并重新选择。",uint32_t(hr));return false;}if(p.cpuUnpack&&captureLegacyCpuLayout(p.layout))log::warn("capture-unpack",std::format("legacy CPU unpack path active packing={} format={} (per-pixel conversion stays on the callback thread)",int(p.layout.packing),int(p.layout.format)));const unsigned colorOverride=selection.colorOverride;log::info("capture-color",std::format("driver controlFlags=0x{:08X} colorInfoPresent={} transfer={} matrix={} primaries={} chroma={} override={}",p.layout.colorControlFlags,bool(p.layout.colorControlFlags&AMCONTROL_COLORINFO_PRESENT),int(p.layout.color.transfer),int(p.layout.color.matrix),int(p.layout.color.primaries),int(p.layout.color.chromaLocation),colorOverride));diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cppindex c115f93a..e6bd74a4 100644--- a/src/ui/QmlPlayerBridge.cpp+++ b/src/ui/QmlPlayerBridge.cpp@@ -345,6 +345,7 @@ struct QmlPlayerBridge::Impl {std::vector<source::CaptureDevice> captureVideo, captureAudio;std::vector<source::CaptureFormat> captureFormatList;std::wstring captureFormatKey;+ std::wstring captureResolutionChoice, captureRateChoice;int captureAudioChoice = source::kCaptureAudioDisabled;bool captureAudioMissing = false;unsigned captureColor = 0;@@ -503,13 +504,21 @@ struct QmlPlayerBridge::Impl {}}}- bool persistCaptureSelection() {+ bool persistCaptureSelection(bool explicitFormat = false) {if(captureDevice.empty())return true; // Disconnecting a card must retain it.const bool sameDevice=capturePrefs.videoPath==captureDevice;capturePrefs.videoPath=captureDevice;// An unavailable saved type has no active selection. Editing another// control must retain its key until the user explicitly picks a new type.- if(!captureFormatKey.empty()||!sameDevice)capturePrefs.formatKey=captureFormatKey;+ if(explicitFormat||!captureFormatKey.empty()||!sameDevice)capturePrefs.formatKey=captureFormatKey;+ if(explicitFormat){+ // A partial form is a deliberate choice too. Keep it without+ // upgrading capture-preferences.v1 or inventing a concrete format.+ prefs["captureDraftDevice"]=utf8Of(captureDevice);+ prefs["captureDraftResolution"]=utf8Of(captureResolutionChoice);+ prefs["captureDraftRate"]=utf8Of(captureRateChoice);+ if(!savePrefs())return false;+ }capturePrefs.colorOverride=captureColor;capturePrefs.requestedFps=captureFps;if(capturePrefs.deviceColors.size()<128||capturePrefs.deviceColors.contains(captureDevice))capturePrefs.deviceColors[captureDevice]=captureColor;if(!captureAudioMissing){@@ -2068,6 +2077,7 @@ void QmlPlayerBridge::setCaptureDeviceId(const QString& value) {if (impl_->captureDevice == wideOf(value)) return;impl_->captureDevice = wideOf(value);impl_->captureFormatList.clear();+ impl_->captureResolutionChoice.clear();impl_->captureRateChoice.clear();impl_->captureFormatKey=impl_->captureDevice==impl_->capturePrefs.videoPath?impl_->capturePrefs.formatKey:std::wstring{};impl_->captureDriverFormatKey.clear();// Colour follows the device, as in 1.4.4; audio returns to "none" unless it@@ -2097,17 +2107,27 @@ QVariantList QmlPlayerBridge::captureFormats() const {}QString QmlPlayerBridge::captureFormatKey() const { return utf8Of(impl_->captureFormatKey); }void QmlPlayerBridge::setCaptureFormatKey(const QString& key) {- if (impl_->captureFormatKey == wideOf(key)) return;- if(!source::selectCaptureFormat(impl_->captureFormatList,-1,wideOf(key)))return;- impl_->captureFormatKey = wideOf(key);- if(!impl_->persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);+ const auto* format=source::selectCaptureFormat(impl_->captureFormatList,-1,wideOf(key));+ if(!format){+ // Retain the attempted identity as invalid, so a subsequent Connect+ // cannot silently open the previous selection instead.+ impl_->captureFormatKey=wideOf(key);+ impl_->captureStatus=tr("此采集卡无此格式,请重新选择分辨率、帧率和像素格式。");+ emit notice(impl_->captureStatus,true);emit captureChanged();return;+ }+ if (impl_->captureFormatKey == format->key && impl_->captureResolutionChoice == source::captureResolutionId(*format) && impl_->captureRateChoice == source::captureFrameRateId(*format)) return;+ impl_->captureResolutionChoice=source::captureResolutionId(*format);+ impl_->captureRateChoice=source::captureFrameRateId(*format);+ impl_->captureFormatKey = format->key;+ impl_->captureStatus.clear();+ if(!impl_->persistCaptureSelection(true))emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);emit captureChanged();}namespace {QVariantList captureChoiceList(const std::vector<source::CaptureFormatOption>& options) {QVariantList out;for (const auto& option : options)- out << QVariantMap{{"id", utf8Of(option.id)}, {"label", uiText(option.label)}, {"disabled",option.disabled}};+ out << QVariantMap{{"id", utf8Of(option.id)}, {"label", uiText(option.label)+(option.discouraged?uiText(L"(不建议使用)"):QString{})}, {"disabled",option.disabled},{"danger",option.discouraged}};return out;}const source::CaptureFormat* selectedCaptureFormat(const std::vector<source::CaptureFormat>& formats, const std::wstring& key) {@@ -2118,48 +2138,52 @@ QVariantList QmlPlayerBridge::captureResolutionOptions() const {return captureChoiceList(source::captureResolutionOptions(impl_->captureFormatList));}QString QmlPlayerBridge::captureResolutionId() const {- const auto* format = selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey);- return format ? utf8Of(source::captureResolutionId(*format)) : QString();+ return utf8Of(impl_->captureResolutionChoice);}void QmlPlayerBridge::setCaptureResolutionId(const QString& id) {const auto wide = wideOf(id);- const auto* current = selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey);- if (current && source::captureResolutionId(*current) == wide) return;- const auto* next = source::retargetCaptureFormat(impl_->captureFormatList, current, source::CaptureFormatAxis::Resolution, wide);- if (!next || next->key == impl_->captureFormatKey) return;- setCaptureFormatKey(utf8Of(next->key));+ if(impl_->captureResolutionChoice==wide)return;+ const auto* sample=source::captureResolutionSample(impl_->captureFormatList,wide);+ if(!sample){emit notice(tr("此采集卡无此格式,请重新选择分辨率、帧率和像素格式。"),true);return;}+ impl_->captureResolutionChoice=wide;+ if(!source::captureRateSample(impl_->captureFormatList,wide,impl_->captureRateChoice))impl_->captureRateChoice=source::captureFrameRateId(*sample);+ impl_->captureFormatKey.clear();+ if(!impl_->persistCaptureSelection(true))emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);+ emit captureChanged();}QVariantList QmlPlayerBridge::captureFrameRateOptions() const {- return captureChoiceList(source::captureFrameRateOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey)));+ return captureChoiceList(source::captureFrameRateOptions(impl_->captureFormatList, source::captureResolutionSample(impl_->captureFormatList, impl_->captureResolutionChoice)));}QString QmlPlayerBridge::captureFrameRateId() const {- const auto* format = selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey);- return format ? utf8Of(source::captureFrameRateId(*format)) : QString();+ return utf8Of(impl_->captureRateChoice);}void QmlPlayerBridge::setCaptureFrameRateId(const QString& id) {const auto wide = wideOf(id);- const auto* current = selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey);- if (!current || source::captureFrameRateId(*current) == wide) return;- const auto* next = source::retargetCaptureFormat(impl_->captureFormatList, current, source::CaptureFormatAxis::FrameRate, wide);- if (!next || next->key == impl_->captureFormatKey) return;- setCaptureFormatKey(utf8Of(next->key));+ if(impl_->captureResolutionChoice.empty()){emit notice(tr("请先选择分辨率"),true);return;}+ if(impl_->captureRateChoice==wide)return;+ if(!source::captureRateSample(impl_->captureFormatList,impl_->captureResolutionChoice,wide)){+ emit notice(tr("此采集卡无此格式,请重新选择分辨率、帧率和像素格式。"),true);return;+ }+ impl_->captureRateChoice=wide;impl_->captureFormatKey.clear();+ if(!impl_->persistCaptureSelection(true))emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);+ emit captureChanged();}QVariantList QmlPlayerBridge::capturePixelOptions() const {- return captureChoiceList(source::capturePixelOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey)));+ return captureChoiceList(source::capturePixelOptions(impl_->captureFormatList, source::captureRateSample(impl_->captureFormatList,impl_->captureResolutionChoice,impl_->captureRateChoice)));}QString QmlPlayerBridge::capturePixelId() const {- const auto* format = selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey);+ const auto* format = source::selectCapturePixelFormat(impl_->captureFormatList,impl_->captureResolutionChoice,impl_->captureRateChoice,impl_->captureFormatKey);return format ? utf8Of(format->key) : QString();}void QmlPlayerBridge::setCapturePixelId(const QString& id) {const auto key = wideOf(id);- if (key == impl_->captureFormatKey) return;- const auto options = source::capturePixelOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey));- for (const auto& option : options) {- if (option.id != key) continue;- setCaptureFormatKey(id);- return;+ if(impl_->captureResolutionChoice.empty()){emit notice(tr("请先选择分辨率"),true);return;}+ if(!source::selectCapturePixelFormat(impl_->captureFormatList,impl_->captureResolutionChoice,impl_->captureRateChoice,key)){+ impl_->captureFormatKey=key;+ impl_->captureStatus=tr("此采集卡无此格式,请重新选择分辨率、帧率和像素格式。");+ emit notice(impl_->captureStatus,true);emit captureChanged();return;}+ setCaptureFormatKey(id);}QVariantList QmlPlayerBridge::captureAudioInputs() const {// Only what the user picks explicitly is ever opened (1.4.4 rule).@@ -2324,10 +2348,21 @@ void QmlPlayerBridge::tickCapture() {if (const auto* f = source::selectCaptureFormat(i.captureFormatList, -1, driverSelection)) i.captureFormatKey = f->key;} else if (remembered && !i.capturePrefs.formatKey.empty()) {if (const auto* f = source::selectCaptureFormat(i.captureFormatList, -1, i.capturePrefs.formatKey)) i.captureFormatKey = f->key;- } else if (!i.captureFormatList.empty()) i.captureFormatKey = i.captureFormatList.front().key;+ }+ i.captureResolutionChoice.clear();i.captureRateChoice.clear();+ if(const auto* f=selectedCaptureFormat(i.captureFormatList,i.captureFormatKey)){+ i.captureResolutionChoice=source::captureResolutionId(*f);i.captureRateChoice=source::captureFrameRateId(*f);+ }else if(remembered&&i.capturePrefs.formatKey.empty()&&wideOf(i.prefs.value("captureDraftDevice").toString())==i.captureDevice){+ const auto resolution=wideOf(i.prefs.value("captureDraftResolution").toString());+ const auto rate=wideOf(i.prefs.value("captureDraftRate").toString());+ if(source::captureResolutionSample(i.captureFormatList,resolution)){+ i.captureResolutionChoice=resolution;+ if(source::captureRateSample(i.captureFormatList,resolution,rate))i.captureRateChoice=rate;+ }+ }if(!i.captureFormatKey.empty()&&!i.persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);i.captureStatus = i.captureFormatList.empty() ? tr("未读到设备上报的采集格式,或设备正被其他应用占用。")- : i.captureFormatKey.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。"): captureBlackmagicDevice() ? tr("请选择与输入信号一致的格式。驱动默认格式不代表检测到的信号。")@@ -2344,11 +2379,12 @@ bool QmlPlayerBridge::startCaptureSession() {if (captureQueryBusy()) { emit notice(tr("设备查询或驱动设置尚未完成"), true); return false; }int device = -1;for (size_t k = 0; k < i.captureVideo.size(); ++k) if (i.captureVideo[k].path == i.captureDevice) device = int(k);- const auto* format = source::selectCaptureFormat(i.captureFormatList, -1, i.captureFormatKey);+ const auto* format = source::selectCapturePixelFormat(i.captureFormatList,i.captureResolutionChoice,i.captureRateChoice,i.captureFormatKey);if(source::decklink::isPath(i.captureDevice)!=i.prefBool("blackmagicNativeCapture",false)&&captureBlackmagicDevice()){emit notice(tr("采集接口已切换,请刷新并重新选择设备和格式"),true);return false;}- if (device < 0 || !format) { emit notice(tr("请先选择采集设备和格式"), true); return false; }+ if(device<0){emit notice(tr("请先选择采集设备和格式"),true);return false;}+ if(!format){emit notice(i.captureFormatKey.empty()&&i.capturePrefs.formatKey.empty()?tr("请先选择分辨率和像素格式"):tr("此采集卡无此格式,请重新选择分辨率、帧率和像素格式。"),true);return false;}if(!format->supported){emit notice(tr("设备提供此格式,但当前播放器不支持其尺寸或像素布局,请选择其他格式"),true);return false;}if(i.captureAudioMissing){emit notice(tr("上次的音频输入未连接,请插回设备或重新选择音频监听"),true);return false;}const int audio = i.captureAudioChoice;diff --git a/tests/qml/quick/tst_menu_layout.qml b/tests/qml/quick/tst_menu_layout.qmlindex 52411bb0..477ee562 100644--- a/tests/qml/quick/tst_menu_layout.qml+++ b/tests/qml/quick/tst_menu_layout.qml@@ -9,6 +9,11 @@ Item {width: 900; height: 600Item { id: anchor; x: root.width - 24; y: root.height - 24; width: 1; height: 1 }VMenu { id: menu; title: "Long context menu" }+ VSelect {+ id: warningSelect; x: 12; y: 220; width: 250+ value: "MJPEG(不建议使用)"+ options: [{id:"nv12",label:"NV12"},{id:"jpeg",label:"MJPEG(不建议使用)",danger:true}]+ }VRow {id: row; x: 12; y: 12; width: 285label: "The capture device's actual supported pixel format"@@ -24,6 +29,19 @@ Item {name: "MenuAndRowLayout"when: windowShownfunction cleanup() { menu.close() }+ function test_mjpeg_warning() {+ compare(warningSelect.valueColor,Theme.err)+ warningSelect.value="NV12"+ compare(warningSelect.valueColor,Theme.t1)+ warningSelect.value="MJPEG(不建议使用)"+ menu.items=warningSelect.options+ menu.openAt(warningSelect,"at");tryCompare(menu,"opened",true)+ const items=labels(menu.contentItem,[])+ compare(items.length,2)+ compare(items[0].color,Theme.t1)+ compare(items[1].color,Theme.err)+ verify(!items[1].truncated)+ }function test_text_data() {return [{tag:"English",label:"Duplicate the selected enhancement node and reconnect its downstream output",width:900},{tag:"Chinese",label:"3840 × 2160 @ 59.94 fps · P010 · 原生格式 · HDR · 低延迟 · 驱动默认输入",width:900},diff --git a/tests/unit/CaptureFormatSelectionTests.cpp b/tests/unit/CaptureFormatSelectionTests.cppindex eea92f9a..8957c3ff 100644--- a/tests/unit/CaptureFormatSelectionTests.cpp+++ b/tests/unit/CaptureFormatSelectionTests.cpp@@ -76,7 +76,7 @@ int main(){check(pixels[0].label.find(L"[format 0]")!=std::wstring::npos&&pixels[2].label.find(L"[format 5]")!=std::wstring::npos,"duplicate pixel names stay selectable");check(pixels[1].label==L"YUY2","unique pixel name is not decorated");const auto* to4k=retargetCaptureFormat(listed,p60,CaptureFormatAxis::Resolution,L"3840x2160");- check(to4k==&listed[4],"resolution change falls back to a real 4k media type");+ check(!to4k,"missing 4k NV12 never silently switches to YUY2");const auto* keepNv12=retargetCaptureFormat(listed,p60,CaptureFormatAxis::FrameRate,captureFrameRateId(listed[2]));check(keepNv12==&listed[2],"frame-rate change keeps NV12 instead of another pixel at that rate");const auto* toInterlace=retargetCaptureFormat(listed,p60,CaptureFormatAxis::FrameRate,captureFrameRateId(listed[3]));@@ -88,6 +88,24 @@ int main(){check(keptPixel==&listed[4],"resolution change keeps YUY2 when that pixel exists at the new size");const auto interlacedPixels=capturePixelOptions(listed,&listed[3]);check(interlacedPixels.size()==1&&interlacedPixels[0].id==L"1080i60-nv12","interlaced rate does not offer the progressive NV12 row");+ {+ const auto resolution=captureResolutionId(*p60),rate=captureFrameRateId(*p60);+ check(!captureResolutionSample(listed,L""),"blank resolution cannot populate dependent menus");+ check(!captureRateSample(listed,L"",rate)&&!captureRateSample(listed,resolution,L""),"rate requires a selected resolution and rate");+ check(!selectCapturePixelFormat(listed,L"",rate,p60->key),"pixel cannot be selected before resolution");+ check(!selectCapturePixelFormat(listed,resolution,L"",p60->key),"pixel cannot be selected before rate");+ check(selectCapturePixelFormat(listed,resolution,rate,p60->key)==p60,"exact advertised combination accepted");+ check(!selectCapturePixelFormat(listed,L"3840x2160",rate,p60->key),"stale 1080p pixel key cannot open at 4k");+ check(!selectCapturePixelFormat(listed,resolution,captureFrameRateId(listed[2]),p60->key),"stale 60fps key cannot open at 30fps");+ check(!selectCapturePixelFormat(listed,resolution,rate,L"not-advertised"),"unknown pixel key rejected without fallback");+ for(auto pixel:{L"MJPEG",L"MJPG",L"mjpeg",L"mJpG"}){+ auto jpeg=media(50,1920,1080,60,L"jpeg",pixel,false,L"逐行");+ const std::array warningFormats{*p60,jpeg};+ const auto choices=capturePixelOptions(warningFormats,p60);+ check(choices.size()==2&&!choices[0].discouraged&&choices[1].discouraged,"only MJPEG/MJPG receives warning, regardless of case");+ check(!choices[1].disabled,"MJPEG remains selectable with a warning");+ }+ }{RateDriver driver;driver.intervals={166667,333667,417083,100000,0,-1,333667};HRESULT hr=E_FAIL;auto* pin=reinterpret_cast<IPin*>(uintptr_t(1));@@ -101,11 +119,12 @@ int main(){{auto unusual=media(25,1448,1086,47.952,L"unusual",L"CUSTOM",false,L"逐行");auto huge=media(30,7680,4320,120,L"8k",L"P010",false,L"逐行");huge.supported=false;- CaptureFormat automatic;automatic.key=L"decklink:auto";automatic.automatic=true;automatic.pixel=L"自动选择像素格式";+ CaptureFormat automatic;automatic.index=-1;automatic.key=L"decklink:auto";automatic.automatic=true;automatic.pixel=L"自动选择像素格式";std::vector<CaptureFormat> all{automatic,unusual,huge,unusual};const auto sizes=captureResolutionOptions(all);check(sizes.size()==3&&sizes[0].id==L"auto"&&sizes[0].label.find(L"0")==std::wstring::npos&&sizes[1].id==L"1448x1086"&&sizes[2].id==L"7680x4320","automatic, nonstandard and oversized device modes all visible");check(captureFrameRateOptions(all,&all[0])[0].label==L"跟随实际信号","DeckLink automatic rate never displayed as zero fps");+ check(!selectCapturePixelFormat(all,L"auto",L"auto",L""),"blank pixel key cannot select DeckLink automatic ordinal -1");check(capturePixelOptions(all,&all[1]).size()==1,"identical media keys are not duplicated");const auto unsupported=capturePixelOptions(all,&all[2]);check(unsupported.size()==1&&unsupported[0].disabled&&unsupported[0].label.find(L"不支持")!=std::wstring::npos,"unsupported driver format remains visible with explicit limit");