6 #include <schroedinger/schro.h>
11 dump_bits (SchroBits
*bits
, int n
)
16 printf(" %d", (bits
->buffer
->data
[(i
>>3)] >> (7 - (i
&7))) & 1);
24 SchroBuffer
*buffer
= schro_buffer_new_and_alloc (300);
35 bits
= schro_bits_new ();
36 schro_bits_encode_init (bits
, buffer
);
38 for(i
=0;i
<chunk1
;i
++){
39 schro_bits_encode_bit (bits
, rand()&1);
44 ref
[i
] = rand() & 0xf;
45 schro_bits_encode_sint (bits
, ref
[i
]);
46 chunk2
+= schro_bits_estimate_sint (ref
[i
]);
50 schro_bits_encode_bit (bits
, rand()&1);
53 schro_bits_flush (bits
);
54 schro_bits_free (bits
);
57 bits
= schro_bits_new ();
58 schro_bits_decode_init (bits
, buffer
);
60 schro_bits_copy (&bits2
, bits
);
62 schro_bits_skip_bits (&bits2
, chunk1
);
63 schro_bits_set_length (&bits2
, chunk2
);
65 printf("chunk1 %d\n", chunk1
);
67 x
= schro_bits_decode_sint (&bits2
);
68 printf("%d %d\n", ref
[i
], x
);
69 if (x
!= ref
[i
]) fail
= TRUE
;
72 schro_bits_free (bits
);
78 main (int argc
, char *argv
[])