Merge pull request #423 from jdgleaver/set-message-ext
[pcsx_rearmed.git] / deps / libchdr / bitstream.h
CommitLineData
ce188d4d 1// license:BSD-3-Clause\r
2// copyright-holders:Aaron Giles\r
3/***************************************************************************\r
4\r
5 bitstream.h\r
6\r
7 Helper classes for reading/writing at the bit level.\r
8\r
9***************************************************************************/\r
10\r
11#pragma once\r
12\r
13#ifndef __BITSTREAM_H__\r
14#define __BITSTREAM_H__\r
15\r
16#include <stdint.h>\r
17\r
18//**************************************************************************\r
19// TYPE DEFINITIONS\r
20//**************************************************************************\r
21\r
22// helper class for reading from a bit buffer\r
23struct bitstream\r
24{\r
25 uint32_t buffer; // current bit accumulator\r
26 int bits; // number of bits in the accumulator\r
27 const uint8_t * read; // read pointer\r
28 uint32_t doffset; // byte offset within the data\r
29 uint32_t dlength; // length of the data\r
30};\r
31\r
32struct bitstream* create_bitstream(const void *src, uint32_t srclength);\r
33int bitstream_overflow(struct bitstream* bitstream);\r
34uint32_t bitstream_read_offset(struct bitstream* bitstream);\r
35\r
36uint32_t bitstream_read(struct bitstream* bitstream, int numbits);\r
37uint32_t bitstream_peek(struct bitstream* bitstream, int numbits);\r
38void bitstream_remove(struct bitstream* bitstream, int numbits);\r
39uint32_t bitstream_flush(struct bitstream* bitstream);\r
40\r
41\r
42#endif\r