From f733ae8b8642c54713bc6d3670b757c4971f066c Mon Sep 17 00:00:00 2001 From: Vladislav Mikhalin Date: Wed, 6 Nov 2024 18:53:36 +0300 Subject: [PATCH] Add support for non-interleaved flag --- externals/LibAtrac9 | 2 +- src/core/libraries/ajm/ajm_at9.cpp | 13 +++++++------ src/core/libraries/ajm/ajm_at9.h | 9 ++++++++- src/core/libraries/ajm/ajm_instance.cpp | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/externals/LibAtrac9 b/externals/LibAtrac9 index a350a4b727..3acdcdc78f 160000 --- a/externals/LibAtrac9 +++ b/externals/LibAtrac9 @@ -1 +1 @@ -Subproject commit a350a4b727b14ded8460649779b43d1ad902f373 +Subproject commit 3acdcdc78f129c2e6145331ff650fa76dd88d62c diff --git a/src/core/libraries/ajm/ajm_at9.cpp b/src/core/libraries/ajm/ajm_at9.cpp index 91a2c86f0e..b945e3cdd8 100644 --- a/src/core/libraries/ajm/ajm_at9.cpp +++ b/src/core/libraries/ajm/ajm_at9.cpp @@ -14,8 +14,8 @@ extern "C" { namespace Libraries::Ajm { -AjmAt9Decoder::AjmAt9Decoder(AjmFormatEncoding format) - : m_format(format), m_handle(Atrac9GetHandle()) { +AjmAt9Decoder::AjmAt9Decoder(AjmFormatEncoding format, AjmAt9CodecFlags flags) + : m_format(format), m_flags(flags), m_handle(Atrac9GetHandle()) { ASSERT_MSG(m_handle, "Atrac9GetHandle failed"); AjmAt9Decoder::Reset(); } @@ -72,15 +72,16 @@ std::tuple AjmAt9Decoder::ProcessData(std::span& in_buf, SparseOut switch (m_format) { case AjmFormatEncoding::S16: ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast(m_pcm_buffer.data()), - &bytes_used); + &bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput)); break; case AjmFormatEncoding::S32: ret = Atrac9DecodeS32(m_handle, in_buf.data(), reinterpret_cast(m_pcm_buffer.data()), - &bytes_used); + &bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput)); break; case AjmFormatEncoding::Float: - ret = Atrac9DecodeF32(m_handle, in_buf.data(), - reinterpret_cast(m_pcm_buffer.data()), &bytes_used); + ret = + Atrac9DecodeF32(m_handle, in_buf.data(), reinterpret_cast(m_pcm_buffer.data()), + &bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput)); break; default: UNREACHABLE(); diff --git a/src/core/libraries/ajm/ajm_at9.h b/src/core/libraries/ajm/ajm_at9.h index ac87b5e499..0864bba147 100644 --- a/src/core/libraries/ajm/ajm_at9.h +++ b/src/core/libraries/ajm/ajm_at9.h @@ -14,6 +14,12 @@ namespace Libraries::Ajm { constexpr s32 ORBIS_AJM_DEC_AT9_MAX_CHANNELS = 8; +enum AjmAt9CodecFlags : u32 { + ParseRiffHeader = 1 << 0, + NonInterleavedOutput = 1 << 8, +}; +DECLARE_ENUM_FLAG_OPERATORS(AjmAt9CodecFlags) + struct AjmSidebandDecAt9CodecInfo { u32 super_frame_size; u32 frames_in_super_frame; @@ -22,7 +28,7 @@ struct AjmSidebandDecAt9CodecInfo { }; struct AjmAt9Decoder final : AjmCodec { - explicit AjmAt9Decoder(AjmFormatEncoding format); + explicit AjmAt9Decoder(AjmFormatEncoding format, AjmAt9CodecFlags flags); ~AjmAt9Decoder() override; void Reset() override; @@ -45,6 +51,7 @@ struct AjmAt9Decoder final : AjmCodec { } const AjmFormatEncoding m_format; + const AjmAt9CodecFlags m_flags; void* m_handle{}; u8 m_config_data[ORBIS_AT9_CONFIG_DATA_SIZE]{}; u32 m_superframe_bytes_remain{}; diff --git a/src/core/libraries/ajm/ajm_instance.cpp b/src/core/libraries/ajm/ajm_instance.cpp index 39b2da4bbf..dc4e631d92 100644 --- a/src/core/libraries/ajm/ajm_instance.cpp +++ b/src/core/libraries/ajm/ajm_instance.cpp @@ -25,7 +25,8 @@ constexpr int ORBIS_AJM_RESULT_FATAL = 0x80000000; AjmInstance::AjmInstance(AjmCodecType codec_type, AjmInstanceFlags flags) : m_flags(flags) { switch (codec_type) { case AjmCodecType::At9Dec: { - m_codec = std::make_unique(AjmFormatEncoding(flags.format)); + m_codec = std::make_unique(AjmFormatEncoding(flags.format), + AjmAt9CodecFlags(flags.codec)); break; } case AjmCodecType::Mp3Dec: {