1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <schroedinger/schroarith.h>
#include <schroedinger/schrotables.h>
#include "arith.h"
void
arith_bit_init (Arith *arith)
{
memset (arith, 0, sizeof(*arith));
arith->code = 0;
arith->range0 = 0;
arith->range1 = 0xffff;
arith->cntr = 0;
arith->offset = 0;
arith->contexts[0].count[0] = 1;
arith->contexts[0].count[1] = 1;
arith->contexts[0].next = 0;
}
void
arith_bit_flush (Arith *arith)
{
}
static void
push_bit (Arith *arith, int value)
{
arith->output_byte <<= 1;
arith->output_byte |= value;
arith->output_bits++;
if (arith->output_bits == 8) {
arith->data[arith->offset] = arith->output_byte;
arith->offset++;
arith->output_byte = 0;
arith->output_bits = 0;
}
}
static void
arith_bit_encode (Arith *arith, int i, int value)
{
push_bit(arith, value);
}
DEFINE_EFFICIENCY(bit)
DEFINE_SPEED(bit)
|