Move c/h files implementing/defining standard library stuff into a new libc directory...
[kugel-rb.git] / apps / codecs / demac / libdemac / demac_config.h
blobf3b293e1d2a51138f8523947a96431ffccab3e38
1 /*
3 libdemac - A Monkey's Audio decoder
5 $Id$
7 Copyright (C) Dave Chapman 2007
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
25 #ifndef _DEMAC_CONFIG_H
26 #define _DEMAC_CONFIG_H
28 /* Build-time choices for libdemac.
29 * Note that this file is included by both .c and .S files. */
31 #ifdef ROCKBOX
33 #include "config.h"
35 #ifndef __ASSEMBLER__
36 #include "codeclib.h"
37 #include <codecs.h>
38 #endif
40 #define APE_OUTPUT_DEPTH 29
42 /* On ARMv4, using 32 bit ints for the filters is faster. */
43 #if defined(CPU_ARM) && (ARM_ARCH == 4)
44 #define FILTER_BITS 32
45 #endif
47 #if !defined(CPU_PP) && !defined(CPU_S5L870X)
48 #define FILTER256_IRAM
49 #endif
51 #if CONFIG_CPU == PP5002 || defined(CPU_S5L870X)
52 /* Code and data IRAM for speed (PP5002 has a broken cache), not enough IRAM
53 * for the insane filter buffer. Reciprocal table for division in IRAM. */
54 #define ICODE_SECTION_DEMAC_ARM .icode
55 #define ICODE_ATTR_DEMAC ICODE_ATTR
56 #define ICONST_ATTR_DEMAC ICONST_ATTR
57 #define IBSS_ATTR_DEMAC IBSS_ATTR
58 #define IBSS_ATTR_DEMAC_INSANEBUF
60 #elif CONFIG_CPU == PP5020
61 /* Code and small data in DRAM for speed (PP5020 IRAM isn't completely single
62 * cycle). Insane filter buffer not in IRAM in favour of reciprocal table for
63 * divison. Decoded data buffers should be in IRAM (defined by the caller). */
64 #define ICODE_SECTION_DEMAC_ARM .text
65 #define ICODE_ATTR_DEMAC
66 #define ICONST_ATTR_DEMAC
67 #define IBSS_ATTR_DEMAC
68 #define IBSS_ATTR_DEMAC_INSANEBUF
70 #elif CONFIG_CPU == PP5022
71 /* Code in DRAM, data in IRAM. Insane filter buffer not in IRAM in favour of
72 * reciprocal table for divison */
73 #define ICODE_SECTION_DEMAC_ARM .text
74 #define ICODE_ATTR_DEMAC
75 #define ICONST_ATTR_DEMAC ICONST_ATTR
76 #define IBSS_ATTR_DEMAC IBSS_ATTR
77 #define IBSS_ATTR_DEMAC_INSANEBUF
79 #else
80 /* Code in DRAM, data in IRAM, including insane filter buffer. */
81 #define ICODE_SECTION_DEMAC_ARM .text
82 #define ICODE_ATTR_DEMAC
83 #define ICONST_ATTR_DEMAC ICONST_ATTR
84 #define IBSS_ATTR_DEMAC IBSS_ATTR
85 #define IBSS_ATTR_DEMAC_INSANEBUF IBSS_ATTR
86 #endif
88 #else /* !ROCKBOX */
90 #define APE_OUTPUT_DEPTH (ape_ctx->bps)
92 #define ICODE_ATTR_DEMAC
93 #define ICONST_ATTR_DEMAC
94 #define IBSS_ATTR_DEMAC
95 #define IBSS_ATTR_DEMAC_INSANEBUF
97 /* Use to give gcc hints on which branch is most likely taken */
98 #if defined(__GNUC__) && __GNUC__ >= 3
99 #define LIKELY(x) __builtin_expect(!!(x), 1)
100 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
101 #else
102 #define LIKELY(x) (x)
103 #define UNLIKELY(x) (x)
104 #endif
106 #endif /* !ROCKBOX */
108 /* Defaults */
110 #ifndef FILTER_HISTORY_SIZE
111 #define FILTER_HISTORY_SIZE 512
112 #endif
114 #ifndef PREDICTOR_HISTORY_SIZE
115 #define PREDICTOR_HISTORY_SIZE 512
116 #endif
118 #ifndef FILTER_BITS
119 #define FILTER_BITS 16
120 #endif
123 #ifndef __ASSEMBLER__
125 #if defined(CPU_ARM) && (ARM_ARCH < 5 || defined(USE_IRAM))
126 /* optimised unsigned integer division for ARMv4, in IRAM */
127 unsigned udiv32_arm(unsigned a, unsigned b);
128 #define UDIV32(a, b) udiv32_arm(a, b)
129 #else
130 /* default */
131 #define UDIV32(a, b) (a / b)
132 #endif
134 #include <inttypes.h>
135 #if FILTER_BITS == 32
136 typedef int32_t filter_int;
137 #elif FILTER_BITS == 16
138 typedef int16_t filter_int;
139 #endif
140 #endif
142 #endif /* _DEMAC_CONFIG_H */