yuzu/src/video_core/host1x/nvdec.cpp

49 lines
1.4 KiB
C++
Raw Normal View History

2022-11-05 16:58:44 +04:00
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/assert.h"
#include "video_core/host1x/host1x.h"
#include "video_core/host1x/nvdec.h"
namespace Tegra::Host1x {
#define NVDEC_REG_INDEX(field_name) \
(offsetof(NvdecCommon::NvdecRegisters, field_name) / sizeof(u64))
2024-01-26 10:10:49 +04:00
Nvdec::Nvdec(Host1x& host1x_)
: host1x(host1x_), state{}, codec(std::make_unique<Codec>(host1x, state)) {}
2022-11-05 16:58:44 +04:00
2024-01-26 10:10:49 +04:00
Nvdec::~Nvdec() = default;
2022-11-05 16:58:44 +04:00
void Nvdec::ProcessMethod(u32 method, u32 argument) {
2024-01-26 10:10:49 +04:00
state.reg_array[method] = static_cast<u64>(argument) << 8;
2022-11-05 16:58:44 +04:00
switch (method) {
case NVDEC_REG_INDEX(set_codec_id):
2024-01-26 10:10:49 +04:00
codec->SetTargetCodec(static_cast<NvdecCommon::VideoCodec>(argument));
2022-11-05 16:58:44 +04:00
break;
2024-01-26 10:10:49 +04:00
case NVDEC_REG_INDEX(execute):
2022-11-05 16:58:44 +04:00
Execute();
2024-01-26 10:10:49 +04:00
break;
2022-11-05 16:58:44 +04:00
}
}
2024-01-26 10:10:49 +04:00
std::unique_ptr<FFmpeg::Frame> Nvdec::GetFrame() {
return codec->GetCurrentFrame();
2022-11-05 16:58:44 +04:00
}
void Nvdec::Execute() {
2024-01-26 10:10:49 +04:00
switch (codec->GetCurrentCodec()) {
2022-11-05 16:58:44 +04:00
case NvdecCommon::VideoCodec::H264:
case NvdecCommon::VideoCodec::VP8:
case NvdecCommon::VideoCodec::VP9:
2024-01-26 10:10:49 +04:00
codec->Decode();
2022-11-05 16:58:44 +04:00
break;
default:
2024-01-26 10:10:49 +04:00
UNIMPLEMENTED_MSG("Codec {}", codec->GetCurrentCodecName());
2022-11-05 16:58:44 +04:00
break;
}
}
} // namespace Tegra::Host1x