Commit a756cd95 authored by Max Kellermann's avatar Max Kellermann

decoder/dsf: add constant DSF_BLOCK_SIZE

parent ae27c3f4
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <string.h> #include <string.h>
static constexpr unsigned DSF_BLOCK_SIZE = 4096;
struct DsfMetaData { struct DsfMetaData {
unsigned sample_rate, channels; unsigned sample_rate, channels;
bool bitreverse; bool bitreverse;
...@@ -137,7 +139,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is, ...@@ -137,7 +139,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
uint32_t chblksize = FromLE32(dsf_fmt_chunk.block_size); uint32_t chblksize = FromLE32(dsf_fmt_chunk.block_size);
/* according to the spec block size should always be 4096 */ /* according to the spec block size should always be 4096 */
if (chblksize != 4096) if (chblksize != DSF_BLOCK_SIZE)
return false; return false;
/* read the 'data' chunk of the DSF file */ /* read the 'data' chunk of the DSF file */
...@@ -197,7 +199,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end) ...@@ -197,7 +199,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
static void static void
dsf_to_pcm_order(uint8_t *dest, size_t nrbytes) 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)); assert(nrbytes <= sizeof(scratch));
for (size_t i = 0, j = 0; i < nrbytes; i += 2) { 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) ...@@ -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) { for (size_t i = 1, j = 0; i < nrbytes; i += 2) {
scratch[i] = *(dest+4096+j); scratch[i] = *(dest + DSF_BLOCK_SIZE + j);
j++; j++;
} }
...@@ -222,7 +224,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is, ...@@ -222,7 +224,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
offset_type chunk_size, offset_type chunk_size,
bool bitreverse) bool bitreverse)
{ {
uint8_t buffer[8192]; uint8_t buffer[DSF_BLOCK_SIZE * 2];
const size_t sample_size = sizeof(buffer[0]); const size_t sample_size = sizeof(buffer[0]);
const size_t frame_size = channels * sample_size; const size_t frame_size = channels * sample_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment