mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-15 21:39:59 +02:00
make the token page size be variable instead of fixed 8192
also changed the token-page layout a little bit to remove a not-needed field. This reduces the number of malloc()/free() calls substantially with minimal increase in memory consumption (~2%). For the tail of large sources, the number of malloc calls goes typically from ~10000 to ~100 (e.g.: bryce_big.jpg: 22711 -> 105) Change-Id: Ib847f41e618ed8c303d26b76da982fbc48de45b9
This commit is contained in:
@ -258,7 +258,12 @@ static VP8Encoder* InitVP8Encoder(const WebPConfig* const config,
|
||||
VP8EncInitLayer(enc);
|
||||
#endif
|
||||
|
||||
VP8TBufferInit(&enc->tokens_);
|
||||
// lower quality means smaller output -> we modulate a little the page
|
||||
// size based on quality. This is just a crude 1rst-order prediction.
|
||||
{
|
||||
const float scale = 1.f + config->quality * 5.f / 100.f; // in [1,6]
|
||||
VP8TBufferInit(&enc->tokens_, (int)(mb_w * mb_h * 4 * scale));
|
||||
}
|
||||
return enc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user