summaryrefslogtreecommitdiff
path: root/apps/codecs/lib/codeclib.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/lib/codeclib.c')
-rw-r--r--apps/codecs/lib/codeclib.c182
1 files changed, 0 insertions, 182 deletions
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c
deleted file mode 100644
index 36f4279941..0000000000
--- a/apps/codecs/lib/codeclib.c
+++ /dev/null
@@ -1,182 +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/* "helper functions" common to all codecs */
23
24#include <string.h>
25#include "codecs.h"
26#include "dsp.h"
27#include "codeclib.h"
28#include "metadata.h"
29
30/* The following variables are used by codec_malloc() to make use of free RAM
31 * within the statically allocated codec buffer. */
32static size_t mem_ptr = 0;
33static size_t bufsize = 0;
34static unsigned char* mallocbuf = NULL;
35
36int codec_init(void)
37{
38 /* codec_get_buffer() aligns the resulting point to CACHEALIGN_SIZE. */
39 mem_ptr = 0;
40 mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize);
41
42 return 0;
43}
44
45void codec_set_replaygain(const struct mp3entry *id3)
46{
47 ci->configure(DSP_SET_TRACK_GAIN, id3->track_gain);
48 ci->configure(DSP_SET_ALBUM_GAIN, id3->album_gain);
49 ci->configure(DSP_SET_TRACK_PEAK, id3->track_peak);
50 ci->configure(DSP_SET_ALBUM_PEAK, id3->album_peak);
51}
52
53/* Various "helper functions" common to all the xxx2wav decoder plugins */
54
55
56void* codec_malloc(size_t size)
57{
58 void* x;
59
60 if (mem_ptr + (long)size > bufsize)
61 return NULL;
62
63 x=&mallocbuf[mem_ptr];
64
65 /* Keep memory aligned to CACHEALIGN_SIZE. */
66 mem_ptr += (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1);
67
68 return(x);
69}
70
71void* codec_calloc(size_t nmemb, size_t size)
72{
73 void* x;
74 x = codec_malloc(nmemb*size);
75 if (x == NULL)
76 return NULL;
77 ci->memset(x,0,nmemb*size);
78 return(x);
79}
80
81void codec_free(void* ptr) {
82 (void)ptr;
83}
84
85void* codec_realloc(void* ptr, size_t size)
86{
87 void* x;
88 (void)ptr;
89 x = codec_malloc(size);
90 return(x);
91}
92
93size_t strlen(const char *s)
94{
95 return(ci->strlen(s));
96}
97
98char *strcpy(char *dest, const char *src)
99{
100 return(ci->strcpy(dest,src));
101}
102
103char *strcat(char *dest, const char *src)
104{
105 return(ci->strcat(dest,src));
106}
107
108int strcmp(const char *s1, const char *s2)
109{
110 return(ci->strcmp(s1,s2));
111}
112
113void *memcpy(void *dest, const void *src, size_t n)
114{
115 return(ci->memcpy(dest,src,n));
116}
117
118void *memset(void *s, int c, size_t n)
119{
120 return(ci->memset(s,c,n));
121}
122
123int memcmp(const void *s1, const void *s2, size_t n)
124{
125 return(ci->memcmp(s1,s2,n));
126}
127
128void* memchr(const void *s, int c, size_t n)
129{
130 return(ci->memchr(s,c,n));
131}
132
133void *memmove(void *dest, const void *src, size_t n)
134{
135 return(ci->memmove(dest,src,n));
136}
137
138void qsort(void *base, size_t nmemb, size_t size,
139 int(*compar)(const void *, const void *))
140{
141 ci->qsort(base,nmemb,size,compar);
142}
143
144/* From ffmpeg - libavutil/common.h */
145const uint8_t bs_log2_tab[256] ICONST_ATTR = {
146 0,0,1,1,2,2,2,2,3,3,3,3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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
165};
166
167#ifdef RB_PROFILE
168void __cyg_profile_func_enter(void *this_fn, void *call_site) {
169/* This workaround is required for coldfire gcc 3.4 but is broken for 4.4
170 and 4.5, but for those the other way works. */
171#if defined(CPU_COLDFIRE) && defined(__GNUC__) && __GNUC__ < 4
172 (void)call_site;
173 ci->profile_func_enter(this_fn, __builtin_return_address(1));
174#else
175 ci->profile_func_enter(this_fn, call_site);
176#endif
177}
178
179void __cyg_profile_func_exit(void *this_fn, void *call_site) {
180 ci->profile_func_exit(this_fn,call_site);
181}
182#endif