aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core/host1x/codecs/decoder.cpp
diff options
context:
space:
mode:
authoryuzubot <[email protected]>2024-03-04 00:57:21 +0000
committeryuzubot <[email protected]>2024-03-04 00:57:21 +0000
commit276ceb26d0c58a00a0e65e3bf4d9c4371428f82d (patch)
tree587c6b5415501f1b1a1795ddd6df8d3403252cb4 /src/video_core/host1x/codecs/decoder.cpp
parent15e6e48bef0216480661444a8d8b348c1cca47bb (diff)
downloadyuzu-android-276ceb26d0c58a00a0e65e3bf4d9c4371428f82d.tar.gz
yuzu-android-276ceb26d0c58a00a0e65e3bf4d9c4371428f82d.zip
Merge yuzu-emu#12461
Diffstat (limited to 'src/video_core/host1x/codecs/decoder.cpp')
-rw-r--r--src/video_core/host1x/codecs/decoder.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/video_core/host1x/codecs/decoder.cpp b/src/video_core/host1x/codecs/decoder.cpp
new file mode 100644
index 000000000..49a601969
--- /dev/null
+++ b/src/video_core/host1x/codecs/decoder.cpp
@@ -0,0 +1,71 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "common/assert.h"
+#include "common/settings.h"
+#include "video_core/host1x/codecs/decoder.h"
+#include "video_core/host1x/host1x.h"
+#include "video_core/memory_manager.h"
+
+namespace Tegra {
+
+Decoder::Decoder(Host1x::Host1x& host1x_, s32 id_, const Host1x::NvdecCommon::NvdecRegisters& regs_,
+ Host1x::FrameQueue& frame_queue_)
+ : host1x(host1x_), memory_manager{host1x.GMMU()}, regs{regs_}, id{id_}, frame_queue{
+ frame_queue_} {}
+
+Decoder::~Decoder() = default;
+
+void Decoder::Decode() {
+ if (!initialized) {
+ return;
+ }
+
+ const auto packet_data = ComposeFrame();
+ // Send assembled bitstream to decoder.
+ if (!decode_api.SendPacket(packet_data)) {
+ return;
+ }
+
+ // Only receive/store visible frames.
+ if (vp9_hidden_frame) {
+ return;
+ }
+
+ // Receive output frames from decoder.
+ auto frame = decode_api.ReceiveFrame();
+
+ if (IsInterlaced()) {
+ auto [luma_top, luma_bottom, chroma_top, chroma_bottom] = GetInterlacedOffsets();
+ auto frame_copy = frame;
+
+ if (!frame.get()) {
+ LOG_ERROR(HW_GPU,
+ "Nvdec {} dailed to decode interlaced frame for top 0x{:X} bottom 0x{:X}", id,
+ luma_top, luma_bottom);
+ }
+
+ if (UsingDecodeOrder()) {
+ frame_queue.PushDecodeOrder(id, luma_top, std::move(frame));
+ frame_queue.PushDecodeOrder(id, luma_bottom, std::move(frame_copy));
+ } else {
+ frame_queue.PushPresentOrder(id, luma_top, std::move(frame));
+ frame_queue.PushPresentOrder(id, luma_bottom, std::move(frame_copy));
+ }
+ } else {
+ auto [luma_offset, chroma_offset] = GetProgressiveOffsets();
+
+ if (!frame.get()) {
+ LOG_ERROR(HW_GPU, "Nvdec {} failed to decode progressive frame for luma 0x{:X}", id,
+ luma_offset);
+ }
+
+ if (UsingDecodeOrder()) {
+ frame_queue.PushDecodeOrder(id, luma_offset, std::move(frame));
+ } else {
+ frame_queue.PushPresentOrder(id, luma_offset, std::move(frame));
+ }
+ }
+}
+
+} // namespace Tegra