mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
a problem for brotli working on-the-fly #116
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @RenterRen on GitHub (May 27, 2016).
In my scene, I will not finish compressing when I run my program. so,BrotliCompressor object is only one. And on the client, I call the BrotliStateInit(&s) just for once.
So, like this:
while(1)
{
I read 500 bytes to compress------->send to the client--->client decompress the data---->
}
after client decompress the data, the decompressed data is not 500, sometimes,it may be 200, sometimes,it may be 800, How can I resolve the problem?
@eustas commented on GitHub (May 27, 2016):
When you compress block you need to set "force_flush" parameter to "true".
Moreover, after block is flushed, you need to append empty metadata block (WriteMetadata) to make sure that output is byte-aligned.
Sorry for confusing API. In two weeks API will be updated to make things like that more straightforward.
Best regards,
Eugene.
@RenterRen commented on GitHub (May 30, 2016):
@eustas Do you mean that I need call the Api like this below:
WriteMetaBlock(0, NULL, true, encoded_size, encoded_buffer);
if I set the parameter of is_last true, means this is the last frame, but I hava no last frame In my system, If I call this, how about next data,data is not finished!
@eustas commented on GitHub (May 30, 2016):
No, just something like this:
@RenterRen commented on GitHub (Jun 12, 2016):
@eustas
Hi eustas:
I write the code like yours:
while (true) {
CopyOneBlockToRingBuffer(in, &compressor, &in_bytes, &final_block)
out_bytes = 0;
compressor.WriteBrotliData(false,true,&out_bytes, &output)
printf("bbbbbbbbbbbbbbbbbbbb:%d\n",out_bytes);
compressor.WriteMetaBlock( 0,NULL, false, &out_bytes, output);
printf("ttttttttttttttttttt:%d\n",out_bytes);
}
The test result is this:
bbbbbbbbbbbbbbbbbbbb:16126
ttttttttttttttttttt:0
bbbbbbbbbbbbbbbbbbbb:13349
ttttttttttttttttttt:0
bbbbbbbbbbbbbbbbbbbb:12419
ttttttttttttttttttt:0
How to fix it????
Best Regars:
@eustas commented on GitHub (Jun 13, 2016):
Sorry for misguiding you. Use WriteMetadata instead of WriteMetaBlock.
And pay attention that unlike WriteBrotliData output buffer is provided by client, not by encoder.
@RenterRen commented on GitHub (Jun 13, 2016):
@eustas
Thanks your support, It seems to work!!!
@eustas commented on GitHub (Jun 13, 2016):
You are welcome.
Soon we will publish v0.4 with more clear interface...