I
in_tyrannos
First, the file is read to the buffer. Now, I want to access this
buffer in the following way. Start index is defined as i =
j*size(byte) +k*size(bit) = j*8+k*1. The length of the sequence to be
read from buffer is defined similarly. So basically, I want to read
sequence of bits from buffer at specified bit-location. Further, I
want to do this efficiently.
For example, start index is 13. The length of sequence of bits to be
read is 17. This means that (when reading bytes in c), we first read
two bytes to reach position 13 from positon 0. Sequence is now
obtained by reading 3 bits from second byte, then 16 bits (=two
bytes). From the last byte we read only 6 bits. Since c has only
limited number of primitive types, the question becomes: "How to do
this efficiently?" Of course, next the solution should be expandable
to such scheme, where the original is read continuosly to the buffer,
and bit-sequnces are also read continuosly (size of the buffer and
sequnce should be variables)...
Any ideas? Maybe something like this is done when writing file headers
or compressing files?
BR, J
buffer in the following way. Start index is defined as i =
j*size(byte) +k*size(bit) = j*8+k*1. The length of the sequence to be
read from buffer is defined similarly. So basically, I want to read
sequence of bits from buffer at specified bit-location. Further, I
want to do this efficiently.
For example, start index is 13. The length of sequence of bits to be
read is 17. This means that (when reading bytes in c), we first read
two bytes to reach position 13 from positon 0. Sequence is now
obtained by reading 3 bits from second byte, then 16 bits (=two
bytes). From the last byte we read only 6 bits. Since c has only
limited number of primitive types, the question becomes: "How to do
this efficiently?" Of course, next the solution should be expandable
to such scheme, where the original is read continuosly to the buffer,
and bit-sequnces are also read continuosly (size of the buffer and
sequnce should be variables)...
Any ideas? Maybe something like this is done when writing file headers
or compressing files?
BR, J