Re: Z_SYNC_FLUSH and adding empty blocks after that (_tr_align)



On Mar 29, 9:34 am, byaa...@xxxxxxxxx wrote:
On Mar 29, 9:05 am, "Mark Adler" <mad...@xxxxxxxxxxxxxxxxxx> wrote:

On Mar 28, 9:41 pm, byaa...@xxxxxxxxx wrote:

I am trying to add dummy data for a certain number of bytes after I am
done calling deflate.

To do this, I first call deflate with Z_SYNC_FLUSH to ensure it has
ended on a byte boundary.

Good, then that's all you need to do. (You don't need to mess with
the internal zlib routines.) Simply make sure you get all of the
output from deflate, indicated by avail_out not zero, after providing
all of the input. Then you're done with deflate (call deflateEnd() or
deflateReset()).

Wont deflateEnd() indicate end of the entire deflate stream? I still
need to add some empty blocks after this point... will the
decompressor just stop reading data after this point? Because I want
the decompressor to read data after this point, but just consume empty
blocks



Now you can append empty blocks as desired. The last empty block
needs to have its last bit set.

Is this done via calling _tr_align() for the 10 bit block and
_tr_stored_blocks(s, (char *)0, 0L, 0) for the stored block?

(let me know if this is off topic and email is preferred)

Couple of observations
1. after I send the last data into deflate with the Z_SYNC_FLUSH flag
set, calling deflate with Z_FINISH always adds 2 bytes to the output
stream

2. Calling _tr_align before the last deflate(Z_FINISH) does
successfully help in altering the size, but it seems to share some
bytes with what Z_FINISH does.

How can I tell exactly how many bits it shares with Z_FINISH so I can
calculate how many _tr_aligns to issue?

Please do let me know if I need to take this off line. Thank you for
your patience

B

.



Relevant Pages