mirror of https://github.com/madler/zlib
Add deflateUsed() function to get the used bits in the last byte.
This returns the number of used bits in the last byte of a stream that has just been compressed with deflate.
This commit is contained in:
parent
534864bccd
commit
e011d8c164
|
@ -156,3 +156,6 @@ EXPORTS
|
||||||
crc32_combine_gen @176
|
crc32_combine_gen @176
|
||||||
crc32_combine_gen64 @177
|
crc32_combine_gen64 @177
|
||||||
crc32_combine_op @178
|
crc32_combine_op @178
|
||||||
|
|
||||||
|
; zlib1 v1.3.2 added:
|
||||||
|
deflateUsed @179
|
||||||
|
|
|
@ -156,3 +156,6 @@ EXPORTS
|
||||||
crc32_combine_gen @176
|
crc32_combine_gen @176
|
||||||
crc32_combine_gen64 @177
|
crc32_combine_gen64 @177
|
||||||
crc32_combine_op @178
|
crc32_combine_op @178
|
||||||
|
|
||||||
|
; zlib1 v1.3.2 added:
|
||||||
|
deflateUsed @179
|
||||||
|
|
|
@ -156,3 +156,6 @@ EXPORTS
|
||||||
crc32_combine_gen @176
|
crc32_combine_gen @176
|
||||||
crc32_combine_gen64 @177
|
crc32_combine_gen64 @177
|
||||||
crc32_combine_op @178
|
crc32_combine_op @178
|
||||||
|
|
||||||
|
; zlib1 v1.3.2 added:
|
||||||
|
deflateUsed @179
|
||||||
|
|
|
@ -156,3 +156,6 @@ EXPORTS
|
||||||
crc32_combine_gen @176
|
crc32_combine_gen @176
|
||||||
crc32_combine_gen64 @177
|
crc32_combine_gen64 @177
|
||||||
crc32_combine_op @178
|
crc32_combine_op @178
|
||||||
|
|
||||||
|
; zlib1 v1.3.2 added:
|
||||||
|
deflateUsed @179
|
||||||
|
|
|
@ -156,3 +156,6 @@ EXPORTS
|
||||||
crc32_combine_gen @176
|
crc32_combine_gen @176
|
||||||
crc32_combine_gen64 @177
|
crc32_combine_gen64 @177
|
||||||
crc32_combine_op @178
|
crc32_combine_op @178
|
||||||
|
|
||||||
|
; zlib1 v1.3.2 added:
|
||||||
|
deflateUsed @179
|
||||||
|
|
|
@ -156,3 +156,6 @@ EXPORTS
|
||||||
crc32_combine_gen @176
|
crc32_combine_gen @176
|
||||||
crc32_combine_gen64 @177
|
crc32_combine_gen64 @177
|
||||||
crc32_combine_op @178
|
crc32_combine_op @178
|
||||||
|
|
||||||
|
; zlib1 v1.3.2 added:
|
||||||
|
deflateUsed @179
|
||||||
|
|
|
@ -719,6 +719,14 @@ int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
|
||||||
|
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
|
if (bits != Z_NULL)
|
||||||
|
*bits = strm->state->bi_used;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
|
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
|
|
|
@ -271,6 +271,9 @@ typedef struct internal_state {
|
||||||
/* Number of valid bits in bi_buf. All bits above the last valid bit
|
/* Number of valid bits in bi_buf. All bits above the last valid bit
|
||||||
* are always zero.
|
* are always zero.
|
||||||
*/
|
*/
|
||||||
|
int bi_used;
|
||||||
|
/* Last number of used bits when going to a byte boundary.
|
||||||
|
*/
|
||||||
|
|
||||||
ulg high_water;
|
ulg high_water;
|
||||||
/* High water mark offset in window for initialized bytes -- bytes above
|
/* High water mark offset in window for initialized bytes -- bytes above
|
||||||
|
|
|
@ -124,4 +124,10 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
|
||||||
EXPORT SYMBOL("crc32_combine_gen")
|
EXPORT SYMBOL("crc32_combine_gen")
|
||||||
EXPORT SYMBOL("crc32_combine_op")
|
EXPORT SYMBOL("crc32_combine_op")
|
||||||
|
|
||||||
|
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
|
||||||
|
/* Version 1.3.2 additional entry points. */
|
||||||
|
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
|
||||||
|
|
||||||
|
EXPORT SYMBOL("deflateUsed")
|
||||||
|
|
||||||
ENDPGMEXP
|
ENDPGMEXP
|
||||||
|
|
|
@ -371,6 +371,10 @@
|
||||||
D pending 10U 0 Pending bytes
|
D pending 10U 0 Pending bytes
|
||||||
D bits 10I 0 Pending bits
|
D bits 10I 0 Pending bits
|
||||||
*
|
*
|
||||||
|
D deflateUsed PR 10I 0 extproc('deflateUsed') Get used bits
|
||||||
|
D strm like(z_stream) Compression stream
|
||||||
|
D bits 10I 0 Used bits
|
||||||
|
*
|
||||||
D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
|
D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
|
||||||
D strm like(z_stream) Compression stream
|
D strm like(z_stream) Compression stream
|
||||||
D bits 10I 0 value # of bits to insert
|
D bits 10I 0 value # of bits to insert
|
||||||
|
|
2
trees.c
2
trees.c
|
@ -184,6 +184,7 @@ local void bi_windup(deflate_state *s) {
|
||||||
} else if (s->bi_valid > 0) {
|
} else if (s->bi_valid > 0) {
|
||||||
put_byte(s, (Byte)s->bi_buf);
|
put_byte(s, (Byte)s->bi_buf);
|
||||||
}
|
}
|
||||||
|
s->bi_used = ((s->bi_valid - 1) & 7) + 1;
|
||||||
s->bi_buf = 0;
|
s->bi_buf = 0;
|
||||||
s->bi_valid = 0;
|
s->bi_valid = 0;
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
|
@ -466,6 +467,7 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
|
||||||
|
|
||||||
s->bi_buf = 0;
|
s->bi_buf = 0;
|
||||||
s->bi_valid = 0;
|
s->bi_valid = 0;
|
||||||
|
s->bi_used = 0;
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
s->compressed_len = 0L;
|
s->compressed_len = 0L;
|
||||||
s->bits_sent = 0L;
|
s->bits_sent = 0L;
|
||||||
|
|
|
@ -15,6 +15,7 @@ EXPORTS
|
||||||
deflateTune
|
deflateTune
|
||||||
deflateBound
|
deflateBound
|
||||||
deflatePending
|
deflatePending
|
||||||
|
deflateUsed
|
||||||
deflatePrime
|
deflatePrime
|
||||||
deflateSetHeader
|
deflateSetHeader
|
||||||
inflateSetDictionary
|
inflateSetDictionary
|
||||||
|
|
1
zconf.h
1
zconf.h
|
@ -59,6 +59,7 @@
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
# define deflateSetHeader z_deflateSetHeader
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
# define deflateTune z_deflateTune
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflateUsed z_deflateUsed
|
||||||
# define deflate_copyright z_deflate_copyright
|
# define deflate_copyright z_deflate_copyright
|
||||||
# define get_crc_table z_get_crc_table
|
# define get_crc_table z_get_crc_table
|
||||||
# ifndef Z_SOLO
|
# ifndef Z_SOLO
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
# define deflateSetHeader z_deflateSetHeader
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
# define deflateTune z_deflateTune
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflateUsed z_deflateUsed
|
||||||
# define deflate_copyright z_deflate_copyright
|
# define deflate_copyright z_deflate_copyright
|
||||||
# define get_crc_table z_get_crc_table
|
# define get_crc_table z_get_crc_table
|
||||||
# ifndef Z_SOLO
|
# ifndef Z_SOLO
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
# define deflateSetHeader z_deflateSetHeader
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
# define deflateTune z_deflateTune
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflateUsed z_deflateUsed
|
||||||
# define deflate_copyright z_deflate_copyright
|
# define deflate_copyright z_deflate_copyright
|
||||||
# define get_crc_table z_get_crc_table
|
# define get_crc_table z_get_crc_table
|
||||||
# ifndef Z_SOLO
|
# ifndef Z_SOLO
|
||||||
|
|
12
zlib.h
12
zlib.h
|
@ -791,6 +791,18 @@ ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
|
||||||
stream state was inconsistent.
|
stream state was inconsistent.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflateUsed(z_streamp strm,
|
||||||
|
int *bits);
|
||||||
|
/*
|
||||||
|
deflateUsed() returns in *bits the most recent number of deflate bits used
|
||||||
|
in the last byte when flushing to a byte boundary. The result is in 1..8, or
|
||||||
|
0 if there has not yet been a flush. This helps determine the location of
|
||||||
|
the last bit of a deflate stream.
|
||||||
|
|
||||||
|
deflateUsed returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||||
|
stream state was inconsistent.
|
||||||
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
|
ZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
|
||||||
int bits,
|
int bits,
|
||||||
int value);
|
int value);
|
||||||
|
|
Loading…
Reference in New Issue