Ignore:
Timestamp:
11/08/06 00:20:07 (18 years ago)
Author:
r2d
Message:
  • can read sv7 & sv8
  • seek broken (not implemented)
  • added demuxer in API
  • added access to decoder in API
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpcdec/branches/zorg/src/mpc_reader.c

    r85 r104  
    179179}
    180180
    181 mpc_status mpc_get_block(mpc_reader * p_reader, mpc_block_t * p_block)
    182 {
    183         unsigned char tmp;
    184         unsigned int size = 2;
    185181
    186         p_block->size = 0;
    187         p_reader->read(p_reader, p_block->key, 2);
    188         do {
    189                 p_reader->read(p_reader, &tmp, 1);
    190                 p_block->size = (p_block->size << 7) | (tmp & 0x7F);
    191                 size++;
    192         } while((tmp & 0x80));
    193182
    194         if (size > p_block->size)
    195                 return MPC_STATUS_FILE;
    196 
    197         p_block->size -= size;
    198 
    199         return MPC_STATUS_OK;
    200 }
    201 
    202 mpc_status mpc_find_block(mpc_reader * p_reader, mpc_block_t * p_block,
    203                                                   char * find_key, char * stop_key)
    204 {
    205         while (1) {
    206                 mpc_get_block(p_reader, p_block);
    207                 if (memcmp(p_block->key, find_key, 2) != 0 &&
    208                                   memcmp(p_block->key, stop_key, 2) != 0)
    209                         p_reader->seek(p_reader, p_block->size);
    210                 else
    211                         break;
    212         }
    213 
    214         if (memcmp(p_block->key, find_key, 2) != 0)
    215                 return MPC_STATUS_FILE;
    216 
    217         return MPC_STATUS_OK;
    218 }
    219 
    220 mpc_uint32_t mpc_read_bits(mpc_reader * p_reader, mpc_bits_reader * p_bits,
    221                                                    int nb_bits)
    222 {
    223         mpc_uint32_t ret = p_bits->buff;
    224         unsigned char tmp = 0;
    225 
    226         while(nb_bits > p_bits->bitsCount){
    227                 p_reader->read(p_reader, &tmp, 1);
    228                 ret = (ret << 8) | tmp;
    229                 p_bits->bitsCount += 8;
    230         }
    231 
    232         p_bits->buff = (unsigned int) ret;
    233         p_bits->bitsCount -= nb_bits;
    234         ret >>= p_bits->bitsCount;
    235 
    236         if (nb_bits == 32)
    237                 return ret;
    238         else
    239                 return ret & ((1 << nb_bits) - 1);
    240 }
    241 
Note: See TracChangeset for help on using the changeset viewer.