From fde2904b8a79d95b199e7c50915df7293681d03c Mon Sep 17 00:00:00 2001 From: Vikas Arora Date: Tue, 11 Feb 2014 11:12:21 -0800 Subject: [PATCH] Increase initial buffer size for VP8L Bit Writer. Increase the initial buffer size for VP8L Bit Writer from 4bpp to 8bpp. The resize buffer is expensive (requires realloc and copy) and this additional memory (0.5 * W * H) doesn't add much overhead on the lossless encoder. Change-Id: Ic1fe55cd7bc3d1afadc799e4c2c8786ec848ee66 --- src/enc/vp8l.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 60bec8a0..07caafa0 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -1096,7 +1096,8 @@ int VP8LEncodeImage(const WebPConfig* const config, width = picture->width; height = picture->height; - if (!VP8LBitWriterInit(&bw, (width * height) >> 1)) { + // Initialize BitWriter with size corresponding to 8bpp. + if (!VP8LBitWriterInit(&bw, width * height)) { err = VP8_ENC_ERROR_OUT_OF_MEMORY; goto Error; }