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.cpp48
1 files changed, 48 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..a4bd5b79f
--- /dev/null
+++ b/src/video_core/host1x/nvdec.cpp
@@ -0,0 +1,48 @@
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/host1x/host1x.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(Host1x& host1x_)
14 : host1x(host1x_), state{}, codec(std::make_unique<Codec>(host1x, state)) {}
15
16Nvdec::~Nvdec() = default;
17
18void Nvdec::ProcessMethod(u32 method, u32 argument) {
19 state.reg_array[method] = static_cast<u64>(argument) << 8;
20
21 switch (method) {
22 case NVDEC_REG_INDEX(set_codec_id):
23 codec->SetTargetCodec(static_cast<NvdecCommon::VideoCodec>(argument));
24 break;
25 case NVDEC_REG_INDEX(execute):
26 Execute();
27 break;
28 }
29}
30
31AVFramePtr Nvdec::GetFrame() {
32 return codec->GetCurrentFrame();
33}
34
35void Nvdec::Execute() {
36 switch (codec->GetCurrentCodec()) {
37 case NvdecCommon::VideoCodec::H264:
38 case NvdecCommon::VideoCodec::VP8:
39 case NvdecCommon::VideoCodec::VP9:
40 codec->Decode();
41 break;
42 default:
43 UNIMPLEMENTED_MSG("Codec {}", codec->GetCurrentCodecName());
44 break;
45 }
46}
47
48} // namespace Tegra::Host1x