codec.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include <vector>
  6. #include "common/common_types.h"
  7. namespace AudioCore::Codec {
  8. enum class PcmFormat : u32 {
  9. Invalid = 0,
  10. Int8 = 1,
  11. Int16 = 2,
  12. Int24 = 3,
  13. Int32 = 4,
  14. PcmFloat = 5,
  15. Adpcm = 6,
  16. };
  17. /// See: Codec::DecodeADPCM
  18. struct ADPCMState {
  19. // Two historical samples from previous processed buffer,
  20. // required for ADPCM decoding
  21. s16 yn1; ///< y[n-1]
  22. s16 yn2; ///< y[n-2]
  23. };
  24. using ADPCM_Coeff = std::array<s16, 16>;
  25. /**
  26. * @param data Pointer to buffer that contains ADPCM data to decode
  27. * @param size Size of buffer in bytes
  28. * @param coeff ADPCM coefficients
  29. * @param state ADPCM state, this is updated with new state
  30. * @return Decoded stereo signed PCM16 data, sample_count in length
  31. */
  32. std::vector<s16> DecodeADPCM(const u8* data, std::size_t size, const ADPCM_Coeff& coeff,
  33. ADPCMState& state);
  34. }; // namespace AudioCore::Codec