library for read / write bitstream data
default BC_UNIT is uint64_t, if you want to use different unit (uint8_t for example), just add '-DBC_UNIT=uint8_t' in your compilation clags
Please notice: bitstreams writing by differnt BC_UINT are imcompatible! (UNIT is used for concatenatation and file read/write)
- create context by 'bcw_open'
bc_context *ctx = bcw_open("test.bin");
- write 1~64 bits you want to write by 'bcw_write'
bcw_write(ctx, bits, value);
- if you want to have alignment write, next writing will be aligned to BC_UNIT
bcw_align(ctx);
- close context by 'bcw_close'
bcw_close(ctx);
- create context by 'bcr_open'
bc_context *ctx = bcr_open("test.bin");
- read 1~64 bits you want to read by 'bcr_read', return value will be negative for abnormal case. Please provides an uint64_t to get error code.
int64_t value = bcr_readbits(ctx, bits, &err);
- get value without change current context steps by 'bcr_getbits', this is useful for VLC decoding Please provides an uint64_t pointer to get error code.
int64_t value = bcr_getbits(ctx, bits, &err);
- skip bits without get the value, moving the context pointer forward by 'bcr_skipbits' Please provides an uint64_t pointer to get error code.
bcr_skipbits(ctx, bits, &err);
- if you want to have alignment write, next reading will be aligned to BC_UNIT Please provides an uint64_t pointer to get error code.
bcr_align(ctx, &err);
- close context by 'bcr_close'
bcr_close(ctx);