diff options
author | Dave Bryant <bryant@rockbox.org> | 2006-04-22 22:21:36 +0000 |
---|---|---|
committer | Dave Bryant <bryant@rockbox.org> | 2006-04-22 22:21:36 +0000 |
commit | b76bb60219c08d8321ffe6260072b8291499e79a (patch) | |
tree | 2b36532e7b913a7544712da313864ca29de21d81 /apps/codecs/libwavpack/unpack.c | |
parent | 2ec18b521c845be6ccb18217a877680904db3905 (diff) | |
download | rockbox-b76bb60219c08d8321ffe6260072b8291499e79a.tar.gz rockbox-b76bb60219c08d8321ffe6260072b8291499e79a.zip |
Update libwavpack to the latest stream specification, and cross fingers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9769 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwavpack/unpack.c')
-rw-r--r-- | apps/codecs/libwavpack/unpack.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c index dcc9bf5bf9..5bb4467440 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_FLAG)) | 131 | if (!(wps->wphdr.flags & MONO_DATA)) |
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_FLAG)) | 143 | if (!(wps->wphdr.flags & MONO_DATA)) |
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_FLAG)) | 173 | if (!(wps->wphdr.flags & MONO_DATA)) |
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_FLAG)) { | 183 | if (!(wps->wphdr.flags & MONO_DATA)) { |
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_FLAG)) { | 201 | if (!(wps->wphdr.flags & MONO_DATA)) { |
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_FLAG) { | 325 | if (flags & MONO_DATA) { |
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,9 +394,20 @@ 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_FLAG) ? i : i * 2, | 397 | float_normalize (buffer, (flags & MONO_DATA) ? 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 | |||
400 | wps->sample_index += i; | 411 | wps->sample_index += i; |
401 | wps->crc = crc; | 412 | wps->crc = crc; |
402 | 413 | ||
@@ -695,12 +706,12 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_ | |||
695 | shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign) | 706 | shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign) |
696 | 707 | ||
697 | if (flags & FLOAT_DATA) { | 708 | if (flags & FLOAT_DATA) { |
698 | float_values (wps, buffer, (flags & MONO_FLAG) ? sample_count : sample_count * 2); | 709 | float_values (wps, buffer, (flags & MONO_DATA) ? sample_count : sample_count * 2); |
699 | return; | 710 | return; |
700 | } | 711 | } |
701 | 712 | ||
702 | if (flags & INT32_DATA) { | 713 | if (flags & INT32_DATA) { |
703 | uint32_t count = (flags & MONO_FLAG) ? sample_count : sample_count * 2; | 714 | uint32_t count = (flags & MONO_DATA) ? sample_count : sample_count * 2; |
704 | int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; | 715 | int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; |
705 | int ones = wps->int32_ones, dups = wps->int32_dups; | 716 | int ones = wps->int32_ones, dups = wps->int32_dups; |
706 | int32_t *dptr = buffer; | 717 | int32_t *dptr = buffer; |
@@ -721,7 +732,7 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_ | |||
721 | } | 732 | } |
722 | 733 | ||
723 | if (shift > 0) { | 734 | if (shift > 0) { |
724 | if (!(flags & MONO_FLAG)) | 735 | if (!(flags & MONO_DATA)) |
725 | sample_count *= 2; | 736 | sample_count *= 2; |
726 | 737 | ||
727 | while (sample_count--) | 738 | while (sample_count--) |
@@ -730,7 +741,7 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_ | |||
730 | else if (shift < 0) { | 741 | else if (shift < 0) { |
731 | shift = -shift; | 742 | shift = -shift; |
732 | 743 | ||
733 | if (!(flags & MONO_FLAG)) | 744 | if (!(flags & MONO_DATA)) |
734 | sample_count *= 2; | 745 | sample_count *= 2; |
735 | 746 | ||
736 | while (sample_count--) | 747 | while (sample_count--) |