2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2017-01-11 15:18:57 +01:00
|
|
|
|
|
|
|
#ifndef MPD_PCM_DSD_32_HXX
|
|
|
|
#define MPD_PCM_DSD_32_HXX
|
|
|
|
|
2019-06-17 23:31:52 +02:00
|
|
|
#include "Buffer.hxx"
|
2019-06-18 11:19:27 +02:00
|
|
|
#include "RestBuffer.hxx"
|
2019-06-17 23:31:52 +02:00
|
|
|
|
2020-03-13 01:08:53 +01:00
|
|
|
#include <cstdint>
|
2022-07-04 15:27:03 +02:00
|
|
|
#include <span>
|
2017-01-11 15:18:57 +01:00
|
|
|
|
|
|
|
/**
|
2017-01-11 22:25:54 +01:00
|
|
|
* Convert DSD_U8 to DSD_U32 (native endian, oldest bits in MSB).
|
2017-01-11 15:18:57 +01:00
|
|
|
*/
|
2019-06-17 23:31:52 +02:00
|
|
|
class Dsd32Converter {
|
|
|
|
unsigned channels;
|
|
|
|
|
|
|
|
PcmBuffer buffer;
|
|
|
|
|
2019-06-18 11:19:27 +02:00
|
|
|
PcmRestBuffer<uint8_t, 4> rest_buffer;
|
|
|
|
|
2019-06-17 23:31:52 +02:00
|
|
|
public:
|
|
|
|
void Open(unsigned _channels) noexcept;
|
|
|
|
|
|
|
|
void Reset() noexcept {
|
2019-06-18 11:19:27 +02:00
|
|
|
rest_buffer.Reset();
|
2019-06-17 23:31:52 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 15:32:58 +02:00
|
|
|
/**
|
|
|
|
* @return the size of one input block in bytes
|
|
|
|
*/
|
|
|
|
size_t GetInputBlockSize() const noexcept {
|
|
|
|
return rest_buffer.GetInputBlockSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the size of one output block in bytes
|
|
|
|
*/
|
|
|
|
size_t GetOutputBlockSize() const noexcept {
|
|
|
|
return GetInputBlockSize();
|
|
|
|
}
|
|
|
|
|
2022-07-04 15:27:03 +02:00
|
|
|
std::span<const uint32_t> Convert(std::span<const uint8_t> src) noexcept;
|
2019-06-17 23:31:52 +02:00
|
|
|
};
|
2017-01-11 15:18:57 +01:00
|
|
|
|
|
|
|
#endif
|