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.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c
index af5d71585e..dcc9bf5bf9 100644
--- a/apps/codecs/libwavpack/unpack.c
+++ b/apps/codecs/libwavpack/unpack.c
@@ -35,7 +35,7 @@ int unpack_init (WavpackContext *wpc)
35 WavpackStream *wps = &wpc->stream; 35 WavpackStream *wps = &wpc->stream;
36 WavpackMetadata wpmd; 36 WavpackMetadata wpmd;
37 37
38 if (wps->wphdr.block_samples && wps->wphdr.block_index != (ulong) -1) 38 if (wps->wphdr.block_samples && wps->wphdr.block_index != (uint32_t) -1)
39 wps->sample_index = wps->wphdr.block_index; 39 wps->sample_index = wps->wphdr.block_index;
40 40
41 wps->mute_error = FALSE; 41 wps->mute_error = FALSE;
@@ -237,7 +237,7 @@ int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd)
237{ 237{
238 int bytecnt = wpmd->byte_length, shift = 0; 238 int bytecnt = wpmd->byte_length, shift = 0;
239 char *byteptr = wpmd->data; 239 char *byteptr = wpmd->data;
240 ulong mask = 0; 240 uint32_t mask = 0;
241 241
242 if (!bytecnt || bytecnt > 5) 242 if (!bytecnt || bytecnt > 5)
243 return FALSE; 243 return FALSE;
@@ -245,7 +245,7 @@ int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd)
245 wpc->config.num_channels = *byteptr++; 245 wpc->config.num_channels = *byteptr++;
246 246
247 while (--bytecnt) { 247 while (--bytecnt) {
248 mask |= (ulong) *byteptr++ << shift; 248 mask |= (uint32_t) *byteptr++ << shift;
249 shift += 8; 249 shift += 8;
250 } 250 }
251 251
@@ -262,9 +262,9 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd)
262 262
263 if (bytecnt >= 3) { 263 if (bytecnt >= 3) {
264 wpc->config.flags &= 0xff; 264 wpc->config.flags &= 0xff;
265 wpc->config.flags |= (long) *byteptr++ << 8; 265 wpc->config.flags |= (int32_t) *byteptr++ << 8;
266 wpc->config.flags |= (long) *byteptr++ << 16; 266 wpc->config.flags |= (int32_t) *byteptr++ << 16;
267 wpc->config.flags |= (long) *byteptr << 24; 267 wpc->config.flags |= (int32_t) *byteptr << 24;
268 } 268 }
269 269
270 return TRUE; 270 return TRUE;
@@ -273,7 +273,7 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd)
273// This monster actually unpacks the WavPack bitstream(s) into the specified 273// This monster actually unpacks the WavPack bitstream(s) into the specified
274// buffer as 32-bit integers or floats (depending on orignal data). Lossy 274// buffer as 32-bit integers or floats (depending on orignal data). Lossy
275// samples will be clipped to their original limits (i.e. 8-bit samples are 275// samples will be clipped to their original limits (i.e. 8-bit samples are
276// clipped to -128/+127) but are still returned in longs. It is up to the 276// clipped to -128/+127) but are still returned in int32_ts. It is up to the
277// caller to potentially reformat this for the final output including any 277// caller to potentially reformat this for the final output including any
278// multichannel distribution, block alignment or endian compensation. The 278// multichannel distribution, block alignment or endian compensation. The
279// function unpack_init() must have been called and the entire WavPack block 279// function unpack_init() must have been called and the entire WavPack block
@@ -287,25 +287,25 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd)
287// occurs or the end of the block is reached. 287// occurs or the end of the block is reached.
288 288
289#if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 289#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
290extern void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, long *buffer, long sample_count); 290extern void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count);
291#elif defined(CPU_ARM) && !defined(SIMULATOR) 291#elif defined(CPU_ARM) && !defined(SIMULATOR)
292extern void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, long *buffer, long sample_count); 292extern void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count);
293extern void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, long *buffer, long sample_count); 293extern void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count);
294#else 294#else
295static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count); 295static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count);
296#endif 296#endif
297 297
298static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count); 298static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count);
299static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long sample_count); 299static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count);
300static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count); 300static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count);
301 301
302long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count) 302int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count)
303{ 303{
304 WavpackStream *wps = &wpc->stream; 304 WavpackStream *wps = &wpc->stream;
305 ulong flags = wps->wphdr.flags, crc = wps->crc, i; 305 uint32_t flags = wps->wphdr.flags, crc = wps->crc, i;
306 long mute_limit = (1L << ((flags & MAG_MASK) >> MAG_LSB)) + 2; 306 int32_t mute_limit = (1L << ((flags & MAG_MASK) >> MAG_LSB)) + 2;
307 struct decorr_pass *dpp; 307 struct decorr_pass *dpp;
308 long *bptr, *eptr; 308 int32_t *bptr, *eptr;
309 int tcount; 309 int tcount;
310 310
311 if (wps->sample_index + sample_count > wps->wphdr.block_index + wps->wphdr.block_samples) 311 if (wps->sample_index + sample_count > wps->wphdr.block_index + wps->wphdr.block_samples)
@@ -403,10 +403,10 @@ long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count)
403 return i; 403 return i;
404} 404}
405 405
406static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long sample_count) 406static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count)
407{ 407{
408 long delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; 408 int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B;
409 long *bptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; 409 int32_t *bptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B;
410 int m, k; 410 int m, k;
411 411
412 switch (dpp->term) { 412 switch (dpp->term) {
@@ -462,7 +462,7 @@ static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long samp
462 } 462 }
463 463
464 if (m) { 464 if (m) {
465 long temp_samples [MAX_TERM]; 465 int32_t temp_samples [MAX_TERM];
466 466
467 memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); 467 memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A));
468 468
@@ -520,10 +520,10 @@ static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long samp
520 520
521#if (!defined(CPU_COLDFIRE) && !defined(CPU_ARM)) || defined(SIMULATOR) 521#if (!defined(CPU_COLDFIRE) && !defined(CPU_ARM)) || defined(SIMULATOR)
522 522
523static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count) 523static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count)
524{ 524{
525 long delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; 525 int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B;
526 long *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; 526 int32_t *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B;
527 int k, i; 527 int k, i;
528 528
529 switch (dpp->term) { 529 switch (dpp->term) {
@@ -619,10 +619,10 @@ static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long
619 619
620#endif 620#endif
621 621
622static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count) 622static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count)
623{ 623{
624 long delta = dpp->delta, weight_A = dpp->weight_A; 624 int32_t delta = dpp->delta, weight_A = dpp->weight_A;
625 long *bptr, *eptr = buffer + sample_count, sam_A; 625 int32_t *bptr, *eptr = buffer + sample_count, sam_A;
626 int m, k; 626 int m, k;
627 627
628 switch (dpp->term) { 628 switch (dpp->term) {
@@ -660,7 +660,7 @@ static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample
660 } 660 }
661 661
662 if (m) { 662 if (m) {
663 long temp_samples [MAX_TERM]; 663 int32_t temp_samples [MAX_TERM];
664 664
665 memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); 665 memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A));
666 666
@@ -687,12 +687,12 @@ static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample
687// as 28-bits, and clipping (for lossy mode) has been eliminated because this 687// as 28-bits, and clipping (for lossy mode) has been eliminated because this
688// now happens in the dsp module. 688// now happens in the dsp module.
689 689
690static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count) 690static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count)
691{ 691{
692 ulong flags = wps->wphdr.flags; 692 uint32_t flags = wps->wphdr.flags;
693 int shift = (flags & SHIFT_MASK) >> SHIFT_LSB; 693 int shift = (flags & SHIFT_MASK) >> SHIFT_LSB;
694 694
695 shift += 20 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit data 695 shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign)
696 696
697 if (flags & FLOAT_DATA) { 697 if (flags & FLOAT_DATA) {
698 float_values (wps, buffer, (flags & MONO_FLAG) ? sample_count : sample_count * 2); 698 float_values (wps, buffer, (flags & MONO_FLAG) ? sample_count : sample_count * 2);
@@ -700,10 +700,10 @@ static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count)
700 } 700 }
701 701
702 if (flags & INT32_DATA) { 702 if (flags & INT32_DATA) {
703 ulong count = (flags & MONO_FLAG) ? sample_count : sample_count * 2; 703 uint32_t count = (flags & MONO_FLAG) ? sample_count : sample_count * 2;
704 int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; 704 int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros;
705 int ones = wps->int32_ones, dups = wps->int32_dups; 705 int ones = wps->int32_ones, dups = wps->int32_dups;
706 long *dptr = buffer; 706 int32_t *dptr = buffer;
707 707
708 if (!(flags & HYBRID_FLAG) && !sent_bits && (zeros + ones + dups)) 708 if (!(flags & HYBRID_FLAG) && !sent_bits && (zeros + ones + dups))
709 while (count--) { 709 while (count--) {