From 412222c88c219bce7da4d4105709f54f21cc653e Mon Sep 17 00:00:00 2001 From: Vikas Arora Date: Tue, 24 Apr 2012 08:46:24 +0000 Subject: [PATCH] Make histo_bits and transform_bits function of quality. Change-Id: Ic34e40853604811abc63a38e09d6a01961649efc --- src/enc/vp8l.c | 10 ++++++---- src/enc/vp8li.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 57e3eca6..e423eb76 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -997,6 +997,7 @@ 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); VP8LEncoder* enc = (VP8LEncoder*)malloc(sizeof(*enc)); if (enc == NULL) { WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); @@ -1007,11 +1008,12 @@ static VP8LEncoder* InitVP8LEncoder(const WebPConfig* const config, enc->config_ = config; enc->pic_ = picture; enc->use_lz77_ = 1; - enc->palette_bits_ = 7; - // TODO: Use config.quality to initialize histo_bits_ and transform_bits_. - enc->histo_bits_ = 4; - enc->transform_bits_ = 4; + if (sampling_bits > 8) sampling_bits = 8; + if (sampling_bits < 3) sampling_bits = 3; + + enc->histo_bits_ = sampling_bits; + enc->transform_bits_ = sampling_bits; return enc; } diff --git a/src/enc/vp8li.h b/src/enc/vp8li.h index 2a07e48d..305c3451 100644 --- a/src/enc/vp8li.h +++ b/src/enc/vp8li.h @@ -45,7 +45,6 @@ typedef struct { // Encoding parameters derived from quality parameter. int use_lz77_; - int palette_bits_; int histo_bits_; int transform_bits_;