* @param s
     * @param out
     * @throws java.io.IOException
     */
    static void addRun(int x, G4State s, BitStream out) throws IOException {
        s.runLength += x;
        s.cur[s.curIndex++] = s.runLength;
        s.a0 += x;
        if (s.runLength > 0) {
            // black/white color switch !s.white
            out.putRunBits(s.white ? white : black, s.runLength);
        }
        out.close();
        s.runLength = 0;
    }