Reverting r10651: Make WebP decoding independent of stream length.

git-svn-id: http://skia.googlecode.com/svn/trunk@10656 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
jvanverth@google.com 2013-08-09 14:24:30 +00:00
parent 9c1a967967
commit 1904df0413

View File

@ -203,27 +203,31 @@ static bool webp_idecode(SkStream* stream, WebPDecoderConfig* config) {
return false;
}
bool success = true;
VP8StatusCode status = VP8_STATUS_SUSPENDED;
do {
const uint32_t bytesToRead = WEBP_IDECODE_BUFFER_SZ;
uint32_t bytesRemaining = contentSize;
while (bytesRemaining > 0) {
const uint32_t bytesToRead = (bytesRemaining < WEBP_IDECODE_BUFFER_SZ) ?
bytesRemaining : WEBP_IDECODE_BUFFER_SZ;
const size_t bytesRead = stream->read(input, bytesToRead);
if (0 == bytesRead) {
success = false;
break;
}
status = WebPIAppend(idec, input, bytesRead);
if (VP8_STATUS_OK != status && VP8_STATUS_SUSPENDED != status) {
success = false;
VP8StatusCode status = WebPIAppend(idec, input, bytesRead);
if (VP8_STATUS_OK == status || VP8_STATUS_SUSPENDED == status) {
bytesRemaining -= bytesRead;
} else {
break;
}
} while (VP8_STATUS_OK != status);
}
srcStorage.free();
WebPIDelete(idec);
WebPFreeDecBuffer(&config->output);
return success;
if (bytesRemaining > 0) {
return false;
} else {
return true;
}
}
static bool webp_get_config_resize(WebPDecoderConfig* config,