summaryrefslogtreecommitdiff
path: root/src/video_core/host1x/nvdec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/host1x/nvdec.cpp')
-rw-r--r--src/video_core/host1x/nvdec.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/video_core/host1x/nvdec.cpp b/src/video_core/host1x/nvdec.cpp
new file mode 100644
index 000000000..5f6decd0d
--- /dev/null
+++ b/src/video_core/host1x/nvdec.cpp
@@ -0,0 +1,47 @@
1// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/assert.h"
5#include "video_core/gpu.h"
6#include "video_core/host1x/nvdec.h"
7
8namespace Tegra::Host1x {
9
10#define NVDEC_REG_INDEX(field_name) \
11 (offsetof(NvdecCommon::NvdecRegisters, field_name) / sizeof(u64))
12
13Nvdec::Nvdec(GPU& gpu_) : gpu(gpu_), state{}, codec(std::make_unique<Codec>(gpu, state)) {}
14
15Nvdec::~Nvdec() = default;
16
17void Nvdec::ProcessMethod(u32 method, u32 argument) {
18 state.reg_array[method] = static_cast<u64>(argument) << 8;
19
20 switch (method) {
21 case NVDEC_REG_INDEX(set_codec_id):
22 codec->SetTargetCodec(static_cast<NvdecCommon::VideoCodec>(argument));
23 break;
24 case NVDEC_REG_INDEX(execute):
25 Execute();
26 break;
27 }
28}
29
30AVFramePtr Nvdec::GetFrame() {
31 return codec->GetCurrentFrame();
32}
33
34void Nvdec::Execute() {
35 switch (codec->GetCurrentCodec()) {
36 case NvdecCommon::VideoCodec::H264:
37 case NvdecCommon::VideoCodec::VP8:
38 case NvdecCommon::VideoCodec::VP9:
39 codec->Decode();
40 break;
41 default:
42 UNIMPLEMENTED_MSG("Codec {}", codec->GetCurrentCodecName());
43 break;
44 }
45}
46
47} // namespace Tegra::Host1x