diff options
| author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-04-16 19:08:50 +0000 |
|---|---|---|
| committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-04-16 19:08:50 +0000 |
| commit | 19f9fd0f5feaf329a6e386eb859e0700b6e8dcc6 (patch) | |
| tree | 257873f6803c480dbdf8fd7669e7f120cd1b79d5 /apps/codecs | |
| parent | e4dd514e6ffed290f07eff20b586b704008d0a8a (diff) | |
| download | rockbox-19f9fd0f5feaf329a6e386eb859e0700b6e8dcc6.zip rockbox-19f9fd0f5feaf329a6e386eb859e0700b6e8dcc6.tar.gz rockbox-19f9fd0f5feaf329a6e386eb859e0700b6e8dcc6.tar.bz2 rockbox-19f9fd0f5feaf329a6e386eb859e0700b6e8dcc6.tar.xz | |
Refactor alac decoder as preparation for upcoming m4a changes. The alac decoder does not need to use get_sample_info() to gather frame size or the number of consumed bytes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29724 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
| -rw-r--r-- | apps/codecs/alac.c | 21 | ||||
| -rw-r--r-- | apps/codecs/libalac/alac.c | 9 | ||||
| -rw-r--r-- | apps/codecs/libalac/decomp.h | 1 |
3 files changed, 15 insertions, 16 deletions
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c index 3721f04..428fc59 100644 --- a/apps/codecs/alac.c +++ b/apps/codecs/alac.c @@ -35,8 +35,6 @@ enum codec_status codec_main(void) stream_t input_stream; uint32_t samplesdone; uint32_t elapsedtime; - uint32_t sample_duration; - uint32_t sample_byte_size; int samplesdecoded; unsigned int i; unsigned char* buffer; @@ -112,18 +110,9 @@ enum codec_status codec_main(void) ci->seek_complete(); } - /* Lookup the length (in samples and bytes) of block i */ - if (!get_sample_info(&demux_res, i, &sample_duration, - &sample_byte_size)) { - LOGF("ALAC: Error in get_sample_info\n"); - retval = CODEC_ERROR; - goto done; - } - /* Request the required number of bytes from the input buffer */ - - buffer=ci->request_buffer(&n,sample_byte_size); - if (n!=sample_byte_size) { + buffer=ci->request_buffer(&n, demux_res.sample_byte_size[i]); + if (n!=demux_res.sample_byte_size[i]) { retval = CODEC_ERROR; goto done; } @@ -132,15 +121,15 @@ enum codec_status codec_main(void) ci->yield(); samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, ci->yield); - /* Advance codec buffer n bytes */ - ci->advance_buffer(n); + /* Advance codec buffer by amount of consumed bytes */ + ci->advance_buffer(alac.bytes_consumed); /* Output the audio */ ci->yield(); ci->pcmbuf_insert(outputbuffer[0], outputbuffer[1], samplesdecoded); /* Update the elapsed-time indicator */ - samplesdone+=sample_duration; + samplesdone+=samplesdecoded; elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); ci->set_elapsed(elapsedtime); diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c index a7d7448..38fd6e1 100644 --- a/apps/codecs/libalac/alac.c +++ b/apps/codecs/libalac/alac.c @@ -1108,10 +1108,14 @@ int alac_decode_frame(alac_file *alac, { int channels; int outputsamples; + int input_buffer_start; /* setup the stream */ alac->input_buffer = inbuffer; alac->input_buffer_bitaccumulator = 0; + + /* save to gather byte consumption */ + input_buffer_start = (int)alac->input_buffer; channels = readbits(alac, 3); @@ -1127,6 +1131,11 @@ int alac_decode_frame(alac_file *alac, default: /* Unsupported */ return -1; } + + /* calculate consumed bytes */ + alac->bytes_consumed = (int)alac->input_buffer - input_buffer_start; + alac->bytes_consumed += (alac->input_buffer_bitaccumulator>5) ? 2 : 1; + return outputsamples; } diff --git a/apps/codecs/libalac/decomp.h b/apps/codecs/libalac/decomp.h index bd47680..d7abd4d 100644 --- a/apps/codecs/libalac/decomp.h +++ b/apps/codecs/libalac/decomp.h @@ -20,6 +20,7 @@ typedef struct int samplesize; int numchannels; int bytespersample; + int bytes_consumed; /* stuff from setinfo */ uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */ |