diff options
author | Thom Johansen <thomj@rockbox.org> | 2006-04-27 23:52:55 +0000 |
---|---|---|
committer | Thom Johansen <thomj@rockbox.org> | 2006-04-27 23:52:55 +0000 |
commit | 43a105aae3047a4a9b7b3f9bae5fd5ea9c3fc118 (patch) | |
tree | ca25445a6686f8e451845a9bb75960e0e2d30ab2 /apps/codecs/libmusepack/mpc_decoder.c | |
parent | a181a4c1eb3b307f5b82e1223a72ee5344937c58 (diff) | |
download | rockbox-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
Diffstat (limited to 'apps/codecs/libmusepack/mpc_decoder.c')
-rw-r--r-- | apps/codecs/libmusepack/mpc_decoder.c | 31 |
1 files changed, 19 insertions, 12 deletions
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) | |||
351 | 351 | ||
352 | mpc_uint32_t FrameBitCnt = 0; | 352 | mpc_uint32_t FrameBitCnt = 0; |
353 | 353 | ||
354 | // output the last part of the last frame here, if needed | ||
355 | if (d->last_block_samples > 0) { | ||
356 | output_frame_length = d->last_block_samples; | ||
357 | d->last_block_samples = 0; // it's going to be handled now, so reset it | ||
358 | if (!d->TrueGaplessPresent) { | ||
359 | mpc_decoder_reset_y(d); | ||
360 | } else { | ||
361 | mpc_decoder_bitstream_read(d, 20); | ||
362 | mpc_decoder_read_bitstream_sv7(d); | ||
363 | mpc_decoder_requantisierung(d, d->Max_Band); | ||
364 | } | ||
365 | mpc_decoder_synthese_filter_float(d, buffer); | ||
366 | return output_frame_length; | ||
367 | } | ||
368 | |||
354 | if (d->DecodedFrames >= d->OverallFrames) { | 369 | if (d->DecodedFrames >= d->OverallFrames) { |
355 | return (mpc_uint32_t)(-1); // end of file -> abort decoding | 370 | return (mpc_uint32_t)(-1); // end of file -> abort decoding |
356 | } | 371 | } |
@@ -403,19 +418,10 @@ mpc_decoder_decode_internal(mpc_decoder *d, MPC_SAMPLE_FORMAT *buffer) | |||
403 | 418 | ||
404 | // additional FilterDecay samples are needed for decay of synthesis filter | 419 | // additional FilterDecay samples are needed for decay of synthesis filter |
405 | if (MPC_DECODER_SYNTH_DELAY + mod_block >= MPC_FRAME_LENGTH) { | 420 | if (MPC_DECODER_SYNTH_DELAY + mod_block >= MPC_FRAME_LENGTH) { |
406 | if (!d->TrueGaplessPresent) { | 421 | // this variable will be checked for at the top of the function |
407 | mpc_decoder_reset_y(d); | 422 | d->last_block_samples = FilterDecay; |
408 | } else { | ||
409 | mpc_decoder_bitstream_read(d, 20); | ||
410 | mpc_decoder_read_bitstream_sv7(d); | ||
411 | mpc_decoder_requantisierung(d, d->Max_Band); | ||
412 | } | ||
413 | |||
414 | mpc_decoder_synthese_filter_float(d, buffer + 2304); | ||
415 | |||
416 | output_frame_length = MPC_FRAME_LENGTH + FilterDecay; | ||
417 | } | 423 | } |
418 | else { // there are only FilterDecay samples needed for this frame | 424 | else { // there are only FilterDecay samples needed for this frame |
419 | output_frame_length = FilterDecay; | 425 | output_frame_length = FilterDecay; |
420 | } | 426 | } |
421 | } | 427 | } |
@@ -1173,6 +1179,7 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r) | |||
1173 | d->OverallFrames = 0; | 1179 | d->OverallFrames = 0; |
1174 | d->DecodedFrames = 0; | 1180 | d->DecodedFrames = 0; |
1175 | d->TrueGaplessPresent = 0; | 1181 | d->TrueGaplessPresent = 0; |
1182 | d->last_block_samples = 0; | ||
1176 | d->WordsRead = 0; | 1183 | d->WordsRead = 0; |
1177 | d->Max_Band = 0; | 1184 | d->Max_Band = 0; |
1178 | d->SampleRate = 0; | 1185 | d->SampleRate = 0; |