Jpg vs android webp performance

I am trying to get performance statistics on how Android loads, decodes and displays WebP images against JPG, but my results are a bit confused.

Decoding WebP images in Bitmap is slower than JPG.

Some statistics:

  • WebP is 66% smaller than JPG, 267% more time to decode.
  • WebP is 38% smaller than JPG, 258% longer to decode.
  • WebP is 89% smaller in file size than JPG, 319% longer for decoding.

Does anyone know about any performance issue or why WebP decoding is more complicated than JPG.

This is my test:

public class BulkLoadFromDisk implements Runnable { private static final String TAG = "BulkLoadFromDisk"; private static final int TIMES = 10; private final ResourceProvider resourceProvider; private final Activity context; private final int counter; private long averageLoadTimeNano; private long averageConvertTimeNano; private final ImagesFactory.FORMAT format; private final CompleteListener listener; public BulkLoadFromDisk(Activity context, ResourceProvider resourceProvider, CompleteListener listener, ImagesFactory.FORMAT format) { this.resourceProvider = resourceProvider; this.context = context; this.counter = resourceProvider.length(); this.format = format; this.listener = listener; } @Override public void run() { try { Thread.sleep(200); } catch (InterruptedException e) { Log.e(TAG, e.getMessage(), e); } try { String file; long loadBegin, loadEnd; long convertBegin, convertEnd; Bitmap bitmap; Drawable d; String extension = "." + format.name().toLowerCase(); InputStream inputStream; for(int j = 0; j < TIMES; j++) { for(int index = 0; index < counter; index++) { file = resourceProvider.get(index).concat(extension); inputStream = context.getAssets().open(file); // Load bitmap from file loadBegin = System.nanoTime(); bitmap = BitmapFactory.decodeStream(inputStream); assert (bitmap != null); loadEnd = System.nanoTime(); // Convert bitmap to drawable convertBegin = System.nanoTime(); d = new BitmapDrawable(context.getResources(), bitmap); assert (d != null); convertEnd = System.nanoTime(); averageLoadTimeNano += (loadEnd - loadBegin); averageConvertTimeNano += (convertEnd - convertBegin); } } averageLoadTimeNano = averageLoadTimeNano / (TIMES * counter); averageConvertTimeNano = averageConvertTimeNano / (TIMES * counter); if(listener != null && context != null) { context.runOnUiThread(new Runnable() { @Override public void run() { listener.onComplete(BulkLoadFromDisk.this); } }); } } catch (final IOException e) { if(listener != null && context!= null) { context.runOnUiThread(new Runnable() { @Override public void run() { listener.onError(e); } }); } } finally { System.gc(); } } public interface CompleteListener { void onComplete(BulkLoadFromDisk task); void onError(Exception e); } public long getAverageLoadTimeNano() { return averageLoadTimeNano; } public long getAverageConvertTimeNano() { return averageConvertTimeNano; } public ImagesFactory.FORMAT getFormat() { return format; } public String resultToString() { final StringBuffer sb = new StringBuffer("BulkLoadFromDisk{"); sb.append("averageLoadTimeNano=").append(Utils.nanosToBest(averageLoadTimeNano).first + Utils.nanosToBest(averageLoadTimeNano).second); sb.append(", averageConvertTimeNano=").append(Utils.nanosToBest(averageConvertTimeNano).first + Utils.nanosToBest(averageConvertTimeNano).second); sb.append(", format=").append(format); sb.append('}'); return sb.toString(); } 
+7
java performance android webp
source share
1 answer

I know this is an old question, and I have not studied the depth of WebP yet, but probably because it is a more complex algorithm, therefore it has better compression ratios than JPEG. WebP is based on the VP8 codec, which in itself is a win-win competitor to the widely used and heavy h264 format.

JPEG is widely used, but it is a really old format and much simpler than the VP8 WebP codec.

+1
source share

All Articles