Add support for non-interleaved flag

This commit is contained in:
Vladislav Mikhalin 2024-11-06 18:53:36 +03:00
parent c33c2b93f3
commit f733ae8b86
4 changed files with 18 additions and 9 deletions

2
externals/LibAtrac9 vendored

@ -1 +1 @@
Subproject commit a350a4b727b14ded8460649779b43d1ad902f373 Subproject commit 3acdcdc78f129c2e6145331ff650fa76dd88d62c

View File

@ -14,8 +14,8 @@ extern "C" {
namespace Libraries::Ajm { namespace Libraries::Ajm {
AjmAt9Decoder::AjmAt9Decoder(AjmFormatEncoding format) AjmAt9Decoder::AjmAt9Decoder(AjmFormatEncoding format, AjmAt9CodecFlags flags)
: m_format(format), m_handle(Atrac9GetHandle()) { : m_format(format), m_flags(flags), m_handle(Atrac9GetHandle()) {
ASSERT_MSG(m_handle, "Atrac9GetHandle failed"); ASSERT_MSG(m_handle, "Atrac9GetHandle failed");
AjmAt9Decoder::Reset(); AjmAt9Decoder::Reset();
} }
@ -72,15 +72,16 @@ std::tuple<u32, u32> AjmAt9Decoder::ProcessData(std::span<u8>& in_buf, SparseOut
switch (m_format) { switch (m_format) {
case AjmFormatEncoding::S16: case AjmFormatEncoding::S16:
ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast<s16*>(m_pcm_buffer.data()), ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast<s16*>(m_pcm_buffer.data()),
&bytes_used); &bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
break; break;
case AjmFormatEncoding::S32: case AjmFormatEncoding::S32:
ret = Atrac9DecodeS32(m_handle, in_buf.data(), reinterpret_cast<s32*>(m_pcm_buffer.data()), ret = Atrac9DecodeS32(m_handle, in_buf.data(), reinterpret_cast<s32*>(m_pcm_buffer.data()),
&bytes_used); &bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
break; break;
case AjmFormatEncoding::Float: case AjmFormatEncoding::Float:
ret = Atrac9DecodeF32(m_handle, in_buf.data(), ret =
reinterpret_cast<float*>(m_pcm_buffer.data()), &bytes_used); Atrac9DecodeF32(m_handle, in_buf.data(), reinterpret_cast<float*>(m_pcm_buffer.data()),
&bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();

View File

@ -14,6 +14,12 @@ namespace Libraries::Ajm {
constexpr s32 ORBIS_AJM_DEC_AT9_MAX_CHANNELS = 8; 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 { struct AjmSidebandDecAt9CodecInfo {
u32 super_frame_size; u32 super_frame_size;
u32 frames_in_super_frame; u32 frames_in_super_frame;
@ -22,7 +28,7 @@ struct AjmSidebandDecAt9CodecInfo {
}; };
struct AjmAt9Decoder final : AjmCodec { struct AjmAt9Decoder final : AjmCodec {
explicit AjmAt9Decoder(AjmFormatEncoding format); explicit AjmAt9Decoder(AjmFormatEncoding format, AjmAt9CodecFlags flags);
~AjmAt9Decoder() override; ~AjmAt9Decoder() override;
void Reset() override; void Reset() override;
@ -45,6 +51,7 @@ private:
} }
const AjmFormatEncoding m_format; const AjmFormatEncoding m_format;
const AjmAt9CodecFlags m_flags;
void* m_handle{}; void* m_handle{};
u8 m_config_data[ORBIS_AT9_CONFIG_DATA_SIZE]{}; u8 m_config_data[ORBIS_AT9_CONFIG_DATA_SIZE]{};
u32 m_superframe_bytes_remain{}; u32 m_superframe_bytes_remain{};

View File

@ -25,7 +25,8 @@ constexpr int ORBIS_AJM_RESULT_FATAL = 0x80000000;
AjmInstance::AjmInstance(AjmCodecType codec_type, AjmInstanceFlags flags) : m_flags(flags) { AjmInstance::AjmInstance(AjmCodecType codec_type, AjmInstanceFlags flags) : m_flags(flags) {
switch (codec_type) { switch (codec_type) {
case AjmCodecType::At9Dec: { case AjmCodecType::At9Dec: {
m_codec = std::make_unique<AjmAt9Decoder>(AjmFormatEncoding(flags.format)); m_codec = std::make_unique<AjmAt9Decoder>(AjmFormatEncoding(flags.format),
AjmAt9CodecFlags(flags.codec));
break; break;
} }
case AjmCodecType::Mp3Dec: { case AjmCodecType::Mp3Dec: {