* Functions useful for decompression, mainly bitstreams.
*/
-#ifndef _WIMLIB_DECOMP_H
-#define _WIMLIB_DECOMP_H
+#ifndef _WIMLIB_DECOMPRESS_H
+#define _WIMLIB_DECOMPRESS_H
-#include "util.h"
-#include "endianness.h"
+#include "wimlib/assert.h"
+#include "wimlib/endianness.h"
+#include "wimlib/error.h"
+#include "wimlib/types.h"
/* Must be at least 32 bits. */
typedef unsigned long input_bitbuf_t;
};
/* Initializes a bitstream to receive its input from @data. */
-static inline void init_input_bitstream(struct input_bitstream *istream,
- const void *data, unsigned num_data_bytes)
+static inline void
+init_input_bitstream(struct input_bitstream *istream,
+ const void *data, unsigned num_data_bytes)
{
istream->bitbuf = 0;
istream->bitsleft = 0;
*
* If there are at least @num_bits bits remaining in the bitstream, 0 is
* returned. Otherwise, -1 is returned. */
-static inline int bitstream_ensure_bits(struct input_bitstream *istream,
- unsigned num_bits)
+static inline int
+bitstream_ensure_bits(struct input_bitstream *istream, unsigned num_bits)
{
wimlib_assert2(num_bits <= 16);
/* Removes @num_bits bits from the buffer variable, which must contain at least
* @num_bits bits, for the bitstream. */
-static inline void bitstream_remove_bits(struct input_bitstream *istream,
- unsigned num_bits)
+static inline void
+bitstream_remove_bits(struct input_bitstream *istream, unsigned num_bits)
{
wimlib_assert2(istream->bitsleft >= num_bits);
istream->bitbuf <<= num_bits;
/* Reads @num_bits bits from the input bitstream. @num_bits must be 16 or fewer.
* On success, returns 0 and returns the requested bits in @n. If there are
* fewer than @num_bits remaining in the bitstream, -1 is returned. */
-static inline int bitstream_read_bits(struct input_bitstream *istream,
- unsigned num_bits, unsigned *n)
+static inline int
+bitstream_read_bits(struct input_bitstream *istream,
+ unsigned num_bits, unsigned *n)
{
wimlib_assert2(num_bits <= 16);
int ret = bitstream_ensure_bits(istream, num_bits);
*
* This function returns the next such literal byte, or -1 if there are no more.
*/
-static inline int bitstream_read_byte(struct input_bitstream *istream)
+static inline int
+bitstream_read_byte(struct input_bitstream *istream)
{
wimlib_assert2(istream->bitsleft < 32);
int ret;
return n;
}
-extern int read_huffsym_near_end_of_input(struct input_bitstream *istream,
- const u16 decode_table[],
- const u8 lens[],
- unsigned num_syms,
- unsigned table_bits,
- unsigned *n);
+extern int
+read_huffsym_near_end_of_input(struct input_bitstream *istream,
+ const u16 decode_table[],
+ const u8 lens[],
+ unsigned num_syms,
+ unsigned table_bits,
+ unsigned *n);
/*
* Reads a Huffman-encoded symbol from a bitstream.
* directory in the decode_table, as the
* decode_table contains 2**table_bits entries.
*/
-static inline int read_huffsym(struct input_bitstream *istream,
- const u16 decode_table[],
- const u8 lens[],
- unsigned num_syms,
- unsigned table_bits,
- unsigned *n,
- unsigned max_codeword_len)
+static inline int
+read_huffsym(struct input_bitstream *istream,
+ const u16 decode_table[],
+ const u8 lens[],
+ unsigned num_syms,
+ unsigned table_bits,
+ unsigned *n,
+ unsigned max_codeword_len)
{
int ret;
unsigned num_bits, const u8 lengths[],
unsigned max_codeword_len);
-#endif /* _WIMLIB_DECOMP_H */
+#endif /* _WIMLIB_DECOMPRESS_H */