Changeset 376


Ignore:
Timestamp:
12/18/07 23:55:26 (17 years ago)
Author:
r2d
Message:

added LONG_SEEK_TABLE define for a 64 bits long offset in the seek table in libmpcdec. Same change may be done to the encoder.

Location:
libmpc/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/include/mpc/mpc_types.h

    r359 r376  
    7373typedef mpc_uint8_t mpc_bool_t;
    7474
     75// #define LONG_SEEK_TABLE
     76#ifdef LONG_SEEK_TABLE  // define as needed (mpc_uint32_t supports files up to 512 MB)
     77typedef mpc_uint64_t mpc_seek_t;
     78#else
     79typedef mpc_uint32_t mpc_seek_t;
     80#endif
     81
    7582# define mpc_int64_min -9223372036854775808ll
    7683# define mpc_int64_max 9223372036854775807ll
  • libmpc/trunk/include/mpc/mpcdec.h

    r291 r376  
    112112mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample);
    113113mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds);
    114 mpc_size_t mpc_demux_pos(mpc_demux * d);
     114mpc_seek_t mpc_demux_pos(mpc_demux * d);
    115115
    116116
  • libmpc/trunk/libmpcdec/internal.h

    r360 r376  
    7979
    8080        // seeking
    81         mpc_uint32_t * seek_table;
     81        mpc_seek_t * seek_table;
    8282        mpc_uint_t seek_pwr; /// distance between 2 frames in seek_table = 2^seek_pwr
    8383        mpc_uint32_t seek_table_size; /// used size in seek_table
  • libmpc/trunk/libmpcdec/mpc_demux.c

    r358 r376  
    115115 */
    116116static 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;
     117mpc_demux_seek(mpc_demux * d, mpc_seek_t fpos, mpc_uint32_t min_bytes) {
     118        mpc_seek_t next_pos;
    120119        mpc_int_t bit_offset;
    121120
     
    142141 * @return current stream position in bits
    143142 */
    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;
     143mpc_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;
    147147}
    148148
     
    208208        if (d->si.block_pwr > d->seek_pwr)
    209209                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));
    211211        if (d->seek_table == 0)
    212212                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);
    214214        d->seek_table_size = 1;
    215215
     
    220220{
    221221        mpc_uint64_t tmp;
    222         mpc_uint32_t * table;
     222        mpc_seek_t * table;
    223223        mpc_bits_reader r = d->bits_reader;
    224224        mpc_uint_t i;
     
    228228
    229229        mpc_bits_get_size(&r, &tmp);
    230         d->seek_table_size = (mpc_uint32_t) tmp;
     230        d->seek_table_size = (mpc_seek_t) tmp;
    231231        d->seek_pwr = d->si.block_pwr + mpc_bits_read(&r, 4);
    232232        tmp = 2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr);
    233233        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)));
    235235
    236236        table = d->seek_table;
    237237        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;
    239239
    240240        if (d->seek_table_size == 1)
     
    242242
    243243        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;
    245245
    246246        for (i = 2; i < d->seek_table_size; i++) {
     
    255255static void mpc_demux_SP(mpc_demux * d, int size, int block_size)
    256256{
    257         mpc_size_t cur;
     257        mpc_seek_t cur;
    258258        mpc_uint64_t ptr;
    259259        mpc_block b;
     
    376376                        d->bits_reader.count &= -8;
    377377                        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);
    379379                                d->seek_table_size ++;
    380380                        }
     
    407407        } else {
    408408                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);
    410410                        d->seek_table_size ++;
    411411                }
     
    434434mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample)
    435435{
    436         mpc_uint32_t fwd, samples_to_skip, fpos, i;
     436        mpc_uint32_t fwd, samples_to_skip, i;
    437437        mpc_uint32_t block_samples = MPC_FRAME_LENGTH << d->si.block_pwr;
     438        mpc_seek_t fpos;
    438439
    439440        destsample += d->si.beg_silence;
     
    467468                        if (memcmp(b.key, "AP", 2) == 0) {
    468469                                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;
    470471                                        d->seek_table_size ++;
    471472                                }
     
    483484                for( ; i < fwd; i++){
    484485                        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);
    486487                                d->seek_table_size ++;
    487488                        }
Note: See TracChangeset for help on using the changeset viewer.