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++
22.6 KB
Raw Blame
// One NR editor; each parameter group independently chooses web or list.
// Both views use the same specs, bridge parameters and persistence.
import QtQuick
import QtQuick.Layouts
import "EffectSupport.js" as Support

ColumnLayout {
    id: editor
    required property var layerData
    property int layerCount: 1
    property bool nrFirst: false
    // The list page owns copy/delete and the list-wide NR->SR order; the node
    // page uses its node menu and wiring instead.
    property bool listControls: true
    // Read the previous global choice only as a migration fallback.
    function usesWeb(key) {
        const prefs = veyra.preferences
        return (prefs[key] ?? (prefs.nrWebEditor === true ? "web" : "list")) === "web"
    }
    readonly property bool residualWeb: usesWeb("nrResidualView")
    readonly property bool correctionWeb: usesWeb("nrCorrectionView")
    readonly property var residualSpecs: [{key:"total",label:qsTr("总变化强度"),hint:qsTr("整体倍率 · 同时影响四个方向的变化"),min:0,max:5,defaultValue:1},
               {key:"darken",label:qsTr("暗化变化"),hint:qsTr("增加 NR 带来的暗化,不是直接调低画面亮度。"),min:0,max:2,defaultValue:1},
               {key:"brighten",label:qsTr("亮化变化"),hint:qsTr("增加 NR 带来的提亮;0 取消这部分变化。"),min:0,max:2,defaultValue:1},
               {key:"color",label:qsTr("色彩变化"),hint:qsTr("增加 NR 带来的颜色变化;0 取消这部分变化。"),min:0,max:2,defaultValue:1},
               {key:"luminance",label:qsTr("明度变化"),hint:qsTr("增加 NR 带来的明度变化;0 取消这部分变化。"),min:0,max:2,defaultValue:1}]
    readonly property var correctionSpecs: [{key:"hueProtection",label:qsTr("色相保护"),hint:qsTr("保留原图色相;没有色相偏移时变化较小"),min:0,max:1,defaultValue:1},
                    {key:"chromaProtection",label:qsTr("色度保护"),hint:qsTr("软化过量色度变化;小幅变化保留"),min:0,max:1,defaultValue:0.75},
                    {key:"neutralProtection",label:qsTr("中性色保护"),hint:qsTr("抑制白墙、云和灰色区域的额外染色"),min:0,max:1,defaultValue:0},
                    {key:"colorRetention",label:qsTr("原图色彩保留"),hint:qsTr("保留原图色相与饱和度;1 为完全保留色彩"),min:0,max:1,defaultValue:0},
                    {key:"luminanceRetention",label:qsTr("亮度保持"),hint:qsTr("减少 NR 明暗改动;1 为保留原图亮度"),min:0,max:1,defaultValue:0},
                    {key:"shadowProtection",label:qsTr("暗部保护"),hint:qsTr("减少暗部被进一步压黑,保留提亮细节"),min:0,max:1,defaultValue:0},
                    {key:"highlightProtection",label:qsTr("高光保护"),hint:qsTr("只压缩向白色溢出的变化,保留高光回暗"),min:0,max:1,defaultValue:1},
                    {key:"localCompression",label:qsTr("局部压缩"),hint:qsTr("同时软化过大的亮度和颜色变化"),min:0,max:1,defaultValue:0.75},
                    {key:"temporalStability",label:qsTr("时域稳定"),hint:qsTr("播放时减闪;暂停单帧不体现时域效果"),min:0,max:1,defaultValue:0.8}]
    signal edited(int nodeIndex, string key, double amount)
    signal duplicateRequested(int nodeIndex)
    signal removeRequested(int nodeIndex)
    signal orderEdited(bool enabled)
    readonly property bool amdNr: layerData.runtime === 4
    readonly property string amdRuntimeLabel: {
        const choices = veyra.nrRuntimeChoices || []
        const choice = choices.find(entry => String(entry.id) === "4")
        return choice ? choice.label : qsTr("RX 7000 / 9000 · AMD NR(实验)")
    }
    property string autoReason: ""
    readonly property bool manualSize: layerData.manualSize ?? false
    property int lastManualPercent: 100
    function updateAutoReason() {
        autoReason = veyra.nrAutoSelectionReason(layerData.index)
        if (layerData.manualSize) lastManualPercent = layerData.sizePercent ?? 100
    }
    Component.onCompleted: updateAutoReason()
    onLayerDataChanged: updateAutoReason()
    // The snapshot arrives about 60 times a second and both editor pages stay
    // loaded; a hidden editor catches up when it is shown.
    onVisibleChanged: if (visible) updateAutoReason()
    Connections {
        target: veyra
        function onSettingsChanged() { editor.updateAutoReason() }
        function onChainChanged() { editor.updateAutoReason() }
        function onSnapshotChanged() { if (editor.visible) editor.updateAutoReason() }
        function onEffectCapabilitiesChanged() { editor.updateAutoReason() }
    }
    readonly property var sizeChoices: [
        {id:"2",label:"480p"}, {id:"3",label:"720p"}, {id:"4",label:"900p"},
        {id:"0",label:qsTr("1080p · 默认")}, {id:"5",label:"1440p",disabled:amdNr,note:amdNr ? qsTr("AMD NR 最高 1080p 像素预算") : ""}, {id:"1",label:qsTr("原生"),disabled:amdNr,note:amdNr ? qsTr("AMD NR 最高 1080p 像素预算") : ""},
        {id:"6",label:qsTr("自动(按负载)"),disabled:autoReason.length>0,note:autoReason},
        {id:"manual",label:qsTr("手动")}
    ]
    readonly property string sizeLabel: manualSize ? qsTr("手动") : sizeChoices.find(o => Number(o.id) === layerData.sizePolicy)?.label ?? qsTr("未知")
    spacing: 6

    component NrValueRow: VRow {
        id: valueRow
        required property var spec
        required property double amount
        signal edited(double amount)
        label: spec.label
        hint: spec.hint ?? ""
        value: amount.toFixed(2)
        VSlider {
            objectName: "nr-" + valueRow.spec.key
            valueFromModel: true
            resettable: true; defaultValue: valueRow.spec.defaultValue ?? (valueRow.spec.key === "skin" ? -1 : 1)
            implicitWidth: 110
            from: valueRow.spec.min; to: valueRow.spec.max
            value: valueRow.amount
            onMoved: value => { if (valueRow.visible && valueRow.enabled) valueRow.edited(value) }
        }
    }

    RowLayout {
        Layout.fillWidth: true
        visible: editor.listControls
        VButton {
            objectName: "nr-copy"
            text: qsTr("复制此层"); enabled: editor.layerCount < 4
            onClicked: editor.duplicateRequested(editor.layerData.index)
        }
        VButton {
            objectName: "nr-reset"
            text: qsTr("恢复默认"); ghost: true
            onClicked: if (editor.enabled) veyra.resetNrLayer(editor.layerData.index)
        }
        VButton {
            objectName: "nr-remove"
            text: qsTr("删除此层")
            onClicked: editor.removeRequested(editor.layerData.index)
        }
    }
    VRow {
        label: qsTr("NR 版本")
        hint: qsTr("全链共享 · 切换会重建 NR 管线")
        VSelect {
            objectName: "nr-runtime"
            value: editor.layerData.runtime === 4 ? editor.amdRuntimeLabel
                   : editor.layerData.runtime === 3 ? qsTr("RTX 50 · NVIDIA 原版")
                   : "RTX 20–50 · SF 310.9.16"
            options: veyra.nrRuntimeChoices || [{id:"2",label:"RTX 20–50 · SF 310.9.16"},{id:"3",label:qsTr("RTX 50 · NVIDIA 原版")},{id:"4",label:qsTr("RX 7000 / 9000 · AMD NR(实验)")}]
            onPicked: id => editor.edited(editor.layerData.index, "runtime", Number(id))
        }
    }
    VRow {
        objectName: "nr-performance-row"
        label: qsTr("启用性能优化版")
        hint: editor.amdNr ? qsTr("开启使用 Small 模型;关闭使用原模型。每层独立选择,切换会重建 NR,画面可能有所不同。")
                           : qsTr("开启使用新版模型 B;关闭使用旧版模型 A。切换会重建 NR,画面可能有所不同。")
        enabled: (editor.layerData.runtime === 2 || editor.amdNr) && Support.available(veyra, "nr" + editor.layerData.runtime)
        opacity: enabled ? 1 : 0.4
        VSwitch {
            objectName: "nr-performance"
            checked: editor.layerData.performance ?? true
            onToggled: checked => editor.edited(editor.layerData.index, "performance", checked ? 1 : 0)
        }
    }
    VRow {
        label: qsTr("NR 运动来源")
        enabled: Support.available(veyra, "nr" + editor.layerData.runtime)
        opacity: enabled ? 1 : 0.4
        hint: qsTr("全链共享;抗闪烁开启时仍需估算光流")
        VSeg {
            objectName: "nr-motion-source"
            options: [{id:"0",label:qsTr("零运动")},{id:"1",label:qsTr("光流")}]
            current: String(veyra.nrMotionSource)
            onPicked: id => { if (editor.enabled) veyra.nrMotionSource = Number(id) }
        }
    }
    VRow {
        label: qsTr("内部处理分辨率")
        enabled: Support.available(veyra, "nr" + editor.layerData.runtime)
        opacity: enabled ? 1 : 0.4
        hint: qsTr("内部降采样 · 不改变输出尺寸")
        VSelect {
            objectName: "nr-resolution"
            value: editor.sizeLabel; options: editor.sizeChoices
            onPicked: id => id === "manual" ? editor.edited(editor.layerData.index, "sizePercent", editor.lastManualPercent)
                                             : editor.edited(editor.layerData.index, "sizePolicy", Number(id))
        }
    }
    VRow {
        objectName: "nr-manual-size-row"
        visible: editor.manualSize
        enabled: Support.available(veyra, "nr" + editor.layerData.runtime)
        opacity: enabled ? 1 : 0.4
        label: qsTr("处理比例")
        hint: qsTr("松开后应用 · 宽高同比例")
        value: Math.round(percentSlider.displayedValue) + "%"
        VSlider {
            id: percentSlider
            objectName: "nr-size-percent"
            valueFromModel: true
            resettable: true; defaultValue: 100
            implicitWidth: 110
            from: 25; to: 100; stepSize: 1
            live: false // NR dimensions rebuild GPU features: commit once on release.
            value: editor.layerData.sizePercent ?? 100
            onMoved: value => editor.edited(editor.layerData.index, "sizePercent", Math.round(value))
        }
    }
    Text {
        Layout.fillWidth: true
        visible: editor.manualSize
        text: editor.amdNr ? qsTr("手动比例以最高 1080p 预算内的输入为基准;适用于预览与视频导出,输出尺寸不变。")
                          : qsTr("手动比例缩放该层输入的宽高;50% 约为四分之一像素。适用于预览与视频导出,输出尺寸不变。")
        color: Theme.t3; font.family: Theme.fontUi; font.pixelSize: 11
        wrapMode: Text.WordWrap
    }
    Text {
        Layout.fillWidth: true
        visible: editor.layerData.sizePolicy === 6
        text: qsTr("自动档在预览中按增强耗时调整 100%–40%;预建实例约增加 1.7GB 显存及半秒启动时间。视频导出固定按最高 1440p 处理,输出尺寸不变。") +
              (veyra.nrAutoStatus.length > 0 ? "\n" + veyra.nrAutoStatus : "")
        color: Theme.t3; font.family: Theme.fontUi; font.pixelSize: 11
        wrapMode: Text.WordWrap
    }
    Text {
        Layout.fillWidth: true
        text: editor.amdNr ? qsTr("AMD NR 预览与视频导出最高按内部 1080p 处理,视频保持输出尺寸;图片导出仍需符合模型尺寸预算。")
                          : qsTr("预览与视频导出都按所选内部分辨率处理,保留比例且不放大小输入,输出尺寸不变;图片导出仍完整处理。")
        color: Theme.t3; font.family: Theme.fontUi; font.pixelSize: 11
        wrapMode: Text.WordWrap
    }
    Text {
        Layout.fillWidth: true
        visible: !editor.amdNr && editor.layerCount > 1 &&
                 (!editor.listControls || (veyra.nrLayers.length > 0 && editor.layerData.index === veyra.nrLayers[0].index))
        text: qsTr("多层 NR 可尝试前层 720p、末层 1080p;三层可尝试 480p / 720p / 1080p。降低前层分辨率会改变画面,视频导出同样按各层所选分辨率处理。")
        color: Theme.t3; font.family: Theme.fontUi; font.pixelSize: 11
        wrapMode: Text.WordWrap
    }
    NrValueRow {
        spec: ({key:"intensity",label:qsTr("模型强度"),min:0,max:1})
        enabled: Support.available(veyra, "nr" + editor.layerData.runtime)
        opacity: enabled ? 1 : 0.4
        amount: editor.layerData.intensity
        onEdited: amount => editor.edited(editor.layerData.index, "intensity", amount)
    }
    Text {
        Layout.fillWidth: true
        visible: editor.amdNr || !Support.available(veyra, "nr" + editor.layerData.runtime)
        text: !Support.available(veyra, "nr" + editor.layerData.runtime) ? Support.reason(veyra, "nr" + editor.layerData.runtime) : qsTr("AMD NR(实验):RX 7000 / 9000 使用各自运行组件,需要 HIP 7 驱动。性能模式使用 Small,关闭使用原模型;内部最高 1080p 像素预算,支持百分比尺寸。7000 系风格固定默认,9000 系沿用运行时配置。原生 HDR 保留基底,通过 SDR 代理增强后还原。7000 系仍需实卡验收。")
        color: Theme.t3; font.pixelSize: 11; wrapMode: Text.WordWrap
    }
    VSubGroup {
        objectName: "nr-model-group"
        enabled: !editor.amdNr && Support.available(veyra, "nr" + editor.layerData.runtime)
        opacity: enabled ? 1 : 0.4
        Layout.fillWidth: true
        label: qsTr("模型参数"); count: 6
        Repeater {
            model: [{key:"tone",label:qsTr("局部明暗"),min:0,max:1},
                    {key:"structure",label:qsTr("局部结构"),min:0,max:1}]
            delegate: NrValueRow {
                required property var modelData
                spec: modelData; amount: editor.layerData[modelData.key]
                onEdited: amount => editor.edited(editor.layerData.index, modelData.key, amount)
            }
        }
        VRow {
            label: qsTr("肤质 · 未证实")
            VSelect {
                objectName: "nr-skin-mode"
                value: editor.layerData.skin < 0 ? qsTr("未指定") : qsTr("自定义")
                options: [{id:"-1",label:qsTr("未指定")},{id:"0",label:qsTr("自定义")}]
                onPicked: id => editor.edited(editor.layerData.index,"skin",Number(id))
            }
        }
        NrValueRow {
            visible: editor.layerData.skin >= 0
            spec: ({key:"skin",label:qsTr("肤质数值"),min:0,max:2})
            amount: Math.max(0,editor.layerData.skin)
            onEdited: amount => editor.edited(editor.layerData.index,"skin",amount)
        }
        VRow {
            label: qsTr("风格 · 实验")
            VSeg {
                objectName: "nr-style"
                options: [{id:"0",label:"0"},{id:"1",label:"1"},{id:"2",label:"2"}]
                current: String(editor.layerData.style)
                onPicked: id => editor.edited(editor.layerData.index,"style",Number(id))
            }
        }
        VRow {
            label: qsTr("自动遮罩 · 实验")
            VSwitch {
                objectName: "nr-autoMask"
                checked: editor.layerData.autoMask
                onToggled: checked => editor.edited(editor.layerData.index,"autoMask",checked?1:0)
            }
        }
        VRow {
            label: qsTr("UI 修正 · 未证实")
            VSwitch {
                objectName: "nr-uiCorrection"
                checked: editor.layerData.uiCorrection
                onToggled: checked => editor.edited(editor.layerData.index,"uiCorrection",checked?1:0)
            }
        }
    }
    VSubGroup {
        objectName: "nr-residual-group"
        Layout.fillWidth: true
        label: qsTr("增强变化量"); count: 5
        VRow {
            label: qsTr("调节方式")
            VSeg {
                objectName: "nr-residual-view"
                options: [{id:"web",label:qsTr("网状")},{id:"list",label:qsTr("列表")}]
                current: editor.residualWeb ? "web" : "list"
                onPicked: id => veyra.setPreference("nrResidualView", id)
            }
        }
        Repeater {
            model: editor.residualSpecs
            delegate: NrValueRow {
                required property var modelData
                visible: !editor.residualWeb || modelData.key === "total"
                spec: modelData; amount: editor.layerData[modelData.key]
                onEdited: amount => editor.edited(editor.layerData.index, modelData.key, amount)
            }
        }
        NrWebPad {
            id: residualPad
            objectName: "nr-residual-web"
            Layout.fillWidth: true
            visible: editor.residualWeb
            identity: String(editor.layerData.index) + ":" + editor.layerData.runtime
            axes: editor.residualSpecs.slice(1)
            values: editor.layerData
            onEdited: (key, value) => { if (residualPad.visible && residualPad.enabled) editor.edited(editor.layerData.index, key, value) }
        }
    }
    VSubGroup {
        objectName: "nr-correction-group"
        Layout.fillWidth: true
        label: qsTr("画面调控"); count: editor.layerData.correctionEnabled ? (editor.layerData.correctionAuto ? 1 : 9) : 0
        VRow {
            label: qsTr("开启调控")
            hint: qsTr("关闭时保留原始变化量,最高 5")
            VSwitch {
                objectName: "nr-correctionEnabled"
                checked: editor.layerData.correctionEnabled ?? false
                onToggled: checked => editor.edited(editor.layerData.index,"correctionEnabled",checked?1:0)
            }
        }
        VRow {
            visible: editor.layerData.correctionEnabled ?? false
            label: qsTr("调控方式")
            VSeg {
                objectName: "nr-correctionAuto"
                options: [{id:"1",label:qsTr("自动")},{id:"0",label:qsTr("手动")}]
                current: (editor.layerData.correctionAuto ?? true) ? "1" : "0"
                onPicked: id => editor.edited(editor.layerData.index,"correctionAuto",Number(id))
            }
        }
        VRow {
            visible: (editor.layerData.correctionEnabled ?? false) && !(editor.layerData.correctionAuto ?? true)
            label: qsTr("调节方式")
            VSeg {
                objectName: "nr-correction-view"
                options: [{id:"web",label:qsTr("网状")},{id:"list",label:qsTr("列表")}]
                current: editor.correctionWeb ? "web" : "list"
                onPicked: id => veyra.setPreference("nrCorrectionView", id)
            }
        }
        NrWebPad {
            id: correctionPad
            objectName: "nr-correction-web"
            Layout.fillWidth: true
            visible: (editor.layerData.correctionEnabled ?? false) && !(editor.layerData.correctionAuto ?? true) && editor.correctionWeb
            identity: String(editor.layerData.index) + ":" + editor.layerData.runtime
            axes: editor.correctionSpecs
            values: editor.layerData
            onEdited: (key, value) => { if (correctionPad.visible && correctionPad.enabled) editor.edited(editor.layerData.index, key, value) }
        }
        Repeater {
            model: editor.correctionSpecs
            delegate: NrValueRow {
                required property var modelData
                visible: (editor.layerData.correctionEnabled ?? false) && !(editor.layerData.correctionAuto ?? true) &&
                         !editor.correctionWeb
                spec: modelData; amount: editor.layerData[modelData.key] ?? modelData.defaultValue
                onEdited: amount => editor.edited(editor.layerData.index,modelData.key,amount)
            }
        }
        NrValueRow {
            visible: (editor.layerData.correctionEnabled ?? false) && (editor.layerData.correctionAuto ?? true)
            spec: ({key:"correctionAmount",label:qsTr("自动调控力度"),hint:qsTr("0 保留原始变化;1 按当前风格完整纠偏"),min:0,max:1,defaultValue:1})
            amount: editor.layerData.correctionAmount ?? 1
            onEdited: amount => editor.edited(editor.layerData.index,"correctionAmount",amount)
        }
        VButton {
            objectName: "nr-use-auto-defaults"
            visible: (editor.layerData.correctionEnabled ?? false) && !(editor.layerData.correctionAuto ?? true)
            text: qsTr("采用当前风格的自动参数"); ghost: true
            onClicked: editor.edited(editor.layerData.index,"correctionUseAuto",1)
        }
        Text {
            Layout.fillWidth: true
            visible: editor.layerData.correctionEnabled ?? false
            text: qsTr("自动参数分别适配风格 0/1/2。手动可独立保留颜色、亮度和暗部;保护会降低对应变化量。时域稳定复用光流,切换方式保留手动数值。")
            color: Theme.t3; font.pixelSize: 11; wrapMode: Text.WordWrap
        }
    }
    VSubGroup {
        objectName: "nr-experimental-group"
        Layout.fillWidth: true
        label: qsTr("实验"); count: editor.layerData.temporal ? 3 : 2
        VRow {
            label: qsTr("时间域防闪烁")
            hint: editor.layerData.correctionEnabled ? qsTr("画面调控已接管时域稳定;关闭调控后恢复此设置") : qsTr("需要光流;关掉则不做时域累积")
            VSwitch {
                objectName: "nr-temporal"
                checked: editor.layerData.temporal
                enabled: !(editor.layerData.correctionEnabled ?? false)
                onToggled: checked => editor.edited(editor.layerData.index,"temporal",checked?1:0)
            }
        }
        VRow {
            objectName: "nr-antiflicker-row"
            // Only meaningful when temporal accumulation is on; the tier picks
            // how the accumulation behaves, not whether it runs.
            visible: editor.layerData.temporal
            label: qsTr("抗闪烁档位")
            hint: qsTr("静态最稳、光流为默认、低频保留高频细节")
            VSelect {
                objectName: "nr-antiflicker"
                enabled: !(editor.layerData.correctionEnabled ?? false)
                options: [
                    {id:"1",label:qsTr("静态累积")},
                    {id:"2",label:qsTr("光流累积 · 默认")},
                    {id:"3",label:qsTr("光流累积+")},
                    {id:"4",label:qsTr("低频时域重建")}
                ]
                value: options.find(o => Number(o.id) === editor.layerData.antiFlicker)?.label ?? qsTr("光流累积 · 默认")
                onPicked: id => editor.edited(editor.layerData.index,"antiFlicker",Number(id))
            }
        }
        VRow {
            visible: editor.listControls
            label: qsTr("NR → SR · 全层")
            hint: qsTr("低延迟顺序,仅预览、全层同步")
            VSwitch {
                checked: editor.nrFirst
                onToggled: checked => editor.orderEdited(checked)
            }
        }
    }
}