diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/audio/audin_u.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audout_u.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audren_u.cpp | 23 | ||||
| -rw-r--r-- | src/core/hle/service/audio/hwopus.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv_interface.cpp | 25 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv_interface.h | 5 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/codec.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/h264.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/h264.h | 12 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/vp8.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/vp8.h | 7 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/vp9.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/vp9.h | 8 | ||||
| -rw-r--r-- | src/video_core/host1x/codecs/vp9_types.h | 1 |
14 files changed, 81 insertions, 64 deletions
diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index c8d574993..526a39130 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include "audio_core/renderer/audio_device.h" | 5 | #include "audio_core/renderer/audio_device.h" |
| 6 | #include "common/common_funcs.h" | 6 | #include "common/common_funcs.h" |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "common/settings.h" | 8 | #include "common/scratch_buffer.h" |
| 9 | #include "common/string_util.h" | 9 | #include "common/string_util.h" |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/hle/kernel/k_event.h" | 11 | #include "core/hle/kernel/k_event.h" |
| @@ -124,12 +124,15 @@ private: | |||
| 124 | 124 | ||
| 125 | void GetReleasedAudioInBuffer(HLERequestContext& ctx) { | 125 | void GetReleasedAudioInBuffer(HLERequestContext& ctx) { |
| 126 | const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); | 126 | const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); |
| 127 | tmp_buffer.resize_destructive(write_buffer_size); | 127 | released_buffer.resize_destructive(write_buffer_size); |
| 128 | tmp_buffer[0] = 0; | 128 | released_buffer[0] = 0; |
| 129 | 129 | ||
| 130 | const auto count = impl->GetReleasedBuffers(tmp_buffer); | 130 | const auto count = impl->GetReleasedBuffers(released_buffer); |
| 131 | 131 | ||
| 132 | ctx.WriteBuffer(tmp_buffer); | 132 | LOG_TRACE(Service_Audio, "called. Session {} released {} buffers", |
| 133 | impl->GetSystem().GetSessionId(), count); | ||
| 134 | |||
| 135 | ctx.WriteBuffer(released_buffer); | ||
| 133 | 136 | ||
| 134 | IPC::ResponseBuilder rb{ctx, 3}; | 137 | IPC::ResponseBuilder rb{ctx, 3}; |
| 135 | rb.Push(ResultSuccess); | 138 | rb.Push(ResultSuccess); |
| @@ -155,7 +158,6 @@ private: | |||
| 155 | LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); | 158 | LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); |
| 156 | 159 | ||
| 157 | IPC::ResponseBuilder rb{ctx, 3}; | 160 | IPC::ResponseBuilder rb{ctx, 3}; |
| 158 | |||
| 159 | rb.Push(ResultSuccess); | 161 | rb.Push(ResultSuccess); |
| 160 | rb.Push(buffer_count); | 162 | rb.Push(buffer_count); |
| 161 | } | 163 | } |
| @@ -195,7 +197,7 @@ private: | |||
| 195 | KernelHelpers::ServiceContext service_context; | 197 | KernelHelpers::ServiceContext service_context; |
| 196 | Kernel::KEvent* event; | 198 | Kernel::KEvent* event; |
| 197 | std::shared_ptr<AudioCore::AudioIn::In> impl; | 199 | std::shared_ptr<AudioCore::AudioIn::In> impl; |
| 198 | Common::ScratchBuffer<u64> tmp_buffer; | 200 | Common::ScratchBuffer<u64> released_buffer; |
| 199 | }; | 201 | }; |
| 200 | 202 | ||
| 201 | AudInU::AudInU(Core::System& system_) | 203 | AudInU::AudInU(Core::System& system_) |
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 032c8c11f..23f84a29f 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "audio_core/renderer/audio_device.h" | 9 | #include "audio_core/renderer/audio_device.h" |
| 10 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/scratch_buffer.h" | ||
| 12 | #include "common/string_util.h" | 13 | #include "common/string_util.h" |
| 13 | #include "common/swap.h" | 14 | #include "common/swap.h" |
| 14 | #include "core/core.h" | 15 | #include "core/core.h" |
| @@ -102,8 +103,8 @@ private: | |||
| 102 | AudioOutBuffer buffer{}; | 103 | AudioOutBuffer buffer{}; |
| 103 | std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer)); | 104 | std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer)); |
| 104 | 105 | ||
| 105 | [[maybe_unused]] auto sessionid{impl->GetSystem().GetSessionId()}; | 106 | LOG_TRACE(Service_Audio, "called. Session {} Appending buffer {:08X}", |
| 106 | LOG_TRACE(Service_Audio, "called. Session {} Appending buffer {:08X}", sessionid, tag); | 107 | impl->GetSystem().GetSessionId(), tag); |
| 107 | 108 | ||
| 108 | auto result = impl->AppendBuffer(buffer, tag); | 109 | auto result = impl->AppendBuffer(buffer, tag); |
| 109 | 110 | ||
| @@ -123,12 +124,15 @@ private: | |||
| 123 | 124 | ||
| 124 | void GetReleasedAudioOutBuffers(HLERequestContext& ctx) { | 125 | void GetReleasedAudioOutBuffers(HLERequestContext& ctx) { |
| 125 | const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); | 126 | const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); |
| 126 | tmp_buffer.resize_destructive(write_buffer_size); | 127 | released_buffer.resize_destructive(write_buffer_size); |
| 127 | tmp_buffer[0] = 0; | 128 | released_buffer[0] = 0; |
| 128 | 129 | ||
| 129 | const auto count = impl->GetReleasedBuffers(tmp_buffer); | 130 | const auto count = impl->GetReleasedBuffers(released_buffer); |
| 130 | 131 | ||
| 131 | ctx.WriteBuffer(tmp_buffer); | 132 | ctx.WriteBuffer(released_buffer); |
| 133 | |||
| 134 | LOG_TRACE(Service_Audio, "called. Session {} released {} buffers", | ||
| 135 | impl->GetSystem().GetSessionId(), count); | ||
| 132 | 136 | ||
| 133 | IPC::ResponseBuilder rb{ctx, 3}; | 137 | IPC::ResponseBuilder rb{ctx, 3}; |
| 134 | rb.Push(ResultSuccess); | 138 | rb.Push(ResultSuccess); |
| @@ -154,7 +158,6 @@ private: | |||
| 154 | LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); | 158 | LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); |
| 155 | 159 | ||
| 156 | IPC::ResponseBuilder rb{ctx, 3}; | 160 | IPC::ResponseBuilder rb{ctx, 3}; |
| 157 | |||
| 158 | rb.Push(ResultSuccess); | 161 | rb.Push(ResultSuccess); |
| 159 | rb.Push(buffer_count); | 162 | rb.Push(buffer_count); |
| 160 | } | 163 | } |
| @@ -165,7 +168,6 @@ private: | |||
| 165 | LOG_DEBUG(Service_Audio, "called. Played samples={}", samples_played); | 168 | LOG_DEBUG(Service_Audio, "called. Played samples={}", samples_played); |
| 166 | 169 | ||
| 167 | IPC::ResponseBuilder rb{ctx, 4}; | 170 | IPC::ResponseBuilder rb{ctx, 4}; |
| 168 | |||
| 169 | rb.Push(ResultSuccess); | 171 | rb.Push(ResultSuccess); |
| 170 | rb.Push(samples_played); | 172 | rb.Push(samples_played); |
| 171 | } | 173 | } |
| @@ -205,7 +207,7 @@ private: | |||
| 205 | KernelHelpers::ServiceContext service_context; | 207 | KernelHelpers::ServiceContext service_context; |
| 206 | Kernel::KEvent* event; | 208 | Kernel::KEvent* event; |
| 207 | std::shared_ptr<AudioCore::AudioOut::Out> impl; | 209 | std::shared_ptr<AudioCore::AudioOut::Out> impl; |
| 208 | Common::ScratchBuffer<u64> tmp_buffer; | 210 | Common::ScratchBuffer<u64> released_buffer; |
| 209 | }; | 211 | }; |
| 210 | 212 | ||
| 211 | AudOutU::AudOutU(Core::System& system_) | 213 | AudOutU::AudOutU(Core::System& system_) |
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 12845c23a..003870176 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "common/common_funcs.h" | 15 | #include "common/common_funcs.h" |
| 16 | #include "common/logging/log.h" | 16 | #include "common/logging/log.h" |
| 17 | #include "common/polyfill_ranges.h" | 17 | #include "common/polyfill_ranges.h" |
| 18 | #include "common/scratch_buffer.h" | ||
| 18 | #include "common/string_util.h" | 19 | #include "common/string_util.h" |
| 19 | #include "core/core.h" | 20 | #include "core/core.h" |
| 20 | #include "core/hle/kernel/k_event.h" | 21 | #include "core/hle/kernel/k_event.h" |
| @@ -119,23 +120,23 @@ private: | |||
| 119 | auto is_buffer_b{ctx.BufferDescriptorB()[0].Size() != 0}; | 120 | auto is_buffer_b{ctx.BufferDescriptorB()[0].Size() != 0}; |
| 120 | if (is_buffer_b) { | 121 | if (is_buffer_b) { |
| 121 | const auto buffersB{ctx.BufferDescriptorB()}; | 122 | const auto buffersB{ctx.BufferDescriptorB()}; |
| 122 | tmp_output.resize_destructive(buffersB[0].Size()); | 123 | output_buffer.resize_destructive(buffersB[0].Size()); |
| 123 | tmp_performance.resize_destructive(buffersB[1].Size()); | 124 | performance_buffer.resize_destructive(buffersB[1].Size()); |
| 124 | } else { | 125 | } else { |
| 125 | const auto buffersC{ctx.BufferDescriptorC()}; | 126 | const auto buffersC{ctx.BufferDescriptorC()}; |
| 126 | tmp_output.resize_destructive(buffersC[0].Size()); | 127 | output_buffer.resize_destructive(buffersC[0].Size()); |
| 127 | tmp_performance.resize_destructive(buffersC[1].Size()); | 128 | performance_buffer.resize_destructive(buffersC[1].Size()); |
| 128 | } | 129 | } |
| 129 | 130 | ||
| 130 | auto result = impl->RequestUpdate(input, tmp_performance, tmp_output); | 131 | auto result = impl->RequestUpdate(input, performance_buffer, output_buffer); |
| 131 | 132 | ||
| 132 | if (result.IsSuccess()) { | 133 | if (result.IsSuccess()) { |
| 133 | if (is_buffer_b) { | 134 | if (is_buffer_b) { |
| 134 | ctx.WriteBufferB(tmp_output.data(), tmp_output.size(), 0); | 135 | ctx.WriteBufferB(output_buffer.data(), output_buffer.size(), 0); |
| 135 | ctx.WriteBufferB(tmp_performance.data(), tmp_performance.size(), 1); | 136 | ctx.WriteBufferB(performance_buffer.data(), performance_buffer.size(), 1); |
| 136 | } else { | 137 | } else { |
| 137 | ctx.WriteBufferC(tmp_output.data(), tmp_output.size(), 0); | 138 | ctx.WriteBufferC(output_buffer.data(), output_buffer.size(), 0); |
| 138 | ctx.WriteBufferC(tmp_performance.data(), tmp_performance.size(), 1); | 139 | ctx.WriteBufferC(performance_buffer.data(), performance_buffer.size(), 1); |
| 139 | } | 140 | } |
| 140 | } else { | 141 | } else { |
| 141 | LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!", result.description); | 142 | LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!", result.description); |
| @@ -233,8 +234,8 @@ private: | |||
| 233 | Kernel::KEvent* rendered_event; | 234 | Kernel::KEvent* rendered_event; |
| 234 | Manager& manager; | 235 | Manager& manager; |
| 235 | std::unique_ptr<Renderer> impl; | 236 | std::unique_ptr<Renderer> impl; |
| 236 | Common::ScratchBuffer<u8> tmp_output; | 237 | Common::ScratchBuffer<u8> output_buffer; |
| 237 | Common::ScratchBuffer<u8> tmp_performance; | 238 | Common::ScratchBuffer<u8> performance_buffer; |
| 238 | }; | 239 | }; |
| 239 | 240 | ||
| 240 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { | 241 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { |
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index c835f6cb7..fa77007f3 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | #include "common/scratch_buffer.h" | ||
| 14 | #include "core/hle/service/audio/hwopus.h" | 15 | #include "core/hle/service/audio/hwopus.h" |
| 15 | #include "core/hle/service/ipc_helpers.h" | 16 | #include "core/hle/service/ipc_helpers.h" |
| 16 | 17 | ||
| @@ -68,13 +69,13 @@ private: | |||
| 68 | ExtraBehavior extra_behavior) { | 69 | ExtraBehavior extra_behavior) { |
| 69 | u32 consumed = 0; | 70 | u32 consumed = 0; |
| 70 | u32 sample_count = 0; | 71 | u32 sample_count = 0; |
| 71 | tmp_samples.resize_destructive(ctx.GetWriteBufferNumElements<opus_int16>()); | 72 | samples.resize_destructive(ctx.GetWriteBufferNumElements<opus_int16>()); |
| 72 | 73 | ||
| 73 | if (extra_behavior == ExtraBehavior::ResetContext) { | 74 | if (extra_behavior == ExtraBehavior::ResetContext) { |
| 74 | ResetDecoderContext(); | 75 | ResetDecoderContext(); |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), tmp_samples, performance)) { | 78 | if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), samples, performance)) { |
| 78 | LOG_ERROR(Audio, "Failed to decode opus data"); | 79 | LOG_ERROR(Audio, "Failed to decode opus data"); |
| 79 | IPC::ResponseBuilder rb{ctx, 2}; | 80 | IPC::ResponseBuilder rb{ctx, 2}; |
| 80 | // TODO(ogniK): Use correct error code | 81 | // TODO(ogniK): Use correct error code |
| @@ -90,7 +91,7 @@ private: | |||
| 90 | if (performance) { | 91 | if (performance) { |
| 91 | rb.Push<u64>(*performance); | 92 | rb.Push<u64>(*performance); |
| 92 | } | 93 | } |
| 93 | ctx.WriteBuffer(tmp_samples); | 94 | ctx.WriteBuffer(samples); |
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input, | 97 | bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input, |
| @@ -154,7 +155,7 @@ private: | |||
| 154 | OpusDecoderPtr decoder; | 155 | OpusDecoderPtr decoder; |
| 155 | u32 sample_rate; | 156 | u32 sample_rate; |
| 156 | u32 channel_count; | 157 | u32 channel_count; |
| 157 | Common::ScratchBuffer<opus_int16> tmp_samples; | 158 | Common::ScratchBuffer<opus_int16> samples; |
| 158 | }; | 159 | }; |
| 159 | 160 | ||
| 160 | class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> { | 161 | class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> { |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index 348207e25..c8a880e84 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // SPDX-FileCopyrightText: 2021 Skyline Team and Contributors | 2 | // SPDX-FileCopyrightText: 2021 Skyline Team and Contributors |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later | 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | 4 | ||
| 5 | #include <cinttypes> | ||
| 6 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 6 | #include "core/core.h" |
| 8 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/kernel/k_event.h" |
| @@ -63,12 +62,12 @@ void NVDRV::Ioctl1(HLERequestContext& ctx) { | |||
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | // Check device | 64 | // Check device |
| 66 | tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); | 65 | output_buffer.resize_destructive(ctx.GetWriteBufferSize(0)); |
| 67 | const auto input_buffer = ctx.ReadBuffer(0); | 66 | const auto input_buffer = ctx.ReadBuffer(0); |
| 68 | 67 | ||
| 69 | const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, tmp_output); | 68 | const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, output_buffer); |
| 70 | if (command.is_out != 0) { | 69 | if (command.is_out != 0) { |
| 71 | ctx.WriteBuffer(tmp_output); | 70 | ctx.WriteBuffer(output_buffer); |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | IPC::ResponseBuilder rb{ctx, 3}; | 73 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -90,12 +89,12 @@ void NVDRV::Ioctl2(HLERequestContext& ctx) { | |||
| 90 | 89 | ||
| 91 | const auto input_buffer = ctx.ReadBuffer(0); | 90 | const auto input_buffer = ctx.ReadBuffer(0); |
| 92 | const auto input_inlined_buffer = ctx.ReadBuffer(1); | 91 | const auto input_inlined_buffer = ctx.ReadBuffer(1); |
| 93 | tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); | 92 | output_buffer.resize_destructive(ctx.GetWriteBufferSize(0)); |
| 94 | 93 | ||
| 95 | const auto nv_result = | 94 | const auto nv_result = |
| 96 | nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, tmp_output); | 95 | nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, output_buffer); |
| 97 | if (command.is_out != 0) { | 96 | if (command.is_out != 0) { |
| 98 | ctx.WriteBuffer(tmp_output); | 97 | ctx.WriteBuffer(output_buffer); |
| 99 | } | 98 | } |
| 100 | 99 | ||
| 101 | IPC::ResponseBuilder rb{ctx, 3}; | 100 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -116,12 +115,14 @@ void NVDRV::Ioctl3(HLERequestContext& ctx) { | |||
| 116 | } | 115 | } |
| 117 | 116 | ||
| 118 | const auto input_buffer = ctx.ReadBuffer(0); | 117 | const auto input_buffer = ctx.ReadBuffer(0); |
| 119 | tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); | 118 | output_buffer.resize_destructive(ctx.GetWriteBufferSize(0)); |
| 120 | tmp_output_inline.resize_destructive(ctx.GetWriteBufferSize(1)); | 119 | inline_output_buffer.resize_destructive(ctx.GetWriteBufferSize(1)); |
| 121 | const auto nv_result = nvdrv->Ioctl3(fd, command, input_buffer, tmp_output, tmp_output_inline); | 120 | |
| 121 | const auto nv_result = | ||
| 122 | nvdrv->Ioctl3(fd, command, input_buffer, output_buffer, inline_output_buffer); | ||
| 122 | if (command.is_out != 0) { | 123 | if (command.is_out != 0) { |
| 123 | ctx.WriteBuffer(tmp_output, 0); | 124 | ctx.WriteBuffer(output_buffer, 0); |
| 124 | ctx.WriteBuffer(tmp_output_inline, 1); | 125 | ctx.WriteBuffer(inline_output_buffer, 1); |
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | IPC::ResponseBuilder rb{ctx, 3}; | 128 | IPC::ResponseBuilder rb{ctx, 3}; |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.h b/src/core/hle/service/nvdrv/nvdrv_interface.h index 4b593ff90..6e98115dc 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.h +++ b/src/core/hle/service/nvdrv/nvdrv_interface.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | |||
| 7 | #include "common/scratch_buffer.h" | 8 | #include "common/scratch_buffer.h" |
| 8 | #include "core/hle/service/nvdrv/nvdrv.h" | 9 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| @@ -34,8 +35,8 @@ private: | |||
| 34 | 35 | ||
| 35 | u64 pid{}; | 36 | u64 pid{}; |
| 36 | bool is_initialized{}; | 37 | bool is_initialized{}; |
| 37 | Common::ScratchBuffer<u8> tmp_output; | 38 | Common::ScratchBuffer<u8> output_buffer; |
| 38 | Common::ScratchBuffer<u8> tmp_output_inline; | 39 | Common::ScratchBuffer<u8> inline_output_buffer; |
| 39 | }; | 40 | }; |
| 40 | 41 | ||
| 41 | } // namespace Service::Nvidia | 42 | } // namespace Service::Nvidia |
diff --git a/src/video_core/host1x/codecs/codec.cpp b/src/video_core/host1x/codecs/codec.cpp index cd6a3a9b8..da07a556f 100644 --- a/src/video_core/host1x/codecs/codec.cpp +++ b/src/video_core/host1x/codecs/codec.cpp | |||
| @@ -290,7 +290,7 @@ void Codec::Decode() { | |||
| 290 | return vp9_decoder->GetFrameBytes(); | 290 | return vp9_decoder->GetFrameBytes(); |
| 291 | default: | 291 | default: |
| 292 | ASSERT(false); | 292 | ASSERT(false); |
| 293 | return std::vector<u8>{}; | 293 | return std::span<const u8>{}; |
| 294 | } | 294 | } |
| 295 | }(); | 295 | }(); |
| 296 | AVPacketPtr packet{av_packet_alloc(), AVPacketDeleter}; | 296 | AVPacketPtr packet{av_packet_alloc(), AVPacketDeleter}; |
diff --git a/src/video_core/host1x/codecs/h264.cpp b/src/video_core/host1x/codecs/h264.cpp index ce827eb6c..862904e39 100644 --- a/src/video_core/host1x/codecs/h264.cpp +++ b/src/video_core/host1x/codecs/h264.cpp | |||
| @@ -29,15 +29,15 @@ H264::H264(Host1x::Host1x& host1x_) : host1x{host1x_} {} | |||
| 29 | 29 | ||
| 30 | H264::~H264() = default; | 30 | H264::~H264() = default; |
| 31 | 31 | ||
| 32 | const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state, | 32 | std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state, |
| 33 | bool is_first_frame) { | 33 | bool is_first_frame) { |
| 34 | H264DecoderContext context; | 34 | H264DecoderContext context; |
| 35 | host1x.MemoryManager().ReadBlock(state.picture_info_offset, &context, | 35 | host1x.MemoryManager().ReadBlock(state.picture_info_offset, &context, |
| 36 | sizeof(H264DecoderContext)); | 36 | sizeof(H264DecoderContext)); |
| 37 | 37 | ||
| 38 | const s64 frame_number = context.h264_parameter_set.frame_number.Value(); | 38 | const s64 frame_number = context.h264_parameter_set.frame_number.Value(); |
| 39 | if (!is_first_frame && frame_number != 0) { | 39 | if (!is_first_frame && frame_number != 0) { |
| 40 | frame.resize(context.stream_len); | 40 | frame.resize_destructive(context.stream_len); |
| 41 | host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size()); | 41 | host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size()); |
| 42 | return frame; | 42 | return frame; |
| 43 | } | 43 | } |
| @@ -135,14 +135,14 @@ const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegist | |||
| 135 | for (s32 index = 0; index < 6; index++) { | 135 | for (s32 index = 0; index < 6; index++) { |
| 136 | writer.WriteBit(true); | 136 | writer.WriteBit(true); |
| 137 | std::span<const u8> matrix{context.weight_scale}; | 137 | std::span<const u8> matrix{context.weight_scale}; |
| 138 | writer.WriteScalingList(matrix, index * 16, 16); | 138 | writer.WriteScalingList(scan, matrix, index * 16, 16); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | if (context.h264_parameter_set.transform_8x8_mode_flag) { | 141 | if (context.h264_parameter_set.transform_8x8_mode_flag) { |
| 142 | for (s32 index = 0; index < 2; index++) { | 142 | for (s32 index = 0; index < 2; index++) { |
| 143 | writer.WriteBit(true); | 143 | writer.WriteBit(true); |
| 144 | std::span<const u8> matrix{context.weight_scale_8x8}; | 144 | std::span<const u8> matrix{context.weight_scale_8x8}; |
| 145 | writer.WriteScalingList(matrix, index * 64, 64); | 145 | writer.WriteScalingList(scan, matrix, index * 64, 64); |
| 146 | } | 146 | } |
| 147 | } | 147 | } |
| 148 | 148 | ||
| @@ -188,8 +188,8 @@ void H264BitWriter::WriteBit(bool state) { | |||
| 188 | WriteBits(state ? 1 : 0, 1); | 188 | WriteBits(state ? 1 : 0, 1); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | void H264BitWriter::WriteScalingList(std::span<const u8> list, s32 start, s32 count) { | 191 | void H264BitWriter::WriteScalingList(Common::ScratchBuffer<u8>& scan, std::span<const u8> list, |
| 192 | static Common::ScratchBuffer<u8> scan{}; | 192 | s32 start, s32 count) { |
| 193 | scan.resize_destructive(count); | 193 | scan.resize_destructive(count); |
| 194 | if (count == 16) { | 194 | if (count == 16) { |
| 195 | std::memcpy(scan.data(), zig_zag_scan.data(), scan.size()); | 195 | std::memcpy(scan.data(), zig_zag_scan.data(), scan.size()); |
diff --git a/src/video_core/host1x/codecs/h264.h b/src/video_core/host1x/codecs/h264.h index 5cc86454e..d6b556322 100644 --- a/src/video_core/host1x/codecs/h264.h +++ b/src/video_core/host1x/codecs/h264.h | |||
| @@ -5,9 +5,11 @@ | |||
| 5 | 5 | ||
| 6 | #include <span> | 6 | #include <span> |
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | |||
| 8 | #include "common/bit_field.h" | 9 | #include "common/bit_field.h" |
| 9 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/scratch_buffer.h" | ||
| 11 | #include "video_core/host1x/nvdec_common.h" | 13 | #include "video_core/host1x/nvdec_common.h" |
| 12 | 14 | ||
| 13 | namespace Tegra { | 15 | namespace Tegra { |
| @@ -37,7 +39,8 @@ public: | |||
| 37 | 39 | ||
| 38 | /// Based on section 7.3.2.1.1.1 and Table 7-4 in the H.264 specification | 40 | /// Based on section 7.3.2.1.1.1 and Table 7-4 in the H.264 specification |
| 39 | /// Writes the scaling matrices of the sream | 41 | /// Writes the scaling matrices of the sream |
| 40 | void WriteScalingList(std::span<const u8> list, s32 start, s32 count); | 42 | void WriteScalingList(Common::ScratchBuffer<u8>& scan, std::span<const u8> list, s32 start, |
| 43 | s32 count); | ||
| 41 | 44 | ||
| 42 | /// Return the bitstream as a vector. | 45 | /// Return the bitstream as a vector. |
| 43 | [[nodiscard]] std::vector<u8>& GetByteArray(); | 46 | [[nodiscard]] std::vector<u8>& GetByteArray(); |
| @@ -63,11 +66,12 @@ public: | |||
| 63 | ~H264(); | 66 | ~H264(); |
| 64 | 67 | ||
| 65 | /// Compose the H264 frame for FFmpeg decoding | 68 | /// Compose the H264 frame for FFmpeg decoding |
| 66 | [[nodiscard]] const std::vector<u8>& ComposeFrame( | 69 | [[nodiscard]] std::span<const u8> ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state, |
| 67 | const Host1x::NvdecCommon::NvdecRegisters& state, bool is_first_frame = false); | 70 | bool is_first_frame = false); |
| 68 | 71 | ||
| 69 | private: | 72 | private: |
| 70 | std::vector<u8> frame; | 73 | Common::ScratchBuffer<u8> frame; |
| 74 | Common::ScratchBuffer<u8> scan; | ||
| 71 | Host1x::Host1x& host1x; | 75 | Host1x::Host1x& host1x; |
| 72 | 76 | ||
| 73 | struct H264ParameterSet { | 77 | struct H264ParameterSet { |
diff --git a/src/video_core/host1x/codecs/vp8.cpp b/src/video_core/host1x/codecs/vp8.cpp index 28fb12cb8..ee6392ff9 100644 --- a/src/video_core/host1x/codecs/vp8.cpp +++ b/src/video_core/host1x/codecs/vp8.cpp | |||
| @@ -12,7 +12,7 @@ VP8::VP8(Host1x::Host1x& host1x_) : host1x{host1x_} {} | |||
| 12 | 12 | ||
| 13 | VP8::~VP8() = default; | 13 | VP8::~VP8() = default; |
| 14 | 14 | ||
| 15 | const std::vector<u8>& VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state) { | 15 | std::span<const u8> VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state) { |
| 16 | VP8PictureInfo info; | 16 | VP8PictureInfo info; |
| 17 | host1x.MemoryManager().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo)); | 17 | host1x.MemoryManager().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo)); |
| 18 | 18 | ||
diff --git a/src/video_core/host1x/codecs/vp8.h b/src/video_core/host1x/codecs/vp8.h index 5bf07ecab..7926b73f3 100644 --- a/src/video_core/host1x/codecs/vp8.h +++ b/src/video_core/host1x/codecs/vp8.h | |||
| @@ -4,10 +4,11 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <vector> | 7 | #include <span> |
| 8 | 8 | ||
| 9 | #include "common/common_funcs.h" | 9 | #include "common/common_funcs.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/scratch_buffer.h" | ||
| 11 | #include "video_core/host1x/nvdec_common.h" | 12 | #include "video_core/host1x/nvdec_common.h" |
| 12 | 13 | ||
| 13 | namespace Tegra { | 14 | namespace Tegra { |
| @@ -24,11 +25,11 @@ public: | |||
| 24 | ~VP8(); | 25 | ~VP8(); |
| 25 | 26 | ||
| 26 | /// Compose the VP8 frame for FFmpeg decoding | 27 | /// Compose the VP8 frame for FFmpeg decoding |
| 27 | [[nodiscard]] const std::vector<u8>& ComposeFrame( | 28 | [[nodiscard]] std::span<const u8> ComposeFrame( |
| 28 | const Host1x::NvdecCommon::NvdecRegisters& state); | 29 | const Host1x::NvdecCommon::NvdecRegisters& state); |
| 29 | 30 | ||
| 30 | private: | 31 | private: |
| 31 | std::vector<u8> frame; | 32 | Common::ScratchBuffer<u8> frame; |
| 32 | Host1x::Host1x& host1x; | 33 | Host1x::Host1x& host1x; |
| 33 | 34 | ||
| 34 | struct VP8PictureInfo { | 35 | struct VP8PictureInfo { |
diff --git a/src/video_core/host1x/codecs/vp9.cpp b/src/video_core/host1x/codecs/vp9.cpp index cf40c9012..306c3d0e8 100644 --- a/src/video_core/host1x/codecs/vp9.cpp +++ b/src/video_core/host1x/codecs/vp9.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <algorithm> // for std::copy | 4 | #include <algorithm> // for std::copy |
| 5 | #include <numeric> | 5 | #include <numeric> |
| 6 | |||
| 6 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 7 | #include "video_core/host1x/codecs/vp9.h" | 8 | #include "video_core/host1x/codecs/vp9.h" |
| 8 | #include "video_core/host1x/host1x.h" | 9 | #include "video_core/host1x/host1x.h" |
diff --git a/src/video_core/host1x/codecs/vp9.h b/src/video_core/host1x/codecs/vp9.h index d4083e8d3..f1ed19508 100644 --- a/src/video_core/host1x/codecs/vp9.h +++ b/src/video_core/host1x/codecs/vp9.h | |||
| @@ -4,9 +4,11 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <span> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | 9 | ||
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/scratch_buffer.h" | ||
| 10 | #include "common/stream.h" | 12 | #include "common/stream.h" |
| 11 | #include "video_core/host1x/codecs/vp9_types.h" | 13 | #include "video_core/host1x/codecs/vp9_types.h" |
| 12 | #include "video_core/host1x/nvdec_common.h" | 14 | #include "video_core/host1x/nvdec_common.h" |
| @@ -128,8 +130,8 @@ public: | |||
| 128 | return !current_frame_info.show_frame; | 130 | return !current_frame_info.show_frame; |
| 129 | } | 131 | } |
| 130 | 132 | ||
| 131 | /// Returns a const reference to the composed frame data. | 133 | /// Returns a const span to the composed frame data. |
| 132 | [[nodiscard]] const std::vector<u8>& GetFrameBytes() const { | 134 | [[nodiscard]] std::span<const u8> GetFrameBytes() const { |
| 133 | return frame; | 135 | return frame; |
| 134 | } | 136 | } |
| 135 | 137 | ||
| @@ -181,7 +183,7 @@ private: | |||
| 181 | [[nodiscard]] VpxBitStreamWriter ComposeUncompressedHeader(); | 183 | [[nodiscard]] VpxBitStreamWriter ComposeUncompressedHeader(); |
| 182 | 184 | ||
| 183 | Host1x::Host1x& host1x; | 185 | Host1x::Host1x& host1x; |
| 184 | std::vector<u8> frame; | 186 | Common::ScratchBuffer<u8> frame; |
| 185 | 187 | ||
| 186 | std::array<s8, 4> loop_filter_ref_deltas{}; | 188 | std::array<s8, 4> loop_filter_ref_deltas{}; |
| 187 | std::array<s8, 2> loop_filter_mode_deltas{}; | 189 | std::array<s8, 2> loop_filter_mode_deltas{}; |
diff --git a/src/video_core/host1x/codecs/vp9_types.h b/src/video_core/host1x/codecs/vp9_types.h index adad8ed7e..cc9b25690 100644 --- a/src/video_core/host1x/codecs/vp9_types.h +++ b/src/video_core/host1x/codecs/vp9_types.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | |||
| 8 | #include "common/common_funcs.h" | 9 | #include "common/common_funcs.h" |
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 10 | 11 | ||