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++
Split capture format selection into resolution, frame rate, and pixel format.
Ethanf1f53ace3b9a
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex b5792aa9..36c5674a 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,11 @@# Veyra 工作记录+## 2026-10-11 采集格式拆成分辨率 / 帧率 / 像素格式++首页采集卡对话框不再用一条合并格式列表。分辨率、帧率、像素格式三个下拉一起决定原来的 `captureFormatKey`;后两项只列出当前选择下设备真实枚举到的组合,逐行/隔行分属不同帧率,同名像素格式(场序不同)仍可分别选择。连接、继续上次、Blackmagic 驱动页回选仍保存并恢复这一条格式键。音频输入、设备帧率覆盖(0 = 沿用所选格式)、PQ/HLG/709 与 Limited/Full 未改。++`g++ -std=c++20 -I include tests/unit/CaptureFormatSelectionTests.cpp -o /tmp/capture-format-selection-tests && /tmp/capture-format-selection-tests`:`failures=0`。本环境不是 Windows,未跑 VS2022/Qt 构建,未生成 Win64 包。+## 2026-10-07 2.0.6 正式发布完成[GitHub Release](https://github.com/Likely7/Veyra-NRVideo/releases/tag/v2.0.6)已发布(ID 405696687,2026-10-07T11:47:13Z),5资产服务器SHA256/大小一致,最新正式版、对应源码、双QR和公开下载核对通过。新群5二维码原字节,赞助/Discord/Ko-fi保留。完整命令、结果、资产哈希、边界及路径见[发布回执](RELEASE_2.0.6_REPORT_2026-10-07.md)。标签e3aa842a00f693a4a17d1fc4c454d0ebc59428f6、源码e1f6952a6ab11483fc6ff67177d8d390a8faea2f;随后只追加三文件收尾文档。NV显存持续增长未修复。diff --git a/i18n/catalog.json b/i18n/catalog.jsonindex 55ea7213..16d4312b 100644--- a/i18n/catalog.json+++ b/i18n/catalog.json@@ -2044,6 +2044,13 @@"en": "The connection to the host was lost.","ja": "ホストとの接続が切れました。"},+ {+ "zh": "与帧率和像素格式一起决定采集媒体类型",+ "src": "qml/DialogHost.qml",+ "zh-TW": "與幀率和像素格式一起決定採集媒體類型",+ "en": "Together with frame rate and pixel format, this selects the capture media type",+ "ja": "フレームレートとピクセルフォーマットと合わせて、キャプチャのメディアタイプを決めます"+ },{"zh": "专业模式","src": "qml/SettingsPage.qml",@@ -2821,6 +2828,13 @@"en": "Offset %1 ms","ja": "オフセット %1 ms"},+ {+ "zh": "像素格式",+ "src": "qml/DialogHost.qml",+ "zh-TW": "像素格式",+ "en": "Pixel format",+ "ja": "ピクセルフォーマット"+ },{"zh": "允许撕裂","src": "qml/NodePage.qml",@@ -3893,6 +3907,20 @@"en": "Save as","ja": "名前を付けて保存"},+ {+ "zh": "只列出当前分辨率下设备上报的帧率。设备帧率填 0 时,连接使用这里选中的帧率",+ "src": "qml/DialogHost.qml",+ "zh-TW": "只列出目前解析度下裝置回報的幀率。裝置幀率填 0 時,連接使用這裡選中的幀率",+ "en": "Only frame rates the device reports for the current resolution. A device frame rate of 0 uses the rate selected here",+ "ja": "現在の解像度でデバイスが報告するフレームレートだけを表示します。デバイスのフレームレートが 0 のときは、ここで選んだ値で接続します"+ },+ {+ "zh": "只列出当前分辨率和帧率下的像素格式",+ "src": "qml/DialogHost.qml",+ "zh-TW": "只列出目前解析度與幀率下的像素格式",+ "en": "Only pixel formats available at the current resolution and frame rate",+ "ja": "現在の解像度とフレームレートで使えるピクセルフォーマットだけを表示します"+ },{"zh": "只删除本机保存的这台主机;以后需要重新配对","src": "qml/DialogHost.qml",@@ -8206,6 +8234,13 @@"en": "Unknown effect type","ja": "不明なエフェクトの種類"},+ {+ "zh": "未知格式",+ "src": "include/veyra/source/CaptureFormatSelection.h",+ "zh-TW": "未知格式",+ "en": "Unknown format",+ "ja": "不明なフォーマット"+ },{"zh": "未知格式 {}","src": "include/veyra/source/CapturePixelFormat.h",@@ -11202,13 +11237,6 @@"en": "Device","ja": "デバイス"},- {- "zh": "设备实际支持的格式",- "src": "qml/DialogHost.qml",- "zh-TW": "裝置實際支援的格式",- "en": "Formats the device actually supports",- "ja": "デバイスが実際に対応するフォーマット"- },{"zh": "设备帧率 FPS","src": "qml/DialogHost.qml",@@ -11524,6 +11552,20 @@"en": "Choose","ja": "選択してください"},+ {+ "zh": "请选择像素格式",+ "src": "qml/DialogHost.qml",+ "zh-TW": "請選擇像素格式",+ "en": "Choose a pixel format",+ "ja": "ピクセルフォーマットを選んでください"+ },+ {+ "zh": "请选择分辨率",+ "src": "qml/DialogHost.qml",+ "zh-TW": "請選擇解析度",+ "en": "Choose a resolution",+ "ja": "解像度を選んでください"+ },{"zh": "请选择图片和已存在的输出目录","src": "src/ui/QmlPlayerBridge.cpp",@@ -11531,6 +11573,13 @@"en": "Choose images and an existing output folder","ja": "画像と既存の出力フォルダーを選んでください"},+ {+ "zh": "请选择帧率",+ "src": "qml/DialogHost.qml",+ "zh-TW": "請選擇幀率",+ "en": "Choose a frame rate",+ "ja": "フレームレートを選んでください"+ },{"zh": "请选择有效的输出目录","src": "src/engine/ExportQueue.cpp",@@ -11545,13 +11594,6 @@"en": "Choose a local video and valid export settings","ja": "ローカルの動画と有効な書き出し設定を選んでください"},- {- "zh": "请选择格式",- "src": "qml/DialogHost.qml",- "zh-TW": "請選擇格式",- "en": "Choose a format",- "ja": "フォーマットを選んでください"- },{"zh": "请选择输入端口完成连接 · Esc 取消","src": "qml/NodePage.qml",@@ -12567,6 +12609,13 @@"en": "Options","ja": "オプション"},+ {+ "zh": "逐行",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "逐行",+ "en": "Progressive",+ "ja": "プログレッシブ"+ },{"zh": "部分轨道当前封装装不下,未保留(详见队列说明)","src": "src/engine/VideoExportJob.cpp",@@ -13036,6 +13085,13 @@"en": "Hide the playback bar (it can be shown again from the dock at the top)","ja": "再生バーを非表示(上部のドックから再表示できます)"},+ {+ "zh": "隔行({:.2f} 场/秒)",+ "src": "src/source/CaptureCardSource.cpp",+ "zh-TW": "隔行({:.2f} 場/秒)",+ "en": "Interlaced ({:.2f} fields/s)",+ "ja": "インターレース({:.2f} フィールド/秒)"+ },{"zh": "零运动","src": "qml/NodePage.qml",diff --git a/include/veyra/source/CaptureFormatSelection.h b/include/veyra/source/CaptureFormatSelection.hindex 3b7ccf70..155feac0 100644--- a/include/veyra/source/CaptureFormatSelection.h+++ b/include/veyra/source/CaptureFormatSelection.h@@ -1,10 +1,17 @@#pragma once#include "veyra/source/CaptureFrameRate.h"+#include <algorithm>#include <format>#include <span>+#include <vector>namespace veyra::source {-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;};+// `pixel` / `scan` / `interlaced` describe the same media type as `key`.+// The capture dialog offers them as three linked choices; `key` stays the+// 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;};+enum class CaptureFormatAxis { Resolution, FrameRate };+struct CaptureFormatOption { std::wstring id, label; };inline const CaptureFormat* selectCaptureFormat(std::span<const CaptureFormat> formats,int legacyIndex,std::wstring_view key){for(const auto& format:formats)@@ -22,6 +29,99 @@ inline const CaptureFormat* selectCaptureFormat(std::span<const CaptureFormat> freturn nullptr;}+inline std::wstring captureResolutionId(const CaptureFormat& format){+ return std::format(L"{}x{}",format.width,format.height);+}+inline std::wstring captureFrameRateId(const CaptureFormat& format){+ // 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"{:.6f}|{}",format.fps,format.interlaced?1:0);+}+inline std::wstring captureResolutionLabel(const CaptureFormat& format){+ return std::format(L"{} × {}",format.width,format.height);+}+inline std::wstring captureFrameRateLabel(const CaptureFormat& format){+ auto label=std::format(L"{:.2f} fps",format.fps);+ if(!format.scan.empty())label+=L" · "+format.scan;+ return label;+}+inline std::wstring capturePixelLabel(const CaptureFormat& format,bool ambiguous){+ std::wstring label=format.pixel.empty()?L"未知格式":format.pixel;+ if(ambiguous){+ if(!format.scan.empty())label+=L" · "+format.scan;+ label+=std::format(L" [format {}]",format.index);+ }+ if(format.driverCurrent)label+=L" · 驱动默认";+ return label;+}+inline std::vector<CaptureFormatOption> captureResolutionOptions(std::span<const CaptureFormat> formats){+ std::vector<CaptureFormatOption> out;+ for(const auto& format:formats){+ const auto id=captureResolutionId(format);+ if(std::any_of(out.begin(),out.end(),[&](const CaptureFormatOption& option){return option.id==id;}))continue;+ out.push_back({id,captureResolutionLabel(format)});+ }+ return out;+}+inline std::vector<CaptureFormatOption> captureFrameRateOptions(std::span<const CaptureFormat> formats,const CaptureFormat* current){+ std::vector<CaptureFormatOption> out;+ if(!current)return out;+ const auto resolution=captureResolutionId(*current);+ for(const auto& format:formats){+ if(captureResolutionId(format)!=resolution)continue;+ const auto id=captureFrameRateId(format);+ if(std::any_of(out.begin(),out.end(),[&](const CaptureFormatOption& option){return option.id==id;}))continue;+ auto label=captureFrameRateLabel(format);+ if(std::any_of(out.begin(),out.end(),[&](const CaptureFormatOption& option){return option.label==label;}))+ label+=std::format(L" [format {}]",format.index);+ out.push_back({id,std::move(label)});+ }+ return out;+}+inline std::vector<CaptureFormatOption> capturePixelOptions(std::span<const CaptureFormat> formats,const CaptureFormat* current){+ std::vector<CaptureFormatOption> out;+ if(!current)return out;+ const auto resolution=captureResolutionId(*current);+ const auto rate=captureFrameRateId(*current);+ std::vector<const CaptureFormat*> matched;+ for(const auto& format:formats)+ if(captureResolutionId(format)==resolution&&captureFrameRateId(format)==rate)matched.push_back(&format);+ for(const auto* format:matched){+ int copies=0;+ for(const auto* other:matched)if(other->pixel==format->pixel)++copies;+ out.push_back({format->key,capturePixelLabel(*format,copies>1)});+ }+ 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.+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{};+ const auto rate=current?captureFrameRateId(*current):std::wstring{};+ 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+ :captureResolutionId(format)==resolution&&captureFrameRateId(format)==id;+ if(!match)continue;+ if(!fallback)fallback=&format;+ if(!current)continue;+ 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;+}+inline std::wstring capturePathOptions(double fps,std::wstring_view encodedKey){std::wstring result;if(fps>0)result=std::format(L"?fps={:.6f}",fps);diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.hindex 0f029e3f..58c49494 100644--- a/include/veyra/ui/QmlPlayerBridge.h+++ b/include/veyra/ui/QmlPlayerBridge.h@@ -121,6 +121,14 @@ class QmlPlayerBridge : public QObject {// the choice is remembered in capture-preferences.v1 for "continue".Q_PROPERTY(QVariantList captureFormats READ captureFormats NOTIFY captureChanged)Q_PROPERTY(QString captureFormatKey READ captureFormatKey WRITE setCaptureFormatKey NOTIFY captureChanged)+ // Resolution, frame rate and pixel format are three views of captureFormatKey.+ // Changing one retargets that key to a media type the device actually enumerated.+ Q_PROPERTY(QVariantList captureResolutionOptions READ captureResolutionOptions NOTIFY captureChanged)+ Q_PROPERTY(QString captureResolutionId READ captureResolutionId WRITE setCaptureResolutionId NOTIFY captureChanged)+ Q_PROPERTY(QVariantList captureFrameRateOptions READ captureFrameRateOptions NOTIFY captureChanged)+ Q_PROPERTY(QString captureFrameRateId READ captureFrameRateId WRITE setCaptureFrameRateId NOTIFY captureChanged)+ Q_PROPERTY(QVariantList capturePixelOptions READ capturePixelOptions NOTIFY captureChanged)+ Q_PROPERTY(QString capturePixelId READ capturePixelId WRITE setCapturePixelId NOTIFY captureChanged)Q_PROPERTY(QVariantList captureAudioInputs READ captureAudioInputs NOTIFY captureChanged)Q_PROPERTY(int captureAudioChoice READ captureAudioChoice WRITE setCaptureAudioChoice NOTIFY captureChanged)Q_PROPERTY(int captureColorSpace READ captureColorSpace WRITE setCaptureColorSpace NOTIFY captureChanged)@@ -555,6 +563,15 @@ public:QVariantList captureFormats() const;QString captureFormatKey() const;void setCaptureFormatKey(const QString& key);+ QVariantList captureResolutionOptions() const;+ QString captureResolutionId() const;+ void setCaptureResolutionId(const QString& id);+ QVariantList captureFrameRateOptions() const;+ QString captureFrameRateId() const;+ void setCaptureFrameRateId(const QString& id);+ QVariantList capturePixelOptions() const;+ QString capturePixelId() const;+ void setCapturePixelId(const QString& id);QVariantList captureAudioInputs() const;int captureAudioChoice() const;void setCaptureAudioChoice(int choice);diff --git a/qml/Veyra/DialogHost.qml b/qml/Veyra/DialogHost.qmlindex 1cc8ee6c..115e392c 100644--- a/qml/Veyra/DialogHost.qml+++ b/qml/Veyra/DialogHost.qml@@ -213,7 +213,8 @@ Item {// --- 采集卡 -----------------------------------------------------------// The 1.4.4 capture panel, in the new design: device details and formats are// queried asynchronously, only an explicitly chosen audio input is opened,- // and the choice is remembered for "继续上次采集".+ // and the choice is remembered for "继续上次采集". Resolution, frame rate and+ // pixel format are three views of that one saved format key.DLayer {id: captureDialogobjectName: "capture-dialog"@@ -329,14 +330,36 @@ Item {}}VRow {- label: qsTr("设备实际支持的格式")- hint: { const f = veyra.captureFormats.find(x => x.id === veyra.captureFormatKey); return f && f.costHint ? qsTr("该格式比低延迟格式多一道处理环节,高分辨率/高帧率下建议优先低延迟格式") : "" }+ label: qsTr("分辨率")+ hint: qsTr("与帧率和像素格式一起决定采集媒体类型")+ VSelect {+ objectName: "capture-resolution"+ implicitWidth: 180+ value: captureDialog.labelOf(veyra.captureResolutionOptions, veyra.captureResolutionId, veyra.captureResolutionOptions.length ? qsTr("请选择分辨率") : "—")+ options: veyra.captureResolutionOptions+ onPicked: id => veyra.captureResolutionId = id+ }+ }+ VRow {+ label: qsTr("帧率")+ hint: qsTr("只列出当前分辨率下设备上报的帧率。设备帧率填 0 时,连接使用这里选中的帧率")+ VSelect {+ objectName: "capture-frame-rate"+ implicitWidth: 280+ value: captureDialog.labelOf(veyra.captureFrameRateOptions, veyra.captureFrameRateId, veyra.captureFrameRateOptions.length ? qsTr("请选择帧率") : "—")+ options: veyra.captureFrameRateOptions+ onPicked: id => veyra.captureFrameRateId = id+ }+ }+ VRow {+ label: qsTr("像素格式")+ hint: { const f = veyra.captureFormats.find(x => x.id === veyra.captureFormatKey); return f && f.costHint ? qsTr("该格式比低延迟格式多一道处理环节,高分辨率/高帧率下建议优先低延迟格式") : qsTr("只列出当前分辨率和帧率下的像素格式") }VSelect {objectName: "capture-format"- implicitWidth: 260- value: captureDialog.labelOf(veyra.captureFormats, veyra.captureFormatKey, veyra.captureFormats.length ? qsTr("请选择格式") : "—")- options: veyra.captureFormats- onPicked: id => veyra.captureFormatKey = id+ implicitWidth: 220+ value: captureDialog.labelOf(veyra.capturePixelOptions, veyra.capturePixelId, veyra.capturePixelOptions.length ? qsTr("请选择像素格式") : "—")+ options: veyra.capturePixelOptions+ onPicked: id => veyra.capturePixelId = id}}VRow {diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cppindex 732d7a5a..5298812e 100644--- a/src/source/CaptureCardSource.cpp+++ b/src/source/CaptureCardSource.cpp@@ -723,10 +723,12 @@ std::vector<CaptureFormat> enumerateFormats(IAMStreamConfig* config,bool preferDconst auto tier=valid?captureFormatTier(layout.packing):CaptureFormatTier::Decoded;const int rank=valid?captureFormatRank(layout.packing):captureFormatRank(CapturePacking::Unknown);const auto key=captureFormatIdentity(*type);const bool current=!currentKey.empty()&&key==currentKey;- std::wstring scan;+ std::wstring scan;bool interlaced=false;if(type->formattype==FORMAT_VideoInfo2){const auto flags=reinterpret_cast<const VIDEOINFOHEADER2*>(type->pbFormat)->dwInterlaceFlags;- scan=(flags&AMINTERLACE_IsInterlaced)?std::format(L" · 隔行({:.2f} 场/秒)",fps*((flags&AMINTERLACE_1FieldPerSample)?1:2)):L" · 逐行";}- out.push_back({i,width,height,fps,std::format(L"{} x {} @ {:.2f} fps{} · {} · {} · {}{} [format {}]",width,height,fps,scan,pixel,support,captureFormatTierLabel(tier),current?L" · 驱动默认":L"",i),key,rank,int(tier),current});+ interlaced=(flags&AMINTERLACE_IsInterlaced)!=0;+ scan=interlaced?std::format(L"隔行({:.2f} 场/秒)",fps*((flags&AMINTERLACE_1FieldPerSample)?1:2)):L"逐行";}+ const std::wstring scanMark=scan.empty()?std::wstring{}:L" · "+scan;+ out.push_back({i,width,height,fps,std::format(L"{} x {} @ {:.2f} fps{} · {} · {} · {}{} [format {}]",width,height,fps,scanMark,pixel,support,captureFormatTierLabel(tier),current?L" · 驱动默认":L"",i),key,rank,int(tier),current,pixel,scan,interlaced});}freeType(type);}diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cppindex fe84522b..75a1b57b 100644--- a/src/ui/QmlPlayerBridge.cpp+++ b/src/ui/QmlPlayerBridge.cpp@@ -1975,7 +1975,9 @@ QVariantList QmlPlayerBridge::captureFormats() const {QVariantList out;for (const auto& f : impl_->captureFormatList)out << QVariantMap{{"id", utf8Of(f.key)}, {"label", uiText(f.label)}, {"tier", f.tier},- {"costHint", source::captureFormatNeedsCostHint(static_cast<source::CaptureFormatTier>(f.tier))}, {"driverCurrent", f.driverCurrent}};+ {"costHint", source::captureFormatNeedsCostHint(static_cast<source::CaptureFormatTier>(f.tier))}, {"driverCurrent", f.driverCurrent},+ {"width", int(f.width)}, {"height", int(f.height)}, {"fps", f.fps}, {"pixel", uiText(f.pixel)},+ {"scan", uiText(f.scan)}, {"interlaced", f.interlaced}};return out;}QString QmlPlayerBridge::captureFormatKey() const { return utf8Of(impl_->captureFormatKey); }@@ -1984,6 +1986,67 @@ void QmlPlayerBridge::setCaptureFormatKey(const QString& key) {impl_->captureFormatKey = wideOf(key);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)}};+ return out;+}+const source::CaptureFormat* selectedCaptureFormat(const std::vector<source::CaptureFormat>& formats, const std::wstring& key) {+ return source::selectCaptureFormat(formats, -1, key);+}+}+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();+}+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;+ impl_->captureFormatKey = next->key;+ emit captureChanged();+}+QVariantList QmlPlayerBridge::captureFrameRateOptions() const {+ return captureChoiceList(source::captureFrameRateOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey)));+}+QString QmlPlayerBridge::captureFrameRateId() const {+ const auto* format = selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey);+ return format ? utf8Of(source::captureFrameRateId(*format)) : QString();+}+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;+ impl_->captureFormatKey = next->key;+ emit captureChanged();+}+QVariantList QmlPlayerBridge::capturePixelOptions() const {+ return captureChoiceList(source::capturePixelOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey)));+}+QString QmlPlayerBridge::capturePixelId() const {+ const auto* format = selectedCaptureFormat(impl_->captureFormatList, 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;+ impl_->captureFormatKey = key;+ emit captureChanged();+ return;+ }+}QVariantList QmlPlayerBridge::captureAudioInputs() const {// Only what the user picks explicitly is ever opened (1.4.4 rule).QVariantList out{QVariantMap{{"id", source::kCaptureAudioDisabled}, {"label", tr("不监听音频")}}};diff --git a/tests/unit/CaptureFormatSelectionTests.cpp b/tests/unit/CaptureFormatSelectionTests.cppindex 3c7d9e74..5b37fd82 100644--- a/tests/unit/CaptureFormatSelectionTests.cpp+++ b/tests/unit/CaptureFormatSelectionTests.cpp@@ -1,6 +1,7 @@#include "veyra/source/CaptureFormatSelection.h"#include <array>#include <iostream>+#include <vector>int main(){using namespace veyra::source;@@ -27,5 +28,46 @@ int main(){check(captureFrameRateMatches(60,166833),"nominal 59.94 allowed");check(!captureFrameRateMatches(60,200000),"60 to 50 renegotiation rejected");check(!captureFrameRateMatches(60,0),"unknown negotiated rate rejected");++ auto media=[&](int index,unsigned width,unsigned height,double fps,std::wstring key,std::wstring pixel,bool interlaced,std::wstring scan){+ CaptureFormat format;+ format.index=index;format.width=width;format.height=height;format.fps=fps;+ format.key=std::move(key);format.pixel=std::move(pixel);format.interlaced=interlaced;format.scan=std::move(scan);+ return format;+ };+ std::vector<CaptureFormat> listed{+ media(0,1920,1080,60,L"1080p60-nv12",L"NV12",false,L"逐行"),+ media(1,1920,1080,60,L"1080p60-yuy2",L"YUY2",false,L"逐行"),+ media(2,1920,1080,30,L"1080p30-nv12",L"NV12",false,L"逐行"),+ media(3,1920,1080,30,L"1080i60-nv12",L"NV12",true,L"隔行(59.94 场/秒)"),+ media(4,3840,2160,30,L"4k30-yuy2",L"YUY2",false,L"逐行"),+ media(5,1920,1080,60,L"1080p60-nv12-bff",L"NV12",false,L"逐行"),+ media(6,3840,2160,24,L"4k24-yuy2",L"YUY2",false,L"逐行"),+ };+ const auto resolutions=captureResolutionOptions(listed);+ check(resolutions.size()==2&&resolutions[0].id==L"1920x1080"&&resolutions[1].id==L"3840x2160","resolutions stay unique and in list order");+ const auto* p60=selectCaptureFormat(listed,-1,L"1080p60-nv12");+ const auto rates=captureFrameRateOptions(listed,p60);+ check(rates.size()==3,"1080p lists progressive 60, progressive 30 and interlaced 30 only");+ check(captureFrameRateId(listed[2])!=captureFrameRateId(listed[3]),"same numeric rate keeps progressive and interlaced apart");+ bool saw4kOnlyRate=false;for(const auto& rate:rates)if(rate.id==captureFrameRateId(listed[6]))saw4kOnlyRate=true;+ check(!saw4kOnlyRate,"a frame rate that exists only at 4k is hidden while 1080p is selected");+ const auto pixels=capturePixelOptions(listed,p60);+ check(pixels.size()==3&&pixels[0].id==L"1080p60-nv12"&&pixels[1].id==L"1080p60-yuy2"&&pixels[2].id==L"1080p60-nv12-bff","pixel list is the concrete 1080p60 media types");+ 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");+ 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]));+ check(toInterlace==&listed[3],"interlaced rate selects the interlaced media type");+ check(!retargetCaptureFormat(listed,p60,CaptureFormatAxis::FrameRate,L"50.000000|0"),"missing frame rate is rejected");+ check(!retargetCaptureFormat(listed,p60,CaptureFormatAxis::Resolution,L"1280x720"),"missing resolution is rejected");+ const auto* yuy2=selectCaptureFormat(listed,-1,L"1080p60-yuy2");+ const auto* keptPixel=retargetCaptureFormat(listed,yuy2,CaptureFormatAxis::Resolution,L"3840x2160");+ 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");std::cout<<"capture format selection failures="<<failures<<'\n';return failures?1:0;}