diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/Makefile | 16 | ||||
-rw-r--r-- | apps/codecs/a52.c | 21 | ||||
-rw-r--r-- | apps/codecs/aac.c | 35 | ||||
-rw-r--r-- | apps/codecs/adx.c | 10 | ||||
-rw-r--r-- | apps/codecs/aiff.c | 23 | ||||
-rw-r--r-- | apps/codecs/aiff_enc.c | 18 | ||||
-rw-r--r-- | apps/codecs/alac.c | 37 | ||||
-rw-r--r-- | apps/codecs/codec.h | 2 | ||||
-rw-r--r-- | apps/codecs/codec_crt0.c | 46 | ||||
-rw-r--r-- | apps/codecs/flac.c | 23 | ||||
-rw-r--r-- | apps/codecs/lib/codeclib.c | 45 | ||||
-rw-r--r-- | apps/codecs/lib/codeclib.h | 3 | ||||
-rw-r--r-- | apps/codecs/mp3_enc.c | 18 | ||||
-rw-r--r-- | apps/codecs/mpa.c | 21 | ||||
-rw-r--r-- | apps/codecs/mpc.c | 18 | ||||
-rw-r--r-- | apps/codecs/shorten.c | 27 | ||||
-rw-r--r-- | apps/codecs/sid.c | 27 | ||||
-rw-r--r-- | apps/codecs/vorbis.c | 97 | ||||
-rw-r--r-- | apps/codecs/wav.c | 23 | ||||
-rw-r--r-- | apps/codecs/wav_enc.c | 18 | ||||
-rw-r--r-- | apps/codecs/wavpack.c | 21 | ||||
-rw-r--r-- | apps/codecs/wavpack_enc.c | 18 |
22 files changed, 163 insertions, 404 deletions
diff --git a/apps/codecs/Makefile b/apps/codecs/Makefile index 38723b7940..e964bf70a7 100644 --- a/apps/codecs/Makefile +++ b/apps/codecs/Makefile | |||
@@ -66,7 +66,7 @@ $(OBJDIR)/mp3_enc.elf: $(OBJDIR)/mp3_enc.o | |||
66 | $(OBJDIR)/wav_enc.elf: $(OBJDIR)/wav_enc.o | 66 | $(OBJDIR)/wav_enc.elf: $(OBJDIR)/wav_enc.o |
67 | $(OBJDIR)/wavpack_enc.elf: $(OBJDIR)/wavpack_enc.o $(BUILDDIR)/libwavpack.a | 67 | $(OBJDIR)/wavpack_enc.elf: $(OBJDIR)/wavpack_enc.o $(BUILDDIR)/libwavpack.a |
68 | 68 | ||
69 | $(OBJDIR)/%.elf: | 69 | $(OBJDIR)/%.elf: $(OBJDIR)/codec_crt0.o |
70 | $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -O -nostdlib -o $@ $^ -L$(BUILDDIR) -lcodec -lgcc -T$(LINKCODEC) -Wl,-Map,$(OBJDIR)/$*.map | 70 | $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -O -nostdlib -o $@ $^ -L$(BUILDDIR) -lcodec -lgcc -T$(LINKCODEC) -Wl,-Map,$(OBJDIR)/$*.map |
71 | 71 | ||
72 | $(OBJDIR)/%.codec : $(OBJDIR)/%.elf | 72 | $(OBJDIR)/%.codec : $(OBJDIR)/%.elf |
@@ -77,8 +77,8 @@ ifeq ($(SIMVER), x11) | |||
77 | ################################################### | 77 | ################################################### |
78 | # This is the X11 simulator version | 78 | # This is the X11 simulator version |
79 | 79 | ||
80 | $(OBJDIR)/%.codec : $(OBJDIR)/%.o $(BUILDDIR)/libcodec.a $(OUTPUT) | 80 | $(OBJDIR)/%.codec : $(OBJDIR)/%.o $(OBJDIR)/codec_crt0.o $(BUILDDIR)/libcodec.a $(OUTPUT) |
81 | $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@ | 81 | $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< $(OBJDIR)/codec_crt0.o -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@ |
82 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) | 82 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) |
83 | # 'x' must be kept or you'll have "Win32 error 5" | 83 | # 'x' must be kept or you'll have "Win32 error 5" |
84 | # $ fgrep 5 /usr/include/w32api/winerror.h | head -1 | 84 | # $ fgrep 5 /usr/include/w32api/winerror.h | head -1 |
@@ -92,8 +92,8 @@ ifeq ($(SIMVER), sdl) | |||
92 | ################################################### | 92 | ################################################### |
93 | # This is the SDL simulator version | 93 | # This is the SDL simulator version |
94 | 94 | ||
95 | $(OBJDIR)/%.codec : $(OBJDIR)/%.o $(BUILDDIR)/libcodec.a $(OUTPUT) | 95 | $(OBJDIR)/%.codec : $(OBJDIR)/%.o $(OBJDIR)/codec_crt0.o $(BUILDDIR)/libcodec.a $(OUTPUT) |
96 | $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@ | 96 | $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< $(OBJDIR)/codec_crt0.o -L$(BUILDDIR) $(CODECLIBS) -lcodec -o $@ |
97 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) | 97 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) |
98 | # 'x' must be kept or you'll have "Win32 error 5" | 98 | # 'x' must be kept or you'll have "Win32 error 5" |
99 | # $ fgrep 5 /usr/include/w32api/winerror.h | head -1 | 99 | # $ fgrep 5 /usr/include/w32api/winerror.h | head -1 |
@@ -108,9 +108,9 @@ else # end of sdl-simulator | |||
108 | DLLTOOLFLAGS = --export-all | 108 | DLLTOOLFLAGS = --export-all |
109 | DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin | 109 | DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin |
110 | 110 | ||
111 | $(OBJDIR)/%.codec : $(OBJDIR)/%.o $(BUILDDIR)/libcodec.a $(OUTPUT) | 111 | $(OBJDIR)/%.codec : $(OBJDIR)/%.o $(OBJDIR)/codec_crt0.o $(BUILDDIR)/libcodec.a $(OUTPUT) |
112 | $(call PRINTS,DLL $(@F))$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $< | 112 | $(call PRINTS,DLL $(@F))$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $< $(OBJDIR)/codec_crt0.o |
113 | $(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< \ | 113 | $(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(OBJDIR)/codec_crt0.o\ |
114 | $(BUILDDIR)/libcodec.a $(patsubst -l%,$(BUILDDIR)/lib%.a,$(CODECLIBS)) \ | 114 | $(BUILDDIR)/libcodec.a $(patsubst -l%,$(BUILDDIR)/lib%.a,$(CODECLIBS)) \ |
115 | -o $@ | 115 | -o $@ |
116 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) | 116 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) |
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c index b7190be71b..4f41bfeaf5 100644 --- a/apps/codecs/a52.c +++ b/apps/codecs/a52.c | |||
@@ -28,8 +28,6 @@ CODEC_HEADER | |||
28 | 28 | ||
29 | #define A52_SAMPLESPERFRAME (6*256) | 29 | #define A52_SAMPLESPERFRAME (6*256) |
30 | 30 | ||
31 | struct codec_api *ci; | ||
32 | |||
33 | static a52_state_t *state; | 31 | static a52_state_t *state; |
34 | unsigned long samplesdone; | 32 | unsigned long samplesdone; |
35 | unsigned long frequency; | 33 | unsigned long frequency; |
@@ -117,16 +115,8 @@ void a52_decode_data(uint8_t *start, uint8_t *end) | |||
117 | } | 115 | } |
118 | } | 116 | } |
119 | 117 | ||
120 | #ifdef USE_IRAM | ||
121 | extern char iramcopy[]; | ||
122 | extern char iramstart[]; | ||
123 | extern char iramend[]; | ||
124 | extern char iedata[]; | ||
125 | extern char iend[]; | ||
126 | #endif | ||
127 | |||
128 | /* this is the codec entry point */ | 118 | /* this is the codec entry point */ |
129 | enum codec_status codec_start(struct codec_api *api) | 119 | enum codec_status codec_main(void) |
130 | { | 120 | { |
131 | size_t n; | 121 | size_t n; |
132 | unsigned char *filebuf; | 122 | unsigned char *filebuf; |
@@ -134,19 +124,12 @@ enum codec_status codec_start(struct codec_api *api) | |||
134 | int retval; | 124 | int retval; |
135 | 125 | ||
136 | /* Generic codec initialisation */ | 126 | /* Generic codec initialisation */ |
137 | ci = api; | ||
138 | |||
139 | #ifdef USE_IRAM | ||
140 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
141 | ci->memset(iedata, 0, iend - iedata); | ||
142 | #endif | ||
143 | |||
144 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); | 127 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); |
145 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); | 128 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); |
146 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128)); | 129 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128)); |
147 | 130 | ||
148 | next_track: | 131 | next_track: |
149 | if (codec_init(api)) { | 132 | if (codec_init()) { |
150 | retval = CODEC_ERROR; | 133 | retval = CODEC_ERROR; |
151 | goto exit; | 134 | goto exit; |
152 | } | 135 | } |
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c index 3c9a6372e9..4a9c7479f3 100644 --- a/apps/codecs/aac.c +++ b/apps/codecs/aac.c | |||
@@ -25,19 +25,8 @@ | |||
25 | 25 | ||
26 | CODEC_HEADER | 26 | CODEC_HEADER |
27 | 27 | ||
28 | #ifndef SIMULATOR | ||
29 | extern char iramcopy[]; | ||
30 | extern char iramstart[]; | ||
31 | extern char iramend[]; | ||
32 | extern char iedata[]; | ||
33 | extern char iend[]; | ||
34 | #endif | ||
35 | |||
36 | struct codec_api* rb; | ||
37 | struct codec_api* ci; | ||
38 | |||
39 | /* this is the codec entry point */ | 28 | /* this is the codec entry point */ |
40 | enum codec_status codec_start(struct codec_api* api) | 29 | enum codec_status codec_main(void) |
41 | { | 30 | { |
42 | /* Note that when dealing with QuickTime/MPEG4 files, terminology is | 31 | /* Note that when dealing with QuickTime/MPEG4 files, terminology is |
43 | * a bit confusing. Files with sound are split up in chunks, where | 32 | * 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) | |||
62 | unsigned char c = 0; | 51 | unsigned char c = 0; |
63 | 52 | ||
64 | /* Generic codec initialisation */ | 53 | /* Generic codec initialisation */ |
65 | rb = api; | ||
66 | ci = api; | ||
67 | |||
68 | #ifndef SIMULATOR | ||
69 | ci->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
70 | ci->memset(iedata, 0, iend - iedata); | ||
71 | #endif | ||
72 | |||
73 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16)); | 54 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16)); |
74 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 55 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
75 | 56 | ||
@@ -79,7 +60,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
79 | next_track: | 60 | next_track: |
80 | err = CODEC_OK; | 61 | err = CODEC_OK; |
81 | 62 | ||
82 | if (codec_init(api)) { | 63 | if (codec_init()) { |
83 | LOGF("FAAD: Codec init error\n"); | 64 | LOGF("FAAD: Codec init error\n"); |
84 | err = CODEC_ERROR; | 65 | err = CODEC_ERROR; |
85 | goto exit; | 66 | goto exit; |
@@ -90,8 +71,8 @@ next_track: | |||
90 | 71 | ||
91 | sound_samples_done = ci->id3->offset; | 72 | sound_samples_done = ci->id3->offset; |
92 | 73 | ||
93 | ci->configure(DSP_SWITCH_FREQUENCY, (long *)(rb->id3->frequency)); | 74 | ci->configure(DSP_SWITCH_FREQUENCY, (long *)(ci->id3->frequency)); |
94 | codec_set_replaygain(rb->id3); | 75 | codec_set_replaygain(ci->id3); |
95 | 76 | ||
96 | stream_create(&input_stream,ci); | 77 | stream_create(&input_stream,ci); |
97 | 78 | ||
@@ -139,7 +120,7 @@ next_track: | |||
139 | 120 | ||
140 | /* The main decoding loop */ | 121 | /* The main decoding loop */ |
141 | while (i < demux_res.num_sample_byte_sizes) { | 122 | while (i < demux_res.num_sample_byte_sizes) { |
142 | rb->yield(); | 123 | ci->yield(); |
143 | 124 | ||
144 | if (ci->stop_codec || ci->new_track) { | 125 | if (ci->stop_codec || ci->new_track) { |
145 | break; | 126 | break; |
@@ -195,12 +176,12 @@ next_track: | |||
195 | ci->advance_buffer(n); | 176 | ci->advance_buffer(n); |
196 | 177 | ||
197 | /* Output the audio */ | 178 | /* Output the audio */ |
198 | rb->yield(); | 179 | ci->yield(); |
199 | while (!rb->pcmbuf_insert_split(decoder->time_out[0], | 180 | while (!ci->pcmbuf_insert_split(decoder->time_out[0], |
200 | decoder->time_out[1], | 181 | decoder->time_out[1], |
201 | frame_info.samples * 2)) | 182 | frame_info.samples * 2)) |
202 | { | 183 | { |
203 | rb->sleep(1); | 184 | ci->sleep(1); |
204 | } | 185 | } |
205 | 186 | ||
206 | /* Update the elapsed-time indicator */ | 187 | /* Update the elapsed-time indicator */ |
diff --git a/apps/codecs/adx.c b/apps/codecs/adx.c index 803600b23e..608d9f0a3f 100644 --- a/apps/codecs/adx.c +++ b/apps/codecs/adx.c | |||
@@ -21,8 +21,6 @@ | |||
21 | 21 | ||
22 | CODEC_HEADER | 22 | CODEC_HEADER |
23 | 23 | ||
24 | struct codec_api *rb; | ||
25 | |||
26 | /* Maximum number of bytes to process in one iteration */ | 24 | /* Maximum number of bytes to process in one iteration */ |
27 | #define WAV_CHUNK_SIZE (1024*2) | 25 | #define WAV_CHUNK_SIZE (1024*2) |
28 | 26 | ||
@@ -38,9 +36,8 @@ struct codec_api *rb; | |||
38 | static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR; | 36 | static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR; |
39 | 37 | ||
40 | /* this is the codec entry point */ | 38 | /* this is the codec entry point */ |
41 | enum codec_status codec_start(struct codec_api *api) | 39 | enum codec_status codec_main(void) |
42 | { | 40 | { |
43 | struct codec_api *ci; | ||
44 | int channels; | 41 | int channels; |
45 | int sampleswritten, i; | 42 | int sampleswritten, i; |
46 | uint8_t *buf; | 43 | uint8_t *buf; |
@@ -56,16 +53,13 @@ enum codec_status codec_start(struct codec_api *api) | |||
56 | off_t chanstart, bufoff; | 53 | off_t chanstart, bufoff; |
57 | 54 | ||
58 | /* Generic codec initialisation */ | 55 | /* Generic codec initialisation */ |
59 | rb = api; | ||
60 | ci = api; | ||
61 | |||
62 | /* we only render 16 bits */ | 56 | /* we only render 16 bits */ |
63 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)16); | 57 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)16); |
64 | /*ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));*/ | 58 | /*ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256));*/ |
65 | 59 | ||
66 | next_track: | 60 | next_track: |
67 | DEBUGF("ADX: next_track\n"); | 61 | DEBUGF("ADX: next_track\n"); |
68 | if (codec_init(api)) { | 62 | if (codec_init()) { |
69 | return CODEC_ERROR; | 63 | return CODEC_ERROR; |
70 | } | 64 | } |
71 | DEBUGF("ADX: after init\n"); | 65 | DEBUGF("ADX: after init\n"); |
diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c index 479d405c41..d1bb14aa64 100644 --- a/apps/codecs/aiff.c +++ b/apps/codecs/aiff.c | |||
@@ -25,8 +25,6 @@ CODEC_HEADER | |||
25 | /* Macro that sign extends an unsigned byte */ | 25 | /* Macro that sign extends an unsigned byte */ |
26 | #define SE(x) ((int32_t)((int8_t)(x))) | 26 | #define SE(x) ((int32_t)((int8_t)(x))) |
27 | 27 | ||
28 | struct codec_api *rb; | ||
29 | |||
30 | /* This codec supports AIFF files with the following formats: | 28 | /* This codec supports AIFF files with the following formats: |
31 | * - PCM, 8, 16 and 24 bits, mono or stereo | 29 | * - PCM, 8, 16 and 24 bits, mono or stereo |
32 | */ | 30 | */ |
@@ -43,19 +41,10 @@ enum | |||
43 | /* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */ | 41 | /* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */ |
44 | #define AIF_CHUNK_SIZE (1024*2) | 42 | #define AIF_CHUNK_SIZE (1024*2) |
45 | 43 | ||
46 | #ifdef USE_IRAM | ||
47 | extern char iramcopy[]; | ||
48 | extern char iramstart[]; | ||
49 | extern char iramend[]; | ||
50 | extern char iedata[]; | ||
51 | extern char iend[]; | ||
52 | #endif | ||
53 | |||
54 | static int32_t samples[AIF_CHUNK_SIZE] IBSS_ATTR; | 44 | static int32_t samples[AIF_CHUNK_SIZE] IBSS_ATTR; |
55 | 45 | ||
56 | enum codec_status codec_start(struct codec_api *api) | 46 | enum codec_status codec_main(void) |
57 | { | 47 | { |
58 | struct codec_api *ci; | ||
59 | uint32_t numbytes, bytesdone; | 48 | uint32_t numbytes, bytesdone; |
60 | uint16_t num_channels = 0; | 49 | uint16_t num_channels = 0; |
61 | uint32_t num_sample_frames = 0; | 50 | uint32_t num_sample_frames = 0; |
@@ -73,20 +62,12 @@ enum codec_status codec_start(struct codec_api *api) | |||
73 | off_t firstblockposn; /* position of the first block in file */ | 62 | off_t firstblockposn; /* position of the first block in file */ |
74 | 63 | ||
75 | /* Generic codec initialisation */ | 64 | /* Generic codec initialisation */ |
76 | rb = api; | ||
77 | ci = api; | ||
78 | |||
79 | #ifdef USE_IRAM | ||
80 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
81 | ci->memset(iedata, 0, iend - iedata); | ||
82 | #endif | ||
83 | |||
84 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); | 65 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); |
85 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 66 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
86 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256)); | 67 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256)); |
87 | 68 | ||
88 | next_track: | 69 | next_track: |
89 | if (codec_init(api)) { | 70 | if (codec_init()) { |
90 | i = CODEC_ERROR; | 71 | i = CODEC_ERROR; |
91 | goto exit; | 72 | goto exit; |
92 | } | 73 | } |
diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c index 8b6e2217c9..4f9e0e06e2 100644 --- a/apps/codecs/aiff_enc.c +++ b/apps/codecs/aiff_enc.c | |||
@@ -24,14 +24,6 @@ | |||
24 | 24 | ||
25 | CODEC_ENC_HEADER | 25 | CODEC_ENC_HEADER |
26 | 26 | ||
27 | #ifdef USE_IRAM | ||
28 | extern char iramcopy[]; | ||
29 | extern char iramstart[]; | ||
30 | extern char iramend[]; | ||
31 | extern char iedata[]; | ||
32 | extern char iend[]; | ||
33 | #endif | ||
34 | |||
35 | struct aiff_header | 27 | struct aiff_header |
36 | { | 28 | { |
37 | uint8_t form_id[4]; /* 00h - 'FORM' */ | 29 | uint8_t form_id[4]; /* 00h - 'FORM' */ |
@@ -77,7 +69,6 @@ struct aiff_header aiff_header = | |||
77 | 69 | ||
78 | /* (*) updated when finalizing file */ | 70 | /* (*) updated when finalizing file */ |
79 | 71 | ||
80 | static struct codec_api *ci; | ||
81 | static int num_channels; | 72 | static int num_channels; |
82 | uint32_t sample_rate; | 73 | uint32_t sample_rate; |
83 | uint32_t enc_size; | 74 | uint32_t enc_size; |
@@ -332,17 +323,10 @@ static bool init_encoder(void) | |||
332 | } /* init_encoder */ | 323 | } /* init_encoder */ |
333 | 324 | ||
334 | /* main codec entry point */ | 325 | /* main codec entry point */ |
335 | enum codec_status codec_start(struct codec_api* api) | 326 | enum codec_status codec_start(void) |
336 | { | 327 | { |
337 | bool cpu_boosted; | 328 | bool cpu_boosted; |
338 | 329 | ||
339 | ci = api; /* copy to global api pointer */ | ||
340 | |||
341 | #ifdef USE_IRAM | ||
342 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
343 | ci->memset(iedata, 0, iend - iedata); | ||
344 | #endif | ||
345 | |||
346 | if (!init_encoder()) | 330 | if (!init_encoder()) |
347 | { | 331 | { |
348 | ci->enc_codec_loaded = -1; | 332 | ci->enc_codec_loaded = -1; |
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c index 13423f4804..1c1b14a0da 100644 --- a/apps/codecs/alac.c +++ b/apps/codecs/alac.c | |||
@@ -23,21 +23,10 @@ | |||
23 | 23 | ||
24 | CODEC_HEADER | 24 | CODEC_HEADER |
25 | 25 | ||
26 | #ifdef USE_IRAM | ||
27 | extern char iramcopy[]; | ||
28 | extern char iramstart[]; | ||
29 | extern char iramend[]; | ||
30 | extern char iedata[]; | ||
31 | extern char iend[]; | ||
32 | #endif | ||
33 | |||
34 | int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE] IBSS_ATTR; | 26 | int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE] IBSS_ATTR; |
35 | 27 | ||
36 | struct codec_api* rb; | ||
37 | struct codec_api* ci; | ||
38 | |||
39 | /* this is the codec entry point */ | 28 | /* this is the codec entry point */ |
40 | enum codec_status codec_start(struct codec_api* api) | 29 | enum codec_status codec_main(void) |
41 | { | 30 | { |
42 | size_t n; | 31 | size_t n; |
43 | demux_res_t demux_res; | 32 | demux_res_t demux_res; |
@@ -53,14 +42,6 @@ enum codec_status codec_start(struct codec_api* api) | |||
53 | int retval; | 42 | int retval; |
54 | 43 | ||
55 | /* Generic codec initialisation */ | 44 | /* Generic codec initialisation */ |
56 | rb = api; | ||
57 | ci = api; | ||
58 | |||
59 | #ifdef USE_IRAM | ||
60 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
61 | rb->memset(iedata, 0, iend - iedata); | ||
62 | #endif | ||
63 | |||
64 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 45 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
65 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); | 46 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); |
66 | 47 | ||
@@ -69,7 +50,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
69 | 50 | ||
70 | next_track: | 51 | next_track: |
71 | 52 | ||
72 | if (codec_init(api)) { | 53 | if (codec_init()) { |
73 | LOGF("ALAC: Error initialising codec\n"); | 54 | LOGF("ALAC: Error initialising codec\n"); |
74 | retval = CODEC_ERROR; | 55 | retval = CODEC_ERROR; |
75 | goto exit; | 56 | goto exit; |
@@ -78,8 +59,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
78 | while (!*ci->taginfo_ready && !ci->stop_codec) | 59 | while (!*ci->taginfo_ready && !ci->stop_codec) |
79 | ci->sleep(1); | 60 | ci->sleep(1); |
80 | 61 | ||
81 | ci->configure(DSP_SWITCH_FREQUENCY, (long *)(rb->id3->frequency)); | 62 | ci->configure(DSP_SWITCH_FREQUENCY, (long *)(ci->id3->frequency)); |
82 | codec_set_replaygain(rb->id3); | 63 | codec_set_replaygain(ci->id3); |
83 | 64 | ||
84 | stream_create(&input_stream,ci); | 65 | stream_create(&input_stream,ci); |
85 | 66 | ||
@@ -99,7 +80,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
99 | samplesdone=0; | 80 | samplesdone=0; |
100 | /* The main decoding loop */ | 81 | /* The main decoding loop */ |
101 | while (i < demux_res.num_sample_byte_sizes) { | 82 | while (i < demux_res.num_sample_byte_sizes) { |
102 | rb->yield(); | 83 | ci->yield(); |
103 | if (ci->stop_codec || ci->new_track) { | 84 | if (ci->stop_codec || ci->new_track) { |
104 | break; | 85 | break; |
105 | } | 86 | } |
@@ -132,18 +113,18 @@ enum codec_status codec_start(struct codec_api* api) | |||
132 | } | 113 | } |
133 | 114 | ||
134 | /* Decode one block - returned samples will be host-endian */ | 115 | /* Decode one block - returned samples will be host-endian */ |
135 | rb->yield(); | 116 | ci->yield(); |
136 | samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, rb->yield); | 117 | samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, ci->yield); |
137 | 118 | ||
138 | /* Advance codec buffer n bytes */ | 119 | /* Advance codec buffer n bytes */ |
139 | ci->advance_buffer(n); | 120 | ci->advance_buffer(n); |
140 | 121 | ||
141 | /* Output the audio */ | 122 | /* Output the audio */ |
142 | rb->yield(); | 123 | ci->yield(); |
143 | while(!ci->pcmbuf_insert_split(outputbuffer[0], | 124 | while(!ci->pcmbuf_insert_split(outputbuffer[0], |
144 | outputbuffer[1], | 125 | outputbuffer[1], |
145 | samplesdecoded*sizeof(int32_t))) | 126 | samplesdecoded*sizeof(int32_t))) |
146 | rb->yield(); | 127 | ci->yield(); |
147 | 128 | ||
148 | /* Update the elapsed-time indicator */ | 129 | /* Update the elapsed-time indicator */ |
149 | samplesdone+=sample_duration; | 130 | samplesdone+=sample_duration; |
diff --git a/apps/codecs/codec.h b/apps/codecs/codec.h index daa7c19cd7..44d5a110bd 100644 --- a/apps/codecs/codec.h +++ b/apps/codecs/codec.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #include <sys/types.h> | 25 | #include <sys/types.h> |
26 | 26 | ||
27 | extern struct codec_api *ci; | ||
28 | |||
27 | /* Get these functions 'out of the way' of the standard functions. Not doing | 29 | /* Get these functions 'out of the way' of the standard functions. Not doing |
28 | * so confuses the cygwin linker, and maybe others. These functions need to | 30 | * so confuses the cygwin linker, and maybe others. These functions need to |
29 | * be implemented elsewhere */ | 31 | * be implemented elsewhere */ |
diff --git a/apps/codecs/codec_crt0.c b/apps/codecs/codec_crt0.c new file mode 100644 index 0000000000..96dc862fb5 --- /dev/null +++ b/apps/codecs/codec_crt0.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 Tomasz Malesinski | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "codeclib.h" | ||
22 | |||
23 | struct codec_api *ci; | ||
24 | |||
25 | extern unsigned char iramcopy[]; | ||
26 | extern unsigned char iramstart[]; | ||
27 | extern unsigned char iramend[]; | ||
28 | extern unsigned char iedata[]; | ||
29 | extern unsigned char iend[]; | ||
30 | extern unsigned char plugin_bss_start[]; | ||
31 | extern unsigned char plugin_end_addr[]; | ||
32 | |||
33 | extern enum codec_status codec_main(void); | ||
34 | |||
35 | enum codec_status codec_start(struct codec_api *api) | ||
36 | { | ||
37 | #ifndef SIMULATOR | ||
38 | #ifdef USE_IRAM | ||
39 | api->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
40 | api->memset(iedata, 0, iend - iedata); | ||
41 | #endif | ||
42 | api->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start); | ||
43 | #endif | ||
44 | ci = api; | ||
45 | return codec_main(); | ||
46 | } | ||
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index 4f5f0b1eaa..b3cba32c82 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c | |||
@@ -22,17 +22,6 @@ | |||
22 | 22 | ||
23 | CODEC_HEADER | 23 | CODEC_HEADER |
24 | 24 | ||
25 | #ifdef USE_IRAM | ||
26 | extern char iramcopy[]; | ||
27 | extern char iramstart[]; | ||
28 | extern char iramend[]; | ||
29 | extern char iedata[]; | ||
30 | extern char iend[]; | ||
31 | #endif | ||
32 | |||
33 | struct codec_api* rb; | ||
34 | struct codec_api* ci; | ||
35 | |||
36 | /* The output buffers containing the decoded samples (channels 0 and 1) */ | 25 | /* The output buffers containing the decoded samples (channels 0 and 1) */ |
37 | int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0; | 26 | int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0; |
38 | int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR; | 27 | int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR; |
@@ -423,7 +412,7 @@ bool flac_seek_offset(FLACContext* fc, uint32_t offset) { | |||
423 | } | 412 | } |
424 | 413 | ||
425 | /* this is the codec entry point */ | 414 | /* this is the codec entry point */ |
426 | enum codec_status codec_start(struct codec_api* api) | 415 | enum codec_status codec_main(void) |
427 | { | 416 | { |
428 | int8_t *buf; | 417 | int8_t *buf; |
429 | FLACContext fc; | 418 | FLACContext fc; |
@@ -436,14 +425,6 @@ enum codec_status codec_start(struct codec_api* api) | |||
436 | int retval; | 425 | int retval; |
437 | 426 | ||
438 | /* Generic codec initialisation */ | 427 | /* Generic codec initialisation */ |
439 | rb = api; | ||
440 | ci = api; | ||
441 | |||
442 | #ifdef USE_IRAM | ||
443 | ci->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
444 | ci->memset(iedata, 0, iend - iedata); | ||
445 | #endif | ||
446 | |||
447 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 428 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
448 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); | 429 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); |
449 | 430 | ||
@@ -455,7 +436,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
455 | /* Need to save offset for later use (cleared indirectly by flac_init) */ | 436 | /* Need to save offset for later use (cleared indirectly by flac_init) */ |
456 | samplesdone=ci->id3->offset; | 437 | samplesdone=ci->id3->offset; |
457 | 438 | ||
458 | if (codec_init(api)) { | 439 | if (codec_init()) { |
459 | LOGF("FLAC: Error initialising codec\n"); | 440 | LOGF("FLAC: Error initialising codec\n"); |
460 | retval = CODEC_ERROR; | 441 | retval = CODEC_ERROR; |
461 | goto exit; | 442 | goto exit; |
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c index 4aa7d29e86..f6b2131e88 100644 --- a/apps/codecs/lib/codeclib.c +++ b/apps/codecs/lib/codeclib.c | |||
@@ -24,29 +24,26 @@ | |||
24 | #include "codeclib.h" | 24 | #include "codeclib.h" |
25 | #include "id3.h" | 25 | #include "id3.h" |
26 | 26 | ||
27 | struct codec_api *local_rb; | ||
28 | |||
29 | long mem_ptr; | 27 | long mem_ptr; |
30 | long bufsize; | 28 | long bufsize; |
31 | unsigned char* mp3buf; // The actual MP3 buffer from Rockbox | 29 | unsigned char* mp3buf; // The actual MP3 buffer from Rockbox |
32 | unsigned char* mallocbuf; // 512K from the start of MP3 buffer | 30 | unsigned char* mallocbuf; // 512K from the start of MP3 buffer |
33 | unsigned char* filebuf; // The rest of the MP3 buffer | 31 | unsigned char* filebuf; // The rest of the MP3 buffer |
34 | 32 | ||
35 | int codec_init(struct codec_api* rb) | 33 | int codec_init(void) |
36 | { | 34 | { |
37 | local_rb = rb; | ||
38 | mem_ptr = 0; | 35 | mem_ptr = 0; |
39 | mallocbuf = (unsigned char *)rb->get_codec_memory((size_t *)&bufsize); | 36 | mallocbuf = (unsigned char *)ci->get_codec_memory((size_t *)&bufsize); |
40 | 37 | ||
41 | return 0; | 38 | return 0; |
42 | } | 39 | } |
43 | 40 | ||
44 | void codec_set_replaygain(struct mp3entry* id3) | 41 | void codec_set_replaygain(struct mp3entry* id3) |
45 | { | 42 | { |
46 | local_rb->configure(DSP_SET_TRACK_GAIN, (long *) id3->track_gain); | 43 | ci->configure(DSP_SET_TRACK_GAIN, (long *) id3->track_gain); |
47 | local_rb->configure(DSP_SET_ALBUM_GAIN, (long *) id3->album_gain); | 44 | ci->configure(DSP_SET_ALBUM_GAIN, (long *) id3->album_gain); |
48 | local_rb->configure(DSP_SET_TRACK_PEAK, (long *) id3->track_peak); | 45 | ci->configure(DSP_SET_TRACK_PEAK, (long *) id3->track_peak); |
49 | local_rb->configure(DSP_SET_ALBUM_PEAK, (long *) id3->album_peak); | 46 | ci->configure(DSP_SET_ALBUM_PEAK, (long *) id3->album_peak); |
50 | } | 47 | } |
51 | 48 | ||
52 | /* Various "helper functions" common to all the xxx2wav decoder plugins */ | 49 | /* Various "helper functions" common to all the xxx2wav decoder plugins */ |
@@ -71,7 +68,7 @@ void* codec_calloc(size_t nmemb, size_t size) | |||
71 | x = codec_malloc(nmemb*size); | 68 | x = codec_malloc(nmemb*size); |
72 | if (x == NULL) | 69 | if (x == NULL) |
73 | return NULL; | 70 | return NULL; |
74 | local_rb->memset(x,0,nmemb*size); | 71 | ci->memset(x,0,nmemb*size); |
75 | return(x); | 72 | return(x); |
76 | } | 73 | } |
77 | 74 | ||
@@ -89,71 +86,71 @@ void* codec_realloc(void* ptr, size_t size) | |||
89 | 86 | ||
90 | size_t strlen(const char *s) | 87 | size_t strlen(const char *s) |
91 | { | 88 | { |
92 | return(local_rb->strlen(s)); | 89 | return(ci->strlen(s)); |
93 | } | 90 | } |
94 | 91 | ||
95 | char *strcpy(char *dest, const char *src) | 92 | char *strcpy(char *dest, const char *src) |
96 | { | 93 | { |
97 | return(local_rb->strcpy(dest,src)); | 94 | return(ci->strcpy(dest,src)); |
98 | } | 95 | } |
99 | 96 | ||
100 | char *strcat(char *dest, const char *src) | 97 | char *strcat(char *dest, const char *src) |
101 | { | 98 | { |
102 | return(local_rb->strcat(dest,src)); | 99 | return(ci->strcat(dest,src)); |
103 | } | 100 | } |
104 | 101 | ||
105 | int strcmp(const char *s1, const char *s2) | 102 | int strcmp(const char *s1, const char *s2) |
106 | { | 103 | { |
107 | return(local_rb->strcmp(s1,s2)); | 104 | return(ci->strcmp(s1,s2)); |
108 | } | 105 | } |
109 | 106 | ||
110 | int strncasecmp(const char *s1, const char *s2, size_t n) | 107 | int strncasecmp(const char *s1, const char *s2, size_t n) |
111 | { | 108 | { |
112 | return(local_rb->strncasecmp(s1,s2,n)); | 109 | return(ci->strncasecmp(s1,s2,n)); |
113 | } | 110 | } |
114 | 111 | ||
115 | void *memcpy(void *dest, const void *src, size_t n) | 112 | void *memcpy(void *dest, const void *src, size_t n) |
116 | { | 113 | { |
117 | return(local_rb->memcpy(dest,src,n)); | 114 | return(ci->memcpy(dest,src,n)); |
118 | } | 115 | } |
119 | 116 | ||
120 | void *memset(void *s, int c, size_t n) | 117 | void *memset(void *s, int c, size_t n) |
121 | { | 118 | { |
122 | return(local_rb->memset(s,c,n)); | 119 | return(ci->memset(s,c,n)); |
123 | } | 120 | } |
124 | 121 | ||
125 | int memcmp(const void *s1, const void *s2, size_t n) | 122 | int memcmp(const void *s1, const void *s2, size_t n) |
126 | { | 123 | { |
127 | return(local_rb->memcmp(s1,s2,n)); | 124 | return(ci->memcmp(s1,s2,n)); |
128 | } | 125 | } |
129 | 126 | ||
130 | void* memchr(const void *s, int c, size_t n) | 127 | void* memchr(const void *s, int c, size_t n) |
131 | { | 128 | { |
132 | return(local_rb->memchr(s,c,n)); | 129 | return(ci->memchr(s,c,n)); |
133 | } | 130 | } |
134 | 131 | ||
135 | void *memmove(void *dest, const void *src, size_t n) | 132 | void *memmove(void *dest, const void *src, size_t n) |
136 | { | 133 | { |
137 | return(local_rb->memmove(dest,src,n)); | 134 | return(ci->memmove(dest,src,n)); |
138 | } | 135 | } |
139 | 136 | ||
140 | void qsort(void *base, size_t nmemb, size_t size, | 137 | void qsort(void *base, size_t nmemb, size_t size, |
141 | int(*compar)(const void *, const void *)) | 138 | int(*compar)(const void *, const void *)) |
142 | { | 139 | { |
143 | local_rb->qsort(base,nmemb,size,compar); | 140 | ci->qsort(base,nmemb,size,compar); |
144 | } | 141 | } |
145 | 142 | ||
146 | #ifdef RB_PROFILE | 143 | #ifdef RB_PROFILE |
147 | void __cyg_profile_func_enter(void *this_fn, void *call_site) { | 144 | void __cyg_profile_func_enter(void *this_fn, void *call_site) { |
148 | #ifdef CPU_COLDFIRE | 145 | #ifdef CPU_COLDFIRE |
149 | (void)call_site; | 146 | (void)call_site; |
150 | local_rb->profile_func_enter(this_fn, __builtin_return_address(1)); | 147 | ci->profile_func_enter(this_fn, __builtin_return_address(1)); |
151 | #else | 148 | #else |
152 | local_rb->profile_func_enter(this_fn, call_site); | 149 | ci->profile_func_enter(this_fn, call_site); |
153 | #endif | 150 | #endif |
154 | } | 151 | } |
155 | 152 | ||
156 | void __cyg_profile_func_exit(void *this_fn, void *call_site) { | 153 | void __cyg_profile_func_exit(void *this_fn, void *call_site) { |
157 | local_rb->profile_func_exit(this_fn,call_site); | 154 | ci->profile_func_exit(this_fn,call_site); |
158 | } | 155 | } |
159 | #endif | 156 | #endif |
diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h index 00b60c3e92..366d30e064 100644 --- a/apps/codecs/lib/codeclib.h +++ b/apps/codecs/lib/codeclib.h | |||
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #define MALLOC_BUFSIZE (512*1024) | 25 | #define MALLOC_BUFSIZE (512*1024) |
26 | 26 | ||
27 | extern struct codec_api *ci; | ||
27 | extern long mem_ptr; | 28 | extern long mem_ptr; |
28 | extern long bufsize; | 29 | extern long bufsize; |
29 | extern unsigned char* mp3buf; // The actual MP3 buffer from Rockbox | 30 | 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 | |||
55 | 56 | ||
56 | /* Various codec helper functions */ | 57 | /* Various codec helper functions */ |
57 | 58 | ||
58 | int codec_init(struct codec_api* rb); | 59 | int codec_init(void); |
59 | void codec_set_replaygain(struct mp3entry* id3); | 60 | void codec_set_replaygain(struct mp3entry* id3); |
60 | 61 | ||
61 | #ifdef RB_PROFILE | 62 | #ifdef RB_PROFILE |
diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c index cb727ce01e..12a24a7c9b 100644 --- a/apps/codecs/mp3_enc.c +++ b/apps/codecs/mp3_enc.c | |||
@@ -53,14 +53,6 @@ CODEC_ENC_HEADER | |||
53 | #define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \ | 53 | #define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \ |
54 | else { putbits(cc, sz); cc = c; sz = s; } | 54 | else { putbits(cc, sz); cc = c; sz = s; } |
55 | 55 | ||
56 | #ifdef USE_IRAM | ||
57 | extern char iramcopy[]; | ||
58 | extern char iramstart[]; | ||
59 | extern char iramend[]; | ||
60 | extern char iedata[]; | ||
61 | extern char iend[]; | ||
62 | #endif | ||
63 | |||
64 | typedef struct { | 56 | typedef struct { |
65 | int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */ | 57 | int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */ |
66 | int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */ | 58 | int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */ |
@@ -181,7 +173,6 @@ static unsigned pcm_chunk_size IBSS_ATTR; | |||
181 | static unsigned samp_per_frame IBSS_ATTR; | 173 | static unsigned samp_per_frame IBSS_ATTR; |
182 | 174 | ||
183 | static config_t cfg IBSS_ATTR; | 175 | static config_t cfg IBSS_ATTR; |
184 | static struct codec_api *ci; | ||
185 | static char *res_buffer; | 176 | static char *res_buffer; |
186 | 177 | ||
187 | static const uint8_t ht_count_const[2][2][16] = | 178 | static const uint8_t ht_count_const[2][2][16] = |
@@ -2460,18 +2451,11 @@ static bool enc_init(void) | |||
2460 | return true; | 2451 | return true; |
2461 | } /* enc_init */ | 2452 | } /* enc_init */ |
2462 | 2453 | ||
2463 | enum codec_status codec_start(struct codec_api* api) | 2454 | enum codec_status codec_main(void) |
2464 | { | 2455 | { |
2465 | bool cpu_boosted; | 2456 | bool cpu_boosted; |
2466 | 2457 | ||
2467 | /* Generic codec initialisation */ | 2458 | /* Generic codec initialisation */ |
2468 | ci = api; | ||
2469 | |||
2470 | #ifdef USE_IRAM | ||
2471 | memcpy(iramstart, iramcopy, iramend - iramstart); | ||
2472 | memset(iedata, 0, iend - iedata); | ||
2473 | #endif | ||
2474 | |||
2475 | if (!enc_init()) | 2459 | if (!enc_init()) |
2476 | { | 2460 | { |
2477 | ci->enc_codec_loaded = -1; | 2461 | ci->enc_codec_loaded = -1; |
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 94947a9d1c..6e474c1abb 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c | |||
@@ -42,16 +42,6 @@ unsigned char mad_main_data[MAD_BUFFER_MDLEN] IBSS_ATTR; | |||
42 | int mpeg_latency[3] = { 0, 481, 529 }; | 42 | int mpeg_latency[3] = { 0, 481, 529 }; |
43 | int mpeg_framesize[3] = {384, 1152, 1152}; | 43 | int mpeg_framesize[3] = {384, 1152, 1152}; |
44 | 44 | ||
45 | #ifdef USE_IRAM | ||
46 | extern char iramcopy[]; | ||
47 | extern char iramstart[]; | ||
48 | extern char iramend[]; | ||
49 | extern char iedata[]; | ||
50 | extern char iend[]; | ||
51 | #endif | ||
52 | |||
53 | struct codec_api *ci; | ||
54 | |||
55 | void init_mad(void) | 45 | void init_mad(void) |
56 | { | 46 | { |
57 | ci->memset(&stream, 0, sizeof(struct mad_stream)); | 47 | ci->memset(&stream, 0, sizeof(struct mad_stream)); |
@@ -69,7 +59,7 @@ void init_mad(void) | |||
69 | } | 59 | } |
70 | 60 | ||
71 | /* this is the codec entry point */ | 61 | /* this is the codec entry point */ |
72 | enum codec_status codec_start(struct codec_api *api) | 62 | enum codec_status codec_main(void) |
73 | { | 63 | { |
74 | int status; | 64 | int status; |
75 | size_t size; | 65 | size_t size; |
@@ -83,14 +73,7 @@ enum codec_status codec_start(struct codec_api *api) | |||
83 | int framelength; | 73 | int framelength; |
84 | int padding = MAD_BUFFER_GUARD; /* to help mad decode the last frame */ | 74 | int padding = MAD_BUFFER_GUARD; /* to help mad decode the last frame */ |
85 | 75 | ||
86 | ci = api; | 76 | if (codec_init()) |
87 | |||
88 | #ifdef USE_IRAM | ||
89 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
90 | ci->memset(iedata, 0, iend - iedata); | ||
91 | #endif | ||
92 | |||
93 | if (codec_init(api)) | ||
94 | return CODEC_ERROR; | 77 | return CODEC_ERROR; |
95 | 78 | ||
96 | /* Create a decoder instance */ | 79 | /* Create a decoder instance */ |
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c index ad38185fe0..1075d88aa1 100644 --- a/apps/codecs/mpc.c +++ b/apps/codecs/mpc.c | |||
@@ -67,18 +67,9 @@ MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH] | |||
67 | IBSS_ATTR_MPC_SAMPLE_BUF; | 67 | IBSS_ATTR_MPC_SAMPLE_BUF; |
68 | mpc_uint32_t seek_table[10000]; | 68 | mpc_uint32_t seek_table[10000]; |
69 | 69 | ||
70 | #ifdef USE_IRAM | ||
71 | extern char iramcopy[]; | ||
72 | extern char iramstart[]; | ||
73 | extern char iramend[]; | ||
74 | extern char iedata[]; | ||
75 | extern char iend[]; | ||
76 | #endif | ||
77 | |||
78 | /* this is the codec entry point */ | 70 | /* this is the codec entry point */ |
79 | enum codec_status codec_start(struct codec_api *api) | 71 | enum codec_status codec_main(void) |
80 | { | 72 | { |
81 | struct codec_api *ci = api; | ||
82 | mpc_int64_t samplesdone; | 73 | mpc_int64_t samplesdone; |
83 | unsigned long frequency; | 74 | unsigned long frequency; |
84 | unsigned status; | 75 | unsigned status; |
@@ -86,11 +77,6 @@ enum codec_status codec_start(struct codec_api *api) | |||
86 | mpc_streaminfo info; | 77 | mpc_streaminfo info; |
87 | int retval = CODEC_OK; | 78 | int retval = CODEC_OK; |
88 | 79 | ||
89 | #ifdef USE_IRAM | ||
90 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
91 | ci->memset(iedata, 0, iend - iedata); | ||
92 | #endif | ||
93 | |||
94 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)(28)); | 80 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)(28)); |
95 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*16)); | 81 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*16)); |
96 | ci->configure(CODEC_SET_FILEBUF_PRESEEK, (long *)(0)); | 82 | ci->configure(CODEC_SET_FILEBUF_PRESEEK, (long *)(0)); |
@@ -109,7 +95,7 @@ enum codec_status codec_start(struct codec_api *api) | |||
109 | mpc_decoder_set_seek_table(&decoder, seek_table, sizeof(seek_table)); | 95 | mpc_decoder_set_seek_table(&decoder, seek_table, sizeof(seek_table)); |
110 | 96 | ||
111 | next_track: | 97 | next_track: |
112 | if (codec_init(api)) { | 98 | if (codec_init()) { |
113 | retval = CODEC_ERROR; | 99 | retval = CODEC_ERROR; |
114 | goto exit; | 100 | goto exit; |
115 | } | 101 | } |
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c index b48a91ea17..1b9563a676 100644 --- a/apps/codecs/shorten.c +++ b/apps/codecs/shorten.c | |||
@@ -20,23 +20,12 @@ | |||
20 | #include "codeclib.h" | 20 | #include "codeclib.h" |
21 | #include <codecs/libffmpegFLAC/shndec.h> | 21 | #include <codecs/libffmpegFLAC/shndec.h> |
22 | 22 | ||
23 | #ifndef IBSS_ATTR_SHORTEN_DECODED0 | ||
24 | #define IBSS_ATTR_SHORTEN_DECODED0 IBSS_ATTR | ||
25 | #endif | ||
26 | |||
27 | CODEC_HEADER | 23 | CODEC_HEADER |
28 | 24 | ||
29 | #ifdef USE_IRAM | 25 | #ifndef IBSS_ATTR_SHORTEN_DECODED0 |
30 | extern char iramcopy[]; | 26 | #define IBSS_ATTR_SHORTEN_DECODED0 IBSS_ATTR |
31 | extern char iramstart[]; | ||
32 | extern char iramend[]; | ||
33 | extern char iedata[]; | ||
34 | extern char iend[]; | ||
35 | #endif | 27 | #endif |
36 | 28 | ||
37 | struct codec_api* rb; | ||
38 | struct codec_api* ci; | ||
39 | |||
40 | int32_t decoded0[MAX_DECODE_SIZE] IBSS_ATTR_SHORTEN_DECODED0; | 29 | int32_t decoded0[MAX_DECODE_SIZE] IBSS_ATTR_SHORTEN_DECODED0; |
41 | int32_t decoded1[MAX_DECODE_SIZE] IBSS_ATTR; | 30 | int32_t decoded1[MAX_DECODE_SIZE] IBSS_ATTR; |
42 | 31 | ||
@@ -46,7 +35,7 @@ int32_t offset1[MAX_OFFSET_SIZE] IBSS_ATTR; | |||
46 | int8_t ibuf[MAX_BUFFER_SIZE] IBSS_ATTR; | 35 | int8_t ibuf[MAX_BUFFER_SIZE] IBSS_ATTR; |
47 | 36 | ||
48 | /* this is the codec entry point */ | 37 | /* this is the codec entry point */ |
49 | enum codec_status codec_start(struct codec_api* api) | 38 | enum codec_status codec_main(void) |
50 | { | 39 | { |
51 | ShortenContext sc; | 40 | ShortenContext sc; |
52 | uint32_t samplesdone; | 41 | uint32_t samplesdone; |
@@ -56,14 +45,6 @@ enum codec_status codec_start(struct codec_api* api) | |||
56 | size_t bytesleft; | 45 | size_t bytesleft; |
57 | 46 | ||
58 | /* Generic codec initialisation */ | 47 | /* Generic codec initialisation */ |
59 | rb = api; | ||
60 | ci = api; | ||
61 | |||
62 | #ifdef USE_IRAM | ||
63 | ci->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
64 | ci->memset(iedata, 0, iend - iedata); | ||
65 | #endif | ||
66 | |||
67 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 48 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
68 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); | 49 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); |
69 | 50 | ||
@@ -72,7 +53,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
72 | 53 | ||
73 | next_track: | 54 | next_track: |
74 | /* Codec initialization */ | 55 | /* Codec initialization */ |
75 | if (codec_init(api)) { | 56 | if (codec_init()) { |
76 | LOGF("Shorten: codec_init error\n"); | 57 | LOGF("Shorten: codec_init error\n"); |
77 | return CODEC_ERROR; | 58 | return CODEC_ERROR; |
78 | } | 59 | } |
diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c index d356da7fee..58eb725057 100644 --- a/apps/codecs/sid.c +++ b/apps/codecs/sid.c | |||
@@ -65,21 +65,10 @@ CODEC_HEADER | |||
65 | 65 | ||
66 | #define CHUNK_SIZE (1024*2) | 66 | #define CHUNK_SIZE (1024*2) |
67 | 67 | ||
68 | |||
69 | struct codec_api *rb; | ||
70 | |||
71 | /* This codec supports SID Files: | 68 | /* This codec supports SID Files: |
72 | * | 69 | * |
73 | */ | 70 | */ |
74 | 71 | ||
75 | #ifdef USE_IRAM | ||
76 | extern char iramcopy[]; | ||
77 | extern char iramstart[]; | ||
78 | extern char iramend[]; | ||
79 | extern char iedata[]; | ||
80 | extern char iend[]; | ||
81 | #endif | ||
82 | |||
83 | static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ | 72 | static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ |
84 | 73 | ||
85 | /* Static buffer for the plain SID-File */ | 74 | /* Static buffer for the plain SID-File */ |
@@ -1213,9 +1202,8 @@ unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr, | |||
1213 | } | 1202 | } |
1214 | 1203 | ||
1215 | 1204 | ||
1216 | enum codec_status codec_start(struct codec_api *api) | 1205 | enum codec_status codec_main(void) |
1217 | { | 1206 | { |
1218 | struct codec_api *ci; | ||
1219 | size_t n, bytesfree; | 1207 | size_t n, bytesfree; |
1220 | unsigned char *p; | 1208 | unsigned char *p; |
1221 | unsigned int filesize; | 1209 | unsigned int filesize; |
@@ -1228,20 +1216,11 @@ enum codec_status codec_start(struct codec_api *api) | |||
1228 | int nSamplesToRender = 0; | 1216 | int nSamplesToRender = 0; |
1229 | 1217 | ||
1230 | /* Generic codec initialisation */ | 1218 | /* Generic codec initialisation */ |
1231 | rb = api; | ||
1232 | ci = api; | ||
1233 | |||
1234 | |||
1235 | #ifdef USE_IRAM | ||
1236 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
1237 | ci->memset(iedata, 0, iend - iedata); | ||
1238 | #endif | ||
1239 | |||
1240 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 1219 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
1241 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256)); | 1220 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256)); |
1242 | 1221 | ||
1243 | next_track: | 1222 | next_track: |
1244 | if (codec_init(api)) { | 1223 | if (codec_init()) { |
1245 | return CODEC_ERROR; | 1224 | return CODEC_ERROR; |
1246 | } | 1225 | } |
1247 | 1226 | ||
@@ -1251,7 +1230,7 @@ next_track: | |||
1251 | /* Load SID file */ | 1230 | /* Load SID file */ |
1252 | p = sidfile; | 1231 | p = sidfile; |
1253 | bytesfree=sizeof(sidfile); | 1232 | bytesfree=sizeof(sidfile); |
1254 | while ((n = rb->read_filebuf(p, bytesfree)) > 0) { | 1233 | while ((n = ci->read_filebuf(p, bytesfree)) > 0) { |
1255 | p += n; | 1234 | p += n; |
1256 | bytesfree -= n; | 1235 | bytesfree -= n; |
1257 | } | 1236 | } |
diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c index d08cb0e90d..ca4aa9dd12 100644 --- a/apps/codecs/vorbis.c +++ b/apps/codecs/vorbis.c | |||
@@ -23,14 +23,12 @@ | |||
23 | 23 | ||
24 | CODEC_HEADER | 24 | CODEC_HEADER |
25 | 25 | ||
26 | static struct codec_api *rb; | ||
27 | |||
28 | /* Some standard functions and variables needed by Tremor */ | 26 | /* Some standard functions and variables needed by Tremor */ |
29 | 27 | ||
30 | size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) | 28 | size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) |
31 | { | 29 | { |
32 | (void)datasource; | 30 | (void)datasource; |
33 | return rb->read_filebuf(ptr, nmemb*size); | 31 | return ci->read_filebuf(ptr, nmemb*size); |
34 | } | 32 | } |
35 | 33 | ||
36 | int initial_seek_handler(void *datasource, ogg_int64_t offset, int whence) | 34 | 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) | |||
46 | (void)datasource; | 44 | (void)datasource; |
47 | 45 | ||
48 | if (whence == SEEK_CUR) { | 46 | if (whence == SEEK_CUR) { |
49 | offset += rb->curpos; | 47 | offset += ci->curpos; |
50 | } else if (whence == SEEK_END) { | 48 | } else if (whence == SEEK_END) { |
51 | offset += rb->filesize; | 49 | offset += ci->filesize; |
52 | } | 50 | } |
53 | 51 | ||
54 | if (rb->seek_buffer(offset)) { | 52 | if (ci->seek_buffer(offset)) { |
55 | return 0; | 53 | return 0; |
56 | } | 54 | } |
57 | 55 | ||
@@ -67,7 +65,7 @@ int close_handler(void *datasource) | |||
67 | long tell_handler(void *datasource) | 65 | long tell_handler(void *datasource) |
68 | { | 66 | { |
69 | (void)datasource; | 67 | (void)datasource; |
70 | return rb->curpos; | 68 | return ci->curpos; |
71 | } | 69 | } |
72 | 70 | ||
73 | /* This sets the DSP parameters based on the current logical bitstream | 71 | /* This sets the DSP parameters based on the current logical bitstream |
@@ -81,32 +79,24 @@ bool vorbis_set_codec_parameters(OggVorbis_File *vf) | |||
81 | vi = ov_info(vf, -1); | 79 | vi = ov_info(vf, -1); |
82 | 80 | ||
83 | if (vi == NULL) { | 81 | if (vi == NULL) { |
84 | //rb->splash(HZ*2, true, "Vorbis Error"); | 82 | //ci->splash(HZ*2, true, "Vorbis Error"); |
85 | return false; | 83 | return false; |
86 | } | 84 | } |
87 | 85 | ||
88 | rb->configure(DSP_SWITCH_FREQUENCY, (int *)rb->id3->frequency); | 86 | ci->configure(DSP_SWITCH_FREQUENCY, (int *)ci->id3->frequency); |
89 | codec_set_replaygain(rb->id3); | 87 | codec_set_replaygain(ci->id3); |
90 | 88 | ||
91 | if (vi->channels == 2) { | 89 | if (vi->channels == 2) { |
92 | rb->configure(DSP_SET_STEREO_MODE, (int *)STEREO_NONINTERLEAVED); | 90 | ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_NONINTERLEAVED); |
93 | } else if (vi->channels == 1) { | 91 | } else if (vi->channels == 1) { |
94 | rb->configure(DSP_SET_STEREO_MODE, (int *)STEREO_MONO); | 92 | ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_MONO); |
95 | } | 93 | } |
96 | 94 | ||
97 | return true; | 95 | return true; |
98 | } | 96 | } |
99 | 97 | ||
100 | #ifdef USE_IRAM | ||
101 | extern char iramcopy[]; | ||
102 | extern char iramstart[]; | ||
103 | extern char iramend[]; | ||
104 | extern char iedata[]; | ||
105 | extern char iend[]; | ||
106 | #endif | ||
107 | |||
108 | /* this is the codec entry point */ | 98 | /* this is the codec entry point */ |
109 | enum codec_status codec_start(struct codec_api *api) | 99 | enum codec_status codec_main(void) |
110 | { | 100 | { |
111 | ov_callbacks callbacks; | 101 | ov_callbacks callbacks; |
112 | OggVorbis_File vf; | 102 | OggVorbis_File vf; |
@@ -122,16 +112,9 @@ enum codec_status codec_start(struct codec_api *api) | |||
122 | ogg_uint32_t vf_serialnos; | 112 | ogg_uint32_t vf_serialnos; |
123 | ogg_int64_t vf_pcmlengths[2]; | 113 | ogg_int64_t vf_pcmlengths[2]; |
124 | 114 | ||
125 | rb = api; | 115 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)24); |
126 | 116 | ci->configure(DSP_SET_CLIP_MAX, (long *)((1 << 24) - 1)); | |
127 | #ifdef USE_IRAM | 117 | ci->configure(DSP_SET_CLIP_MIN, (long *)-((1 << 24) - 1)); |
128 | rb->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
129 | rb->memset(iedata, 0, iend - iedata); | ||
130 | #endif | ||
131 | |||
132 | rb->configure(DSP_SET_SAMPLE_DEPTH, (long *)24); | ||
133 | rb->configure(DSP_SET_CLIP_MAX, (long *)((1 << 24) - 1)); | ||
134 | rb->configure(DSP_SET_CLIP_MIN, (long *)-((1 << 24) - 1)); | ||
135 | /* Note: These are sane defaults for these values. Perhaps | 118 | /* Note: These are sane defaults for these values. Perhaps |
136 | * they should be set differently based on quality setting | 119 | * they should be set differently based on quality setting |
137 | */ | 120 | */ |
@@ -139,17 +122,17 @@ enum codec_status codec_start(struct codec_api *api) | |||
139 | /* The chunk size below is magic. If set any lower, resume | 122 | /* The chunk size below is magic. If set any lower, resume |
140 | * doesn't work properly (ov_raw_seek() does the wrong thing). | 123 | * doesn't work properly (ov_raw_seek() does the wrong thing). |
141 | */ | 124 | */ |
142 | rb->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*256)); | 125 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*256)); |
143 | 126 | ||
144 | /* We need to flush reserver memory every track load. */ | 127 | /* We need to flush reserver memory every track load. */ |
145 | next_track: | 128 | next_track: |
146 | if (codec_init(rb)) { | 129 | if (codec_init()) { |
147 | error = CODEC_ERROR; | 130 | error = CODEC_ERROR; |
148 | goto exit; | 131 | goto exit; |
149 | } | 132 | } |
150 | 133 | ||
151 | while (!*rb->taginfo_ready && !rb->stop_codec) | 134 | while (!*ci->taginfo_ready && !ci->stop_codec) |
152 | rb->sleep(1); | 135 | ci->sleep(1); |
153 | 136 | ||
154 | /* Create a decoder instance */ | 137 | /* Create a decoder instance */ |
155 | callbacks.read_func = read_handler; | 138 | callbacks.read_func = read_handler; |
@@ -158,14 +141,14 @@ next_track: | |||
158 | callbacks.close_func = close_handler; | 141 | callbacks.close_func = close_handler; |
159 | 142 | ||
160 | /* Open a non-seekable stream */ | 143 | /* Open a non-seekable stream */ |
161 | error = ov_open_callbacks(rb, &vf, NULL, 0, callbacks); | 144 | error = ov_open_callbacks(ci, &vf, NULL, 0, callbacks); |
162 | 145 | ||
163 | /* If the non-seekable open was successful, we need to supply the missing | 146 | /* If the non-seekable open was successful, we need to supply the missing |
164 | * data to make it seekable. This is a hack, but it's reasonable since we | 147 | * data to make it seekable. This is a hack, but it's reasonable since we |
165 | * don't want to run the whole file through the buffer before we start | 148 | * don't want to run the whole file through the buffer before we start |
166 | * playing. Using Tremor's seekable open routine would cause us to do | 149 | * playing. Using Tremor's seekable open routine would cause us to do |
167 | * this, so we pretend not to be seekable at first. Then we fill in the | 150 | * this, so we pretend not to be seekable at first. Then we fill in the |
168 | * missing fields of vf with 1) information in rb->id3, and 2) info | 151 | * missing fields of vf with 1) information in ci->id3, and 2) info |
169 | * obtained by Tremor in the above ov_open call. | 152 | * obtained by Tremor in the above ov_open call. |
170 | * | 153 | * |
171 | * Note that this assumes there is only ONE logical Vorbis bitstream in our | 154 | * Note that this assumes there is only ONE logical Vorbis bitstream in our |
@@ -179,40 +162,40 @@ next_track: | |||
179 | vf.pcmlengths = vf_pcmlengths; | 162 | vf.pcmlengths = vf_pcmlengths; |
180 | 163 | ||
181 | vf.offsets[0] = 0; | 164 | vf.offsets[0] = 0; |
182 | vf.offsets[1] = rb->id3->filesize; | 165 | vf.offsets[1] = ci->id3->filesize; |
183 | vf.dataoffsets[0] = vf.offset; | 166 | vf.dataoffsets[0] = vf.offset; |
184 | vf.pcmlengths[0] = 0; | 167 | vf.pcmlengths[0] = 0; |
185 | vf.pcmlengths[1] = rb->id3->samples; | 168 | vf.pcmlengths[1] = ci->id3->samples; |
186 | vf.serialnos[0] = vf.current_serialno; | 169 | vf.serialnos[0] = vf.current_serialno; |
187 | vf.callbacks.seek_func = seek_handler; | 170 | vf.callbacks.seek_func = seek_handler; |
188 | vf.seekable = 1; | 171 | vf.seekable = 1; |
189 | vf.end = rb->id3->filesize; | 172 | vf.end = ci->id3->filesize; |
190 | vf.ready_state = OPENED; | 173 | vf.ready_state = OPENED; |
191 | vf.links = 1; | 174 | vf.links = 1; |
192 | } else { | 175 | } else { |
193 | //rb->logf("ov_open: %d", error); | 176 | //ci->logf("ov_open: %d", error); |
194 | error = CODEC_ERROR; | 177 | error = CODEC_ERROR; |
195 | goto done; | 178 | goto done; |
196 | } | 179 | } |
197 | 180 | ||
198 | if (rb->id3->offset) { | 181 | if (ci->id3->offset) { |
199 | rb->advance_buffer(rb->id3->offset); | 182 | ci->advance_buffer(ci->id3->offset); |
200 | ov_raw_seek(&vf, rb->id3->offset); | 183 | ov_raw_seek(&vf, ci->id3->offset); |
201 | rb->set_elapsed(ov_time_tell(&vf)); | 184 | ci->set_elapsed(ov_time_tell(&vf)); |
202 | rb->set_offset(ov_raw_tell(&vf)); | 185 | ci->set_offset(ov_raw_tell(&vf)); |
203 | } | 186 | } |
204 | 187 | ||
205 | eof = 0; | 188 | eof = 0; |
206 | while (!eof) { | 189 | while (!eof) { |
207 | rb->yield(); | 190 | ci->yield(); |
208 | if (rb->stop_codec || rb->new_track) | 191 | if (ci->stop_codec || ci->new_track) |
209 | break; | 192 | break; |
210 | 193 | ||
211 | if (rb->seek_time) { | 194 | if (ci->seek_time) { |
212 | if (ov_time_seek(&vf, rb->seek_time - 1)) { | 195 | if (ov_time_seek(&vf, ci->seek_time - 1)) { |
213 | //rb->logf("ov_time_seek failed"); | 196 | //ci->logf("ov_time_seek failed"); |
214 | } | 197 | } |
215 | rb->seek_complete(); | 198 | ci->seek_complete(); |
216 | } | 199 | } |
217 | 200 | ||
218 | /* Read host-endian signed 24-bit PCM samples */ | 201 | /* Read host-endian signed 24-bit PCM samples */ |
@@ -233,18 +216,18 @@ next_track: | |||
233 | } else if (n < 0) { | 216 | } else if (n < 0) { |
234 | DEBUGF("Error decoding frame\n"); | 217 | DEBUGF("Error decoding frame\n"); |
235 | } else { | 218 | } else { |
236 | while (!rb->pcmbuf_insert_split(pcm[0], pcm[1], | 219 | while (!ci->pcmbuf_insert_split(pcm[0], pcm[1], |
237 | n*sizeof(ogg_int32_t))) { | 220 | n*sizeof(ogg_int32_t))) { |
238 | rb->sleep(1); | 221 | ci->sleep(1); |
239 | } | 222 | } |
240 | rb->set_offset(ov_raw_tell(&vf)); | 223 | ci->set_offset(ov_raw_tell(&vf)); |
241 | rb->set_elapsed(ov_time_tell(&vf)); | 224 | ci->set_elapsed(ov_time_tell(&vf)); |
242 | } | 225 | } |
243 | } | 226 | } |
244 | error = CODEC_OK; | 227 | error = CODEC_OK; |
245 | 228 | ||
246 | done: | 229 | done: |
247 | if (rb->request_next_track()) { | 230 | if (ci->request_next_track()) { |
248 | /* Clean things up for the next track */ | 231 | /* Clean things up for the next track */ |
249 | vf.dataoffsets = NULL; | 232 | vf.dataoffsets = NULL; |
250 | vf.offsets = NULL; | 233 | vf.offsets = NULL; |
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c index 9add1f512a..26cbf7f6a1 100644 --- a/apps/codecs/wav.c +++ b/apps/codecs/wav.c | |||
@@ -25,8 +25,6 @@ CODEC_HEADER | |||
25 | /* Macro that sign extends an unsigned byte */ | 25 | /* Macro that sign extends an unsigned byte */ |
26 | #define SE(x) ((int32_t)((int8_t)(x))) | 26 | #define SE(x) ((int32_t)((int8_t)(x))) |
27 | 27 | ||
28 | struct codec_api *rb; | ||
29 | |||
30 | /* This codec support WAVE files with the following formats: | 28 | /* This codec support WAVE files with the following formats: |
31 | * - PCM, up to 32 bits, supporting 32 bits playback when useful. | 29 | * - PCM, up to 32 bits, supporting 32 bits playback when useful. |
32 | * - ALAW and MULAW (16 bits compressed on 8 bits). | 30 | * - ALAW and MULAW (16 bits compressed on 8 bits). |
@@ -95,14 +93,6 @@ enum | |||
95 | /* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */ | 93 | /* for 44.1kHz stereo 16bits, this represents 0.023s ~= 1/50s */ |
96 | #define WAV_CHUNK_SIZE (1024*2) | 94 | #define WAV_CHUNK_SIZE (1024*2) |
97 | 95 | ||
98 | #ifdef USE_IRAM | ||
99 | extern char iramcopy[]; | ||
100 | extern char iramstart[]; | ||
101 | extern char iramend[]; | ||
102 | extern char iedata[]; | ||
103 | extern char iend[]; | ||
104 | #endif | ||
105 | |||
106 | static const int16_t alaw2linear16[256] ICONST_ATTR = { | 96 | static const int16_t alaw2linear16[256] ICONST_ATTR = { |
107 | -5504, -5248, -6016, -5760, -4480, -4224, -4992, | 97 | -5504, -5248, -6016, -5760, -4480, -4224, -4992, |
108 | -4736, -7552, -7296, -8064, -7808, -6528, -6272, | 98 | -4736, -7552, -7296, -8064, -7808, -6528, -6272, |
@@ -213,9 +203,8 @@ decode_dvi_adpcm(struct codec_api *ci, | |||
213 | size_t *pcmoutsize); | 203 | size_t *pcmoutsize); |
214 | 204 | ||
215 | /* this is the codec entry point */ | 205 | /* this is the codec entry point */ |
216 | enum codec_status codec_start(struct codec_api *api) | 206 | enum codec_status codec_main(void) |
217 | { | 207 | { |
218 | struct codec_api *ci; | ||
219 | uint32_t numbytes, bytesdone; | 208 | uint32_t numbytes, bytesdone; |
220 | uint32_t totalsamples = 0; | 209 | uint32_t totalsamples = 0; |
221 | uint16_t channels = 0; | 210 | uint16_t channels = 0; |
@@ -235,20 +224,12 @@ enum codec_status codec_start(struct codec_api *api) | |||
235 | 224 | ||
236 | 225 | ||
237 | /* Generic codec initialisation */ | 226 | /* Generic codec initialisation */ |
238 | rb = api; | ||
239 | ci = api; | ||
240 | |||
241 | #ifdef USE_IRAM | ||
242 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
243 | ci->memset(iedata, 0, iend - iedata); | ||
244 | #endif | ||
245 | |||
246 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); | 227 | ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); |
247 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 228 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
248 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256)); | 229 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256)); |
249 | 230 | ||
250 | next_track: | 231 | next_track: |
251 | if (codec_init(api)) { | 232 | if (codec_init()) { |
252 | i = CODEC_ERROR; | 233 | i = CODEC_ERROR; |
253 | goto exit; | 234 | goto exit; |
254 | } | 235 | } |
diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c index 974a903310..ff49238303 100644 --- a/apps/codecs/wav_enc.c +++ b/apps/codecs/wav_enc.c | |||
@@ -24,14 +24,6 @@ | |||
24 | 24 | ||
25 | CODEC_ENC_HEADER | 25 | CODEC_ENC_HEADER |
26 | 26 | ||
27 | #ifdef USE_IRAM | ||
28 | extern char iramcopy[]; | ||
29 | extern char iramstart[]; | ||
30 | extern char iramend[]; | ||
31 | extern char iedata[]; | ||
32 | extern char iend[]; | ||
33 | #endif | ||
34 | |||
35 | struct riff_header | 27 | struct riff_header |
36 | { | 28 | { |
37 | uint8_t riff_id[4]; /* 00h - "RIFF" */ | 29 | uint8_t riff_id[4]; /* 00h - "RIFF" */ |
@@ -65,7 +57,6 @@ struct riff_header | |||
65 | #define PCM_SAMP_PER_CHUNK 2048 | 57 | #define PCM_SAMP_PER_CHUNK 2048 |
66 | #define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4) | 58 | #define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4) |
67 | 59 | ||
68 | static struct codec_api *ci; | ||
69 | static int num_channels; | 60 | static int num_channels; |
70 | uint32_t sample_rate; | 61 | uint32_t sample_rate; |
71 | uint32_t enc_size; | 62 | uint32_t enc_size; |
@@ -321,17 +312,10 @@ static bool init_encoder(void) | |||
321 | } /* init_encoder */ | 312 | } /* init_encoder */ |
322 | 313 | ||
323 | /* main codec entry point */ | 314 | /* main codec entry point */ |
324 | enum codec_status codec_start(struct codec_api* api) | 315 | enum codec_status codec_main(void) |
325 | { | 316 | { |
326 | bool cpu_boosted; | 317 | bool cpu_boosted; |
327 | 318 | ||
328 | ci = api; // copy to global api pointer | ||
329 | |||
330 | #ifdef USE_IRAM | ||
331 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
332 | ci->memset(iedata, 0, iend - iedata); | ||
333 | #endif | ||
334 | |||
335 | if (!init_encoder()) | 319 | if (!init_encoder()) |
336 | { | 320 | { |
337 | ci->enc_codec_loaded = -1; | 321 | ci->enc_codec_loaded = -1; |
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c index 65280535e6..e2c19c82e4 100644 --- a/apps/codecs/wavpack.c +++ b/apps/codecs/wavpack.c | |||
@@ -22,8 +22,6 @@ | |||
22 | 22 | ||
23 | CODEC_HEADER | 23 | CODEC_HEADER |
24 | 24 | ||
25 | static struct codec_api *ci; | ||
26 | |||
27 | #define BUFFER_SIZE 4096 | 25 | #define BUFFER_SIZE 4096 |
28 | 26 | ||
29 | static int32_t temp_buffer [BUFFER_SIZE] IBSS_ATTR; | 27 | static int32_t temp_buffer [BUFFER_SIZE] IBSS_ATTR; |
@@ -35,16 +33,8 @@ static int32_t read_callback (void *buffer, int32_t bytes) | |||
35 | return retval; | 33 | return retval; |
36 | } | 34 | } |
37 | 35 | ||
38 | #ifdef USE_IRAM | ||
39 | extern char iramcopy[]; | ||
40 | extern char iramstart[]; | ||
41 | extern char iramend[]; | ||
42 | extern char iedata[]; | ||
43 | extern char iend[]; | ||
44 | #endif | ||
45 | |||
46 | /* this is the codec entry point */ | 36 | /* this is the codec entry point */ |
47 | enum codec_status codec_start(struct codec_api* api) | 37 | enum codec_status codec_main(void) |
48 | { | 38 | { |
49 | WavpackContext *wpc; | 39 | WavpackContext *wpc; |
50 | char error [80]; | 40 | char error [80]; |
@@ -52,13 +42,6 @@ enum codec_status codec_start(struct codec_api* api) | |||
52 | int retval; | 42 | int retval; |
53 | 43 | ||
54 | /* Generic codec initialisation */ | 44 | /* Generic codec initialisation */ |
55 | ci = api; | ||
56 | |||
57 | #ifdef USE_IRAM | ||
58 | ci->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
59 | ci->memset(iedata, 0, iend - iedata); | ||
60 | #endif | ||
61 | |||
62 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); | 45 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); |
63 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); | 46 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); |
64 | 47 | ||
@@ -66,7 +49,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
66 | 49 | ||
67 | next_track: | 50 | next_track: |
68 | 51 | ||
69 | if (codec_init(api)) { | 52 | if (codec_init()) { |
70 | retval = CODEC_ERROR; | 53 | retval = CODEC_ERROR; |
71 | goto exit; | 54 | goto exit; |
72 | } | 55 | } |
diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c index 5318abc8fb..cee8c40615 100644 --- a/apps/codecs/wavpack_enc.c +++ b/apps/codecs/wavpack_enc.c | |||
@@ -24,14 +24,6 @@ | |||
24 | 24 | ||
25 | CODEC_ENC_HEADER | 25 | CODEC_ENC_HEADER |
26 | 26 | ||
27 | #ifdef USE_IRAM | ||
28 | extern char iramcopy[]; | ||
29 | extern char iramstart[]; | ||
30 | extern char iramend[]; | ||
31 | extern char iedata[]; | ||
32 | extern char iend[]; | ||
33 | #endif | ||
34 | |||
35 | /** Types **/ | 27 | /** Types **/ |
36 | typedef struct | 28 | typedef struct |
37 | { | 29 | { |
@@ -73,7 +65,6 @@ struct riff_header | |||
73 | #define PCM_CHUNK_SIZE (4*PCM_SAMP_PER_CHUNK) | 65 | #define PCM_CHUNK_SIZE (4*PCM_SAMP_PER_CHUNK) |
74 | 66 | ||
75 | /** Data **/ | 67 | /** Data **/ |
76 | static struct codec_api *ci; | ||
77 | static int8_t input_buffer[PCM_CHUNK_SIZE*2] IBSS_ATTR; | 68 | static int8_t input_buffer[PCM_CHUNK_SIZE*2] IBSS_ATTR; |
78 | static WavpackConfig config IBSS_ATTR; | 69 | static WavpackConfig config IBSS_ATTR; |
79 | static WavpackContext *wpc; | 70 | static WavpackContext *wpc; |
@@ -381,17 +372,10 @@ static bool init_encoder(void) | |||
381 | return true; | 372 | return true; |
382 | } /* init_encoder */ | 373 | } /* init_encoder */ |
383 | 374 | ||
384 | enum codec_status codec_start(struct codec_api* api) | 375 | enum codec_status codec_main(void) |
385 | { | 376 | { |
386 | bool cpu_boosted; | 377 | bool cpu_boosted; |
387 | 378 | ||
388 | ci = api; /* copy to global api pointer */ | ||
389 | |||
390 | #ifdef USE_IRAM | ||
391 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | ||
392 | ci->memset(iedata, 0, iend - iedata); | ||
393 | #endif | ||
394 | |||
395 | /* initialize params and config */ | 379 | /* initialize params and config */ |
396 | if (!init_encoder()) | 380 | if (!init_encoder()) |
397 | { | 381 | { |