diff options
author | MerryMage <MerryMage@users.noreply.github.com> | 2016-03-24 01:12:54 +0100 |
---|---|---|
committer | MerryMage <MerryMage@users.noreply.github.com> | 2016-03-24 04:46:59 +0100 |
commit | efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98 (patch) | |
tree | 566d3fda83b4cb2272b1bf8113ac13e130b4fdcb /src/audio_core/codec.h | |
parent | Merge pull request #1302 from Subv/save_fix (diff) | |
download | yuzu-efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98.tar yuzu-efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98.tar.gz yuzu-efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98.tar.bz2 yuzu-efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98.tar.lz yuzu-efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98.tar.xz yuzu-efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98.tar.zst yuzu-efd1c3f8c3f649b0fa3fec0b236e9a748fc34e98.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/codec.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/audio_core/codec.h b/src/audio_core/codec.h new file mode 100644 index 000000000..e695f2edc --- /dev/null +++ b/src/audio_core/codec.h @@ -0,0 +1,50 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <array> +#include <vector> + +#include "common/common_types.h" + +namespace Codec { + +/// A variable length buffer of signed PCM16 stereo samples. +using StereoBuffer16 = std::vector<std::array<s16, 2>>; + +/// See: Codec::DecodeADPCM +struct ADPCMState { + // Two historical samples from previous processed buffer, + // required for ADPCM decoding + s16 yn1; ///< y[n-1] + s16 yn2; ///< y[n-2] +}; + +/** + * @param data Pointer to buffer that contains ADPCM data to decode + * @param sample_count Length of buffer in terms of number of samples + * @param adpcm_coeff ADPCM coefficients + * @param state ADPCM state, this is updated with new state + * @return Decoded stereo signed PCM16 data, sample_count in length + */ +StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, const std::array<s16, 16>& adpcm_coeff, ADPCMState& state); + +/** + * @param num_channels Number of channels + * @param data Pointer to buffer that contains PCM8 data to decode + * @param sample_count Length of buffer in terms of number of samples + * @return Decoded stereo signed PCM16 data, sample_count in length + */ +StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, const size_t sample_count); + +/** + * @param num_channels Number of channels + * @param data Pointer to buffer that contains PCM16 data to decode + * @param sample_count Length of buffer in terms of number of samples + * @return Decoded stereo signed PCM16 data, sample_count in length + */ +StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data, const size_t sample_count); + +}; |