From 83332b3c1636ae210e5b97ca7f403b1724bcf21a Mon Sep 17 00:00:00 2001 From: Vikas Arora Date: Wed, 25 Apr 2012 02:54:06 +0000 Subject: [PATCH] Make transform bits a function of encode method (-m). Change-Id: Idc392f7cba6e160ea068eacd7f82be4ebc971eaa --- src/enc/vp8l.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 744684db..e4472776 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -1002,7 +1002,8 @@ static WebPEncodingError WriteImage(VP8LEncoder* const enc, static VP8LEncoder* InitVP8LEncoder(const WebPConfig* const config, WebPPicture* const picture) { - int sampling_bits = 9 - (((int)config->quality + 8) >> 4); + const int method = config->method; + const int histo_bits = 9 - (int)(config->quality / 16.f + .5f); VP8LEncoder* enc = (VP8LEncoder*)malloc(sizeof(*enc)); if (enc == NULL) { WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); @@ -1014,11 +1015,9 @@ static VP8LEncoder* InitVP8LEncoder(const WebPConfig* const config, enc->pic_ = picture; enc->use_lz77_ = 1; - if (sampling_bits > 8) sampling_bits = 8; - if (sampling_bits < 3) sampling_bits = 3; - - enc->histo_bits_ = sampling_bits; - enc->transform_bits_ = sampling_bits; + enc->histo_bits_ = + (histo_bits < 3) ? 3 : (histo_bits > 8) ? 8 : histo_bits; + enc->transform_bits_ = (method < 4) ? 5 : (method > 4) ? 3 : 4; return enc; }