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++
1.6 KB
Raw Blame
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <cstddef>

namespace veyra::xbox {
enum class VideoDecodeRecoveryAction { ResetHistory, ReopenHardware, UseSoftware, Stop };

// A bad decoder must not be retried forever with new IDRs. Keep transient
// loss on hardware, reopen that context once, then fall back once per session.
// A successful picture clears consecutive errors, not the bounded reopen budget.
class VideoDecodeRecovery {
public:
    VideoDecodeRecoveryAction failed(bool hardware) {
        if (++consecutiveFailures_ < 3) return VideoDecodeRecoveryAction::ResetHistory;
        consecutiveFailures_ = 0;
        if (hardware && !hardwareReopened_) {
            hardwareReopened_ = true;
            return VideoDecodeRecoveryAction::ReopenHardware;
        }
        if (hardware && !softwareUsed_) {
            softwareUsed_ = true;
            return VideoDecodeRecoveryAction::UseSoftware;
        }
        return VideoDecodeRecoveryAction::Stop;
    }
    void picture() { consecutiveFailures_ = 0; }
private:
    unsigned consecutiveFailures_ = 0;
    bool hardwareReopened_ = false, softwareUsed_ = false;
};

// Call while holding the source queue lock, before adding the new AU. Loss
// belongs to the first surviving AU, even when the IDR itself was discarded.
template<class Queue>
std::size_t trimVideoInputs(Queue& queue, std::size_t capacity) {
    if (!capacity) capacity = 1;
    std::size_t dropped = 0;
    while (queue.size() >= capacity) { queue.pop_front(); ++dropped; }
    if (dropped && !queue.empty()) queue.front().inputLoss = true;
    return dropped;
}
}