diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2008-12-21 01:29:36 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2008-12-21 01:29:36 +0000 |
| commit | 0bf6e36628291855701de14e8575ac6fa5e25341 (patch) | |
| tree | 2bfc3bac0a01ec753233661033a7ee04de2c3a45 /apps/codecs/demac/libdemac/decoder.c | |
| parent | 558cce602766ee5d9faf6da7d70434e0657fc5b0 (diff) | |
| download | rockbox-0bf6e36628291855701de14e8575ac6fa5e25341.zip rockbox-0bf6e36628291855701de14e8575ac6fa5e25341.tar.gz rockbox-0bf6e36628291855701de14e8575ac6fa5e25341.tar.bz2 rockbox-0bf6e36628291855701de14e8575ac6fa5e25341.tar.xz | |
Fix handling of 8 bit mono and stereo APE files, and also optimise 16 and 24 bit output in the standalone decoder a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19517 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/demac/libdemac/decoder.c')
| -rw-r--r-- | apps/codecs/demac/libdemac/decoder.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/apps/codecs/demac/libdemac/decoder.c b/apps/codecs/demac/libdemac/decoder.c index 79b5255..2200faf 100644 --- a/apps/codecs/demac/libdemac/decoder.c +++ b/apps/codecs/demac/libdemac/decoder.c @@ -91,14 +91,14 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, #endif if ((ape_ctx->channels==1) || (ape_ctx->frameflags & APE_FRAMECODE_PSEUDO_STEREO)) { - if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { + if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, decoded1, count); /* We are pure silence, so we're done. */ return 0; } else { entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, NULL, count); } - + switch (ape_ctx->compressiontype) { case 2000: @@ -124,26 +124,23 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, predictor_decode_mono(&ape_ctx->predictor,decoded0,count); if (ape_ctx->channels==2) { - /* Pseudo-stereo - just copy left channel to right channel */ + /* Pseudo-stereo - copy left channel to right channel */ while (count--) { left = *decoded0; *(decoded1++) = *(decoded0++) = SCALE(left); } - } else { - /* Mono - do nothing unless it's 8-bit audio */ - if (ape_ctx->bps == 8) { - /* TODO: Handle 8-bit streams */ - } else { - /* Scale to output depth */ - while (count--) - { - left = *decoded0; - *(decoded0++) = SCALE(left); - } + } +#ifdef ROCKBOX + else { + /* Scale to output depth */ + while (count--) + { + left = *decoded0; + *(decoded0++) = SCALE(left); } - } +#endif } else { /* Stereo */ if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { /* We are pure silence, so we're done. */ @@ -177,18 +174,14 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, /* Now apply the predictor decoding */ predictor_decode_stereo(&ape_ctx->predictor,decoded0,decoded1,count); - if (ape_ctx->bps == 8) { - /* TODO: Handle 8-bit streams */ - } else { - /* Decorrelate and scale to output depth */ - while (count--) - { - left = *decoded1 - (*decoded0 / 2); - right = left + *decoded0; + /* Decorrelate and scale to output depth */ + while (count--) + { + left = *decoded1 - (*decoded0 / 2); + right = left + *decoded0; - *(decoded0++) = SCALE(left); - *(decoded1++) = SCALE(right); - } + *(decoded0++) = SCALE(left); + *(decoded1++) = SCALE(right); } } return 0; |