Skip to content

Commit

Permalink
Add support for non-interleaved flag
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmikhalin committed Nov 6, 2024
1 parent c33c2b9 commit f733ae8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion externals/LibAtrac9
13 changes: 7 additions & 6 deletions src/core/libraries/ajm/ajm_at9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -72,15 +72,16 @@ std::tuple<u32, u32> AjmAt9Decoder::ProcessData(std::span<u8>& in_buf, SparseOut
switch (m_format) {
case AjmFormatEncoding::S16:
ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast<s16*>(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<s32*>(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<float*>(m_pcm_buffer.data()), &bytes_used);
ret =
Atrac9DecodeF32(m_handle, in_buf.data(), reinterpret_cast<float*>(m_pcm_buffer.data()),
&bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
break;
default:
UNREACHABLE();
Expand Down
9 changes: 8 additions & 1 deletion src/core/libraries/ajm/ajm_at9.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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{};
Expand Down
3 changes: 2 additions & 1 deletion src/core/libraries/ajm/ajm_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AjmAt9Decoder>(AjmFormatEncoding(flags.format));
m_codec = std::make_unique<AjmAt9Decoder>(AjmFormatEncoding(flags.format),
AjmAt9CodecFlags(flags.codec));
break;
}
case AjmCodecType::Mp3Dec: {
Expand Down

0 comments on commit f733ae8

Please sign in to comment.