mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-08-04 02:06:31 -04:00
programs: move output_bitstream to test_util
This commit is contained in:
parent
ce6a95f47b
commit
c398e237b6
@ -7,28 +7,6 @@
|
|||||||
|
|
||||||
#include "test_util.h"
|
#include "test_util.h"
|
||||||
|
|
||||||
struct output_bitstream {
|
|
||||||
unsigned long bitbuf;
|
|
||||||
int bitcount;
|
|
||||||
u8 *next;
|
|
||||||
u8 *end;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool
|
|
||||||
put_bits(struct output_bitstream *os, unsigned long bits, int num_bits)
|
|
||||||
{
|
|
||||||
os->bitbuf |= bits << os->bitcount;
|
|
||||||
os->bitcount += num_bits;
|
|
||||||
while (os->bitcount >= 8) {
|
|
||||||
if (os->next == os->end)
|
|
||||||
return false;
|
|
||||||
*os->next++ = os->bitbuf;
|
|
||||||
os->bitcount -= 8;
|
|
||||||
os->bitbuf >>= 8;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate a DEFLATE stream containing all empty "static Huffman" blocks.
|
* Generate a DEFLATE stream containing all empty "static Huffman" blocks.
|
||||||
*
|
*
|
||||||
|
@ -202,3 +202,18 @@ u64 timer_KB_per_s(u64 bytes, u64 ticks)
|
|||||||
{
|
{
|
||||||
return bytes * timer_frequency() / ticks / 1000;
|
return bytes * timer_frequency() / ticks / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
put_bits(struct output_bitstream *os, machine_word_t bits, int num_bits)
|
||||||
|
{
|
||||||
|
os->bitbuf |= bits << os->bitcount;
|
||||||
|
os->bitcount += num_bits;
|
||||||
|
while (os->bitcount >= 8) {
|
||||||
|
if (os->next == os->end)
|
||||||
|
return false;
|
||||||
|
*os->next++ = os->bitbuf;
|
||||||
|
os->bitcount -= 8;
|
||||||
|
os->bitbuf >>= 8;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -52,4 +52,14 @@ extern u64 timer_ticks_to_ms(u64 ticks);
|
|||||||
extern u64 timer_MB_per_s(u64 bytes, u64 ticks);
|
extern u64 timer_MB_per_s(u64 bytes, u64 ticks);
|
||||||
extern u64 timer_KB_per_s(u64 bytes, u64 ticks);
|
extern u64 timer_KB_per_s(u64 bytes, u64 ticks);
|
||||||
|
|
||||||
|
struct output_bitstream {
|
||||||
|
machine_word_t bitbuf;
|
||||||
|
int bitcount;
|
||||||
|
u8 *next;
|
||||||
|
u8 *end;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern bool put_bits(struct output_bitstream *os, machine_word_t bits,
|
||||||
|
int num_bits);
|
||||||
|
|
||||||
#endif /* PROGRAMS_TEST_UTIL_H */
|
#endif /* PROGRAMS_TEST_UTIL_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user