From 7ec2cc7f8ee03a02662f5071164f7939dd44b8f3 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 20 Mar 2011 23:32:44 +0000 Subject: Update to use official libwebp 0.1 Remove libvpx references as no longer needed. svn path=/trunk/netsurf/; revision=12115 --- image/webp.c | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'image/webp.c') diff --git a/image/webp.c b/image/webp.c index 449b069fb..42f8ece04 100644 --- a/image/webp.c +++ b/image/webp.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "desktop/plotters.h" #include "image/bitmap.h" #include "content/content_protected.h" @@ -44,24 +44,21 @@ bool webp_convert(struct content *c) { union content_msg_data msg_data; - const uint8 *data; + const uint8_t *data; unsigned char *imagebuf = NULL; - uint32 *imagebufptr = NULL; + uint32_t *imagebufptr = NULL; unsigned long size; - uint8 *Y = NULL, *U = NULL, *V = NULL; int width = 0, height = 0; - uint32 offset = 0; - uint8 r, g, b, a; char title[100]; - WebPResult res = webp_success; + int res = 0; + uint8_t *res_p = NULL; data = (uint8 *)content__get_source_data(c, &size); - res = WebPDecode(data, size, &Y, &U, &V, &width, &height); - if (res != webp_success) { + res = WebPGetInfo(data, size, &width, &height); + if (res == 0) { msg_data.error = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - if(Y) free(Y); return false; } @@ -69,35 +66,23 @@ bool webp_convert(struct content *c) if (!c->bitmap) { msg_data.error = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - if(Y) free(Y); return false; } + imagebuf = bitmap_get_buffer(c->bitmap); if (!imagebuf) { msg_data.error = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - if(Y) free(Y); return false; } - unsigned int row_width = bitmap_get_rowstride(c->bitmap) / 4; - - YUV420toRGBA(Y, U, V, row_width, width, height, (uint32 *)imagebuf); - - if(Y) free(Y); - - /* Decoded data is RGBA on both big- and little-endian platforms, - * so ensure correct byte order. */ - - size = width * height * 4; + unsigned int row_width = bitmap_get_rowstride(c->bitmap); - for (offset = 0; offset < size; offset += 4) { - a = imagebuf[offset+3]; - b = imagebuf[offset+2]; - g = imagebuf[offset+1]; - r = imagebuf[offset]; - - imagebufptr = imagebuf + offset; - *imagebufptr = r << 24 | g << 16 | b << 8 | a; + res_p = WebPDecodeRGBAInto(data, size, imagebuf, + row_width * height, row_width); + if (res_p == NULL) { + msg_data.error = messages_get("NoMemory"); + content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + return false; } c->width = width; -- cgit v1.2.3