Path: blob/a-new-beginning/SharedDependencies/Sources/libchdr/include/bitstream.h
2 views
/* license:BSD-3-Clause1* copyright-holders:Aaron Giles2***************************************************************************34bitstream.h56Helper classes for reading/writing at the bit level.78***************************************************************************/910#pragma once1112#ifndef __BITSTREAM_H__13#define __BITSTREAM_H__1415#include <stdint.h>1617/***************************************************************************18* TYPE DEFINITIONS19***************************************************************************20*/2122/* helper class for reading from a bit buffer */23struct bitstream24{25uint32_t buffer; /* current bit accumulator */26int bits; /* number of bits in the accumulator */27const uint8_t * read; /* read pointer */28uint32_t doffset; /* byte offset within the data */29uint32_t dlength; /* length of the data */30};3132struct bitstream* create_bitstream(const void *src, uint32_t srclength);33int bitstream_overflow(struct bitstream* bitstream);34uint32_t bitstream_read_offset(struct bitstream* bitstream);3536uint32_t bitstream_read(struct bitstream* bitstream, int numbits);37uint32_t bitstream_peek(struct bitstream* bitstream, int numbits);38void bitstream_remove(struct bitstream* bitstream, int numbits);39uint32_t bitstream_flush(struct bitstream* bitstream);404142#endif434445