summaryrefslogtreecommitdiff
path: root/apps/codecs/libwavpack/unpack.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwavpack/unpack.c')
-rw-r--r--apps/codecs/libwavpack/unpack.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c
index 5bb4467440..dcc9bf5bf9 100644
--- a/apps/codecs/libwavpack/unpack.c
+++ b/apps/codecs/libwavpack/unpack.c
@@ -128,7 +128,7 @@ int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd)
128 signed char *byteptr = wpmd->data; 128 signed char *byteptr = wpmd->data;
129 struct decorr_pass *dpp; 129 struct decorr_pass *dpp;
130 130
131 if (!(wps->wphdr.flags & MONO_DATA)) 131 if (!(wps->wphdr.flags & MONO_FLAG))
132 termcnt /= 2; 132 termcnt /= 2;
133 133
134 if (termcnt > wps->num_terms) 134 if (termcnt > wps->num_terms)
@@ -140,7 +140,7 @@ int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd)
140 while (--dpp >= wps->decorr_passes && termcnt--) { 140 while (--dpp >= wps->decorr_passes && termcnt--) {
141 dpp->weight_A = restore_weight (*byteptr++); 141 dpp->weight_A = restore_weight (*byteptr++);
142 142
143 if (!(wps->wphdr.flags & MONO_DATA)) 143 if (!(wps->wphdr.flags & MONO_FLAG))
144 dpp->weight_B = restore_weight (*byteptr++); 144 dpp->weight_B = restore_weight (*byteptr++);
145 } 145 }
146 146
@@ -170,7 +170,7 @@ int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd)
170 if (wps->wphdr.version == 0x402 && (wps->wphdr.flags & HYBRID_FLAG)) { 170 if (wps->wphdr.version == 0x402 && (wps->wphdr.flags & HYBRID_FLAG)) {
171 byteptr += 2; 171 byteptr += 2;
172 172
173 if (!(wps->wphdr.flags & MONO_DATA)) 173 if (!(wps->wphdr.flags & MONO_FLAG))
174 byteptr += 2; 174 byteptr += 2;
175 } 175 }
176 176
@@ -180,7 +180,7 @@ int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd)
180 dpp->samples_A [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); 180 dpp->samples_A [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8)));
181 byteptr += 4; 181 byteptr += 4;
182 182
183 if (!(wps->wphdr.flags & MONO_DATA)) { 183 if (!(wps->wphdr.flags & MONO_FLAG)) {
184 dpp->samples_B [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); 184 dpp->samples_B [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
185 dpp->samples_B [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); 185 dpp->samples_B [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8)));
186 byteptr += 4; 186 byteptr += 4;
@@ -198,7 +198,7 @@ int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd)
198 dpp->samples_A [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); 198 dpp->samples_A [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
199 byteptr += 2; 199 byteptr += 2;
200 200
201 if (!(wps->wphdr.flags & MONO_DATA)) { 201 if (!(wps->wphdr.flags & MONO_FLAG)) {
202 dpp->samples_B [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); 202 dpp->samples_B [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
203 byteptr += 2; 203 byteptr += 2;
204 } 204 }
@@ -322,7 +322,7 @@ int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_co
322 322
323 ///////////////////// handle version 4 mono data ///////////////////////// 323 ///////////////////// handle version 4 mono data /////////////////////////
324 324
325 if (flags & MONO_DATA) { 325 if (flags & MONO_FLAG) {
326 eptr = buffer + sample_count; 326 eptr = buffer + sample_count;
327 i = get_words (buffer, sample_count, flags, &wps->w, &wps->wvbits); 327 i = get_words (buffer, sample_count, flags, &wps->w, &wps->wvbits);
328 328
@@ -394,20 +394,9 @@ int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_co
394 fixup_samples (wps, buffer, i); 394 fixup_samples (wps, buffer, i);
395 395
396 if (flags & FLOAT_DATA) 396 if (flags & FLOAT_DATA)
397 float_normalize (buffer, (flags & MONO_DATA) ? i : i * 2, 397 float_normalize (buffer, (flags & MONO_FLAG) ? i : i * 2,
398 127 - wps->float_norm_exp + wpc->norm_offset); 398 127 - wps->float_norm_exp + wpc->norm_offset);
399 399
400 if (flags & FALSE_STEREO) {
401 int32_t *dptr = buffer + i * 2;
402 int32_t *sptr = buffer + i;
403 int32_t c = i;
404
405 while (c--) {
406 *--dptr = *--sptr;
407 *--dptr = *sptr;
408 }
409 }
410
411 wps->sample_index += i; 400 wps->sample_index += i;
412 wps->crc = crc; 401 wps->crc = crc;
413 402
@@ -706,12 +695,12 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_
706 shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign) 695 shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign)
707 696
708 if (flags & FLOAT_DATA) { 697 if (flags & FLOAT_DATA) {
709 float_values (wps, buffer, (flags & MONO_DATA) ? sample_count : sample_count * 2); 698 float_values (wps, buffer, (flags & MONO_FLAG) ? sample_count : sample_count * 2);
710 return; 699 return;
711 } 700 }
712 701
713 if (flags & INT32_DATA) { 702 if (flags & INT32_DATA) {
714 uint32_t count = (flags & MONO_DATA) ? sample_count : sample_count * 2; 703 uint32_t count = (flags & MONO_FLAG) ? sample_count : sample_count * 2;
715 int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; 704 int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros;
716 int ones = wps->int32_ones, dups = wps->int32_dups; 705 int ones = wps->int32_ones, dups = wps->int32_dups;
717 int32_t *dptr = buffer; 706 int32_t *dptr = buffer;
@@ -732,7 +721,7 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_
732 } 721 }
733 722
734 if (shift > 0) { 723 if (shift > 0) {
735 if (!(flags & MONO_DATA)) 724 if (!(flags & MONO_FLAG))
736 sample_count *= 2; 725 sample_count *= 2;
737 726
738 while (sample_count--) 727 while (sample_count--)
@@ -741,7 +730,7 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_
741 else if (shift < 0) { 730 else if (shift < 0) {
742 shift = -shift; 731 shift = -shift;
743 732
744 if (!(flags & MONO_DATA)) 733 if (!(flags & MONO_FLAG))
745 sample_count *= 2; 734 sample_count *= 2;
746 735
747 while (sample_count--) 736 while (sample_count--)