From 2fafb855792ef50a6257690539716f4b352ced49 Mon Sep 17 00:00:00 2001 From: Vikas Arora Date: Wed, 9 May 2012 12:27:34 +0530 Subject: [PATCH] Set correct encode size in encoder's stats. The current implementation doesn't take care one byte signature and associated one byte padding (for odd sized chunk). Change-Id: I35b81d0644818cdba38189aa48c75db5f92e68f4 --- src/enc/vp8l.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 7da54254..c76f132d 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -825,7 +825,8 @@ static void WriteImageSize(VP8LEncoder* const enc, VP8LBitWriter* const bw) { } static WebPEncodingError WriteImage(const VP8LEncoder* const enc, - VP8LBitWriter* const bw) { + VP8LBitWriter* const bw, + size_t* const coded_size) { size_t riff_size, vp8l_size, webpll_size, pad; const WebPPicture* const pic = enc->pic_; WebPEncodingError err = VP8_ENC_OK; @@ -852,6 +853,7 @@ static WebPEncodingError WriteImage(const VP8LEncoder* const enc, goto Error; } } + *coded_size = vp8l_size; return VP8_ENC_OK; Error: @@ -1020,6 +1022,7 @@ int VP8LEncodeImage(const WebPConfig* const config, WebPPicture* const picture) { int ok = 0; int width, height, quality; + size_t coded_size; VP8LEncoder* enc = NULL; WebPEncodingError err = VP8_ENC_OK; VP8LBitWriter bw; @@ -1112,7 +1115,7 @@ int VP8LEncodeImage(const WebPConfig* const config, quality, enc->cache_bits_, enc->histo_bits_); if (!ok) goto Error; - err = WriteImage(enc, &bw); + err = WriteImage(enc, &bw, &coded_size); if (err != VP8_ENC_OK) { ok = 0; goto Error; @@ -1125,8 +1128,7 @@ int VP8LEncodeImage(const WebPConfig* const config, stats->PSNR[1] = 99.; stats->PSNR[2] = 99.; stats->PSNR[3] = 99.; - // note: padding byte may be missing. Not a big deal. - stats->coded_size = VP8LBitWriterNumBytes(&bw) + HEADER_SIZE; + stats->coded_size = coded_size; } if (picture->extra_info != NULL) {