Last change
on this file since 3365 was 3365, checked in by kjdon, 22 years ago |
Initial revision
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Rev | Line | |
---|
[3365] | 1 | #include <stdlib.h>
|
---|
| 2 | #include <stdio.h>
|
---|
| 3 |
|
---|
| 4 | #include "bitio_m_abstract.h"
|
---|
| 5 | #include "bitio_m_mems.h"
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * Create decoding "stream"/"file"
|
---|
| 9 | */
|
---|
| 10 | mems_bitio_buffer::mems_bitio_buffer()
|
---|
| 11 | {
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | mems_bitio_buffer::mems_bitio_buffer(unsigned char *readbuffer, long _pos)
|
---|
| 15 | {
|
---|
| 16 | base = readbuffer;
|
---|
| 17 | pos = _pos;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | void mems_bitio_buffer::encodeStart()
|
---|
| 21 | {
|
---|
| 22 | // Do nothing
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | void mems_bitio_buffer::error()
|
---|
| 27 | {
|
---|
| 28 | fprintf(stderr, "Unexpected EOF in \"%s\" on line %d\n", __FILE__, __LINE__);
|
---|
| 29 | exit(1);
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | void mems_bitio_buffer::seek(unsigned long toPos)
|
---|
| 34 | {
|
---|
| 35 | pos = toPos;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | unsigned long mems_bitio_buffer::position()
|
---|
| 39 | {
|
---|
| 40 | return pos;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | long mems_bitio_buffer::addff(long b)
|
---|
| 44 | {
|
---|
| 45 | do
|
---|
| 46 | {
|
---|
| 47 | b = b + b + (base[pos>>3] & (0x80 >> (pos & 0x07)) != 0);
|
---|
| 48 | pos ++;
|
---|
| 49 | }
|
---|
| 50 | while(0);
|
---|
| 51 |
|
---|
| 52 | return b;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | long mems_bitio_buffer::add00(long b)
|
---|
| 56 | {
|
---|
| 57 | return addff(b);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | int mems_bitio_buffer::bit()
|
---|
| 61 | {
|
---|
| 62 | pos ++;
|
---|
| 63 | return ((base[(pos-1)>>3] & (0x80 >> ((pos-1) & 0x07))) != 0);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | void mems_bitio_buffer::encodeBit(int bit)
|
---|
| 67 | {
|
---|
| 68 | if (bit)
|
---|
| 69 | base[pos>>3] |= 0x80 >> (pos & 0x07);
|
---|
| 70 | else
|
---|
| 71 | base[pos>>3] &= 0xff7f >> (pos & 0x07);
|
---|
| 72 | pos++;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | void mems_bitio_buffer::flush()
|
---|
| 76 | {
|
---|
| 77 | // do nothing
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | void mems_bitio_buffer::done()
|
---|
| 81 | {
|
---|
| 82 | // do nothing
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | void mems_bitio_buffer::encodeDone()
|
---|
| 86 | {
|
---|
| 87 | flush();
|
---|
| 88 | }
|
---|
| 89 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.