diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2008-05-19 18:06:00 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2008-05-19 18:06:00 +0000 |
commit | 1d28fe7d798eaad14e7e4553d4af6c8082309126 (patch) | |
tree | afcd2f46938300dff183d58e4690d1999af17c67 | |
parent | 69fc5ad48a5d8063cc0d94da8c1db5d141341dc5 (diff) | |
download | rockbox-1d28fe7d798eaad14e7e4553d4af6c8082309126.tar.gz rockbox-1d28fe7d798eaad14e7e4553d4af6c8082309126.zip |
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
-rw-r--r-- | apps/codecs/libmusepack/decoder.h | 3 | ||||
-rw-r--r-- | apps/codecs/libmusepack/mpc_decoder.c | 14 | ||||
-rw-r--r-- | apps/codecs/libmusepack/musepack.h | 3 | ||||
-rw-r--r-- | apps/codecs/mpc.c | 1 |
4 files changed, 6 insertions, 15 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 @@ | |||
48 | 48 | ||
49 | enum { | 49 | enum { |
50 | MPC_V_MEM = 2304, | 50 | MPC_V_MEM = 2304, |
51 | MPC_DECODER_MEMSIZE = 16384, // overall buffer size | 51 | MPC_DECODER_MEMSIZE = 16384, // overall buffer size (words) |
52 | MPC_SEEK_BUFFER_SIZE = 65536, // seek buffer size (words) | ||
52 | }; | 53 | }; |
53 | 54 | ||
54 | typedef struct { | 55 | 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) | |||
118 | 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); | 118 | 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); |
119 | static void mpc_move_next(mpc_decoder *d); | 119 | static void mpc_move_next(mpc_decoder *d); |
120 | 120 | ||
121 | mpc_uint32_t Seekbuffer[MPC_SEEK_BUFFER_SIZE]; | ||
121 | mpc_uint32_t Speicher[MPC_DECODER_MEMSIZE]; | 122 | mpc_uint32_t Speicher[MPC_DECODER_MEMSIZE]; |
122 | MPC_SAMPLE_FORMAT Y_L[36][32] IBSS_ATTR_MPC_LARGE_IRAM; | 123 | MPC_SAMPLE_FORMAT Y_L[36][32] IBSS_ATTR_MPC_LARGE_IRAM; |
123 | MPC_SAMPLE_FORMAT Y_R[36][32] IBSS_ATTR_MPC_LARGE_IRAM; | 124 | 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) | |||
1458 | LOOKUP ( mpc_table_HuffQ[1][7], 63, LUT7_1 ); | 1459 | LOOKUP ( mpc_table_HuffQ[1][7], 63, LUT7_1 ); |
1459 | LOOKUP ( mpc_table_HuffDSCF, 16, LUTDSCF ); | 1460 | LOOKUP ( mpc_table_HuffDSCF, 16, LUTDSCF ); |
1460 | 1461 | ||
1462 | d->SeekTable = Seekbuffer; | ||
1461 | d->Speicher = Speicher; | 1463 | d->Speicher = Speicher; |
1462 | d->Y_L = Y_L; | 1464 | d->Y_L = Y_L; |
1463 | d->Y_R = Y_R; | 1465 | d->Y_R = Y_R; |
@@ -1467,12 +1469,6 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r) | |||
1467 | #endif | 1469 | #endif |
1468 | } | 1470 | } |
1469 | 1471 | ||
1470 | void mpc_decoder_destroy(mpc_decoder *d) | ||
1471 | { | ||
1472 | if (d->SeekTable != NULL) | ||
1473 | free(d->SeekTable); | ||
1474 | } | ||
1475 | |||
1476 | static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) | 1472 | static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) |
1477 | { | 1473 | { |
1478 | mpc_uint32_t seekTableSize; | 1474 | mpc_uint32_t seekTableSize; |
@@ -1490,11 +1486,9 @@ static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) | |||
1490 | 1486 | ||
1491 | d->samples_to_skip = MPC_DECODER_SYNTH_DELAY; | 1487 | d->samples_to_skip = MPC_DECODER_SYNTH_DELAY; |
1492 | 1488 | ||
1493 | if (d->SeekTable != NULL) | 1489 | memset(d->SeekTable, 0, sizeof(Seekbuffer)); |
1494 | free(d->SeekTable); | ||
1495 | 1490 | ||
1496 | seekTableSize = si->frames; | 1491 | seekTableSize = min(si->frames, MPC_SEEK_BUFFER_SIZE); |
1497 | d->SeekTable = (mpc_uint32_t*) calloc( sizeof(mpc_uint32_t), seekTableSize); | ||
1498 | d->SeekTable_Step = si->frames / seekTableSize; | 1492 | d->SeekTable_Step = si->frames / seekTableSize; |
1499 | if (si->frames % seekTableSize) | 1493 | if (si->frames % seekTableSize) |
1500 | d->SeekTable_Step+=1; | 1494 | 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); | |||
154 | /// Seeks to specified position in seconds in the source stream. | 154 | /// Seeks to specified position in seconds in the source stream. |
155 | mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds); | 155 | mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds); |
156 | 156 | ||
157 | /// Cleans up the decoder (seektable) | ||
158 | void mpc_decoder_destroy(mpc_decoder *d); | ||
159 | |||
160 | #ifdef __cplusplus | 157 | #ifdef __cplusplus |
161 | } | 158 | } |
162 | #endif // __cplusplus | 159 | #endif // __cplusplus |
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c index c734915f68..79264d3bfc 100644 --- a/apps/codecs/mpc.c +++ b/apps/codecs/mpc.c | |||
@@ -188,7 +188,6 @@ done: | |||
188 | goto next_track; | 188 | goto next_track; |
189 | 189 | ||
190 | exit: | 190 | exit: |
191 | mpc_decoder_destroy(&decoder); | ||
192 | return retval; | 191 | return retval; |
193 | } | 192 | } |
194 | 193 | ||