From 4446d1bc857b41e491d04b05eeccc873a206fd18 Mon Sep 17 00:00:00 2001 From: Yoshihisa Uchida Date: Sat, 13 Mar 2010 05:19:40 +0000 Subject: reduce firmware and sun audio codec. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25140 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libpcm/ieee_float.c | 10 ++++++++++ apps/codecs/libpcm/itut_g711.c | 17 +++++++++++------ apps/codecs/libpcm/linear_pcm.c | 16 ++++++++++++++-- 3 files changed, 35 insertions(+), 8 deletions(-) (limited to 'apps/codecs/libpcm') diff --git a/apps/codecs/libpcm/ieee_float.c b/apps/codecs/libpcm/ieee_float.c index 0530993..7e3498e 100644 --- a/apps/codecs/libpcm/ieee_float.c +++ b/apps/codecs/libpcm/ieee_float.c @@ -32,6 +32,12 @@ static bool set_format(struct pcm_format *format) { fmt = format; + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + if (fmt->bitspersample != 32 && fmt->bitspersample != 64) { DEBUGF("CODEC_ERROR: ieee float must be 32 or 64 bitspersample: %d\n", @@ -40,6 +46,10 @@ static bool set_format(struct pcm_format *format) } fmt->bytespersample = fmt->bitspersample >> 3; + + if (fmt->blockalign == 0) + fmt->blockalign = fmt->bytespersample * fmt->channels; + fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); /* chunksize = about 1/50[sec] data */ diff --git a/apps/codecs/libpcm/itut_g711.c b/apps/codecs/libpcm/itut_g711.c index 4644a9c..097dd5c 100644 --- a/apps/codecs/libpcm/itut_g711.c +++ b/apps/codecs/libpcm/itut_g711.c @@ -112,6 +112,12 @@ static bool set_format(struct pcm_format *format) { fmt = format; + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + if (fmt->bitspersample != 8) { DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample: %d\n", @@ -119,13 +125,12 @@ static bool set_format(struct pcm_format *format) return false; } - if (fmt->totalsamples == 0) - { - fmt->bytespersample = 1; - fmt->totalsamples = fmt->numbytes / (fmt->bytespersample * fmt->channels); - } + fmt->bytespersample = 1; + + if (fmt->blockalign == 0) + fmt->blockalign = fmt->channels; - fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); + fmt->samplesperblock = fmt->blockalign / fmt->channels; /* chunksize = about 1/50[sec] data */ fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) diff --git a/apps/codecs/libpcm/linear_pcm.c b/apps/codecs/libpcm/linear_pcm.c index 82c70eb..e58856e 100644 --- a/apps/codecs/libpcm/linear_pcm.c +++ b/apps/codecs/libpcm/linear_pcm.c @@ -38,6 +38,18 @@ static bool set_format(struct pcm_format *format) { fmt = format; + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + + if (fmt->bitspersample == 0) + { + DEBUGF("CODEC_ERROR: bitspersample is 0\n"); + return false; + } + if (fmt->bitspersample > 32) { DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " @@ -47,8 +59,8 @@ static bool set_format(struct pcm_format *format) fmt->bytespersample = fmt->bitspersample >> 3; - if (fmt->totalsamples == 0) - fmt->totalsamples = fmt->numbytes/fmt->bytespersample; + if (fmt->blockalign == 0) + fmt->blockalign = fmt->bytespersample * fmt->channels; fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); -- cgit v1.1