pcm/export: add #ifdef ENABLE_DSD
This commit is contained in:
parent
ab2e00bc38
commit
dcaf299864
@ -20,11 +20,14 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "PcmExport.hxx"
|
#include "PcmExport.hxx"
|
||||||
#include "Order.hxx"
|
#include "Order.hxx"
|
||||||
#include "PcmDop.hxx"
|
|
||||||
#include "PcmPack.hxx"
|
#include "PcmPack.hxx"
|
||||||
#include "util/ByteReverse.hxx"
|
#include "util/ByteReverse.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
#include "util/ConstBuffer.hxx"
|
||||||
|
|
||||||
|
#ifdef ENABLE_DSD
|
||||||
|
#include "PcmDop.hxx"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -39,11 +42,16 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
|
|||||||
alsa_channel_order = _alsa_channel_order
|
alsa_channel_order = _alsa_channel_order
|
||||||
? sample_format
|
? sample_format
|
||||||
: SampleFormat::UNDEFINED;
|
: SampleFormat::UNDEFINED;
|
||||||
|
|
||||||
|
#ifdef ENABLE_DSD
|
||||||
dop = _dop && sample_format == SampleFormat::DSD;
|
dop = _dop && sample_format == SampleFormat::DSD;
|
||||||
if (dop)
|
if (dop)
|
||||||
/* after the conversion to DoP, the DSD
|
/* after the conversion to DoP, the DSD
|
||||||
samples are stuffed inside fake 24 bit samples */
|
samples are stuffed inside fake 24 bit samples */
|
||||||
sample_format = SampleFormat::S24_P32;
|
sample_format = SampleFormat::S24_P32;
|
||||||
|
#else
|
||||||
|
(void)_dop;
|
||||||
|
#endif
|
||||||
|
|
||||||
shift8 = _shift8 && sample_format == SampleFormat::S24_P32;
|
shift8 = _shift8 && sample_format == SampleFormat::S24_P32;
|
||||||
pack24 = _pack && sample_format == SampleFormat::S24_P32;
|
pack24 = _pack && sample_format == SampleFormat::S24_P32;
|
||||||
@ -69,12 +77,14 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const
|
|||||||
/* packed 24 bit samples (3 bytes per sample) */
|
/* packed 24 bit samples (3 bytes per sample) */
|
||||||
return audio_format.channels * 3;
|
return audio_format.channels * 3;
|
||||||
|
|
||||||
|
#ifdef ENABLE_DSD
|
||||||
if (dop)
|
if (dop)
|
||||||
/* the DSD-over-USB draft says that DSD 1-bit samples
|
/* the DSD-over-USB draft says that DSD 1-bit samples
|
||||||
are enclosed within 24 bit samples, and MPD's
|
are enclosed within 24 bit samples, and MPD's
|
||||||
representation of 24 bit is padded to 32 bit (4
|
representation of 24 bit is padded to 32 bit (4
|
||||||
bytes per sample) */
|
bytes per sample) */
|
||||||
return channels * 4;
|
return channels * 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
return audio_format.GetFrameSize();
|
return audio_format.GetFrameSize();
|
||||||
}
|
}
|
||||||
@ -86,10 +96,12 @@ PcmExport::Export(ConstBuffer<void> data)
|
|||||||
data = ToAlsaChannelOrder(order_buffer, data,
|
data = ToAlsaChannelOrder(order_buffer, data,
|
||||||
alsa_channel_order, channels);
|
alsa_channel_order, channels);
|
||||||
|
|
||||||
|
#ifdef ENABLE_DSD
|
||||||
if (dop)
|
if (dop)
|
||||||
data = pcm_dsd_to_dop(dop_buffer, channels,
|
data = pcm_dsd_to_dop(dop_buffer, channels,
|
||||||
ConstBuffer<uint8_t>::FromVoid(data))
|
ConstBuffer<uint8_t>::FromVoid(data))
|
||||||
.ToVoid();
|
.ToVoid();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pack24) {
|
if (pack24) {
|
||||||
const auto src = ConstBuffer<int32_t>::FromVoid(data);
|
const auto src = ConstBuffer<int32_t>::FromVoid(data);
|
||||||
@ -134,9 +146,11 @@ PcmExport::CalcSourceSize(size_t size) const
|
|||||||
/* 32 bit to 24 bit conversion (4 to 3 bytes) */
|
/* 32 bit to 24 bit conversion (4 to 3 bytes) */
|
||||||
size = (size / 3) * 4;
|
size = (size / 3) * 4;
|
||||||
|
|
||||||
|
#ifdef ENABLE_DSD
|
||||||
if (dop)
|
if (dop)
|
||||||
/* DoP doubles the transport size */
|
/* DoP doubles the transport size */
|
||||||
size /= 2;
|
size /= 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ struct PcmExport {
|
|||||||
*/
|
*/
|
||||||
PcmBuffer order_buffer;
|
PcmBuffer order_buffer;
|
||||||
|
|
||||||
|
#ifdef ENABLE_DSD
|
||||||
/**
|
/**
|
||||||
* The buffer is used to convert DSD samples to the
|
* The buffer is used to convert DSD samples to the
|
||||||
* DoP format.
|
* DoP format.
|
||||||
@ -47,6 +48,7 @@ struct PcmExport {
|
|||||||
* @see #dop
|
* @see #dop
|
||||||
*/
|
*/
|
||||||
PcmBuffer dop_buffer;
|
PcmBuffer dop_buffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The buffer is used to pack samples, removing padding.
|
* The buffer is used to pack samples, removing padding.
|
||||||
@ -77,12 +79,14 @@ struct PcmExport {
|
|||||||
*/
|
*/
|
||||||
SampleFormat alsa_channel_order;
|
SampleFormat alsa_channel_order;
|
||||||
|
|
||||||
|
#ifdef ENABLE_DSD
|
||||||
/**
|
/**
|
||||||
* Convert DSD to DSD-over-PCM (DoP)? Input format must be
|
* Convert DSD to DSD-over-PCM (DoP)? Input format must be
|
||||||
* SampleFormat::DSD and output format must be
|
* SampleFormat::DSD and output format must be
|
||||||
* SampleFormat::S24_P32.
|
* SampleFormat::S24_P32.
|
||||||
*/
|
*/
|
||||||
bool dop;
|
bool dop;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert (padded) 24 bit samples to 32 bit by shifting 8
|
* Convert (padded) 24 bit samples to 32 bit by shifting 8
|
||||||
|
Loading…
Reference in New Issue
Block a user