2020-10-26 23:07:36 -04:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "video_core/command_classes/nvdec.h"
|
|
|
|
#include "video_core/gpu.h"
|
|
|
|
|
|
|
|
namespace Tegra {
|
|
|
|
|
|
|
|
Nvdec::Nvdec(GPU& gpu_) : gpu(gpu_), codec(std::make_unique<Codec>(gpu)) {}
|
|
|
|
|
|
|
|
Nvdec::~Nvdec() = default;
|
|
|
|
|
2020-11-23 15:01:40 -05:00
|
|
|
void Nvdec::ProcessMethod(Method method, u32 argument) {
|
2020-10-26 23:07:36 -04:00
|
|
|
if (method == Method::SetVideoCodec) {
|
2020-11-23 15:01:40 -05:00
|
|
|
codec->StateWrite(static_cast<u32>(method), argument);
|
2020-10-26 23:07:36 -04:00
|
|
|
} else {
|
2020-11-23 15:01:40 -05:00
|
|
|
codec->StateWrite(static_cast<u32>(method), static_cast<u64>(argument) << 8);
|
2020-10-26 23:07:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (method) {
|
|
|
|
case Method::SetVideoCodec:
|
2020-11-23 15:01:40 -05:00
|
|
|
codec->SetTargetCodec(static_cast<NvdecCommon::VideoCodec>(argument));
|
2020-10-26 23:07:36 -04:00
|
|
|
break;
|
|
|
|
case Method::Execute:
|
|
|
|
Execute();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-25 17:10:44 -05:00
|
|
|
AVFramePtr Nvdec::GetFrame() {
|
2020-10-26 23:07:36 -04:00
|
|
|
return codec->GetCurrentFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nvdec::Execute() {
|
|
|
|
switch (codec->GetCurrentCodec()) {
|
|
|
|
case NvdecCommon::VideoCodec::H264:
|
|
|
|
case NvdecCommon::VideoCodec::Vp9:
|
|
|
|
codec->Decode();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_MSG("Unknown codec {}", static_cast<u32>(codec->GetCurrentCodec()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Tegra
|