forked from len0rd/rockbox
Add vox (Dialogic telephony formats) codec add. (FS#11021)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24956 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4e3c807466
commit
8c5eaa35ec
9 changed files with 241 additions and 0 deletions
|
@ -189,6 +189,7 @@ metadata/nsf.c
|
||||||
metadata/oma.c
|
metadata/oma.c
|
||||||
metadata/smaf.c
|
metadata/smaf.c
|
||||||
metadata/au.c
|
metadata/au.c
|
||||||
|
metadata/vox.c
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
tagcache.c
|
tagcache.c
|
||||||
|
|
|
@ -29,6 +29,7 @@ speex.c
|
||||||
adx.c
|
adx.c
|
||||||
smaf.c
|
smaf.c
|
||||||
au.c
|
au.c
|
||||||
|
vox.c
|
||||||
#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
|
#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
|
||||||
/* encoders */
|
/* encoders */
|
||||||
aiff_enc.c
|
aiff_enc.c
|
||||||
|
|
|
@ -92,6 +92,7 @@ $(CODECDIR)/aiff.codec : $(CODECDIR)/libpcm.a
|
||||||
$(CODECDIR)/wav.codec : $(CODECDIR)/libpcm.a
|
$(CODECDIR)/wav.codec : $(CODECDIR)/libpcm.a
|
||||||
$(CODECDIR)/smaf.codec : $(CODECDIR)/libpcm.a
|
$(CODECDIR)/smaf.codec : $(CODECDIR)/libpcm.a
|
||||||
$(CODECDIR)/au.codec : $(CODECDIR)/libpcm.a
|
$(CODECDIR)/au.codec : $(CODECDIR)/libpcm.a
|
||||||
|
$(CODECDIR)/vox.codec : $(CODECDIR)/libpcm.a
|
||||||
|
|
||||||
$(CODECS): $(CODECLIB) # this must be last in codec dependency list
|
$(CODECS): $(CODECLIB) # this must be last in codec dependency list
|
||||||
|
|
||||||
|
|
181
apps/codecs/vox.c
Normal file
181
apps/codecs/vox.c
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Yoshihisa Uchida
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "codeclib.h"
|
||||||
|
#include "codecs/libpcm/support_formats.h"
|
||||||
|
|
||||||
|
CODEC_HEADER
|
||||||
|
|
||||||
|
/* vox codec (Dialogic telephony file formats) */
|
||||||
|
|
||||||
|
#define PCM_SAMPLE_SIZE (2048)
|
||||||
|
|
||||||
|
static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR;
|
||||||
|
|
||||||
|
static struct pcm_format format;
|
||||||
|
static uint32_t bytesdone;
|
||||||
|
|
||||||
|
static uint8_t *read_buffer(size_t *realsize)
|
||||||
|
{
|
||||||
|
uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize);
|
||||||
|
if (bytesdone + (*realsize) > format.numbytes)
|
||||||
|
*realsize = format.numbytes - bytesdone;
|
||||||
|
bytesdone += *realsize;
|
||||||
|
ci->advance_buffer(*realsize);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this is the codec entry point */
|
||||||
|
enum codec_status codec_main(void)
|
||||||
|
{
|
||||||
|
int status = CODEC_OK;
|
||||||
|
uint32_t decodedsamples;
|
||||||
|
size_t n;
|
||||||
|
int bufcount;
|
||||||
|
int endofstream;
|
||||||
|
uint8_t *voxbuf;
|
||||||
|
off_t firstblockposn; /* position of the first block in file */
|
||||||
|
const struct pcm_codec *codec;
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
/* Generic codec initialisation */
|
||||||
|
ci->configure(DSP_SET_SAMPLE_DEPTH, 28);
|
||||||
|
|
||||||
|
next_track:
|
||||||
|
if (codec_init()) {
|
||||||
|
DEBUGF("codec_init() error\n");
|
||||||
|
status = CODEC_ERROR;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!*ci->taginfo_ready && !ci->stop_codec)
|
||||||
|
ci->sleep(1);
|
||||||
|
|
||||||
|
codec_set_replaygain(ci->id3);
|
||||||
|
|
||||||
|
ci->memset(&format, 0, sizeof(struct pcm_format));
|
||||||
|
|
||||||
|
/* set format */
|
||||||
|
format.channels = 1;
|
||||||
|
format.bitspersample = 4;
|
||||||
|
format.numbytes = ci->id3->filesize;
|
||||||
|
format.blockalign = 1;
|
||||||
|
|
||||||
|
/* advance to first WAVE chunk */
|
||||||
|
ci->advance_buffer(offset);
|
||||||
|
|
||||||
|
firstblockposn = offset;
|
||||||
|
|
||||||
|
decodedsamples = 0;
|
||||||
|
bytesdone = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get codec
|
||||||
|
* supports dialogic oki adpcm only
|
||||||
|
*/
|
||||||
|
codec = get_dialogic_oki_adpcm_codec();
|
||||||
|
if (!codec)
|
||||||
|
{
|
||||||
|
DEBUGF("CODEC_ERROR: dialogic oki adpcm codec does not load.\n");
|
||||||
|
status = CODEC_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!codec->set_format(&format))
|
||||||
|
{
|
||||||
|
status = CODEC_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format.numbytes == 0) {
|
||||||
|
DEBUGF("CODEC_ERROR: data size is 0\n");
|
||||||
|
status = CODEC_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check chunksize */
|
||||||
|
if (format.chunksize * 2 > PCM_SAMPLE_SIZE)
|
||||||
|
format.chunksize = PCM_SAMPLE_SIZE / 2;
|
||||||
|
if (format.chunksize == 0)
|
||||||
|
{
|
||||||
|
DEBUGF("CODEC_ERROR: chunksize is 0\n");
|
||||||
|
status = CODEC_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
|
||||||
|
ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO);
|
||||||
|
|
||||||
|
/* The main decoder loop */
|
||||||
|
endofstream = 0;
|
||||||
|
|
||||||
|
while (!endofstream) {
|
||||||
|
ci->yield();
|
||||||
|
if (ci->stop_codec || ci->new_track) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ci->seek_time) {
|
||||||
|
struct pcm_pos *newpos = codec->get_seek_pos(ci->seek_time, &read_buffer);
|
||||||
|
|
||||||
|
decodedsamples = newpos->samples;
|
||||||
|
if (newpos->pos > format.numbytes)
|
||||||
|
break;
|
||||||
|
if (ci->seek_buffer(firstblockposn + newpos->pos))
|
||||||
|
{
|
||||||
|
bytesdone = newpos->pos;
|
||||||
|
}
|
||||||
|
ci->seek_complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
voxbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize);
|
||||||
|
if (n == 0)
|
||||||
|
break; /* End of stream */
|
||||||
|
if (bytesdone + n > format.numbytes) {
|
||||||
|
n = format.numbytes - bytesdone;
|
||||||
|
endofstream = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = codec->decode(voxbuf, n, samples, &bufcount);
|
||||||
|
if (status == CODEC_ERROR)
|
||||||
|
{
|
||||||
|
DEBUGF("codec error\n");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
ci->pcmbuf_insert(samples, NULL, bufcount);
|
||||||
|
ci->advance_buffer(n);
|
||||||
|
bytesdone += n;
|
||||||
|
decodedsamples += bufcount;
|
||||||
|
|
||||||
|
if (bytesdone >= format.numbytes)
|
||||||
|
endofstream = 1;
|
||||||
|
ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
|
||||||
|
}
|
||||||
|
status = CODEC_OK;
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (ci->request_next_track())
|
||||||
|
goto next_track;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return status;
|
||||||
|
}
|
|
@ -104,6 +104,7 @@ static const struct filetype inbuilt_filetypes[] = {
|
||||||
{ "mmf", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "mmf", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
{ "au", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "au", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
{ "snd", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "snd", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
|
{ "vox", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
#endif
|
#endif
|
||||||
{ "m3u", FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
{ "m3u", FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
||||||
{ "m3u8",FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
{ "m3u8",FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
||||||
|
|
|
@ -171,6 +171,9 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] =
|
||||||
/* Sun Audio file */
|
/* Sun Audio file */
|
||||||
[AFMT_AU] =
|
[AFMT_AU] =
|
||||||
AFMT_ENTRY("AU", "au", NULL, "au\0snd\0" ),
|
AFMT_ENTRY("AU", "au", NULL, "au\0snd\0" ),
|
||||||
|
/* VOX (Dialogic telephony file formats) */
|
||||||
|
[AFMT_VOX] =
|
||||||
|
AFMT_ENTRY("VOX", "vox", NULL, "vox\0" ),
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -470,6 +473,14 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AFMT_VOX:
|
||||||
|
if (!get_vox_metadata(fd, id3))
|
||||||
|
{
|
||||||
|
DEBUGF("get_vox_metadata error\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
#endif /* CONFIG_CODEC == SWCODEC */
|
#endif /* CONFIG_CODEC == SWCODEC */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -80,6 +80,7 @@ enum
|
||||||
AFMT_OMA_ATRAC3, /* Atrac3 in Sony OMA container */
|
AFMT_OMA_ATRAC3, /* Atrac3 in Sony OMA container */
|
||||||
AFMT_SMAF, /* SMAF */
|
AFMT_SMAF, /* SMAF */
|
||||||
AFMT_AU, /* Sun Audio file */
|
AFMT_AU, /* Sun Audio file */
|
||||||
|
AFMT_VOX, /* VOX */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* add new formats at any index above this line to have a sensible order -
|
/* add new formats at any index above this line to have a sensible order -
|
||||||
|
|
|
@ -44,3 +44,4 @@ bool get_nsf_metadata(int fd, struct mp3entry* id3);
|
||||||
bool get_oma_metadata(int fd, struct mp3entry* id3);
|
bool get_oma_metadata(int fd, struct mp3entry* id3);
|
||||||
bool get_smaf_metadata(int fd, struct mp3entry* id3);
|
bool get_smaf_metadata(int fd, struct mp3entry* id3);
|
||||||
bool get_au_metadata(int fd, struct mp3entry* id3);
|
bool get_au_metadata(int fd, struct mp3entry* id3);
|
||||||
|
bool get_vox_metadata(int fd, struct mp3entry* id3);
|
||||||
|
|
43
apps/metadata/vox.c
Normal file
43
apps/metadata/vox.c
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Yoshihisa Uchida
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "system.h"
|
||||||
|
#include "metadata.h"
|
||||||
|
#include "metadata_common.h"
|
||||||
|
#include "metadata_parsers.h"
|
||||||
|
#include "logf.h"
|
||||||
|
|
||||||
|
bool get_vox_metadata(int fd, struct mp3entry* id3)
|
||||||
|
{
|
||||||
|
/* vox is headerless format */
|
||||||
|
|
||||||
|
id3->frequency = 8000;
|
||||||
|
id3->vbr = false; /* All VOX files are CBR */
|
||||||
|
id3->filesize = filesize(fd);
|
||||||
|
id3->length = ((int64_t) id3->filesize * 2000) / id3->frequency;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue