summaryrefslogtreecommitdiff
path: root/apps/codecs/libmusepack
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2008-05-19 18:06:00 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2008-05-19 18:06:00 +0000
commit1d28fe7d798eaad14e7e4553d4af6c8082309126 (patch)
treeafcd2f46938300dff183d58e4690d1999af17c67 /apps/codecs/libmusepack
parent69fc5ad48a5d8063cc0d94da8c1db5d141341dc5 (diff)
Musepack seek hotfix. Do not dynamically allocate seek buffer but use a buffer of constant size (~28.5min). Files larger than this will still not seek properly. Some additional rework has to be done for the seek buffer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17584 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libmusepack')
-rw-r--r--apps/codecs/libmusepack/decoder.h3
-rw-r--r--apps/codecs/libmusepack/mpc_decoder.c14
-rw-r--r--apps/codecs/libmusepack/musepack.h3
3 files changed, 6 insertions, 14 deletions
diff --git a/apps/codecs/libmusepack/decoder.h b/apps/codecs/libmusepack/decoder.h
index 1f78d53c8d..b035ae9574 100644
--- a/apps/codecs/libmusepack/decoder.h
+++ b/apps/codecs/libmusepack/decoder.h
@@ -48,7 +48,8 @@
enum {
MPC_V_MEM = 2304,
- MPC_DECODER_MEMSIZE = 16384, // overall buffer size
+ MPC_DECODER_MEMSIZE = 16384, // overall buffer size (words)
+ MPC_SEEK_BUFFER_SIZE = 65536, // seek buffer size (words)
};
typedef struct {
diff --git a/apps/codecs/libmusepack/mpc_decoder.c b/apps/codecs/libmusepack/mpc_decoder.c
index f7687c5bad..fa3295357c 100644
--- a/apps/codecs/libmusepack/mpc_decoder.c
+++ b/apps/codecs/libmusepack/mpc_decoder.c
@@ -118,6 +118,7 @@ static mpc_uint32_t get_initial_fpos(mpc_decoder *d, mpc_uint32_t StreamVersion)
static inline mpc_int32_t mpc_decoder_huffman_decode_fastest(mpc_decoder *d, const HuffmanTyp* Table, const mpc_uint8_t* tab, mpc_uint16_t unused_bits);
static void mpc_move_next(mpc_decoder *d);
+mpc_uint32_t Seekbuffer[MPC_SEEK_BUFFER_SIZE];
mpc_uint32_t Speicher[MPC_DECODER_MEMSIZE];
MPC_SAMPLE_FORMAT Y_L[36][32] IBSS_ATTR_MPC_LARGE_IRAM;
MPC_SAMPLE_FORMAT Y_R[36][32] IBSS_ATTR_MPC_LARGE_IRAM;
@@ -1458,6 +1459,7 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r)
LOOKUP ( mpc_table_HuffQ[1][7], 63, LUT7_1 );
LOOKUP ( mpc_table_HuffDSCF, 16, LUTDSCF );
+ d->SeekTable = Seekbuffer;
d->Speicher = Speicher;
d->Y_L = Y_L;
d->Y_R = Y_R;
@@ -1467,12 +1469,6 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r)
#endif
}
-void mpc_decoder_destroy(mpc_decoder *d)
-{
- if (d->SeekTable != NULL)
- free(d->SeekTable);
-}
-
static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si)
{
mpc_uint32_t seekTableSize;
@@ -1490,11 +1486,9 @@ static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si)
d->samples_to_skip = MPC_DECODER_SYNTH_DELAY;
- if (d->SeekTable != NULL)
- free(d->SeekTable);
+ memset(d->SeekTable, 0, sizeof(Seekbuffer));
- seekTableSize = si->frames;
- d->SeekTable = (mpc_uint32_t*) calloc( sizeof(mpc_uint32_t), seekTableSize);
+ seekTableSize = min(si->frames, MPC_SEEK_BUFFER_SIZE);
d->SeekTable_Step = si->frames / seekTableSize;
if (si->frames % seekTableSize)
d->SeekTable_Step+=1;
diff --git a/apps/codecs/libmusepack/musepack.h b/apps/codecs/libmusepack/musepack.h
index 9bdebf8b04..b9aff48427 100644
--- a/apps/codecs/libmusepack/musepack.h
+++ b/apps/codecs/libmusepack/musepack.h
@@ -154,9 +154,6 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
/// Seeks to specified position in seconds in the source stream.
mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds);
-/// Cleans up the decoder (seektable)
-void mpc_decoder_destroy(mpc_decoder *d);
-
#ifdef __cplusplus
}
#endif // __cplusplus