2005-06-05 23:05:10 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Dave Chapman
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-06-05 23:05:10 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2005-06-22 19:41:30 +00:00
|
|
|
/* "helper functions" common to all codecs */
|
2005-06-05 23:05:10 +00:00
|
|
|
|
2008-05-03 21:33:00 +00:00
|
|
|
#include <string.h>
|
2005-10-13 11:32:52 +00:00
|
|
|
#include "codecs.h"
|
2005-09-21 13:09:10 +00:00
|
|
|
#include "dsp.h"
|
2005-06-05 23:05:10 +00:00
|
|
|
#include "codeclib.h"
|
2008-10-15 06:38:51 +00:00
|
|
|
#include "metadata.h"
|
2005-06-05 23:05:10 +00:00
|
|
|
|
2006-03-03 02:27:19 +00:00
|
|
|
long mem_ptr;
|
|
|
|
long bufsize;
|
2005-10-13 11:32:52 +00:00
|
|
|
unsigned char* mp3buf; // The actual MP3 buffer from Rockbox
|
|
|
|
unsigned char* mallocbuf; // 512K from the start of MP3 buffer
|
|
|
|
unsigned char* filebuf; // The rest of the MP3 buffer
|
|
|
|
|
2006-11-26 18:31:41 +00:00
|
|
|
int codec_init(void)
|
2005-06-22 19:41:30 +00:00
|
|
|
{
|
2005-06-05 23:05:10 +00:00
|
|
|
mem_ptr = 0;
|
2006-11-26 18:31:41 +00:00
|
|
|
mallocbuf = (unsigned char *)ci->get_codec_memory((size_t *)&bufsize);
|
2005-06-05 23:05:10 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2005-07-24 15:32:28 +00:00
|
|
|
|
|
|
|
void codec_set_replaygain(struct mp3entry* id3)
|
|
|
|
{
|
2007-02-10 16:47:13 +00:00
|
|
|
ci->configure(DSP_SET_TRACK_GAIN, id3->track_gain);
|
|
|
|
ci->configure(DSP_SET_ALBUM_GAIN, id3->album_gain);
|
|
|
|
ci->configure(DSP_SET_TRACK_PEAK, id3->track_peak);
|
|
|
|
ci->configure(DSP_SET_ALBUM_PEAK, id3->album_peak);
|
2005-07-24 15:32:28 +00:00
|
|
|
}
|
2005-10-13 11:32:52 +00:00
|
|
|
|
|
|
|
/* Various "helper functions" common to all the xxx2wav decoder plugins */
|
|
|
|
|
|
|
|
|
|
|
|
void* codec_malloc(size_t size)
|
|
|
|
{
|
|
|
|
void* x;
|
|
|
|
|
2006-03-03 02:27:19 +00:00
|
|
|
if (mem_ptr + (long)size > bufsize)
|
2005-10-13 11:32:52 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
x=&mallocbuf[mem_ptr];
|
|
|
|
mem_ptr+=(size+3)&~3; /* Keep memory 32-bit aligned */
|
|
|
|
|
|
|
|
return(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* codec_calloc(size_t nmemb, size_t size)
|
|
|
|
{
|
|
|
|
void* x;
|
|
|
|
x = codec_malloc(nmemb*size);
|
|
|
|
if (x == NULL)
|
|
|
|
return NULL;
|
2006-11-26 18:31:41 +00:00
|
|
|
ci->memset(x,0,nmemb*size);
|
2005-10-13 11:32:52 +00:00
|
|
|
return(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void codec_free(void* ptr) {
|
|
|
|
(void)ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* codec_realloc(void* ptr, size_t size)
|
|
|
|
{
|
|
|
|
void* x;
|
|
|
|
(void)ptr;
|
|
|
|
x = codec_malloc(size);
|
|
|
|
return(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t strlen(const char *s)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->strlen(s));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *strcpy(char *dest, const char *src)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->strcpy(dest,src));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *strcat(char *dest, const char *src)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->strcat(dest,src));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int strcmp(const char *s1, const char *s2)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->strcmp(s1,s2));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *memcpy(void *dest, const void *src, size_t n)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->memcpy(dest,src,n));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *memset(void *s, int c, size_t n)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->memset(s,c,n));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int memcmp(const void *s1, const void *s2, size_t n)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->memcmp(s1,s2,n));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void* memchr(const void *s, int c, size_t n)
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->memchr(s,c,n));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
2006-02-06 16:04:01 +00:00
|
|
|
void *memmove(void *dest, const void *src, size_t n)
|
2005-10-13 11:32:52 +00:00
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
return(ci->memmove(dest,src,n));
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void qsort(void *base, size_t nmemb, size_t size,
|
|
|
|
int(*compar)(const void *, const void *))
|
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
ci->qsort(base,nmemb,size,compar);
|
2005-10-13 11:32:52 +00:00
|
|
|
}
|
2006-01-18 20:54:13 +00:00
|
|
|
|
|
|
|
#ifdef RB_PROFILE
|
|
|
|
void __cyg_profile_func_enter(void *this_fn, void *call_site) {
|
2006-03-09 01:37:52 +00:00
|
|
|
#ifdef CPU_COLDFIRE
|
2006-01-18 20:54:13 +00:00
|
|
|
(void)call_site;
|
2006-11-26 18:31:41 +00:00
|
|
|
ci->profile_func_enter(this_fn, __builtin_return_address(1));
|
2006-03-09 01:37:52 +00:00
|
|
|
#else
|
2006-11-26 18:31:41 +00:00
|
|
|
ci->profile_func_enter(this_fn, call_site);
|
2006-03-09 01:37:52 +00:00
|
|
|
#endif
|
2006-01-18 20:54:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void __cyg_profile_func_exit(void *this_fn, void *call_site) {
|
2006-11-26 18:31:41 +00:00
|
|
|
ci->profile_func_exit(this_fn,call_site);
|
2006-01-18 20:54:13 +00:00
|
|
|
}
|
|
|
|
#endif
|