mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-18 16:47:32 +01:00
eb67a45ca8
This commit aims to implement the NVDEC (Nvidia Decoder) functionality, with video frame decoding being handled by the FFmpeg library. The process begins with Ioctl commands being sent to the NVDEC and VIC (Video Image Composer) emulated devices. These allocate the necessary GPU buffers for the frame data, along with providing information on the incoming video data. A Submit command then signals the GPU to process and decode the frame data. To decode the frame, the respective codec's header must be manually composed from the information provided by NVDEC, then sent with the raw frame data to the ffmpeg library. Currently, H264 and VP9 are supported, with VP9 having some minor artifacting issues related mainly to the reference frame composition in its uncompressed header. Async GPU is not properly implemented at the moment. Co-Authored-By: David <25727384+ogniK5377@users.noreply.github.com>
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
// Copyright 2020 yuzu Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#include <stdexcept>
|
|
#include "common/common_types.h"
|
|
#include "common/stream.h"
|
|
|
|
namespace Common {
|
|
|
|
Stream::Stream() = default;
|
|
Stream::~Stream() = default;
|
|
|
|
void Stream::Seek(s32 offset, SeekOrigin origin) {
|
|
if (origin == SeekOrigin::SetOrigin) {
|
|
if (offset < 0) {
|
|
position = 0;
|
|
} else if (position >= buffer.size()) {
|
|
position = buffer.size();
|
|
} else {
|
|
position = offset;
|
|
}
|
|
} else if (origin == SeekOrigin::FromCurrentPos) {
|
|
Seek(static_cast<s32>(position) + offset, SeekOrigin::SetOrigin);
|
|
} else if (origin == SeekOrigin::FromEnd) {
|
|
Seek(static_cast<s32>(buffer.size()) - offset, SeekOrigin::SetOrigin);
|
|
}
|
|
}
|
|
|
|
u8 Stream::ReadByte() {
|
|
if (position < buffer.size()) {
|
|
return buffer[position++];
|
|
} else {
|
|
throw std::out_of_range("Attempting to read a byte not within the buffer range");
|
|
}
|
|
}
|
|
|
|
void Stream::WriteByte(u8 byte) {
|
|
if (position == buffer.size()) {
|
|
buffer.push_back(byte);
|
|
position++;
|
|
} else {
|
|
buffer.insert(buffer.begin() + position, byte);
|
|
}
|
|
}
|
|
|
|
} // namespace Common
|