2016-03-24 00:12:54 +00:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
2017-12-20 18:44:32 +00:00
|
|
|
#include "audio_core/audio_types.h"
|
2016-03-24 00:12:54 +00:00
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2019-02-18 04:41:48 +00:00
|
|
|
namespace AudioCore::Codec {
|
2016-03-24 00:12:54 +00:00
|
|
|
|
|
|
|
/// 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
|
|
|
|
*/
|
2020-12-07 15:05:45 +00:00
|
|
|
StereoBuffer16 DecodeADPCM(const u8* data, const std::size_t sample_count,
|
2016-09-18 01:38:01 +01:00
|
|
|
const std::array<s16, 16>& adpcm_coeff, ADPCMState& state);
|
2016-03-24 00:12:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2016-09-18 01:38:01 +01:00
|
|
|
StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data,
|
2018-09-06 21:03:28 +01:00
|
|
|
const std::size_t sample_count);
|
2016-03-24 00:12:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2016-09-18 01:38:01 +01:00
|
|
|
StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data,
|
2018-09-06 21:03:28 +01:00
|
|
|
const std::size_t sample_count);
|
2019-02-18 04:41:48 +00:00
|
|
|
} // namespace AudioCore::Codec
|