mozilla/pdf.js — pull request #4324 by fkaelberer (2014-02-24 19:21:11+00:00)
Title: Faster JBIG2 decoding

This PR doubles the JBIG2 image decoding speed, and so the total rendering times of #2909 and #3816 are reduced by 30-40% (Firefox Nightly, Linux).

The innermost loop of the decoding procedure is fetching the pixel values of 16 neighbor pixels (whose positions are defined by the template). These neighbor pixel values then serve as the context label for decoding the next pixel.
Most of these neighbor pixels are also the neighbor of the next pixel to be processed, and so most of the next context label can be constructed from the previous one (using shift and mask), which is the focus of this PR.