diff options
author | Yoshihisa Uchida <uchida@rockbox.org> | 2010-02-20 02:04:56 +0000 |
---|---|---|
committer | Yoshihisa Uchida <uchida@rockbox.org> | 2010-02-20 02:04:56 +0000 |
commit | 3716abba9274f544dd31cdf4e6c83a845bf2a801 (patch) | |
tree | 07bca7cdd3e40bb176e938fcb5ea8eb2f7c3e9cb /apps/codecs/libpcm/linear_pcm.c | |
parent | 93caf52db5e0afe826278c148936bdfa563724f1 (diff) | |
download | rockbox-3716abba9274f544dd31cdf4e6c83a845bf2a801.tar.gz rockbox-3716abba9274f544dd31cdf4e6c83a845bf2a801.zip |
commit FS#10424 and FS#10425
- wav(RIFF) supports Microsoft ADPCM, Dialogic OKI ADPCM, YAMAHA ADPCM, Adobe SWF ADPCM.
- AIFF supports QuickTime IMA ADPCM.
- DVI ADPCM(IMA ADPCM) reworks.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24782 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libpcm/linear_pcm.c')
-rw-r--r-- | apps/codecs/libpcm/linear_pcm.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/apps/codecs/libpcm/linear_pcm.c b/apps/codecs/libpcm/linear_pcm.c index 4db27ca2b3..5360d79901 100644 --- a/apps/codecs/libpcm/linear_pcm.c +++ b/apps/codecs/libpcm/linear_pcm.c | |||
@@ -29,12 +29,10 @@ | |||
29 | 29 | ||
30 | static struct pcm_format *fmt; | 30 | static struct pcm_format *fmt; |
31 | 31 | ||
32 | static bool set_format(struct pcm_format *format, const unsigned char *fmtpos) | 32 | static bool set_format(struct pcm_format *format) |
33 | { | 33 | { |
34 | fmt = format; | 34 | fmt = format; |
35 | 35 | ||
36 | (void)fmtpos; | ||
37 | |||
38 | if (fmt->bitspersample > 32) | 36 | if (fmt->bitspersample > 32) |
39 | { | 37 | { |
40 | DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " | 38 | DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " |
@@ -42,33 +40,34 @@ static bool set_format(struct pcm_format *format, const unsigned char *fmtpos) | |||
42 | return false; | 40 | return false; |
43 | } | 41 | } |
44 | 42 | ||
43 | fmt->bytespersample = fmt->bitspersample >> 3; | ||
44 | |||
45 | if (fmt->totalsamples == 0) | 45 | if (fmt->totalsamples == 0) |
46 | { | ||
47 | fmt->bytespersample = (((fmt->bitspersample - 1)/8 + 1)*fmt->channels); | ||
48 | fmt->totalsamples = fmt->numbytes/fmt->bytespersample; | 46 | fmt->totalsamples = fmt->numbytes/fmt->bytespersample; |
49 | } | ||
50 | 47 | ||
51 | /* chunksize is computed so that one chunk is about 1/50s. | 48 | fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); |
52 | * this make 4096 for 44.1kHz 16bits stereo. | 49 | |
53 | * It also has to be a multiple of blockalign */ | 50 | /* chunksize = about 1/50[sec] data */ |
54 | fmt->chunksize = (1 + fmt->avgbytespersec / (50*fmt->blockalign))*fmt->blockalign; | 51 | fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) |
52 | * fmt->blockalign; | ||
55 | 53 | ||
56 | return true; | 54 | return true; |
57 | } | 55 | } |
58 | 56 | ||
59 | static uint32_t get_seek_pos(long seek_time) | 57 | static struct pcm_pos *get_seek_pos(long seek_time, |
58 | uint8_t *(*read_buffer)(size_t *realsize)) | ||
60 | { | 59 | { |
61 | uint32_t newpos; | 60 | static struct pcm_pos newpos; |
62 | 61 | uint32_t newblock = ((uint64_t)seek_time * ci->id3->frequency) | |
63 | /* use avgbytespersec to round to the closest blockalign multiple, | 62 | / (1000LL * fmt->samplesperblock); |
64 | add firstblockposn. 64-bit casts to avoid overflows. */ | 63 | |
65 | newpos = (((uint64_t)fmt->avgbytespersec*(seek_time - 1)) | 64 | (void)read_buffer; |
66 | / (1000LL*fmt->blockalign))*fmt->blockalign; | 65 | newpos.pos = newblock * fmt->blockalign; |
67 | return newpos; | 66 | newpos.samples = newblock * fmt->samplesperblock; |
67 | return &newpos; | ||
68 | } | 68 | } |
69 | 69 | ||
70 | static int decode(const uint8_t *inbuf, size_t inbufsize, | 70 | static int decode(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf, int *outbufsize) |
71 | int32_t *outbuf, int *outbufsize) | ||
72 | { | 71 | { |
73 | uint32_t i; | 72 | uint32_t i; |
74 | 73 | ||