forked from len0rd/rockbox
FS#6357, patch 1: let iramcopy and bss share the same space in codecs and
plugins. Currently, in case of plugins using IRAM bss is cleared twice, once in the loader, once in PLUGIN_IRAM_INIT. For codecs, bss is cleared only during codec initialization. Also, removed double variables in codecs storing a pointer to codec_api. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11606 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8ef3c8a342
commit
80da8b141c
33 changed files with 190 additions and 437 deletions
|
@ -243,9 +243,6 @@ int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,
|
||||||
int copy_n;
|
int copy_n;
|
||||||
|
|
||||||
if ((char *)&codecbuf[0] != codecptr) {
|
if ((char *)&codecbuf[0] != codecptr) {
|
||||||
/* zero out codec buffer to ensure a properly zeroed bss area */
|
|
||||||
memset(codecbuf, 0, CODEC_SIZE);
|
|
||||||
|
|
||||||
size = MIN(size, CODEC_SIZE);
|
size = MIN(size, CODEC_SIZE);
|
||||||
copy_n = MIN(size, bufwrap);
|
copy_n = MIN(size, bufwrap);
|
||||||
memcpy(codecbuf, codecptr, copy_n);
|
memcpy(codecbuf, codecptr, copy_n);
|
||||||
|
@ -308,9 +305,6 @@ int codec_load_file(const char *plugin, struct codec_api *api)
|
||||||
|
|
||||||
codec_get_full_path(path, plugin);
|
codec_get_full_path(path, plugin);
|
||||||
|
|
||||||
/* zero out codec buffer to ensure a properly zeroed bss area */
|
|
||||||
memset(codecbuf, 0, CODEC_SIZE);
|
|
||||||
|
|
||||||
fd = open(path, O_RDONLY);
|
fd = open(path, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snprintf(msgbuf, sizeof(msgbuf)-1, "Couldn't load codec: %s", path);
|
snprintf(msgbuf, sizeof(msgbuf)-1, "Couldn't load codec: %s", path);
|
||||||
|
|
|
@ -61,9 +61,9 @@
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(SIMULATOR)
|
#if defined(DEBUG) || defined(SIMULATOR)
|
||||||
#undef DEBUGF
|
#undef DEBUGF
|
||||||
#define DEBUGF rb->debugf
|
#define DEBUGF ci->debugf
|
||||||
#undef LDEBUGF
|
#undef LDEBUGF
|
||||||
#define LDEBUGF rb->debugf
|
#define LDEBUGF ci->debugf
|
||||||
#else
|
#else
|
||||||
#define DEBUGF(...)
|
#define DEBUGF(...)
|
||||||
#define LDEBUGF(...)
|
#define LDEBUGF(...)
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
#ifdef ROCKBOX_HAS_LOGF
|
#ifdef ROCKBOX_HAS_LOGF
|
||||||
#undef LOGF
|
#undef LOGF
|
||||||
#define LOGF rb->logf
|
#define LOGF ci->logf
|
||||||
#else
|
#else
|
||||||
#define LOGF(...)
|
#define LOGF(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -66,7 +66,7 @@ $(OBJDIR)/mp3_enc.elf: $(OBJDIR)/mp3_enc.o
|
||||||
$(OBJDIR)/wav_enc.elf: $(OBJDIR)/wav_enc.o
|
$(OBJDIR)/wav_enc.elf: $(OBJDIR)/wav_enc.o
|
||||||
$(OBJDIR)/wavpack_enc.elf: $(OBJDIR)/wavpack_enc.o $(BUILDDIR)/libwavpack.a
|
$(OBJDIR)/wavpack_enc.elf: $(OBJDIR)/wavpack_enc.o $(BUILDDIR)/libwavpack.a
|
||||||
|
|
||||||
$(OBJDIR)/%.elf:
|
$(OBJDIR)/%.elf: $(OBJDIR)/codec_crt0.o
|
||||||
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -O -nostdlib -o $@ $^ -L$(BUILDDIR) -lcodec -lgcc -T$(LINKCODEC) -Wl,-Map,$(OBJDIR)/$*.map
|
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -O -nostdlib -o $@ $^ -L$(BUILDDIR) -lcodec -lgcc -T$(LINKCODEC) -Wl,-Map,$(OBJDIR)/$*.map
|
||||||
|
|
||||||
$(OBJDIR)/%.codec : $(OBJDIR)/%.elf
|
$(OBJDIR)/%.codec : $(OBJDIR)/%.elf
|
||||||
|
@ -77,8 +77,8 @@ ifeq ($(SIMVER), x11)
|
||||||
###################################################
|
###################################################
|
||||||
# This is the X11 simulator version
|
# This is the X11 simulator version
|
||||||
|
|
||||||
$(OBJDIR)/%.codec : $(OBJDIR)/%.o $(BUILDDIR)/libcodec.a $(OUTPUT)
|
$(OBJDIR)/%.codec : $(OBJDIR)/%.o $(OBJDIR)/codec_crt0.o $(BUILDDIR)/libcodec.a $(OUTPUT)
|
||||||
$(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@
|
$(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< $(OBJDIR)/codec_crt0.o -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@
|
||||||
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
|
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
|
||||||
# 'x' must be kept or you'll have "Win32 error 5"
|
# 'x' must be kept or you'll have "Win32 error 5"
|
||||||
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
|
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
|
||||||
|
@ -92,8 +92,8 @@ ifeq ($(SIMVER), sdl)
|
||||||
###################################################
|
###################################################
|
||||||
# This is the SDL simulator version
|
# This is the SDL simulator version
|
||||||
|
|
||||||
$(OBJDIR)/%.codec : $(OBJDIR)/%.o $(BUILDDIR)/libcodec.a $(OUTPUT)
|
$(OBJDIR)/%.codec : $(OBJDIR)/%.o $(OBJDIR)/codec_crt0.o $(BUILDDIR)/libcodec.a $(OUTPUT)
|
||||||
$(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@
|
$(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< $(OBJDIR)/codec_crt0.o -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@
|
||||||
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
|
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
|
||||||
# 'x' must be kept or you'll have "Win32 error 5"
|
# 'x' must be kept or you'll have "Win32 error 5"
|
||||||
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
|
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
|
||||||
|
@ -108,9 +108,9 @@ else # end of sdl-simulator
|
||||||
DLLTOOLFLAGS = --export-all
|
DLLTOOLFLAGS = --export-all
|
||||||
DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin
|
DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin
|
||||||
|
|
||||||
$(OBJDIR)/%.codec : $(OBJDIR)/%.o $(BUILDDIR)/libcodec.a $(OUTPUT)
|
$(OBJDIR)/%.codec : $(OBJDIR)/%.o $(OBJDIR)/codec_crt0.o $(BUILDDIR)/libcodec.a $(OUTPUT)
|
||||||
$(call PRINTS,DLL $(@F))$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
|
$(call PRINTS,DLL $(@F))$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $< $(OBJDIR)/codec_crt0.o
|
||||||
$(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< \
|
$(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(OBJDIR)/codec_crt0.o\
|
||||||
$(BUILDDIR)/libcodec.a $(patsubst -l%,$(BUILDDIR)/lib%.a,$(CODECLIBS)) \
|
$(BUILDDIR)/libcodec.a $(patsubst -l%,$(BUILDDIR)/lib%.a,$(CODECLIBS)) \
|
||||||
-o $@
|
-o $@
|
||||||
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
|
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
|
||||||
|
|
|
@ -28,8 +28,6 @@ CODEC_HEADER
|
||||||
|
|
||||||
#define A52_SAMPLESPERFRAME (6*256)
|
#define A52_SAMPLESPERFRAME (6*256)
|
||||||
|
|
||||||
struct codec_api *ci;
|
|
||||||
|
|
||||||
static a52_state_t *state;
|
static a52_state_t *state;
|
||||||
unsigned long samplesdone;
|
unsigned long samplesdone;
|
||||||
unsigned long frequency;
|
unsigned long frequency;
|
||||||
|
@ -117,16 +115,8 @@ void a52_decode_data(uint8_t *start, uint8_t *end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
unsigned char *filebuf;
|
unsigned char *filebuf;
|
||||||
|
@ -134,19 +124,12 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED);
|
ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED);
|
||||||
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28);
|
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28);
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128));
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
retval = CODEC_ERROR;
|
retval = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,19 +25,8 @@
|
||||||
|
|
||||||
CODEC_HEADER
|
CODEC_HEADER
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct codec_api* rb;
|
|
||||||
struct codec_api* ci;
|
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
/* Note that when dealing with QuickTime/MPEG4 files, terminology is
|
/* Note that when dealing with QuickTime/MPEG4 files, terminology is
|
||||||
* a bit confusing. Files with sound are split up in chunks, where
|
* a bit confusing. Files with sound are split up in chunks, where
|
||||||
|
@ -62,14 +51,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
unsigned char c = 0;
|
unsigned char c = 0;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16));
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
|
|
||||||
|
@ -79,7 +60,7 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
next_track:
|
next_track:
|
||||||
err = CODEC_OK;
|
err = CODEC_OK;
|
||||||
|
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
LOGF("FAAD: Codec init error\n");
|
LOGF("FAAD: Codec init error\n");
|
||||||
err = CODEC_ERROR;
|
err = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -90,8 +71,8 @@ next_track:
|
||||||
|
|
||||||
sound_samples_done = ci->id3->offset;
|
sound_samples_done = ci->id3->offset;
|
||||||
|
|
||||||
ci->configure(DSP_SWITCH_FREQUENCY, (long *)(rb->id3->frequency));
|
ci->configure(DSP_SWITCH_FREQUENCY, (long *)(ci->id3->frequency));
|
||||||
codec_set_replaygain(rb->id3);
|
codec_set_replaygain(ci->id3);
|
||||||
|
|
||||||
stream_create(&input_stream,ci);
|
stream_create(&input_stream,ci);
|
||||||
|
|
||||||
|
@ -139,7 +120,7 @@ next_track:
|
||||||
|
|
||||||
/* The main decoding loop */
|
/* The main decoding loop */
|
||||||
while (i < demux_res.num_sample_byte_sizes) {
|
while (i < demux_res.num_sample_byte_sizes) {
|
||||||
rb->yield();
|
ci->yield();
|
||||||
|
|
||||||
if (ci->stop_codec || ci->new_track) {
|
if (ci->stop_codec || ci->new_track) {
|
||||||
break;
|
break;
|
||||||
|
@ -195,12 +176,12 @@ next_track:
|
||||||
ci->advance_buffer(n);
|
ci->advance_buffer(n);
|
||||||
|
|
||||||
/* Output the audio */
|
/* Output the audio */
|
||||||
rb->yield();
|
ci->yield();
|
||||||
while (!rb->pcmbuf_insert_split(decoder->time_out[0],
|
while (!ci->pcmbuf_insert_split(decoder->time_out[0],
|
||||||
decoder->time_out[1],
|
decoder->time_out[1],
|
||||||
frame_info.samples * 2))
|
frame_info.samples * 2))
|
||||||
{
|
{
|
||||||
rb->sleep(1);
|
ci->sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the elapsed-time indicator */
|
/* Update the elapsed-time indicator */
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
|
|
||||||
CODEC_HEADER
|
CODEC_HEADER
|
||||||
|
|
||||||
struct codec_api *rb;
|
|
||||||
|
|
||||||
/* Maximum number of bytes to process in one iteration */
|
/* Maximum number of bytes to process in one iteration */
|
||||||
#define WAV_CHUNK_SIZE (1024*2)
|
#define WAV_CHUNK_SIZE (1024*2)
|
||||||
|
|
||||||
|
@ -38,9 +36,8 @@ struct codec_api *rb;
|
||||||
static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR;
|
static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR;
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
struct codec_api *ci;
|
|
||||||
int channels;
|
int channels;
|
||||||
int sampleswritten, i;
|
int sampleswritten, i;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
@ -56,16 +53,13 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
off_t chanstart, bufoff;
|
off_t chanstart, bufoff;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
/* we only render 16 bits */
|
/* we only render 16 bits */
|
||||||
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)16);
|
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)16);
|
||||||
/*ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));*/
|
/*ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));*/
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
DEBUGF("ADX: next_track\n");
|
DEBUGF("ADX: next_track\n");
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
return CODEC_ERROR;
|
return CODEC_ERROR;
|
||||||
}
|
}
|
||||||
DEBUGF("ADX: after init\n");
|
DEBUGF("ADX: after init\n");
|
||||||
|
|
|
@ -25,8 +25,6 @@ CODEC_HEADER
|
||||||
/* Macro that sign extends an unsigned byte */
|
/* Macro that sign extends an unsigned byte */
|
||||||
#define SE(x) ((int32_t)((int8_t)(x)))
|
#define SE(x) ((int32_t)((int8_t)(x)))
|
||||||
|
|
||||||
struct codec_api *rb;
|
|
||||||
|
|
||||||
/* This codec supports AIFF files with the following formats:
|
/* This codec supports AIFF files with the following formats:
|
||||||
* - PCM, 8, 16 and 24 bits, mono or stereo
|
* - PCM, 8, 16 and 24 bits, mono or stereo
|
||||||
*/
|
*/
|
||||||
|
@ -43,19 +41,10 @@ enum
|
||||||
/* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */
|
/* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */
|
||||||
#define AIF_CHUNK_SIZE (1024*2)
|
#define AIF_CHUNK_SIZE (1024*2)
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int32_t samples[AIF_CHUNK_SIZE] IBSS_ATTR;
|
static int32_t samples[AIF_CHUNK_SIZE] IBSS_ATTR;
|
||||||
|
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
struct codec_api *ci;
|
|
||||||
uint32_t numbytes, bytesdone;
|
uint32_t numbytes, bytesdone;
|
||||||
uint16_t num_channels = 0;
|
uint16_t num_channels = 0;
|
||||||
uint32_t num_sample_frames = 0;
|
uint32_t num_sample_frames = 0;
|
||||||
|
@ -73,20 +62,12 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
off_t firstblockposn; /* position of the first block in file */
|
off_t firstblockposn; /* position of the first block in file */
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28);
|
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28);
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
i = CODEC_ERROR;
|
i = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,6 @@
|
||||||
|
|
||||||
CODEC_ENC_HEADER
|
CODEC_ENC_HEADER
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct aiff_header
|
struct aiff_header
|
||||||
{
|
{
|
||||||
uint8_t form_id[4]; /* 00h - 'FORM' */
|
uint8_t form_id[4]; /* 00h - 'FORM' */
|
||||||
|
@ -77,7 +69,6 @@ struct aiff_header aiff_header =
|
||||||
|
|
||||||
/* (*) updated when finalizing file */
|
/* (*) updated when finalizing file */
|
||||||
|
|
||||||
static struct codec_api *ci;
|
|
||||||
static int num_channels;
|
static int num_channels;
|
||||||
uint32_t sample_rate;
|
uint32_t sample_rate;
|
||||||
uint32_t enc_size;
|
uint32_t enc_size;
|
||||||
|
@ -332,17 +323,10 @@ static bool init_encoder(void)
|
||||||
} /* init_encoder */
|
} /* init_encoder */
|
||||||
|
|
||||||
/* main codec entry point */
|
/* main codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_start(void)
|
||||||
{
|
{
|
||||||
bool cpu_boosted;
|
bool cpu_boosted;
|
||||||
|
|
||||||
ci = api; /* copy to global api pointer */
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!init_encoder())
|
if (!init_encoder())
|
||||||
{
|
{
|
||||||
ci->enc_codec_loaded = -1;
|
ci->enc_codec_loaded = -1;
|
||||||
|
|
|
@ -23,21 +23,10 @@
|
||||||
|
|
||||||
CODEC_HEADER
|
CODEC_HEADER
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE] IBSS_ATTR;
|
int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE] IBSS_ATTR;
|
||||||
|
|
||||||
struct codec_api* rb;
|
|
||||||
struct codec_api* ci;
|
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
demux_res_t demux_res;
|
demux_res_t demux_res;
|
||||||
|
@ -53,14 +42,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
|
||||||
rb->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
@ -69,7 +50,7 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
|
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
LOGF("ALAC: Error initialising codec\n");
|
LOGF("ALAC: Error initialising codec\n");
|
||||||
retval = CODEC_ERROR;
|
retval = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -78,8 +59,8 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
while (!*ci->taginfo_ready && !ci->stop_codec)
|
while (!*ci->taginfo_ready && !ci->stop_codec)
|
||||||
ci->sleep(1);
|
ci->sleep(1);
|
||||||
|
|
||||||
ci->configure(DSP_SWITCH_FREQUENCY, (long *)(rb->id3->frequency));
|
ci->configure(DSP_SWITCH_FREQUENCY, (long *)(ci->id3->frequency));
|
||||||
codec_set_replaygain(rb->id3);
|
codec_set_replaygain(ci->id3);
|
||||||
|
|
||||||
stream_create(&input_stream,ci);
|
stream_create(&input_stream,ci);
|
||||||
|
|
||||||
|
@ -99,7 +80,7 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
samplesdone=0;
|
samplesdone=0;
|
||||||
/* The main decoding loop */
|
/* The main decoding loop */
|
||||||
while (i < demux_res.num_sample_byte_sizes) {
|
while (i < demux_res.num_sample_byte_sizes) {
|
||||||
rb->yield();
|
ci->yield();
|
||||||
if (ci->stop_codec || ci->new_track) {
|
if (ci->stop_codec || ci->new_track) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -132,18 +113,18 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decode one block - returned samples will be host-endian */
|
/* Decode one block - returned samples will be host-endian */
|
||||||
rb->yield();
|
ci->yield();
|
||||||
samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, rb->yield);
|
samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, ci->yield);
|
||||||
|
|
||||||
/* Advance codec buffer n bytes */
|
/* Advance codec buffer n bytes */
|
||||||
ci->advance_buffer(n);
|
ci->advance_buffer(n);
|
||||||
|
|
||||||
/* Output the audio */
|
/* Output the audio */
|
||||||
rb->yield();
|
ci->yield();
|
||||||
while(!ci->pcmbuf_insert_split(outputbuffer[0],
|
while(!ci->pcmbuf_insert_split(outputbuffer[0],
|
||||||
outputbuffer[1],
|
outputbuffer[1],
|
||||||
samplesdecoded*sizeof(int32_t)))
|
samplesdecoded*sizeof(int32_t)))
|
||||||
rb->yield();
|
ci->yield();
|
||||||
|
|
||||||
/* Update the elapsed-time indicator */
|
/* Update the elapsed-time indicator */
|
||||||
samplesdone+=sample_duration;
|
samplesdone+=sample_duration;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
extern struct codec_api *ci;
|
||||||
|
|
||||||
/* Get these functions 'out of the way' of the standard functions. Not doing
|
/* Get these functions 'out of the way' of the standard functions. Not doing
|
||||||
* so confuses the cygwin linker, and maybe others. These functions need to
|
* so confuses the cygwin linker, and maybe others. These functions need to
|
||||||
* be implemented elsewhere */
|
* be implemented elsewhere */
|
||||||
|
|
46
apps/codecs/codec_crt0.c
Normal file
46
apps/codecs/codec_crt0.c
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Tomasz Malesinski
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "codeclib.h"
|
||||||
|
|
||||||
|
struct codec_api *ci;
|
||||||
|
|
||||||
|
extern unsigned char iramcopy[];
|
||||||
|
extern unsigned char iramstart[];
|
||||||
|
extern unsigned char iramend[];
|
||||||
|
extern unsigned char iedata[];
|
||||||
|
extern unsigned char iend[];
|
||||||
|
extern unsigned char plugin_bss_start[];
|
||||||
|
extern unsigned char plugin_end_addr[];
|
||||||
|
|
||||||
|
extern enum codec_status codec_main(void);
|
||||||
|
|
||||||
|
enum codec_status codec_start(struct codec_api *api)
|
||||||
|
{
|
||||||
|
#ifndef SIMULATOR
|
||||||
|
#ifdef USE_IRAM
|
||||||
|
api->memcpy(iramstart, iramcopy, iramend - iramstart);
|
||||||
|
api->memset(iedata, 0, iend - iedata);
|
||||||
|
#endif
|
||||||
|
api->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start);
|
||||||
|
#endif
|
||||||
|
ci = api;
|
||||||
|
return codec_main();
|
||||||
|
}
|
|
@ -22,17 +22,6 @@
|
||||||
|
|
||||||
CODEC_HEADER
|
CODEC_HEADER
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct codec_api* rb;
|
|
||||||
struct codec_api* ci;
|
|
||||||
|
|
||||||
/* The output buffers containing the decoded samples (channels 0 and 1) */
|
/* The output buffers containing the decoded samples (channels 0 and 1) */
|
||||||
int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0;
|
int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0;
|
||||||
int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR;
|
int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR;
|
||||||
|
@ -423,7 +412,7 @@ bool flac_seek_offset(FLACContext* fc, uint32_t offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
int8_t *buf;
|
int8_t *buf;
|
||||||
FLACContext fc;
|
FLACContext fc;
|
||||||
|
@ -436,14 +425,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
@ -455,7 +436,7 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
/* Need to save offset for later use (cleared indirectly by flac_init) */
|
/* Need to save offset for later use (cleared indirectly by flac_init) */
|
||||||
samplesdone=ci->id3->offset;
|
samplesdone=ci->id3->offset;
|
||||||
|
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
LOGF("FLAC: Error initialising codec\n");
|
LOGF("FLAC: Error initialising codec\n");
|
||||||
retval = CODEC_ERROR;
|
retval = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
|
@ -24,29 +24,26 @@
|
||||||
#include "codeclib.h"
|
#include "codeclib.h"
|
||||||
#include "id3.h"
|
#include "id3.h"
|
||||||
|
|
||||||
struct codec_api *local_rb;
|
|
||||||
|
|
||||||
long mem_ptr;
|
long mem_ptr;
|
||||||
long bufsize;
|
long bufsize;
|
||||||
unsigned char* mp3buf; // The actual MP3 buffer from Rockbox
|
unsigned char* mp3buf; // The actual MP3 buffer from Rockbox
|
||||||
unsigned char* mallocbuf; // 512K from the start of MP3 buffer
|
unsigned char* mallocbuf; // 512K from the start of MP3 buffer
|
||||||
unsigned char* filebuf; // The rest of the MP3 buffer
|
unsigned char* filebuf; // The rest of the MP3 buffer
|
||||||
|
|
||||||
int codec_init(struct codec_api* rb)
|
int codec_init(void)
|
||||||
{
|
{
|
||||||
local_rb = rb;
|
|
||||||
mem_ptr = 0;
|
mem_ptr = 0;
|
||||||
mallocbuf = (unsigned char *)rb->get_codec_memory((size_t *)&bufsize);
|
mallocbuf = (unsigned char *)ci->get_codec_memory((size_t *)&bufsize);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void codec_set_replaygain(struct mp3entry* id3)
|
void codec_set_replaygain(struct mp3entry* id3)
|
||||||
{
|
{
|
||||||
local_rb->configure(DSP_SET_TRACK_GAIN, (long *) id3->track_gain);
|
ci->configure(DSP_SET_TRACK_GAIN, (long *) id3->track_gain);
|
||||||
local_rb->configure(DSP_SET_ALBUM_GAIN, (long *) id3->album_gain);
|
ci->configure(DSP_SET_ALBUM_GAIN, (long *) id3->album_gain);
|
||||||
local_rb->configure(DSP_SET_TRACK_PEAK, (long *) id3->track_peak);
|
ci->configure(DSP_SET_TRACK_PEAK, (long *) id3->track_peak);
|
||||||
local_rb->configure(DSP_SET_ALBUM_PEAK, (long *) id3->album_peak);
|
ci->configure(DSP_SET_ALBUM_PEAK, (long *) id3->album_peak);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Various "helper functions" common to all the xxx2wav decoder plugins */
|
/* Various "helper functions" common to all the xxx2wav decoder plugins */
|
||||||
|
@ -71,7 +68,7 @@ void* codec_calloc(size_t nmemb, size_t size)
|
||||||
x = codec_malloc(nmemb*size);
|
x = codec_malloc(nmemb*size);
|
||||||
if (x == NULL)
|
if (x == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
local_rb->memset(x,0,nmemb*size);
|
ci->memset(x,0,nmemb*size);
|
||||||
return(x);
|
return(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,71 +86,71 @@ void* codec_realloc(void* ptr, size_t size)
|
||||||
|
|
||||||
size_t strlen(const char *s)
|
size_t strlen(const char *s)
|
||||||
{
|
{
|
||||||
return(local_rb->strlen(s));
|
return(ci->strlen(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strcpy(char *dest, const char *src)
|
char *strcpy(char *dest, const char *src)
|
||||||
{
|
{
|
||||||
return(local_rb->strcpy(dest,src));
|
return(ci->strcpy(dest,src));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strcat(char *dest, const char *src)
|
char *strcat(char *dest, const char *src)
|
||||||
{
|
{
|
||||||
return(local_rb->strcat(dest,src));
|
return(ci->strcat(dest,src));
|
||||||
}
|
}
|
||||||
|
|
||||||
int strcmp(const char *s1, const char *s2)
|
int strcmp(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
return(local_rb->strcmp(s1,s2));
|
return(ci->strcmp(s1,s2));
|
||||||
}
|
}
|
||||||
|
|
||||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||||
{
|
{
|
||||||
return(local_rb->strncasecmp(s1,s2,n));
|
return(ci->strncasecmp(s1,s2,n));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *memcpy(void *dest, const void *src, size_t n)
|
void *memcpy(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
return(local_rb->memcpy(dest,src,n));
|
return(ci->memcpy(dest,src,n));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *memset(void *s, int c, size_t n)
|
void *memset(void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
return(local_rb->memset(s,c,n));
|
return(ci->memset(s,c,n));
|
||||||
}
|
}
|
||||||
|
|
||||||
int memcmp(const void *s1, const void *s2, size_t n)
|
int memcmp(const void *s1, const void *s2, size_t n)
|
||||||
{
|
{
|
||||||
return(local_rb->memcmp(s1,s2,n));
|
return(ci->memcmp(s1,s2,n));
|
||||||
}
|
}
|
||||||
|
|
||||||
void* memchr(const void *s, int c, size_t n)
|
void* memchr(const void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
return(local_rb->memchr(s,c,n));
|
return(ci->memchr(s,c,n));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *memmove(void *dest, const void *src, size_t n)
|
void *memmove(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
return(local_rb->memmove(dest,src,n));
|
return(ci->memmove(dest,src,n));
|
||||||
}
|
}
|
||||||
|
|
||||||
void qsort(void *base, size_t nmemb, size_t size,
|
void qsort(void *base, size_t nmemb, size_t size,
|
||||||
int(*compar)(const void *, const void *))
|
int(*compar)(const void *, const void *))
|
||||||
{
|
{
|
||||||
local_rb->qsort(base,nmemb,size,compar);
|
ci->qsort(base,nmemb,size,compar);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RB_PROFILE
|
#ifdef RB_PROFILE
|
||||||
void __cyg_profile_func_enter(void *this_fn, void *call_site) {
|
void __cyg_profile_func_enter(void *this_fn, void *call_site) {
|
||||||
#ifdef CPU_COLDFIRE
|
#ifdef CPU_COLDFIRE
|
||||||
(void)call_site;
|
(void)call_site;
|
||||||
local_rb->profile_func_enter(this_fn, __builtin_return_address(1));
|
ci->profile_func_enter(this_fn, __builtin_return_address(1));
|
||||||
#else
|
#else
|
||||||
local_rb->profile_func_enter(this_fn, call_site);
|
ci->profile_func_enter(this_fn, call_site);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cyg_profile_func_exit(void *this_fn, void *call_site) {
|
void __cyg_profile_func_exit(void *this_fn, void *call_site) {
|
||||||
local_rb->profile_func_exit(this_fn,call_site);
|
ci->profile_func_exit(this_fn,call_site);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#define MALLOC_BUFSIZE (512*1024)
|
#define MALLOC_BUFSIZE (512*1024)
|
||||||
|
|
||||||
|
extern struct codec_api *ci;
|
||||||
extern long mem_ptr;
|
extern long mem_ptr;
|
||||||
extern long bufsize;
|
extern long bufsize;
|
||||||
extern unsigned char* mp3buf; // The actual MP3 buffer from Rockbox
|
extern unsigned char* mp3buf; // The actual MP3 buffer from Rockbox
|
||||||
|
@ -55,7 +56,7 @@ void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, con
|
||||||
|
|
||||||
/* Various codec helper functions */
|
/* Various codec helper functions */
|
||||||
|
|
||||||
int codec_init(struct codec_api* rb);
|
int codec_init(void);
|
||||||
void codec_set_replaygain(struct mp3entry* id3);
|
void codec_set_replaygain(struct mp3entry* id3);
|
||||||
|
|
||||||
#ifdef RB_PROFILE
|
#ifdef RB_PROFILE
|
||||||
|
|
|
@ -53,14 +53,6 @@ CODEC_ENC_HEADER
|
||||||
#define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \
|
#define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \
|
||||||
else { putbits(cc, sz); cc = c; sz = s; }
|
else { putbits(cc, sz); cc = c; sz = s; }
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */
|
int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */
|
||||||
int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */
|
int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */
|
||||||
|
@ -181,7 +173,6 @@ static unsigned pcm_chunk_size IBSS_ATTR;
|
||||||
static unsigned samp_per_frame IBSS_ATTR;
|
static unsigned samp_per_frame IBSS_ATTR;
|
||||||
|
|
||||||
static config_t cfg IBSS_ATTR;
|
static config_t cfg IBSS_ATTR;
|
||||||
static struct codec_api *ci;
|
|
||||||
static char *res_buffer;
|
static char *res_buffer;
|
||||||
|
|
||||||
static const uint8_t ht_count_const[2][2][16] =
|
static const uint8_t ht_count_const[2][2][16] =
|
||||||
|
@ -2460,18 +2451,11 @@ static bool enc_init(void)
|
||||||
return true;
|
return true;
|
||||||
} /* enc_init */
|
} /* enc_init */
|
||||||
|
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
bool cpu_boosted;
|
bool cpu_boosted;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!enc_init())
|
if (!enc_init())
|
||||||
{
|
{
|
||||||
ci->enc_codec_loaded = -1;
|
ci->enc_codec_loaded = -1;
|
||||||
|
|
|
@ -42,16 +42,6 @@ unsigned char mad_main_data[MAD_BUFFER_MDLEN] IBSS_ATTR;
|
||||||
int mpeg_latency[3] = { 0, 481, 529 };
|
int mpeg_latency[3] = { 0, 481, 529 };
|
||||||
int mpeg_framesize[3] = {384, 1152, 1152};
|
int mpeg_framesize[3] = {384, 1152, 1152};
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct codec_api *ci;
|
|
||||||
|
|
||||||
void init_mad(void)
|
void init_mad(void)
|
||||||
{
|
{
|
||||||
ci->memset(&stream, 0, sizeof(struct mad_stream));
|
ci->memset(&stream, 0, sizeof(struct mad_stream));
|
||||||
|
@ -69,7 +59,7 @@ void init_mad(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -83,14 +73,7 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
int framelength;
|
int framelength;
|
||||||
int padding = MAD_BUFFER_GUARD; /* to help mad decode the last frame */
|
int padding = MAD_BUFFER_GUARD; /* to help mad decode the last frame */
|
||||||
|
|
||||||
ci = api;
|
if (codec_init())
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (codec_init(api))
|
|
||||||
return CODEC_ERROR;
|
return CODEC_ERROR;
|
||||||
|
|
||||||
/* Create a decoder instance */
|
/* Create a decoder instance */
|
||||||
|
|
|
@ -67,18 +67,9 @@ MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH]
|
||||||
IBSS_ATTR_MPC_SAMPLE_BUF;
|
IBSS_ATTR_MPC_SAMPLE_BUF;
|
||||||
mpc_uint32_t seek_table[10000];
|
mpc_uint32_t seek_table[10000];
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
struct codec_api *ci = api;
|
|
||||||
mpc_int64_t samplesdone;
|
mpc_int64_t samplesdone;
|
||||||
unsigned long frequency;
|
unsigned long frequency;
|
||||||
unsigned status;
|
unsigned status;
|
||||||
|
@ -86,11 +77,6 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
mpc_streaminfo info;
|
mpc_streaminfo info;
|
||||||
int retval = CODEC_OK;
|
int retval = CODEC_OK;
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)(28));
|
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)(28));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*16));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*16));
|
||||||
ci->configure(CODEC_SET_FILEBUF_PRESEEK, (long *)(0));
|
ci->configure(CODEC_SET_FILEBUF_PRESEEK, (long *)(0));
|
||||||
|
@ -109,7 +95,7 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
mpc_decoder_set_seek_table(&decoder, seek_table, sizeof(seek_table));
|
mpc_decoder_set_seek_table(&decoder, seek_table, sizeof(seek_table));
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
retval = CODEC_ERROR;
|
retval = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,23 +20,12 @@
|
||||||
#include "codeclib.h"
|
#include "codeclib.h"
|
||||||
#include <codecs/libffmpegFLAC/shndec.h>
|
#include <codecs/libffmpegFLAC/shndec.h>
|
||||||
|
|
||||||
|
CODEC_HEADER
|
||||||
|
|
||||||
#ifndef IBSS_ATTR_SHORTEN_DECODED0
|
#ifndef IBSS_ATTR_SHORTEN_DECODED0
|
||||||
#define IBSS_ATTR_SHORTEN_DECODED0 IBSS_ATTR
|
#define IBSS_ATTR_SHORTEN_DECODED0 IBSS_ATTR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CODEC_HEADER
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct codec_api* rb;
|
|
||||||
struct codec_api* ci;
|
|
||||||
|
|
||||||
int32_t decoded0[MAX_DECODE_SIZE] IBSS_ATTR_SHORTEN_DECODED0;
|
int32_t decoded0[MAX_DECODE_SIZE] IBSS_ATTR_SHORTEN_DECODED0;
|
||||||
int32_t decoded1[MAX_DECODE_SIZE] IBSS_ATTR;
|
int32_t decoded1[MAX_DECODE_SIZE] IBSS_ATTR;
|
||||||
|
|
||||||
|
@ -46,7 +35,7 @@ int32_t offset1[MAX_OFFSET_SIZE] IBSS_ATTR;
|
||||||
int8_t ibuf[MAX_BUFFER_SIZE] IBSS_ATTR;
|
int8_t ibuf[MAX_BUFFER_SIZE] IBSS_ATTR;
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
ShortenContext sc;
|
ShortenContext sc;
|
||||||
uint32_t samplesdone;
|
uint32_t samplesdone;
|
||||||
|
@ -56,14 +45,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
size_t bytesleft;
|
size_t bytesleft;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
@ -72,7 +53,7 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
/* Codec initialization */
|
/* Codec initialization */
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
LOGF("Shorten: codec_init error\n");
|
LOGF("Shorten: codec_init error\n");
|
||||||
return CODEC_ERROR;
|
return CODEC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,21 +65,10 @@ CODEC_HEADER
|
||||||
|
|
||||||
#define CHUNK_SIZE (1024*2)
|
#define CHUNK_SIZE (1024*2)
|
||||||
|
|
||||||
|
|
||||||
struct codec_api *rb;
|
|
||||||
|
|
||||||
/* This codec supports SID Files:
|
/* This codec supports SID Files:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */
|
static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */
|
||||||
|
|
||||||
/* Static buffer for the plain SID-File */
|
/* Static buffer for the plain SID-File */
|
||||||
|
@ -1213,9 +1202,8 @@ unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
struct codec_api *ci;
|
|
||||||
size_t n, bytesfree;
|
size_t n, bytesfree;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
unsigned int filesize;
|
unsigned int filesize;
|
||||||
|
@ -1228,20 +1216,11 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
int nSamplesToRender = 0;
|
int nSamplesToRender = 0;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
return CODEC_ERROR;
|
return CODEC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,7 +1230,7 @@ next_track:
|
||||||
/* Load SID file */
|
/* Load SID file */
|
||||||
p = sidfile;
|
p = sidfile;
|
||||||
bytesfree=sizeof(sidfile);
|
bytesfree=sizeof(sidfile);
|
||||||
while ((n = rb->read_filebuf(p, bytesfree)) > 0) {
|
while ((n = ci->read_filebuf(p, bytesfree)) > 0) {
|
||||||
p += n;
|
p += n;
|
||||||
bytesfree -= n;
|
bytesfree -= n;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,12 @@
|
||||||
|
|
||||||
CODEC_HEADER
|
CODEC_HEADER
|
||||||
|
|
||||||
static struct codec_api *rb;
|
|
||||||
|
|
||||||
/* Some standard functions and variables needed by Tremor */
|
/* Some standard functions and variables needed by Tremor */
|
||||||
|
|
||||||
size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource)
|
size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource)
|
||||||
{
|
{
|
||||||
(void)datasource;
|
(void)datasource;
|
||||||
return rb->read_filebuf(ptr, nmemb*size);
|
return ci->read_filebuf(ptr, nmemb*size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int initial_seek_handler(void *datasource, ogg_int64_t offset, int whence)
|
int initial_seek_handler(void *datasource, ogg_int64_t offset, int whence)
|
||||||
|
@ -46,12 +44,12 @@ int seek_handler(void *datasource, ogg_int64_t offset, int whence)
|
||||||
(void)datasource;
|
(void)datasource;
|
||||||
|
|
||||||
if (whence == SEEK_CUR) {
|
if (whence == SEEK_CUR) {
|
||||||
offset += rb->curpos;
|
offset += ci->curpos;
|
||||||
} else if (whence == SEEK_END) {
|
} else if (whence == SEEK_END) {
|
||||||
offset += rb->filesize;
|
offset += ci->filesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rb->seek_buffer(offset)) {
|
if (ci->seek_buffer(offset)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ int close_handler(void *datasource)
|
||||||
long tell_handler(void *datasource)
|
long tell_handler(void *datasource)
|
||||||
{
|
{
|
||||||
(void)datasource;
|
(void)datasource;
|
||||||
return rb->curpos;
|
return ci->curpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This sets the DSP parameters based on the current logical bitstream
|
/* This sets the DSP parameters based on the current logical bitstream
|
||||||
|
@ -81,32 +79,24 @@ bool vorbis_set_codec_parameters(OggVorbis_File *vf)
|
||||||
vi = ov_info(vf, -1);
|
vi = ov_info(vf, -1);
|
||||||
|
|
||||||
if (vi == NULL) {
|
if (vi == NULL) {
|
||||||
//rb->splash(HZ*2, true, "Vorbis Error");
|
//ci->splash(HZ*2, true, "Vorbis Error");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb->configure(DSP_SWITCH_FREQUENCY, (int *)rb->id3->frequency);
|
ci->configure(DSP_SWITCH_FREQUENCY, (int *)ci->id3->frequency);
|
||||||
codec_set_replaygain(rb->id3);
|
codec_set_replaygain(ci->id3);
|
||||||
|
|
||||||
if (vi->channels == 2) {
|
if (vi->channels == 2) {
|
||||||
rb->configure(DSP_SET_STEREO_MODE, (int *)STEREO_NONINTERLEAVED);
|
ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_NONINTERLEAVED);
|
||||||
} else if (vi->channels == 1) {
|
} else if (vi->channels == 1) {
|
||||||
rb->configure(DSP_SET_STEREO_MODE, (int *)STEREO_MONO);
|
ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_MONO);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
ov_callbacks callbacks;
|
ov_callbacks callbacks;
|
||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
|
@ -122,16 +112,9 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
ogg_uint32_t vf_serialnos;
|
ogg_uint32_t vf_serialnos;
|
||||||
ogg_int64_t vf_pcmlengths[2];
|
ogg_int64_t vf_pcmlengths[2];
|
||||||
|
|
||||||
rb = api;
|
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)24);
|
||||||
|
ci->configure(DSP_SET_CLIP_MAX, (long *)((1 << 24) - 1));
|
||||||
#ifdef USE_IRAM
|
ci->configure(DSP_SET_CLIP_MIN, (long *)-((1 << 24) - 1));
|
||||||
rb->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
rb->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rb->configure(DSP_SET_SAMPLE_DEPTH, (long *)24);
|
|
||||||
rb->configure(DSP_SET_CLIP_MAX, (long *)((1 << 24) - 1));
|
|
||||||
rb->configure(DSP_SET_CLIP_MIN, (long *)-((1 << 24) - 1));
|
|
||||||
/* Note: These are sane defaults for these values. Perhaps
|
/* Note: These are sane defaults for these values. Perhaps
|
||||||
* they should be set differently based on quality setting
|
* they should be set differently based on quality setting
|
||||||
*/
|
*/
|
||||||
|
@ -139,17 +122,17 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
/* The chunk size below is magic. If set any lower, resume
|
/* The chunk size below is magic. If set any lower, resume
|
||||||
* doesn't work properly (ov_raw_seek() does the wrong thing).
|
* doesn't work properly (ov_raw_seek() does the wrong thing).
|
||||||
*/
|
*/
|
||||||
rb->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*256));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*256));
|
||||||
|
|
||||||
/* We need to flush reserver memory every track load. */
|
/* We need to flush reserver memory every track load. */
|
||||||
next_track:
|
next_track:
|
||||||
if (codec_init(rb)) {
|
if (codec_init()) {
|
||||||
error = CODEC_ERROR;
|
error = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!*rb->taginfo_ready && !rb->stop_codec)
|
while (!*ci->taginfo_ready && !ci->stop_codec)
|
||||||
rb->sleep(1);
|
ci->sleep(1);
|
||||||
|
|
||||||
/* Create a decoder instance */
|
/* Create a decoder instance */
|
||||||
callbacks.read_func = read_handler;
|
callbacks.read_func = read_handler;
|
||||||
|
@ -158,14 +141,14 @@ next_track:
|
||||||
callbacks.close_func = close_handler;
|
callbacks.close_func = close_handler;
|
||||||
|
|
||||||
/* Open a non-seekable stream */
|
/* Open a non-seekable stream */
|
||||||
error = ov_open_callbacks(rb, &vf, NULL, 0, callbacks);
|
error = ov_open_callbacks(ci, &vf, NULL, 0, callbacks);
|
||||||
|
|
||||||
/* If the non-seekable open was successful, we need to supply the missing
|
/* If the non-seekable open was successful, we need to supply the missing
|
||||||
* data to make it seekable. This is a hack, but it's reasonable since we
|
* data to make it seekable. This is a hack, but it's reasonable since we
|
||||||
* don't want to run the whole file through the buffer before we start
|
* don't want to run the whole file through the buffer before we start
|
||||||
* playing. Using Tremor's seekable open routine would cause us to do
|
* playing. Using Tremor's seekable open routine would cause us to do
|
||||||
* this, so we pretend not to be seekable at first. Then we fill in the
|
* this, so we pretend not to be seekable at first. Then we fill in the
|
||||||
* missing fields of vf with 1) information in rb->id3, and 2) info
|
* missing fields of vf with 1) information in ci->id3, and 2) info
|
||||||
* obtained by Tremor in the above ov_open call.
|
* obtained by Tremor in the above ov_open call.
|
||||||
*
|
*
|
||||||
* Note that this assumes there is only ONE logical Vorbis bitstream in our
|
* Note that this assumes there is only ONE logical Vorbis bitstream in our
|
||||||
|
@ -179,40 +162,40 @@ next_track:
|
||||||
vf.pcmlengths = vf_pcmlengths;
|
vf.pcmlengths = vf_pcmlengths;
|
||||||
|
|
||||||
vf.offsets[0] = 0;
|
vf.offsets[0] = 0;
|
||||||
vf.offsets[1] = rb->id3->filesize;
|
vf.offsets[1] = ci->id3->filesize;
|
||||||
vf.dataoffsets[0] = vf.offset;
|
vf.dataoffsets[0] = vf.offset;
|
||||||
vf.pcmlengths[0] = 0;
|
vf.pcmlengths[0] = 0;
|
||||||
vf.pcmlengths[1] = rb->id3->samples;
|
vf.pcmlengths[1] = ci->id3->samples;
|
||||||
vf.serialnos[0] = vf.current_serialno;
|
vf.serialnos[0] = vf.current_serialno;
|
||||||
vf.callbacks.seek_func = seek_handler;
|
vf.callbacks.seek_func = seek_handler;
|
||||||
vf.seekable = 1;
|
vf.seekable = 1;
|
||||||
vf.end = rb->id3->filesize;
|
vf.end = ci->id3->filesize;
|
||||||
vf.ready_state = OPENED;
|
vf.ready_state = OPENED;
|
||||||
vf.links = 1;
|
vf.links = 1;
|
||||||
} else {
|
} else {
|
||||||
//rb->logf("ov_open: %d", error);
|
//ci->logf("ov_open: %d", error);
|
||||||
error = CODEC_ERROR;
|
error = CODEC_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rb->id3->offset) {
|
if (ci->id3->offset) {
|
||||||
rb->advance_buffer(rb->id3->offset);
|
ci->advance_buffer(ci->id3->offset);
|
||||||
ov_raw_seek(&vf, rb->id3->offset);
|
ov_raw_seek(&vf, ci->id3->offset);
|
||||||
rb->set_elapsed(ov_time_tell(&vf));
|
ci->set_elapsed(ov_time_tell(&vf));
|
||||||
rb->set_offset(ov_raw_tell(&vf));
|
ci->set_offset(ov_raw_tell(&vf));
|
||||||
}
|
}
|
||||||
|
|
||||||
eof = 0;
|
eof = 0;
|
||||||
while (!eof) {
|
while (!eof) {
|
||||||
rb->yield();
|
ci->yield();
|
||||||
if (rb->stop_codec || rb->new_track)
|
if (ci->stop_codec || ci->new_track)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (rb->seek_time) {
|
if (ci->seek_time) {
|
||||||
if (ov_time_seek(&vf, rb->seek_time - 1)) {
|
if (ov_time_seek(&vf, ci->seek_time - 1)) {
|
||||||
//rb->logf("ov_time_seek failed");
|
//ci->logf("ov_time_seek failed");
|
||||||
}
|
}
|
||||||
rb->seek_complete();
|
ci->seek_complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read host-endian signed 24-bit PCM samples */
|
/* Read host-endian signed 24-bit PCM samples */
|
||||||
|
@ -233,18 +216,18 @@ next_track:
|
||||||
} else if (n < 0) {
|
} else if (n < 0) {
|
||||||
DEBUGF("Error decoding frame\n");
|
DEBUGF("Error decoding frame\n");
|
||||||
} else {
|
} else {
|
||||||
while (!rb->pcmbuf_insert_split(pcm[0], pcm[1],
|
while (!ci->pcmbuf_insert_split(pcm[0], pcm[1],
|
||||||
n*sizeof(ogg_int32_t))) {
|
n*sizeof(ogg_int32_t))) {
|
||||||
rb->sleep(1);
|
ci->sleep(1);
|
||||||
}
|
}
|
||||||
rb->set_offset(ov_raw_tell(&vf));
|
ci->set_offset(ov_raw_tell(&vf));
|
||||||
rb->set_elapsed(ov_time_tell(&vf));
|
ci->set_elapsed(ov_time_tell(&vf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error = CODEC_OK;
|
error = CODEC_OK;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (rb->request_next_track()) {
|
if (ci->request_next_track()) {
|
||||||
/* Clean things up for the next track */
|
/* Clean things up for the next track */
|
||||||
vf.dataoffsets = NULL;
|
vf.dataoffsets = NULL;
|
||||||
vf.offsets = NULL;
|
vf.offsets = NULL;
|
||||||
|
|
|
@ -25,8 +25,6 @@ CODEC_HEADER
|
||||||
/* Macro that sign extends an unsigned byte */
|
/* Macro that sign extends an unsigned byte */
|
||||||
#define SE(x) ((int32_t)((int8_t)(x)))
|
#define SE(x) ((int32_t)((int8_t)(x)))
|
||||||
|
|
||||||
struct codec_api *rb;
|
|
||||||
|
|
||||||
/* This codec support WAVE files with the following formats:
|
/* This codec support WAVE files with the following formats:
|
||||||
* - PCM, up to 32 bits, supporting 32 bits playback when useful.
|
* - PCM, up to 32 bits, supporting 32 bits playback when useful.
|
||||||
* - ALAW and MULAW (16 bits compressed on 8 bits).
|
* - ALAW and MULAW (16 bits compressed on 8 bits).
|
||||||
|
@ -95,14 +93,6 @@ enum
|
||||||
/* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */
|
/* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */
|
||||||
#define WAV_CHUNK_SIZE (1024*2)
|
#define WAV_CHUNK_SIZE (1024*2)
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const int16_t alaw2linear16[256] ICONST_ATTR = {
|
static const int16_t alaw2linear16[256] ICONST_ATTR = {
|
||||||
-5504, -5248, -6016, -5760, -4480, -4224, -4992,
|
-5504, -5248, -6016, -5760, -4480, -4224, -4992,
|
||||||
-4736, -7552, -7296, -8064, -7808, -6528, -6272,
|
-4736, -7552, -7296, -8064, -7808, -6528, -6272,
|
||||||
|
@ -213,9 +203,8 @@ decode_dvi_adpcm(struct codec_api *ci,
|
||||||
size_t *pcmoutsize);
|
size_t *pcmoutsize);
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api *api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
struct codec_api *ci;
|
|
||||||
uint32_t numbytes, bytesdone;
|
uint32_t numbytes, bytesdone;
|
||||||
uint32_t totalsamples = 0;
|
uint32_t totalsamples = 0;
|
||||||
uint16_t channels = 0;
|
uint16_t channels = 0;
|
||||||
|
@ -235,20 +224,12 @@ enum codec_status codec_start(struct codec_api *api)
|
||||||
|
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
rb = api;
|
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28);
|
ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28);
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
i = CODEC_ERROR;
|
i = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,6 @@
|
||||||
|
|
||||||
CODEC_ENC_HEADER
|
CODEC_ENC_HEADER
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct riff_header
|
struct riff_header
|
||||||
{
|
{
|
||||||
uint8_t riff_id[4]; /* 00h - "RIFF" */
|
uint8_t riff_id[4]; /* 00h - "RIFF" */
|
||||||
|
@ -65,7 +57,6 @@ struct riff_header
|
||||||
#define PCM_SAMP_PER_CHUNK 2048
|
#define PCM_SAMP_PER_CHUNK 2048
|
||||||
#define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4)
|
#define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4)
|
||||||
|
|
||||||
static struct codec_api *ci;
|
|
||||||
static int num_channels;
|
static int num_channels;
|
||||||
uint32_t sample_rate;
|
uint32_t sample_rate;
|
||||||
uint32_t enc_size;
|
uint32_t enc_size;
|
||||||
|
@ -321,17 +312,10 @@ static bool init_encoder(void)
|
||||||
} /* init_encoder */
|
} /* init_encoder */
|
||||||
|
|
||||||
/* main codec entry point */
|
/* main codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
bool cpu_boosted;
|
bool cpu_boosted;
|
||||||
|
|
||||||
ci = api; // copy to global api pointer
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!init_encoder())
|
if (!init_encoder())
|
||||||
{
|
{
|
||||||
ci->enc_codec_loaded = -1;
|
ci->enc_codec_loaded = -1;
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
CODEC_HEADER
|
CODEC_HEADER
|
||||||
|
|
||||||
static struct codec_api *ci;
|
|
||||||
|
|
||||||
#define BUFFER_SIZE 4096
|
#define BUFFER_SIZE 4096
|
||||||
|
|
||||||
static int32_t temp_buffer [BUFFER_SIZE] IBSS_ATTR;
|
static int32_t temp_buffer [BUFFER_SIZE] IBSS_ATTR;
|
||||||
|
@ -35,16 +33,8 @@ static int32_t read_callback (void *buffer, int32_t bytes)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
WavpackContext *wpc;
|
WavpackContext *wpc;
|
||||||
char error [80];
|
char error [80];
|
||||||
|
@ -52,13 +42,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
ci = api;
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128));
|
||||||
|
|
||||||
|
@ -66,7 +49,7 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
|
|
||||||
next_track:
|
next_track:
|
||||||
|
|
||||||
if (codec_init(api)) {
|
if (codec_init()) {
|
||||||
retval = CODEC_ERROR;
|
retval = CODEC_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,6 @@
|
||||||
|
|
||||||
CODEC_ENC_HEADER
|
CODEC_ENC_HEADER
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
extern char iramcopy[];
|
|
||||||
extern char iramstart[];
|
|
||||||
extern char iramend[];
|
|
||||||
extern char iedata[];
|
|
||||||
extern char iend[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Types **/
|
/** Types **/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -73,7 +65,6 @@ struct riff_header
|
||||||
#define PCM_CHUNK_SIZE (4*PCM_SAMP_PER_CHUNK)
|
#define PCM_CHUNK_SIZE (4*PCM_SAMP_PER_CHUNK)
|
||||||
|
|
||||||
/** Data **/
|
/** Data **/
|
||||||
static struct codec_api *ci;
|
|
||||||
static int8_t input_buffer[PCM_CHUNK_SIZE*2] IBSS_ATTR;
|
static int8_t input_buffer[PCM_CHUNK_SIZE*2] IBSS_ATTR;
|
||||||
static WavpackConfig config IBSS_ATTR;
|
static WavpackConfig config IBSS_ATTR;
|
||||||
static WavpackContext *wpc;
|
static WavpackContext *wpc;
|
||||||
|
@ -381,17 +372,10 @@ static bool init_encoder(void)
|
||||||
return true;
|
return true;
|
||||||
} /* init_encoder */
|
} /* init_encoder */
|
||||||
|
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
bool cpu_boosted;
|
bool cpu_boosted;
|
||||||
|
|
||||||
ci = api; /* copy to global api pointer */
|
|
||||||
|
|
||||||
#ifdef USE_IRAM
|
|
||||||
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
|
|
||||||
ci->memset(iedata, 0, iend - iedata);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* initialize params and config */
|
/* initialize params and config */
|
||||||
if (!init_encoder())
|
if (!init_encoder())
|
||||||
{
|
{
|
||||||
|
|
|
@ -699,6 +699,7 @@ void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
|
||||||
audio_iram_steal();
|
audio_iram_steal();
|
||||||
memcpy(iramstart, iramcopy, iram_size);
|
memcpy(iramstart, iramcopy, iram_size);
|
||||||
memset(iedata, 0, iedata_size);
|
memset(iedata, 0, iedata_size);
|
||||||
|
memset(iramcopy, 0, iram_size);
|
||||||
}
|
}
|
||||||
#endif /* IRAM_STEAL */
|
#endif /* IRAM_STEAL */
|
||||||
|
|
||||||
|
|
|
@ -769,6 +769,8 @@ extern int systemvol;
|
||||||
/* this is the plugin entry point */
|
/* this is the plugin entry point */
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
|
PLUGIN_IRAM_INIT(api)
|
||||||
|
|
||||||
rb = api;
|
rb = api;
|
||||||
(void)parameter;
|
(void)parameter;
|
||||||
|
|
||||||
|
@ -778,8 +780,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
rb->cpu_boost(true);
|
rb->cpu_boost(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PLUGIN_IRAM_INIT(rb)
|
|
||||||
|
|
||||||
rb->lcd_setfont(0);
|
rb->lcd_setfont(0);
|
||||||
|
|
||||||
#ifdef FANCY_MENU
|
#ifdef FANCY_MENU
|
||||||
|
|
|
@ -105,8 +105,10 @@ struct plugin_api * rb;
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
rb = api;
|
|
||||||
|
|
||||||
|
PLUGIN_IRAM_INIT(api)
|
||||||
|
|
||||||
|
rb = api;
|
||||||
if(parameter == NULL)
|
if(parameter == NULL)
|
||||||
{
|
{
|
||||||
rb->splash(HZ*2, true, " Play .MID file ");
|
rb->splash(HZ*2, true, " Play .MID file ");
|
||||||
|
@ -114,8 +116,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
}
|
}
|
||||||
rb->lcd_setfont(0);
|
rb->lcd_setfont(0);
|
||||||
|
|
||||||
PLUGIN_IRAM_INIT(rb)
|
|
||||||
|
|
||||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||||
rb->cpu_boost(true);
|
rb->cpu_boost(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2364,14 +2364,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
int brate[] = { 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 };
|
int brate[] = { 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 };
|
||||||
|
|
||||||
(void)parameter;
|
(void)parameter;
|
||||||
rb = api;
|
|
||||||
|
PLUGIN_IRAM_INIT(api)
|
||||||
|
|
||||||
#ifdef CPU_COLDFIRE
|
#ifdef CPU_COLDFIRE
|
||||||
asm volatile ("move.l #0, %macsr"); /* integer mode */
|
asm volatile ("move.l #0, %macsr"); /* integer mode */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PLUGIN_IRAM_INIT(rb)
|
rb = api;
|
||||||
|
|
||||||
rb->lcd_setfont(FONT_SYSFIXED);
|
rb->lcd_setfont(FONT_SYSFIXED);
|
||||||
|
|
||||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
|
|
|
@ -297,10 +297,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
uint8_t* buffer;
|
uint8_t* buffer;
|
||||||
size_t buffer_size;
|
size_t buffer_size;
|
||||||
|
|
||||||
rb = api;
|
|
||||||
|
|
||||||
/* This also stops audio playback - so we do it before using IRAM */
|
/* This also stops audio playback - so we do it before using IRAM */
|
||||||
audiobuf = rb->plugin_get_audio_buffer(&audiosize);
|
audiobuf = api->plugin_get_audio_buffer(&audiosize);
|
||||||
|
|
||||||
|
PLUGIN_IRAM_INIT(api)
|
||||||
|
rb = api;
|
||||||
|
|
||||||
/* Initialise our malloc buffer */
|
/* Initialise our malloc buffer */
|
||||||
mpeg2_alloc_init(audiobuf,audiosize);
|
mpeg2_alloc_init(audiobuf,audiosize);
|
||||||
|
@ -312,8 +313,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
|
|
||||||
PLUGIN_IRAM_INIT(rb)
|
|
||||||
|
|
||||||
rb->lcd_set_backdrop(NULL);
|
rb->lcd_set_backdrop(NULL);
|
||||||
|
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
|
|
|
@ -364,10 +364,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
(void)parameter;
|
(void)parameter;
|
||||||
|
|
||||||
|
PLUGIN_IRAM_INIT(api)
|
||||||
rb = api;
|
rb = api;
|
||||||
|
|
||||||
PLUGIN_IRAM_INIT(rb)
|
|
||||||
|
|
||||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
rb->cpu_boost(true);
|
rb->cpu_boost(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -115,12 +115,11 @@ SECTIONS
|
||||||
. = ALIGN(0x4);
|
. = ALIGN(0x4);
|
||||||
iend = .;
|
iend = .;
|
||||||
} > PLUGIN_IRAM
|
} > PLUGIN_IRAM
|
||||||
|
|
||||||
.bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram):
|
|
||||||
#else
|
|
||||||
.bss :
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
.bss (NOLOAD) :
|
||||||
{
|
{
|
||||||
|
plugin_bss_start = .;
|
||||||
*(.bss*)
|
*(.bss*)
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
. = ALIGN(0x4);
|
. = ALIGN(0x4);
|
||||||
|
|
|
@ -157,6 +157,8 @@ void savesettings(void)
|
||||||
/* this is the plugin entry point */
|
/* this is the plugin entry point */
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
|
PLUGIN_IRAM_INIT(api)
|
||||||
|
|
||||||
/* if you are using a global api pointer, don't forget to copy it!
|
/* if you are using a global api pointer, don't forget to copy it!
|
||||||
otherwise you will get lovely "I04: IllInstr" errors... :-) */
|
otherwise you will get lovely "I04: IllInstr" errors... :-) */
|
||||||
rb = api;
|
rb = api;
|
||||||
|
@ -181,8 +183,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
#endif
|
#endif
|
||||||
setoptions();
|
setoptions();
|
||||||
|
|
||||||
PLUGIN_IRAM_INIT(rb)
|
|
||||||
|
|
||||||
shut=0;
|
shut=0;
|
||||||
cleanshut=0;
|
cleanshut=0;
|
||||||
|
|
||||||
|
|
|
@ -61,14 +61,16 @@ long start_time IBSS_ATTR = 0;
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
|
|
||||||
rb = api;
|
|
||||||
#if CODEC == SWCODEC && !defined SIMULATOR
|
#if CODEC == SWCODEC && !defined SIMULATOR
|
||||||
rb->pcm_play_stop();
|
api->pcm_play_stop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PLUGIN_IRAM_INIT(api)
|
||||||
|
|
||||||
|
rb = api;
|
||||||
rb->lcd_set_backdrop(NULL);
|
rb->lcd_set_backdrop(NULL);
|
||||||
rb->splash(HZ, true, "Welcome to ZXBox");
|
rb->splash(HZ, true, "Welcome to ZXBox");
|
||||||
|
|
||||||
PLUGIN_IRAM_INIT(rb)
|
|
||||||
|
|
||||||
sp_init();
|
sp_init();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue