decoder/{dsf,dsdiff}: precalculate bit rate

This commit is contained in:
Max Kellermann 2019-09-08 12:52:02 +02:00
parent 0da9c91af2
commit bf49c9e4e2
2 changed files with 4 additions and 2 deletions

View File

@ -362,6 +362,7 @@ dsdiff_decode_chunk(DecoderClient &client, InputStream &is,
unsigned channels, unsigned sample_rate,
const offset_type total_bytes)
{
const unsigned kbit_rate = channels * sample_rate / 1000;
const offset_type start_offset = is.GetOffset();
uint8_t buffer[8192];
@ -408,7 +409,7 @@ dsdiff_decode_chunk(DecoderClient &client, InputStream &is,
bit_reverse_buffer(buffer, buffer + nbytes);
cmd = client.SubmitData(is, buffer, nbytes,
channels * sample_rate / 1000);
kbit_rate);
}
return true;

View File

@ -256,6 +256,7 @@ dsf_decode_chunk(DecoderClient &client, InputStream &is,
offset_type n_blocks,
bool bitreverse)
{
const unsigned kbit_rate = channels * sample_rate / 1000;
const size_t block_size = channels * DSF_BLOCK_SIZE;
const offset_type start_offset = is.GetOffset();
@ -291,7 +292,7 @@ dsf_decode_chunk(DecoderClient &client, InputStream &is,
cmd = client.SubmitData(is,
interleaved_buffer, block_size,
channels * sample_rate / 1000);
kbit_rate);
++i;
}