summaryrefslogtreecommitdiff
path: root/src/pcm
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-06-26 15:32:58 +0200
committerMax Kellermann <max@musicpd.org>2019-06-26 15:49:08 +0200
commit34c6337887bfd5f7d55c3b3cc10a8e74157dc8d4 (patch)
tree88bca7b6ecd3fbb497b7ae74c3d43d83e86a6ecb /src/pcm
parent2093e536414f985886280e361fa5510c492bbf4f (diff)
pcm/Export: add GetInputBlockSize(), GetOutputBlockSize()
Diffstat (limited to 'src/pcm')
-rw-r--r--src/pcm/Dop.hxx14
-rw-r--r--src/pcm/Dsd16.hxx14
-rw-r--r--src/pcm/Dsd32.hxx14
-rw-r--r--src/pcm/Export.cxx46
-rw-r--r--src/pcm/Export.hxx12
-rw-r--r--src/pcm/RestBuffer.hxx7
6 files changed, 107 insertions, 0 deletions
diff --git a/src/pcm/Dop.hxx b/src/pcm/Dop.hxx
index c6b6d2947..92fa0ae72 100644
--- a/src/pcm/Dop.hxx
+++ b/src/pcm/Dop.hxx
@@ -46,6 +46,20 @@ public:
rest_buffer.Reset();
}
+ /**
+ * @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 2 * GetInputBlockSize();
+ }
+
ConstBuffer<uint32_t> Convert(ConstBuffer<uint8_t> src) noexcept;
};
diff --git a/src/pcm/Dsd16.hxx b/src/pcm/Dsd16.hxx
index 18b31b83a..6e00f4039 100644
--- a/src/pcm/Dsd16.hxx
+++ b/src/pcm/Dsd16.hxx
@@ -44,6 +44,20 @@ public:
rest_buffer.Reset();
}
+ /**
+ * @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();
+ }
+
ConstBuffer<uint16_t> Convert(ConstBuffer<uint8_t> src) noexcept;
};
diff --git a/src/pcm/Dsd32.hxx b/src/pcm/Dsd32.hxx
index f6036c527..6a9afb5d4 100644
--- a/src/pcm/Dsd32.hxx
+++ b/src/pcm/Dsd32.hxx
@@ -44,6 +44,20 @@ public:
rest_buffer.Reset();
}
+ /**
+ * @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();
+ }
+
ConstBuffer<uint32_t> Convert(ConstBuffer<uint8_t> src) noexcept;
};
diff --git a/src/pcm/Export.cxx b/src/pcm/Export.cxx
index f70fe8064..ad087d0d8 100644
--- a/src/pcm/Export.cxx
+++ b/src/pcm/Export.cxx
@@ -144,6 +144,52 @@ PcmExport::GetOutputFrameSize() const noexcept
return GetInputFrameSize();
}
+size_t
+PcmExport::GetInputBlockSize() const noexcept
+{
+#ifdef ENABLE_DSD
+ switch (dsd_mode) {
+ case DsdMode::NONE:
+ break;
+
+ case DsdMode::U16:
+ return dsd16_converter.GetInputBlockSize();
+
+ case DsdMode::U32:
+ return dsd32_converter.GetInputBlockSize();
+ break;
+
+ case DsdMode::DOP:
+ return dop_converter.GetInputBlockSize();
+ }
+#endif
+
+ return GetInputFrameSize();
+}
+
+size_t
+PcmExport::GetOutputBlockSize() const noexcept
+{
+#ifdef ENABLE_DSD
+ switch (dsd_mode) {
+ case DsdMode::NONE:
+ break;
+
+ case DsdMode::U16:
+ return dsd16_converter.GetOutputBlockSize();
+
+ case DsdMode::U32:
+ return dsd32_converter.GetOutputBlockSize();
+ break;
+
+ case DsdMode::DOP:
+ return dop_converter.GetOutputBlockSize();
+ }
+#endif
+
+ return GetOutputFrameSize();
+}
+
unsigned
PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const noexcept
{
diff --git a/src/pcm/Export.hxx b/src/pcm/Export.hxx
index 251576e60..b4a8ae9b9 100644
--- a/src/pcm/Export.hxx
+++ b/src/pcm/Export.hxx
@@ -199,6 +199,18 @@ public:
size_t GetOutputFrameSize() const noexcept;
/**
+ * @return the size of one input block in bytes
+ */
+ gcc_pure
+ size_t GetInputBlockSize() const noexcept;
+
+ /**
+ * @return the size of one output block in bytes
+ */
+ gcc_pure
+ size_t GetOutputBlockSize() const noexcept;
+
+ /**
* Export a PCM buffer.
*
* @param src the source PCM buffer
diff --git a/src/pcm/RestBuffer.hxx b/src/pcm/RestBuffer.hxx
index ddcfdfcf8..47ce87903 100644
--- a/src/pcm/RestBuffer.hxx
+++ b/src/pcm/RestBuffer.hxx
@@ -48,6 +48,13 @@ public:
size = 0;
}
+ /**
+ * @return the size of one input block in #T samples
+ */
+ size_t GetInputBlockSize() const noexcept {
+ return capacity;
+ }
+
unsigned GetChannelCount() const noexcept {
return capacity / n_frames;
}