diff options
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; |