pcm/Dsd2Pcm: add class MultiDsd2Pcm
This commit is contained in:
parent
79c585bf03
commit
ee46150329
@ -34,6 +34,7 @@ or implied, of Sebastian Gesemann.
|
|||||||
#include "util/bit_reverse.h"
|
#include "util/bit_reverse.h"
|
||||||
#include "util/GenerateArray.hxx"
|
#include "util/GenerateArray.hxx"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -205,3 +206,16 @@ Dsd2Pcm::Translate(size_t samples,
|
|||||||
}
|
}
|
||||||
fifopos = ffp;
|
fifopos = ffp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MultiDsd2Pcm::Translate(unsigned channels, size_t n_frames,
|
||||||
|
const uint8_t *src, float *dest) noexcept
|
||||||
|
{
|
||||||
|
assert(channels <= per_channel.max_size());
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < channels; ++i) {
|
||||||
|
per_channel[i].Translate(n_frames,
|
||||||
|
src++, channels,
|
||||||
|
dest++, channels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -31,6 +31,10 @@ or implied, of Sebastian Gesemann.
|
|||||||
#ifndef DSD2PCM_H_INCLUDED
|
#ifndef DSD2PCM_H_INCLUDED
|
||||||
#define DSD2PCM_H_INCLUDED
|
#define DSD2PCM_H_INCLUDED
|
||||||
|
|
||||||
|
#include "ChannelDefs.hxx"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -79,5 +83,18 @@ private:
|
|||||||
float TranslateSample(size_t ffp, uint8_t src) noexcept;
|
float TranslateSample(size_t ffp, uint8_t src) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MultiDsd2Pcm {
|
||||||
|
std::array<Dsd2Pcm, MAX_CHANNELS> per_channel;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Reset() noexcept {
|
||||||
|
for (auto &i : per_channel)
|
||||||
|
i.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Translate(unsigned channels, size_t n_frames,
|
||||||
|
const uint8_t *src, float *dest) noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* include guard DSD2PCM_H_INCLUDED */
|
#endif /* include guard DSD2PCM_H_INCLUDED */
|
||||||
|
|
||||||
|
@ -23,31 +23,18 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
void
|
|
||||||
PcmDsd::Reset() noexcept
|
|
||||||
{
|
|
||||||
for (auto &i : dsd2pcm)
|
|
||||||
i.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstBuffer<float>
|
ConstBuffer<float>
|
||||||
PcmDsd::ToFloat(unsigned channels, ConstBuffer<uint8_t> src) noexcept
|
PcmDsd::ToFloat(unsigned channels, ConstBuffer<uint8_t> src) noexcept
|
||||||
{
|
{
|
||||||
assert(!src.IsNull());
|
assert(!src.IsNull());
|
||||||
assert(!src.empty());
|
assert(!src.empty());
|
||||||
assert(src.size % channels == 0);
|
assert(src.size % channels == 0);
|
||||||
assert(channels <= dsd2pcm.max_size());
|
|
||||||
|
|
||||||
const size_t num_samples = src.size;
|
const size_t num_samples = src.size;
|
||||||
const size_t num_frames = src.size / channels;
|
const size_t num_frames = src.size / channels;
|
||||||
|
|
||||||
float *dest = buffer.GetT<float>(num_samples);
|
float *dest = buffer.GetT<float>(num_samples);
|
||||||
|
|
||||||
for (unsigned c = 0; c < channels; ++c) {
|
dsd2pcm.Translate(channels, num_frames, src.data, dest);
|
||||||
dsd2pcm[c].Translate(num_frames,
|
|
||||||
src.data + c, channels,
|
|
||||||
dest + c, channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { dest, num_samples };
|
return { dest, num_samples };
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@
|
|||||||
#define MPD_PCM_DSD_HXX
|
#define MPD_PCM_DSD_HXX
|
||||||
|
|
||||||
#include "Buffer.hxx"
|
#include "Buffer.hxx"
|
||||||
#include "ChannelDefs.hxx"
|
|
||||||
#include "Dsd2Pcm.hxx"
|
#include "Dsd2Pcm.hxx"
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
template<typename T> struct ConstBuffer;
|
template<typename T> struct ConstBuffer;
|
||||||
@ -36,10 +33,12 @@ template<typename T> struct ConstBuffer;
|
|||||||
class PcmDsd {
|
class PcmDsd {
|
||||||
PcmBuffer buffer;
|
PcmBuffer buffer;
|
||||||
|
|
||||||
std::array<Dsd2Pcm, MAX_CHANNELS> dsd2pcm;
|
MultiDsd2Pcm dsd2pcm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Reset() noexcept;
|
void Reset() noexcept {
|
||||||
|
dsd2pcm.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
ConstBuffer<float> ToFloat(unsigned channels,
|
ConstBuffer<float> ToFloat(unsigned channels,
|
||||||
ConstBuffer<uint8_t> src) noexcept;
|
ConstBuffer<uint8_t> src) noexcept;
|
||||||
|
Loading…
Reference in New Issue
Block a user