diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/libmusepack/decoder.h | 2 | ||||
-rw-r--r-- | apps/codecs/libmusepack/mpc_decoder.c | 31 | ||||
-rw-r--r-- | apps/codecs/libmusepack/musepack.h | 2 |
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 { | |||
67 | mpc_uint32_t Zaehler; /// actual index within read-buffer | 67 | mpc_uint32_t Zaehler; /// actual index within read-buffer |
68 | 68 | ||
69 | mpc_uint32_t samples_to_skip; | 69 | mpc_uint32_t samples_to_skip; |
70 | 70 | mpc_uint32_t last_block_samples; | |
71 | mpc_uint32_t FwdJumpInfo; | 71 | mpc_uint32_t FwdJumpInfo; |
72 | mpc_uint32_t ActDecodePos; | 72 | mpc_uint32_t ActDecodePos; |
73 | 73 | ||
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; |
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" { | |||
58 | 58 | ||
59 | enum { | 59 | enum { |
60 | MPC_FRAME_LENGTH = (36 * 32), /// samples per mpc frame | 60 | MPC_FRAME_LENGTH = (36 * 32), /// samples per mpc frame |
61 | MPC_DECODER_BUFFER_LENGTH = 4 * MPC_FRAME_LENGTH /// required buffer size for decoder | 61 | MPC_DECODER_BUFFER_LENGTH = 2 * MPC_FRAME_LENGTH /// required buffer size for decoder |
62 | }; | 62 | }; |
63 | 63 | ||
64 | // error codes | 64 | // error codes |