summaryrefslogtreecommitdiff
path: root/src/video_core/host1x/codecs/decoder.h
blob: c456bbb1b033b80a0f152a9fd6d245046be547b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <memory>
#include <mutex>
#include <optional>
#include <string_view>
#include <unordered_map>
#include <queue>

#include "common/common_types.h"
#include "video_core/host1x/ffmpeg/ffmpeg.h"
#include "video_core/host1x/nvdec_common.h"

namespace Tegra {

    namespace Host1x {
        class Host1x;
        class FrameQueue;
    } // namespace Host1x

    class Decoder {
    public:
        virtual ~Decoder();

        /// Call decoders to construct headers, decode AVFrame with ffmpeg
        void Decode();

        // Removed UsingDecodeOrder() as it's no longer available in FFmpeg::DecodeApi
        // bool UsingDecodeOrder() const {
        //     return decode_api.UsingDecodeOrder();
        // }

        /// Returns the value of current_codec
        [[nodiscard]] Host1x::NvdecCommon::VideoCodec GetCurrentCodec() const {
            return codec;
        }

        /// Return name of the current codec
        [[nodiscard]] virtual std::string_view GetCurrentCodecName() const = 0;

    protected:
        explicit Decoder(Host1x::Host1x& host1x, s32 id,
                         const Host1x::NvdecCommon::NvdecRegisters& regs,
                         Host1x::FrameQueue& frame_queue);

        virtual std::span<const u8> ComposeFrame() = 0;
        virtual std::tuple<u64, u64> GetProgressiveOffsets() = 0;
        virtual std::tuple<u64, u64, u64, u64> GetInterlacedOffsets() = 0;
        virtual bool IsInterlaced() = 0;

        Host1x::Host1x& host1x;
        Tegra::MemoryManager& memory_manager;
        const Host1x::NvdecCommon::NvdecRegisters& regs;
        s32 id;
        Host1x::FrameQueue& frame_queue;
        Host1x::NvdecCommon::VideoCodec codec;
        FFmpeg::DecodeApi decode_api;
        bool initialized{};
        bool vp9_hidden_frame{};
    };

} // namespace Tegra