summaryrefslogtreecommitdiff
path: root/apps/codecs/libpcm/swf_adpcm.c
diff options
context:
space:
mode:
authorYoshihisa Uchida <uchida@rockbox.org>2010-03-07 07:27:45 +0000
committerYoshihisa Uchida <uchida@rockbox.org>2010-03-07 07:27:45 +0000
commit1e9789879ff620c78b594801bf37abc256bdcc2b (patch)
tree5fd66125e86089485fa03a97670683c4a84eaa1d /apps/codecs/libpcm/swf_adpcm.c
parentf640b89a12eb6a222c0371624fe56a2a6dd6d649 (diff)
downloadrockbox-1e9789879ff620c78b594801bf37abc256bdcc2b.zip
rockbox-1e9789879ff620c78b594801bf37abc256bdcc2b.tar.gz
rockbox-1e9789879ff620c78b594801bf37abc256bdcc2b.tar.bz2
rockbox-1e9789879ff620c78b594801bf37abc256bdcc2b.tar.xz
ima adpcm/swf adpcm: corrects the problem the noise occurs after the play ends.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25052 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libpcm/swf_adpcm.c')
-rw-r--r--apps/codecs/libpcm/swf_adpcm.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/apps/codecs/libpcm/swf_adpcm.c b/apps/codecs/libpcm/swf_adpcm.c
index 3441c66..ebc4328 100644
--- a/apps/codecs/libpcm/swf_adpcm.c
+++ b/apps/codecs/libpcm/swf_adpcm.c
@@ -47,6 +47,8 @@ static bool after_seek = false;
static struct pcm_format *fmt;
+#define GET_SAMPLE_COUNT(s) ((((s) << 3) / fmt->channels - 22) / fmt->bitspersample + 1)
+
static bool set_format(struct pcm_format *format)
{
fmt = format;
@@ -139,14 +141,14 @@ static int decode(const uint8_t *inbuf, size_t inbufsize,
{
int ch;
int adpcm_code_size;
- int count = fmt->samplesperblock;
+ int count = ((size_t)fmt->chunksize == inbufsize) ? fmt->samplesperblock :
+ GET_SAMPLE_COUNT(inbufsize);
int32_t init_pcmdata[2];
int8_t init_index[2];
static uint8_t lastbyte = 0;
- (void)inbufsize;
-
validity_bits = 8;
+ *outbufcount = count;
/* read block header */
ch = fmt->channels - 1;
@@ -208,8 +210,6 @@ static int decode(const uint8_t *inbuf, size_t inbufsize,
<< IMA_ADPCM_INC_DEPTH;
}
- *outbufcount = fmt->samplesperblock;
-
lastbyte = *inbuf;
lastbytebits = (8 - validity_bits) & 0x07;