Changeset 459


Ignore:
Timestamp:
05/15/10 20:42:54 (14 years ago)
Author:
r2d
Message:
  • fix cmake libmpcdec build
  • do not flush the demux buffer when seek position is in the buffer
Location:
libmpc/trunk/libmpcdec
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/libmpcdec/CMakeLists.txt

    r238 r459  
    11include_directories(${libmpc_SOURCE_DIR}/include)
    2 add_library(mpcdec_static STATIC huffman mpc_decoder mpc_reader streaminfo mpc_bits_reader mpc_demux requant synth_filter ${libmpc_SOURCE_DIR}/common/crc32)
     2if(SHARED)
     3  add_library(mpcdec_shared SHARED huffman mpc_decoder mpc_reader streaminfo mpc_bits_reader mpc_demux requant synth_filter ${libmpc_SOURCE_DIR}/common/crc32)
     4else(SHARED)
     5  add_library(mpcdec_static STATIC huffman mpc_decoder mpc_reader streaminfo mpc_bits_reader mpc_demux requant synth_filter ${libmpc_SOURCE_DIR}/common/crc32)
     6endif(SHARED)
     7
  • libmpc/trunk/libmpcdec/mpc_demux.c

    r439 r459  
    122122static void
    123123mpc_demux_seek(mpc_demux * d, mpc_seek_t fpos, mpc_uint32_t min_bytes) {
    124         mpc_seek_t next_pos;
     124        mpc_seek_t start_pos, end_pos;
    125125        mpc_int_t bit_offset;
    126126
    127         // FIXME : do not flush the buffer if fpos is in the current buffer
    128 
    129         next_pos = fpos >> 3;
    130         if (d->si.stream_version == 7)
    131                 next_pos = ((next_pos - d->si.header_position) & (-1 << 2)) + d->si.header_position;
    132         bit_offset = (int) (fpos - (next_pos << 3));
    133 
    134         d->r->seek(d->r, (mpc_int32_t) next_pos);
    135         mpc_demux_clear_buff(d);
     127        // get current buffer position
     128        end_pos = ((mpc_seek_t)(d->r->tell(d->r))) << 3;
     129        start_pos =     end_pos - (d->bytes_total << 3);
     130
     131        if (fpos >= start_pos && fpos < end_pos) {
     132                d->bits_reader.buff = d->buffer + ((fpos - start_pos) >> 3);
     133                bit_offset = fpos & 7;
     134        } else {
     135                mpc_seek_t next_pos = fpos >> 3;
     136                if (d->si.stream_version == 7)
     137                        next_pos = ((next_pos - d->si.header_position) & (-1 << 2)) + d->si.header_position;
     138                bit_offset = (int) (fpos - (next_pos << 3));
     139
     140                d->r->seek(d->r, (mpc_int32_t) next_pos);
     141                mpc_demux_clear_buff(d);
     142        }
     143
    136144        if (d->si.stream_version == 7)
    137145                mpc_demux_fill(d, (min_bytes + ((bit_offset + 7) >> 3) + 3) & (~3), MPC_BUFFER_SWAP);
Note: See TracChangeset for help on using the changeset viewer.