codec.h 1.1 KB

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