Changeset 376
- Timestamp:
- 12/18/07 23:55:26 (17 years ago)
- Location:
- libmpc/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/include/mpc/mpc_types.h
r359 r376 73 73 typedef mpc_uint8_t mpc_bool_t; 74 74 75 // #define LONG_SEEK_TABLE 76 #ifdef LONG_SEEK_TABLE // define as needed (mpc_uint32_t supports files up to 512 MB) 77 typedef mpc_uint64_t mpc_seek_t; 78 #else 79 typedef mpc_uint32_t mpc_seek_t; 80 #endif 81 75 82 # define mpc_int64_min -9223372036854775808ll 76 83 # define mpc_int64_max 9223372036854775807ll -
libmpc/trunk/include/mpc/mpcdec.h
r291 r376 112 112 mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample); 113 113 mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds); 114 mpc_s ize_t mpc_demux_pos(mpc_demux * d);114 mpc_seek_t mpc_demux_pos(mpc_demux * d); 115 115 116 116 -
libmpc/trunk/libmpcdec/internal.h
r360 r376 79 79 80 80 // seeking 81 mpc_ uint32_t * seek_table;81 mpc_seek_t * seek_table; 82 82 mpc_uint_t seek_pwr; /// distance between 2 frames in seek_table = 2^seek_pwr 83 83 mpc_uint32_t seek_table_size; /// used size in seek_table -
libmpc/trunk/libmpcdec/mpc_demux.c
r358 r376 115 115 */ 116 116 static void 117 mpc_demux_seek(mpc_demux * d, mpc_size_t fpos, mpc_uint32_t min_bytes) { 118 // mpc_uint32_t cur_pos = d->r->tell(d->r); 119 mpc_size_t next_pos; 117 mpc_demux_seek(mpc_demux * d, mpc_seek_t fpos, mpc_uint32_t min_bytes) { 118 mpc_seek_t next_pos; 120 119 mpc_int_t bit_offset; 121 120 … … 142 141 * @return current stream position in bits 143 142 */ 144 mpc_size_t mpc_demux_pos(mpc_demux * d) 145 { 146 return ((d->r->tell(d->r) - d->bytes_total + d->bits_reader.buff - d->buffer) << 3) + 8 - d->bits_reader.count; 143 mpc_seek_t mpc_demux_pos(mpc_demux * d) 144 { 145 return (((mpc_seek_t)(d->r->tell(d->r)) - d->bytes_total + 146 d->bits_reader.buff - d->buffer) << 3) + 8 - d->bits_reader.count; 147 147 } 148 148 … … 208 208 if (d->si.block_pwr > d->seek_pwr) 209 209 d->seek_pwr = d->si.block_pwr; 210 d->seek_table = malloc((size_t)(2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_ uint32_t));210 d->seek_table = malloc((size_t)(2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_seek_t)); 211 211 if (d->seek_table == 0) 212 212 return MPC_STATUS_FILE; 213 d->seek_table[0] = (mpc_ uint32_t)mpc_demux_pos(d);213 d->seek_table[0] = (mpc_seek_t)mpc_demux_pos(d); 214 214 d->seek_table_size = 1; 215 215 … … 220 220 { 221 221 mpc_uint64_t tmp; 222 mpc_ uint32_t * table;222 mpc_seek_t * table; 223 223 mpc_bits_reader r = d->bits_reader; 224 224 mpc_uint_t i; … … 228 228 229 229 mpc_bits_get_size(&r, &tmp); 230 d->seek_table_size = (mpc_ uint32_t) tmp;230 d->seek_table_size = (mpc_seek_t) tmp; 231 231 d->seek_pwr = d->si.block_pwr + mpc_bits_read(&r, 4); 232 232 tmp = 2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr); 233 233 if (tmp < d->seek_table_size) tmp = d->seek_table_size; 234 d->seek_table = malloc((size_t)(tmp * sizeof(mpc_ uint32_t)));234 d->seek_table = malloc((size_t)(tmp * sizeof(mpc_seek_t))); 235 235 236 236 table = d->seek_table; 237 237 mpc_bits_get_size(&r, &tmp); 238 table[0] = (mpc_ uint32_t) (tmp + d->si.header_position) * 8;238 table[0] = (mpc_seek_t) (tmp + d->si.header_position) * 8; 239 239 240 240 if (d->seek_table_size == 1) … … 242 242 243 243 mpc_bits_get_size(&r, &tmp); 244 table[1] = (mpc_ uint32_t) (tmp + d->si.header_position) * 8;244 table[1] = (mpc_seek_t) (tmp + d->si.header_position) * 8; 245 245 246 246 for (i = 2; i < d->seek_table_size; i++) { … … 255 255 static void mpc_demux_SP(mpc_demux * d, int size, int block_size) 256 256 { 257 mpc_s ize_t cur;257 mpc_seek_t cur; 258 258 mpc_uint64_t ptr; 259 259 mpc_block b; … … 376 376 d->bits_reader.count &= -8; 377 377 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 378 d->seek_table[d->seek_table_size] = (mpc_ uint32_t) mpc_demux_pos(d);378 d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); 379 379 d->seek_table_size ++; 380 380 } … … 407 407 } else { 408 408 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 409 d->seek_table[d->seek_table_size] = (mpc_ uint32_t) mpc_demux_pos(d);409 d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); 410 410 d->seek_table_size ++; 411 411 } … … 434 434 mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample) 435 435 { 436 mpc_uint32_t fwd, samples_to_skip, fpos,i;436 mpc_uint32_t fwd, samples_to_skip, i; 437 437 mpc_uint32_t block_samples = MPC_FRAME_LENGTH << d->si.block_pwr; 438 mpc_seek_t fpos; 438 439 439 440 destsample += d->si.beg_silence; … … 467 468 if (memcmp(b.key, "AP", 2) == 0) { 468 469 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 469 d->seek_table[d->seek_table_size] = (mpc_ uint32_t) mpc_demux_pos(d) - 8 * size;470 d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d) - 8 * size; 470 471 d->seek_table_size ++; 471 472 } … … 483 484 for( ; i < fwd; i++){ 484 485 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 485 d->seek_table[d->seek_table_size] = (mpc_ uint32_t) mpc_demux_pos(d);486 d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); 486 487 d->seek_table_size ++; 487 488 }
Note: See TracChangeset
for help on using the changeset viewer.