aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-21 17:07:43 +0200
committerMax Kellermann <max@duempel.org>2014-08-21 17:12:43 +0200
commita756cd9565b15ed1f4689ee263c95c209db13e2d (patch)
tree584ebd3976cad1ddd13033bfd45c3471693b634f /src/decoder
parentae27c3f4c5dcd5d6306c68c3fd901c07a9ff4330 (diff)
downloadmpd-a756cd9565b15ed1f4689ee263c95c209db13e2d.tar.gz
mpd-a756cd9565b15ed1f4689ee263c95c209db13e2d.tar.xz
mpd-a756cd9565b15ed1f4689ee263c95c209db13e2d.zip
decoder/dsf: add constant DSF_BLOCK_SIZE
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/plugins/DsfDecoderPlugin.cxx10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/decoder/plugins/DsfDecoderPlugin.cxx b/src/decoder/plugins/DsfDecoderPlugin.cxx
index b02d0179c..9f10b8dfc 100644
--- a/src/decoder/plugins/DsfDecoderPlugin.cxx
+++ b/src/decoder/plugins/DsfDecoderPlugin.cxx
@@ -41,6 +41,8 @@
#include <string.h>
+static constexpr unsigned DSF_BLOCK_SIZE = 4096;
+
struct DsfMetaData {
unsigned sample_rate, channels;
bool bitreverse;
@@ -137,7 +139,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
uint32_t chblksize = FromLE32(dsf_fmt_chunk.block_size);
/* according to the spec block size should always be 4096 */
- if (chblksize != 4096)
+ if (chblksize != DSF_BLOCK_SIZE)
return false;
/* read the 'data' chunk of the DSF file */
@@ -197,7 +199,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
static void
dsf_to_pcm_order(uint8_t *dest, size_t nrbytes)
{
- uint8_t scratch[8192];
+ uint8_t scratch[DSF_BLOCK_SIZE * 2];
assert(nrbytes <= sizeof(scratch));
for (size_t i = 0, j = 0; i < nrbytes; i += 2) {
@@ -206,7 +208,7 @@ dsf_to_pcm_order(uint8_t *dest, size_t nrbytes)
}
for (size_t i = 1, j = 0; i < nrbytes; i += 2) {
- scratch[i] = *(dest+4096+j);
+ scratch[i] = *(dest + DSF_BLOCK_SIZE + j);
j++;
}
@@ -222,7 +224,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
offset_type chunk_size,
bool bitreverse)
{
- uint8_t buffer[8192];
+ uint8_t buffer[DSF_BLOCK_SIZE * 2];
const size_t sample_size = sizeof(buffer[0]);
const size_t frame_size = channels * sample_size;