summaryrefslogtreecommitdiff
path: root/apps/codecs/lib/codeclib.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/lib/codeclib.h')
-rw-r--r--apps/codecs/lib/codeclib.h163
1 files changed, 0 insertions, 163 deletions
diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h
deleted file mode 100644
index d0f985b8e1..0000000000
--- a/apps/codecs/lib/codeclib.h
+++ /dev/null
@@ -1,163 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 Dave Chapman
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __CODECLIB_H__
23#define __CODECLIB_H__
24
25#include <inttypes.h>
26#include <string.h>
27#include "config.h"
28#include "codecs.h"
29#include "mdct.h"
30#include "fft.h"
31
32extern struct codec_api *ci;
33
34/* Standard library functions that are used by the codecs follow here */
35
36/* Get these functions 'out of the way' of the standard functions. Not doing
37 * so confuses the cygwin linker, and maybe others. These functions need to
38 * be implemented elsewhere */
39#define malloc(x) codec_malloc(x)
40#define calloc(x,y) codec_calloc(x,y)
41#define realloc(x,y) codec_realloc(x,y)
42#define free(x) codec_free(x)
43#undef alloca
44#define alloca(x) __builtin_alloca(x)
45
46void* codec_malloc(size_t size);
47void* codec_calloc(size_t nmemb, size_t size);
48void* codec_realloc(void* ptr, size_t size);
49void codec_free(void* ptr);
50
51void *memcpy(void *dest, const void *src, size_t n);
52void *memset(void *s, int c, size_t n);
53int memcmp(const void *s1, const void *s2, size_t n);
54void *memmove(void *s1, const void *s2, size_t n);
55
56size_t strlen(const char *s);
57char *strcpy(char *dest, const char *src);
58char *strcat(char *dest, const char *src);
59
60/* on some platforms strcmp() seems to be a tricky define which
61 * breaks if we write down strcmp's prototype */
62#undef strcmp
63int strcmp(const char *s1, const char *s2);
64
65void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
66
67/*MDCT library functions*/
68/* -1- Tremor mdct */
69extern void mdct_backward(int n, int32_t *in, int32_t *out);
70/* -2- ffmpeg fft-based mdct */
71extern void ff_imdct_half(unsigned int nbits, int32_t *output, const int32_t *input);
72extern void ff_imdct_calc(unsigned int nbits, int32_t *output, const int32_t *input);
73/*ffmpeg fft (can be used without mdct)*/
74extern void ff_fft_calc_c(int nbits, FFTComplex *z);
75
76#if !defined(CPU_ARM) || ARM_ARCH < 5
77/* From libavutil/common.h */
78extern const uint8_t bs_log2_tab[256] ICONST_ATTR;
79extern const uint8_t bs_clz_tab[256] ICONST_ATTR;
80#endif
81
82#define BS_LOG2 0 /* default personality, equivalent floor(log2(x)) */
83#define BS_CLZ 1 /* alternate personality, Count Leading Zeros */
84#define BS_SHORT 2 /* input guaranteed not to exceed 16 bits */
85#define BS_0_0 4 /* guarantee mapping of 0 input to 0 output */
86
87/* Generic bit-scanning function, used to wrap platform CLZ instruction or
88 scan-and-lookup code, and to provide control over output for 0 inputs. */
89static inline unsigned int bs_generic(unsigned int v, int mode)
90{
91#if defined(CPU_ARM) && ARM_ARCH >= 5
92 unsigned int r = __builtin_clz(v);
93 if (mode & BS_CLZ)
94 {
95 if (mode & BS_0_0)
96 r &= 31;
97 } else {
98 r = 31 - r;
99 /* If mode is constant, this is a single conditional instruction */
100 if (mode & BS_0_0 && (signed)r < 0)
101 r += 1;
102 }
103#else
104 const uint8_t *bs_tab;
105 unsigned int r;
106 unsigned int n = v;
107 int inc;
108 /* Set up table, increment, and initial result value based on
109 personality. */
110 if (mode & BS_CLZ)
111 {
112 bs_tab = bs_clz_tab;
113 r = 24;
114 inc = -16;
115 } else {
116 bs_tab = bs_log2_tab;
117 r = 0;
118 inc = 16;
119 }
120 if (!(mode & BS_SHORT) && n >= 0x10000) {
121 n >>= 16;
122 r += inc;
123 }
124 if (n > 0xff) {
125 n >>= 8;
126 r += inc / 2;
127 }
128#ifdef CPU_COLDFIRE
129 /* The high 24 bits of n are guaranteed empty after the above, so a
130 superfluous ext.b instruction can be saved by loading the LUT value over
131 n with asm */
132 asm volatile (
133 "move.b (%1,%0.l),%0"
134 : "+d" (n)
135 : "a" (bs_tab)
136 );
137#else
138 n = bs_tab[n];
139#endif
140 r += n;
141 if (mode & BS_CLZ && mode & BS_0_0 && v == 0)
142 r = 0;
143#endif
144 return r;
145}
146
147/* TODO figure out if we really need to care about calculating
148 av_log2(0) */
149#define av_log2(v) bs_generic(v, BS_0_0)
150
151/* Various codec helper functions */
152
153int codec_init(void);
154void codec_set_replaygain(const struct mp3entry *id3);
155
156#ifdef RB_PROFILE
157void __cyg_profile_func_enter(void *this_fn, void *call_site)
158 NO_PROF_ATTR ICODE_ATTR;
159void __cyg_profile_func_exit(void *this_fn, void *call_site)
160 NO_PROF_ATTR ICODE_ATTR;
161#endif
162
163#endif /* __CODECLIB_H__ */