Google just announced a new image format, WebP. The statistics of compression ratio looks very promising. But I wonder about the process time of reading. So I downloaded webp-leptonica (version 0.0.1) tarball and added few lines to webpconv.c to time it with libvpx 0.9.0 (with mmx sse sse2 ssse3 threads flags).
--- webpconv.c.original 2010-09-30 02:19:39.000000000 +0800
+++ webpconv.c 2010-10-01 08:26:48.000000000 +0800
-39,6 +39,7
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include "allheaders.h"
#define DEFAULT_PSNR 42.0
-218,13 +219,17
}
struct Pix \*pixs;
+ clock_t c0, c1;
+ c0 = clock();
if (!strcmp(ext, ".webp")) {
pixs = pixReadWebP(argv[a_idx]);
} else {
pixs = pixRead(argv[a_idx]);
}
+ c1 = clock();
+ printf ("Elapsed CPU time on reading pixels: %10.6f seconds\n", (float) (c1 - c0) / CLOCKS_PER_SEC);
FREE(ext);
-
+
if (pixs == NULL) {
fprintf(stderr, "Failed to read image\n");
return 1;
-240,6 +245,7
format = "png";
}
+ c0 = clock();
if (strcmp(format, "bmp") == 0) {
pixWrite(fileout, pixs, IFF_BMP);
} else if (strcmp(format, "jpeg") == 0) {
-275,6 +281,8
else {
return ERROR_INT("Format not supported", "webpconv", 1);
}
+ c1 = clock();
+ printf ("Elapsed CPU time on conversion : %10.6f seconds\n", (float) (c1 - c0) / CLOCKS_PER_SEC);
free(fileout);
pixDestroy(&pixs);
My goal is to time pixRead() and pixReadWebP(). This may just be a rough numbers, here is the results on images from this page:
The blue block is about JPG to WebP, and the purple block is about WebP, which is from previous conversion of JPG to WebP, to WebP. I didnt set the quality, I let the program to decide on its own.
As you can see the size are reduced after the conversion. But, interestingly, the read time or decode time, its not the same story. For bigger images, it seems to need more time for decoding pixel data. I dont know about image library or processing. Maybe this is not practical or the library is not optimized yet. Anyway, this new format is still new.
Honestly, I dont really think anyone can kill JPEG, even the Google. Yes, Google may be able to push this new format or anything into our programs, WebM is the good example. But the old stuff support is too hard to be dropped, till today some people still use GIF (not for animation) instead of PNG. If someday, Flickr supports the WebP embedding, I will still not use it to put images in my blog.
By the way, why are 5.jpg and 8.jpg missing?