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
This commit is contained in:
Andree Buschmann 2008-05-19 18:06:00 +00:00
parent 69fc5ad48a
commit 1d28fe7d79
4 changed files with 6 additions and 15 deletions

View file

@ -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 {

View file

@ -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;

View file

@ -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

View file

@ -188,7 +188,6 @@ done:
goto next_track;
exit:
mpc_decoder_destroy(&decoder);
return retval;
}