summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2006-04-27 23:52:55 +0000
committerThom Johansen <thomj@rockbox.org>2006-04-27 23:52:55 +0000
commit43a105aae3047a4a9b7b3f9bae5fd5ea9c3fc118 (patch)
treeca25445a6686f8e451845a9bb75960e0e2d30ab2
parenta181a4c1eb3b307f5b82e1223a72ee5344937c58 (diff)
downloadrockbox-43a105aae3047a4a9b7b3f9bae5fd5ea9c3fc118.tar.gz
rockbox-43a105aae3047a4a9b7b3f9bae5fd5ea9c3fc118.zip
Make libmusepack output the last frame in two passes. Reclaim the IRAM taken in the last commit. Please let me know if you can hear any artifacts or get any broken files from this!
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9825 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libmusepack/decoder.h2
-rw-r--r--apps/codecs/libmusepack/mpc_decoder.c31
-rw-r--r--apps/codecs/libmusepack/musepack.h2
3 files changed, 21 insertions, 14 deletions
diff --git a/apps/codecs/libmusepack/decoder.h b/apps/codecs/libmusepack/decoder.h
index 759670ee72..708533b09e 100644
--- a/apps/codecs/libmusepack/decoder.h
+++ b/apps/codecs/libmusepack/decoder.h
@@ -67,7 +67,7 @@ typedef struct mpc_decoder_t {
mpc_uint32_t Zaehler; /// actual index within read-buffer
mpc_uint32_t samples_to_skip;
-
+ mpc_uint32_t last_block_samples;
mpc_uint32_t FwdJumpInfo;
mpc_uint32_t ActDecodePos;
diff --git a/apps/codecs/libmusepack/mpc_decoder.c b/apps/codecs/libmusepack/mpc_decoder.c
index 1291055327..ee98722a05 100644
--- a/apps/codecs/libmusepack/mpc_decoder.c
+++ b/apps/codecs/libmusepack/mpc_decoder.c
@@ -351,6 +351,21 @@ mpc_decoder_decode_internal(mpc_decoder *d, MPC_SAMPLE_FORMAT *buffer)
mpc_uint32_t FrameBitCnt = 0;
+ // output the last part of the last frame here, if needed
+ if (d->last_block_samples > 0) {
+ output_frame_length = d->last_block_samples;
+ d->last_block_samples = 0; // it's going to be handled now, so reset it
+ if (!d->TrueGaplessPresent) {
+ mpc_decoder_reset_y(d);
+ } else {
+ mpc_decoder_bitstream_read(d, 20);
+ mpc_decoder_read_bitstream_sv7(d);
+ mpc_decoder_requantisierung(d, d->Max_Band);
+ }
+ mpc_decoder_synthese_filter_float(d, buffer);
+ return output_frame_length;
+ }
+
if (d->DecodedFrames >= d->OverallFrames) {
return (mpc_uint32_t)(-1); // end of file -> abort decoding
}
@@ -403,19 +418,10 @@ mpc_decoder_decode_internal(mpc_decoder *d, MPC_SAMPLE_FORMAT *buffer)
// additional FilterDecay samples are needed for decay of synthesis filter
if (MPC_DECODER_SYNTH_DELAY + mod_block >= MPC_FRAME_LENGTH) {
- if (!d->TrueGaplessPresent) {
- mpc_decoder_reset_y(d);
- } else {
- mpc_decoder_bitstream_read(d, 20);
- mpc_decoder_read_bitstream_sv7(d);
- mpc_decoder_requantisierung(d, d->Max_Band);
- }
-
- mpc_decoder_synthese_filter_float(d, buffer + 2304);
-
- output_frame_length = MPC_FRAME_LENGTH + FilterDecay;
+ // this variable will be checked for at the top of the function
+ d->last_block_samples = FilterDecay;
}
- else { // there are only FilterDecay samples needed for this frame
+ else { // there are only FilterDecay samples needed for this frame
output_frame_length = FilterDecay;
}
}
@@ -1173,6 +1179,7 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r)
d->OverallFrames = 0;
d->DecodedFrames = 0;
d->TrueGaplessPresent = 0;
+ d->last_block_samples = 0;
d->WordsRead = 0;
d->Max_Band = 0;
d->SampleRate = 0;
diff --git a/apps/codecs/libmusepack/musepack.h b/apps/codecs/libmusepack/musepack.h
index d631c6d05d..9155f3f74d 100644
--- a/apps/codecs/libmusepack/musepack.h
+++ b/apps/codecs/libmusepack/musepack.h
@@ -58,7 +58,7 @@ extern "C" {
enum {
MPC_FRAME_LENGTH = (36 * 32), /// samples per mpc frame
- MPC_DECODER_BUFFER_LENGTH = 4 * MPC_FRAME_LENGTH /// required buffer size for decoder
+ MPC_DECODER_BUFFER_LENGTH = 2 * MPC_FRAME_LENGTH /// required buffer size for decoder
};
// error codes