diff options
author | Yoshihisa Uchida <uchida@rockbox.org> | 2010-02-28 08:13:30 +0000 |
---|---|---|
committer | Yoshihisa Uchida <uchida@rockbox.org> | 2010-02-28 08:13:30 +0000 |
commit | 8c5eaa35ecd8b5239e2cb4848e29310daa6f4a88 (patch) | |
tree | c9da4e9c38f4ebb150c36bdac88136a7336146ff | |
parent | 4e3c8074664fa87b023643f375171d544d662141 (diff) | |
download | rockbox-8c5eaa35ecd8b5239e2cb4848e29310daa6f4a88.tar.gz rockbox-8c5eaa35ecd8b5239e2cb4848e29310daa6f4a88.zip |
Add vox (Dialogic telephony formats) codec add. (FS#11021)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24956 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/SOURCES | 1 | ||||
-rw-r--r-- | apps/codecs/SOURCES | 1 | ||||
-rw-r--r-- | apps/codecs/codecs.make | 1 | ||||
-rw-r--r-- | apps/codecs/vox.c | 181 | ||||
-rw-r--r-- | apps/filetypes.c | 1 | ||||
-rw-r--r-- | apps/metadata.c | 11 | ||||
-rw-r--r-- | apps/metadata.h | 1 | ||||
-rw-r--r-- | apps/metadata/metadata_parsers.h | 1 | ||||
-rw-r--r-- | apps/metadata/vox.c | 43 |
9 files changed, 241 insertions, 0 deletions
diff --git a/apps/SOURCES b/apps/SOURCES index 47937fab70..4666ec9339 100644 --- a/apps/SOURCES +++ b/apps/SOURCES | |||
@@ -189,6 +189,7 @@ metadata/nsf.c | |||
189 | metadata/oma.c | 189 | metadata/oma.c |
190 | metadata/smaf.c | 190 | metadata/smaf.c |
191 | metadata/au.c | 191 | metadata/au.c |
192 | metadata/vox.c | ||
192 | #endif | 193 | #endif |
193 | #ifdef HAVE_TAGCACHE | 194 | #ifdef HAVE_TAGCACHE |
194 | tagcache.c | 195 | tagcache.c |
diff --git a/apps/codecs/SOURCES b/apps/codecs/SOURCES index b8a86aed8a..41247658c7 100644 --- a/apps/codecs/SOURCES +++ b/apps/codecs/SOURCES | |||
@@ -29,6 +29,7 @@ speex.c | |||
29 | adx.c | 29 | adx.c |
30 | smaf.c | 30 | smaf.c |
31 | au.c | 31 | au.c |
32 | vox.c | ||
32 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) | 33 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) |
33 | /* encoders */ | 34 | /* encoders */ |
34 | aiff_enc.c | 35 | aiff_enc.c |
diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make index cf1a057d8c..7bd141e9cd 100644 --- a/apps/codecs/codecs.make +++ b/apps/codecs/codecs.make | |||
@@ -92,6 +92,7 @@ $(CODECDIR)/aiff.codec : $(CODECDIR)/libpcm.a | |||
92 | $(CODECDIR)/wav.codec : $(CODECDIR)/libpcm.a | 92 | $(CODECDIR)/wav.codec : $(CODECDIR)/libpcm.a |
93 | $(CODECDIR)/smaf.codec : $(CODECDIR)/libpcm.a | 93 | $(CODECDIR)/smaf.codec : $(CODECDIR)/libpcm.a |
94 | $(CODECDIR)/au.codec : $(CODECDIR)/libpcm.a | 94 | $(CODECDIR)/au.codec : $(CODECDIR)/libpcm.a |
95 | $(CODECDIR)/vox.codec : $(CODECDIR)/libpcm.a | ||
95 | 96 | ||
96 | $(CODECS): $(CODECLIB) # this must be last in codec dependency list | 97 | $(CODECS): $(CODECLIB) # this must be last in codec dependency list |
97 | 98 | ||
diff --git a/apps/codecs/vox.c b/apps/codecs/vox.c new file mode 100644 index 0000000000..44701fafb8 --- /dev/null +++ b/apps/codecs/vox.c | |||
@@ -0,0 +1,181 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Yoshihisa Uchida | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "codeclib.h" | ||
23 | #include "codecs/libpcm/support_formats.h" | ||
24 | |||
25 | CODEC_HEADER | ||
26 | |||
27 | /* vox codec (Dialogic telephony file formats) */ | ||
28 | |||
29 | #define PCM_SAMPLE_SIZE (2048) | ||
30 | |||
31 | static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; | ||
32 | |||
33 | static struct pcm_format format; | ||
34 | static uint32_t bytesdone; | ||
35 | |||
36 | static uint8_t *read_buffer(size_t *realsize) | ||
37 | { | ||
38 | uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); | ||
39 | if (bytesdone + (*realsize) > format.numbytes) | ||
40 | *realsize = format.numbytes - bytesdone; | ||
41 | bytesdone += *realsize; | ||
42 | ci->advance_buffer(*realsize); | ||
43 | return buffer; | ||
44 | } | ||
45 | |||
46 | /* this is the codec entry point */ | ||
47 | enum codec_status codec_main(void) | ||
48 | { | ||
49 | int status = CODEC_OK; | ||
50 | uint32_t decodedsamples; | ||
51 | size_t n; | ||
52 | int bufcount; | ||
53 | int endofstream; | ||
54 | uint8_t *voxbuf; | ||
55 | off_t firstblockposn; /* position of the first block in file */ | ||
56 | const struct pcm_codec *codec; | ||
57 | int offset = 0; | ||
58 | |||
59 | /* Generic codec initialisation */ | ||
60 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); | ||
61 | |||
62 | next_track: | ||
63 | if (codec_init()) { | ||
64 | DEBUGF("codec_init() error\n"); | ||
65 | status = CODEC_ERROR; | ||
66 | goto exit; | ||
67 | } | ||
68 | |||
69 | while (!*ci->taginfo_ready && !ci->stop_codec) | ||
70 | ci->sleep(1); | ||
71 | |||
72 | codec_set_replaygain(ci->id3); | ||
73 | |||
74 | ci->memset(&format, 0, sizeof(struct pcm_format)); | ||
75 | |||
76 | /* set format */ | ||
77 | format.channels = 1; | ||
78 | format.bitspersample = 4; | ||
79 | format.numbytes = ci->id3->filesize; | ||
80 | format.blockalign = 1; | ||
81 | |||
82 | /* advance to first WAVE chunk */ | ||
83 | ci->advance_buffer(offset); | ||
84 | |||
85 | firstblockposn = offset; | ||
86 | |||
87 | decodedsamples = 0; | ||
88 | bytesdone = 0; | ||
89 | |||
90 | /* | ||
91 | * get codec | ||
92 | * supports dialogic oki adpcm only | ||
93 | */ | ||
94 | codec = get_dialogic_oki_adpcm_codec(); | ||
95 | if (!codec) | ||
96 | { | ||
97 | DEBUGF("CODEC_ERROR: dialogic oki adpcm codec does not load.\n"); | ||
98 | status = CODEC_ERROR; | ||
99 | goto done; | ||
100 | } | ||
101 | |||
102 | if (!codec->set_format(&format)) | ||
103 | { | ||
104 | status = CODEC_ERROR; | ||
105 | goto done; | ||
106 | } | ||
107 | |||
108 | if (format.numbytes == 0) { | ||
109 | DEBUGF("CODEC_ERROR: data size is 0\n"); | ||
110 | status = CODEC_ERROR; | ||
111 | goto done; | ||
112 | } | ||
113 | |||
114 | /* check chunksize */ | ||
115 | if (format.chunksize * 2 > PCM_SAMPLE_SIZE) | ||
116 | format.chunksize = PCM_SAMPLE_SIZE / 2; | ||
117 | if (format.chunksize == 0) | ||
118 | { | ||
119 | DEBUGF("CODEC_ERROR: chunksize is 0\n"); | ||
120 | status = CODEC_ERROR; | ||
121 | goto done; | ||
122 | } | ||
123 | |||
124 | ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); | ||
125 | ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); | ||
126 | |||
127 | /* The main decoder loop */ | ||
128 | endofstream = 0; | ||
129 | |||
130 | while (!endofstream) { | ||
131 | ci->yield(); | ||
132 | if (ci->stop_codec || ci->new_track) { | ||
133 | break; | ||
134 | } | ||
135 | |||
136 | if (ci->seek_time) { | ||
137 | struct pcm_pos *newpos = codec->get_seek_pos(ci->seek_time, &read_buffer); | ||
138 | |||
139 | decodedsamples = newpos->samples; | ||
140 | if (newpos->pos > format.numbytes) | ||
141 | break; | ||
142 | if (ci->seek_buffer(firstblockposn + newpos->pos)) | ||
143 | { | ||
144 | bytesdone = newpos->pos; | ||
145 | } | ||
146 | ci->seek_complete(); | ||
147 | } | ||
148 | |||
149 | voxbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); | ||
150 | if (n == 0) | ||
151 | break; /* End of stream */ | ||
152 | if (bytesdone + n > format.numbytes) { | ||
153 | n = format.numbytes - bytesdone; | ||
154 | endofstream = 1; | ||
155 | } | ||
156 | |||
157 | status = codec->decode(voxbuf, n, samples, &bufcount); | ||
158 | if (status == CODEC_ERROR) | ||
159 | { | ||
160 | DEBUGF("codec error\n"); | ||
161 | goto done; | ||
162 | } | ||
163 | |||
164 | ci->pcmbuf_insert(samples, NULL, bufcount); | ||
165 | ci->advance_buffer(n); | ||
166 | bytesdone += n; | ||
167 | decodedsamples += bufcount; | ||
168 | |||
169 | if (bytesdone >= format.numbytes) | ||
170 | endofstream = 1; | ||
171 | ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); | ||
172 | } | ||
173 | status = CODEC_OK; | ||
174 | |||
175 | done: | ||
176 | if (ci->request_next_track()) | ||
177 | goto next_track; | ||
178 | |||
179 | exit: | ||
180 | return status; | ||
181 | } | ||
diff --git a/apps/filetypes.c b/apps/filetypes.c index bbb52c8418..7837fbc73b 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -104,6 +104,7 @@ static const struct filetype inbuilt_filetypes[] = { | |||
104 | { "mmf", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, | 104 | { "mmf", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, |
105 | { "au", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, | 105 | { "au", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, |
106 | { "snd", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, | 106 | { "snd", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, |
107 | { "vox", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, | ||
107 | #endif | 108 | #endif |
108 | { "m3u", FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, | 109 | { "m3u", FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, |
109 | { "m3u8",FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, | 110 | { "m3u8",FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, |
diff --git a/apps/metadata.c b/apps/metadata.c index fe25bbc074..4e6e47e2bb 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -171,6 +171,9 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
171 | /* Sun Audio file */ | 171 | /* Sun Audio file */ |
172 | [AFMT_AU] = | 172 | [AFMT_AU] = |
173 | AFMT_ENTRY("AU", "au", NULL, "au\0snd\0" ), | 173 | AFMT_ENTRY("AU", "au", NULL, "au\0snd\0" ), |
174 | /* VOX (Dialogic telephony file formats) */ | ||
175 | [AFMT_VOX] = | ||
176 | AFMT_ENTRY("VOX", "vox", NULL, "vox\0" ), | ||
174 | #endif | 177 | #endif |
175 | }; | 178 | }; |
176 | 179 | ||
@@ -470,6 +473,14 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) | |||
470 | } | 473 | } |
471 | break; | 474 | break; |
472 | 475 | ||
476 | case AFMT_VOX: | ||
477 | if (!get_vox_metadata(fd, id3)) | ||
478 | { | ||
479 | DEBUGF("get_vox_metadata error\n"); | ||
480 | return false; | ||
481 | } | ||
482 | break; | ||
483 | |||
473 | #endif /* CONFIG_CODEC == SWCODEC */ | 484 | #endif /* CONFIG_CODEC == SWCODEC */ |
474 | 485 | ||
475 | default: | 486 | default: |
diff --git a/apps/metadata.h b/apps/metadata.h index f5ca99eeff..8ca3f2f746 100644 --- a/apps/metadata.h +++ b/apps/metadata.h | |||
@@ -80,6 +80,7 @@ enum | |||
80 | AFMT_OMA_ATRAC3, /* Atrac3 in Sony OMA container */ | 80 | AFMT_OMA_ATRAC3, /* Atrac3 in Sony OMA container */ |
81 | AFMT_SMAF, /* SMAF */ | 81 | AFMT_SMAF, /* SMAF */ |
82 | AFMT_AU, /* Sun Audio file */ | 82 | AFMT_AU, /* Sun Audio file */ |
83 | AFMT_VOX, /* VOX */ | ||
83 | #endif | 84 | #endif |
84 | 85 | ||
85 | /* add new formats at any index above this line to have a sensible order - | 86 | /* add new formats at any index above this line to have a sensible order - |
diff --git a/apps/metadata/metadata_parsers.h b/apps/metadata/metadata_parsers.h index 392f16a8d9..3e7abb5c53 100644 --- a/apps/metadata/metadata_parsers.h +++ b/apps/metadata/metadata_parsers.h | |||
@@ -44,3 +44,4 @@ bool get_nsf_metadata(int fd, struct mp3entry* id3); | |||
44 | bool get_oma_metadata(int fd, struct mp3entry* id3); | 44 | bool get_oma_metadata(int fd, struct mp3entry* id3); |
45 | bool get_smaf_metadata(int fd, struct mp3entry* id3); | 45 | bool get_smaf_metadata(int fd, struct mp3entry* id3); |
46 | bool get_au_metadata(int fd, struct mp3entry* id3); | 46 | bool get_au_metadata(int fd, struct mp3entry* id3); |
47 | bool get_vox_metadata(int fd, struct mp3entry* id3); | ||
diff --git a/apps/metadata/vox.c b/apps/metadata/vox.c new file mode 100644 index 0000000000..2d937e2c73 --- /dev/null +++ b/apps/metadata/vox.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Yoshihisa Uchida | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <stdio.h> | ||
22 | #include <string.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <ctype.h> | ||
25 | #include <inttypes.h> | ||
26 | |||
27 | #include "system.h" | ||
28 | #include "metadata.h" | ||
29 | #include "metadata_common.h" | ||
30 | #include "metadata_parsers.h" | ||
31 | #include "logf.h" | ||
32 | |||
33 | bool get_vox_metadata(int fd, struct mp3entry* id3) | ||
34 | { | ||
35 | /* vox is headerless format */ | ||
36 | |||
37 | id3->frequency = 8000; | ||
38 | id3->vbr = false; /* All VOX files are CBR */ | ||
39 | id3->filesize = filesize(fd); | ||
40 | id3->length = ((int64_t) id3->filesize * 2000) / id3->frequency; | ||
41 | |||
42 | return true; | ||
43 | } | ||