aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2019-09-19 02:45:11 +0200
committerjduncanator <1518948+jduncanator@users.noreply.github.com>2019-09-19 10:45:11 +1000
commita0720b5681852f3d786d77bd3793b0359dea321c (patch)
tree9d8f61e540d1d1d827999902dad95e5c0c1e076e /Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs
parent4af3101b22e6957d6aa48a2768566d658699f4ed (diff)
Refactoring HOS folder structure (#771)
* Refactoring HOS folder structure Refactoring HOS folder structure: - Added some subfolders when needed (Following structure decided in private). - Added some `Types` folders when needed. - Little cleanup here and there. - Add services placeholders for every HOS services (close #766 and #753). * Remove Types namespaces
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs b/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs
new file mode 100644
index 00000000..ed40cdad
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Audio/IHardwareOpusDecoderManager.cs
@@ -0,0 +1,65 @@
+using Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager;
+
+namespace Ryujinx.HLE.HOS.Services.Audio
+{
+ [Service("hwopus")]
+ class IHardwareOpusDecoderManager : IpcService
+ {
+ public IHardwareOpusDecoderManager(ServiceCtx context) { }
+
+ [Command(0)]
+ // Initialize(bytes<8, 4>, u32, handle<copy>) -> object<nn::codec::detail::IHardwareOpusDecoder>
+ public ResultCode Initialize(ServiceCtx context)
+ {
+ int sampleRate = context.RequestData.ReadInt32();
+ int channelsCount = context.RequestData.ReadInt32();
+
+ MakeObject(context, new IHardwareOpusDecoder(sampleRate, channelsCount));
+
+ return ResultCode.Success;
+ }
+
+ [Command(1)]
+ // GetWorkBufferSize(bytes<8, 4>) -> u32
+ public ResultCode GetWorkBufferSize(ServiceCtx context)
+ {
+ // Note: The sample rate is ignored because it is fixed to 48KHz.
+ int sampleRate = context.RequestData.ReadInt32();
+ int channelsCount = context.RequestData.ReadInt32();
+
+ context.ResponseData.Write(GetOpusDecoderSize(channelsCount));
+
+ return ResultCode.Success;
+ }
+
+ private static int GetOpusDecoderSize(int channelsCount)
+ {
+ const int silkDecoderSize = 0x2198;
+
+ if (channelsCount < 1 || channelsCount > 2)
+ {
+ return 0;
+ }
+
+ int celtDecoderSize = GetCeltDecoderSize(channelsCount);
+
+ int opusDecoderSize = (channelsCount * 0x800 + 0x4807) & -0x800 | 0x50;
+
+ return opusDecoderSize + silkDecoderSize + celtDecoderSize;
+ }
+
+ private static int GetCeltDecoderSize(int channelsCount)
+ {
+ const int decodeBufferSize = 0x2030;
+ const int celtDecoderSize = 0x58;
+ const int celtSigSize = 0x4;
+ const int overlap = 120;
+ const int eBandsCount = 21;
+
+ return (decodeBufferSize + overlap * 4) * channelsCount +
+ eBandsCount * 16 +
+ celtDecoderSize +
+ celtSigSize;
+ }
+ }
+} \ No newline at end of file