diff options
Diffstat (limited to 'apps/codecs/demac/libdemac')
-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 79b5255ce0..2200faf187 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, | |||
91 | #endif | 91 | #endif |
92 | 92 | ||
93 | if ((ape_ctx->channels==1) || (ape_ctx->frameflags & APE_FRAMECODE_PSEUDO_STEREO)) { | 93 | if ((ape_ctx->channels==1) || (ape_ctx->frameflags & APE_FRAMECODE_PSEUDO_STEREO)) { |
94 | if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { | 94 | if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { |
95 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, decoded1, count); | 95 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, decoded1, count); |
96 | /* We are pure silence, so we're done. */ | 96 | /* We are pure silence, so we're done. */ |
97 | return 0; | 97 | return 0; |
98 | } else { | 98 | } else { |
99 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, NULL, count); | 99 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, NULL, count); |
100 | } | 100 | } |
101 | 101 | ||
102 | switch (ape_ctx->compressiontype) | 102 | switch (ape_ctx->compressiontype) |
103 | { | 103 | { |
104 | case 2000: | 104 | case 2000: |
@@ -124,26 +124,23 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, | |||
124 | predictor_decode_mono(&ape_ctx->predictor,decoded0,count); | 124 | predictor_decode_mono(&ape_ctx->predictor,decoded0,count); |
125 | 125 | ||
126 | if (ape_ctx->channels==2) { | 126 | if (ape_ctx->channels==2) { |
127 | /* Pseudo-stereo - just copy left channel to right channel */ | 127 | /* Pseudo-stereo - copy left channel to right channel */ |
128 | while (count--) | 128 | while (count--) |
129 | { | 129 | { |
130 | left = *decoded0; | 130 | left = *decoded0; |
131 | *(decoded1++) = *(decoded0++) = SCALE(left); | 131 | *(decoded1++) = *(decoded0++) = SCALE(left); |
132 | } | 132 | } |
133 | } else { | 133 | } |
134 | /* Mono - do nothing unless it's 8-bit audio */ | 134 | #ifdef ROCKBOX |
135 | if (ape_ctx->bps == 8) { | 135 | else { |
136 | /* TODO: Handle 8-bit streams */ | 136 | /* Scale to output depth */ |
137 | } else { | 137 | while (count--) |
138 | /* Scale to output depth */ | 138 | { |
139 | while (count--) | 139 | left = *decoded0; |
140 | { | 140 | *(decoded0++) = SCALE(left); |
141 | left = *decoded0; | ||
142 | *(decoded0++) = SCALE(left); | ||
143 | } | ||
144 | } | 141 | } |
145 | |||
146 | } | 142 | } |
143 | #endif | ||
147 | } else { /* Stereo */ | 144 | } else { /* Stereo */ |
148 | if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { | 145 | if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { |
149 | /* We are pure silence, so we're done. */ | 146 | /* We are pure silence, so we're done. */ |
@@ -177,18 +174,14 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, | |||
177 | /* Now apply the predictor decoding */ | 174 | /* Now apply the predictor decoding */ |
178 | predictor_decode_stereo(&ape_ctx->predictor,decoded0,decoded1,count); | 175 | predictor_decode_stereo(&ape_ctx->predictor,decoded0,decoded1,count); |
179 | 176 | ||
180 | if (ape_ctx->bps == 8) { | 177 | /* Decorrelate and scale to output depth */ |
181 | /* TODO: Handle 8-bit streams */ | 178 | while (count--) |
182 | } else { | 179 | { |
183 | /* Decorrelate and scale to output depth */ | 180 | left = *decoded1 - (*decoded0 / 2); |
184 | while (count--) | 181 | right = left + *decoded0; |
185 | { | ||
186 | left = *decoded1 - (*decoded0 / 2); | ||
187 | right = left + *decoded0; | ||
188 | 182 | ||
189 | *(decoded0++) = SCALE(left); | 183 | *(decoded0++) = SCALE(left); |
190 | *(decoded1++) = SCALE(right); | 184 | *(decoded1++) = SCALE(right); |
191 | } | ||
192 | } | 185 | } |
193 | } | 186 | } |
194 | return 0; | 187 | return 0; |