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.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c
index ae473787a7..5afaac3659 100644
--- a/apps/codecs/libwavpack/unpack.c
+++ b/apps/codecs/libwavpack/unpack.c
@@ -27,7 +27,11 @@ static void strcpy_loc (char *dst, char *src) { while (*src) *dst++ = *src++; *d
27// these macros implement the weight application and update operations 27// these macros implement the weight application and update operations
28// that are at the heart of the decorrelation loops 28// that are at the heart of the decorrelation loops
29 29
30#if 0 // PERFCOND
30#define apply_weight_i(weight, sample) ((weight * sample + 512) >> 10) 31#define apply_weight_i(weight, sample) ((weight * sample + 512) >> 10)
32#else
33#define apply_weight_i(weight, sample) ((((weight * sample) >> 8) + 2) >> 2)
34#endif
31 35
32#define apply_weight_f(weight, sample) (((((sample & 0xffff) * weight) >> 9) + \ 36#define apply_weight_f(weight, sample) (((((sample & 0xffff) * weight) >> 9) + \
33 (((sample & ~0xffff) >> 9) * weight) + 1) >> 1) 37 (((sample & ~0xffff) >> 9) * weight) + 1) >> 1)
@@ -39,7 +43,7 @@ static void strcpy_loc (char *dst, char *src) { while (*src) *dst++ = *src++; *d
39#define apply_weight(weight, sample) ((int32_t)((weight * (int64_t) sample + 512) >> 10)) 43#define apply_weight(weight, sample) ((int32_t)((weight * (int64_t) sample + 512) >> 10))
40#endif 44#endif
41 45
42#if 1 // PERFCOND 46#if 0 // PERFCOND
43#define update_weight(weight, delta, source, result) \ 47#define update_weight(weight, delta, source, result) \
44 if (source && result) weight -= ((((source ^ result) >> 30) & 2) - 1) * delta; 48 if (source && result) weight -= ((((source ^ result) >> 30) & 2) - 1) * delta;
45#else 49#else
@@ -315,9 +319,14 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd)
315// samples unpacked, which can be less than the number requested if an error 319// samples unpacked, which can be less than the number requested if an error
316// occurs or the end of the block is reached. 320// occurs or the end of the block is reached.
317 321
322#if CONFIG_CPU==MCF5249 && !defined(SIMULATOR)
323extern void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, long *buffer, long sample_count);
324#else
325static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count);
326#endif
327
318static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count); 328static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count);
319static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long sample_count); 329static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long sample_count);
320static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count);
321static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count); 330static void fixup_samples (WavpackStream *wps, long *buffer, ulong sample_count);
322 331
323long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count) 332long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count)
@@ -372,7 +381,11 @@ long unpack_samples (WavpackContext *wpc, long *buffer, ulong sample_count)
372 else 381 else
373 for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { 382 for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) {
374 decorr_stereo_pass (dpp, buffer, 8); 383 decorr_stereo_pass (dpp, buffer, 8);
384#if CONFIG_CPU==MCF5249 && !defined(SIMULATOR)
385 decorr_stereo_pass_cont_mcf5249 (dpp, buffer + 16, sample_count - 8);
386#else
375 decorr_stereo_pass_cont (dpp, buffer + 16, sample_count - 8); 387 decorr_stereo_pass_cont (dpp, buffer + 16, sample_count - 8);
388#endif
376 } 389 }
377 390
378 if (flags & JOINT_STEREO) 391 if (flags & JOINT_STEREO)
@@ -530,11 +543,13 @@ static void decorr_stereo_pass (struct decorr_pass *dpp, long *buffer, long samp
530 dpp->weight_B = weight_B; 543 dpp->weight_B = weight_B;
531} 544}
532 545
546#if CONFIG_CPU != MCF5249 || defined(SIMULATOR)
547
533static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count) 548static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long sample_count)
534{ 549{
535 long delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; 550 long delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B;
536 long *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; 551 long *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B;
537 int k; 552 int k, i;
538 553
539 switch (dpp->term) { 554 switch (dpp->term) {
540 555
@@ -581,23 +596,11 @@ static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long
581 update_weight (weight_B, delta, tptr [1], sam_A); 596 update_weight (weight_B, delta, tptr [1], sam_A);
582 } 597 }
583 598
584 k = dpp->term; 599 for (k = dpp->term - 1, i = 8; i--; k--) {
585 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-1]; 600 dpp->samples_B [k & (MAX_TERM - 1)] = *--bptr;
586 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-2]; 601 dpp->samples_A [k & (MAX_TERM - 1)] = *--bptr;
587 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-3]; 602 }
588 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-4]; 603
589 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-5];
590 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-6];
591 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-7];
592 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-8];
593 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-9];
594 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-10];
595 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-11];
596 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-12];
597 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-13];
598 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-14];
599 dpp->samples_B [--k & (MAX_TERM - 1)] = bptr [-15];
600 dpp->samples_A [ k & (MAX_TERM - 1)] = bptr [-16];
601 break; 604 break;
602 605
603 case -1: 606 case -1:
@@ -639,6 +642,8 @@ static void decorr_stereo_pass_cont (struct decorr_pass *dpp, long *buffer, long
639 dpp->weight_B = weight_B; 642 dpp->weight_B = weight_B;
640} 643}
641 644
645#endif
646
642static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count) 647static void decorr_mono_pass (struct decorr_pass *dpp, long *buffer, long sample_count)
643{ 648{
644 long delta = dpp->delta, weight_A = dpp->weight_A; 649 long delta = dpp->delta, weight_A = dpp->weight_A;