1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
diff --git a/apps/codecs/demac/libdemac/decoder.c b/apps/codecs/demac/libdemac/decoder.c
index 0763c11..9dd6919 100644
--- a/apps/codecs/demac/libdemac/decoder.c
+++ b/apps/codecs/demac/libdemac/decoder.c
@@ -33,10 +33,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA

 /* Statically allocate the filter buffers */

+#ifdef FILTER256_IRAM
 static filter_int filterbuf32[(32*3 + FILTER_HISTORY_SIZE) * 2]   
                   IBSS_ATTR __attribute__((aligned(16))); /* 2432/4864 bytes */
 static filter_int filterbuf256[(256*3 + FILTER_HISTORY_SIZE) * 2]
                   IBSS_ATTR __attribute__((aligned(16))); /* 5120/10240 bytes */
+#define FILTERBUF64 filterbuf256
+#define FILTERBUF32 filterbuf32
+#define FILTERBUF16 filterbuf32
+#else
+static filter_int filterbuf64[(32*3 + FILTER_HISTORY_SIZE) * 2]   
+                  IBSS_ATTR __attribute__((aligned(16))); /* 2432/4864 bytes */
+static filter_int filterbuf256[(256*3 + FILTER_HISTORY_SIZE) * 2]
+                  __attribute__((aligned(16))); /* 5120/10240 bytes */
+#define FILTERBUF64 filterbuf64
+#define FILTERBUF32 filterbuf64
+#define FILTERBUF16 filterbuf64
+#endif

 /* This is only needed for "insane" files, and no current Rockbox targets
    can hope to decode them in realtime, although the Gigabeat S comes close. */
@@ -57,22 +70,22 @@ void init_frame_decoder(struct ape_ctx_t* ape_ctx,
     switch (ape_ctx->compressiontype)
     {
         case 2000:
-            init_filter_16_11(filterbuf32);
+            init_filter_16_11(FILTERBUF16);
             break;

         case 3000:
-            init_filter_64_11(filterbuf256);
+            init_filter_64_11(FILTERBUF64);
             break;

         case 4000:
             init_filter_256_13(filterbuf256);
-            init_filter_32_10(filterbuf32);
+            init_filter_32_10(FILTERBUF32);
             break;

         case 5000:
             init_filter_1280_15(filterbuf1280);
             init_filter_256_13(filterbuf256);
-            init_filter_16_11(filterbuf32);
+            init_filter_16_11(FILTERBUF32);
     }
 }

diff --git a/apps/codecs/demac/libdemac/demac_config.h b/apps/codecs/demac/libdemac/demac_config.h
index 1beda2b..13166f6 100644
--- a/apps/codecs/demac/libdemac/demac_config.h
+++ b/apps/codecs/demac/libdemac/demac_config.h
@@ -44,6 +44,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 #define FILTER_BITS 32
 #endif

+#if !defined(CPU_PP) && !defined(CPU_S5L870X)
+#define FILTER256_IRAM
+#endif
+
 #if CONFIG_CPU == PP5002
 /* Code in IRAM for speed, not enough IRAM for the insane filter buffer. */
 #define ICODE_SECTION_DEMAC_ARM   .icode
diff --git a/apps/codecs/lib/udiv32_arm.S b/apps/codecs/lib/udiv32_arm.S
index 33ab7a4..1b000f4 100644
--- a/apps/codecs/lib/udiv32_arm.S
+++ b/apps/codecs/lib/udiv32_arm.S
@@ -90,18 +90,18 @@

 #ifdef CPU_PP
 #if CONFIG_CPU == PP5020
-.set recip_max, 5952
+.set recip_max, 8576
 #elif CONFIG_CPU == PP5002
-.set recip_max, 1472
+.set recip_max, 3840
 #else
-.set recip_max, 14208
+.set recip_max, 16384
 #endif
 #elif CONFIG_CPU == AS3525
 .set recip_max, 42752
 #elif CONFIG_CPU == S5L8701
-.set recip_max, 9600
+.set recip_max, 12224
 #elif CONFIG_CPU == S5L8700
-.set recip_max, 5504
+.set recip_max, 8128
 #endif

 udiv32_arm: