mozilla/pdf.js — pull request #5114 by fkaelberer (2014-08-01 14:02:26+00:00)
Title: Faster JBIG2 bitmap decoding

While debugging the JBIG2 code I noticed that jbig2dec and xpdf both have special code paths for each of the four standard templates, for performance reasons. And indeed, the code can be simplified a lot if the context template is known.

In this PR, I wrote the decoding procedure from scratch for the case of the most common standard template and the `at` pixels at the standard location (which is the case for most jbig2 documents I have). In this case, each pixel in the main loop can be decoded without looping or branching, and it is much easier to understand what's happening.

The decoding time of #3816 and #2909 and others is reduced by ~25%.