mozilla/pdf.js — pull request #4531 by fkaelberer (2014-03-28 09:48:57+00:00)
Title: simplify conversion to UInt8 in JPX decoder

The existing code unnecessarily differentiates between signed component values and unsigned ones.

If `component.isSigned`, then the first loop is skipped, and the second loop adds offset == 128 to the component values.

If `!component.isSigned`, then the first loop adds `1 << (precision - 1)` and the second loop right-shifts that value by `precision - 8`, so `1 << ((precision - 1) - (precision - 8)) == 128` is added effectively.

Since the `items` are Float32s, no overflow is to be expected, so it doesn't matter if we add the offset before or after the shift.