diff options
author | 2011-01-15 15:54:23 +0100 | |
---|---|---|
committer | 2011-01-22 13:22:50 +0100 | |
commit | 90d9bc02bea0b7d031bd99fa9f4ba3e57d4401fd (patch) | |
tree | 41cfc0c2a254ae9b19b23d2c24f81b36c230f83e /plugins/mpgmad | |
parent | 9eb1aaf36f99ed0564ba507b4d7ff5e7d915369c (diff) |
little mp3 optimization
Diffstat (limited to 'plugins/mpgmad')
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index 3bec56ff..ced16e79 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -781,23 +781,31 @@ cmp3_decode_requested_int16 (mpgmad_info_t *info) { cmp3_skip (info); // copy synthesized samples into readbuffer int idx = info->synth.pcm.length-info->buffer.decode_remaining; - while (info->buffer.decode_remaining > 0 && info->buffer.readsize > 0) { - int16_t sample = MadFixedToSshort (info->synth.pcm.samples[0][idx]); - *((int16_t*)info->buffer.out) = sample; - info->buffer.readsize -= 2; - info->buffer.out += 2; - if (MAD_NCHANNELS(&info->frame.header) == 2 && info->info.fmt.channels == 2) { + if (MAD_NCHANNELS(&info->frame.header) == 2 && info->info.fmt.channels == 2) { + while (info->buffer.decode_remaining > 0 && info->buffer.readsize > 0) { + *((int16_t*)info->buffer.out) = MadFixedToSshort (info->synth.pcm.samples[0][idx]); + info->buffer.readsize -= 2; + info->buffer.out += 2; *((int16_t*)info->buffer.out) = MadFixedToSshort (info->synth.pcm.samples[1][idx]); info->buffer.readsize -= 2; info->buffer.out += 2; + info->buffer.decode_remaining--; + idx++; } - else if (MAD_NCHANNELS(&info->frame.header) == 1 && info->info.fmt.channels == 2) { + } + // workaround for bad mp3s that have both mono and stereo frames + else if (MAD_NCHANNELS(&info->frame.header) == 1 && info->info.fmt.channels == 2) { + while (info->buffer.decode_remaining > 0 && info->buffer.readsize > 0) { + int16_t sample = MadFixedToSshort (info->synth.pcm.samples[0][idx]); *((int16_t*)info->buffer.out) = sample; info->buffer.readsize -= 2; info->buffer.out += 2; + *((int16_t*)info->buffer.out) = sample; + info->buffer.readsize -= 2; + info->buffer.out += 2; + info->buffer.decode_remaining--; + idx++; } - info->buffer.decode_remaining--; - idx++; } assert (info->buffer.readsize >= 0); } |