* @param out
     * @param s
     * @throws java.io.IOException
     */
    static void decodeHorizontal(BitStream in, BitStream out, G4State s, Code code) throws IOException {
        int rl = 0;
        do {
            rl = s.white ? findWhite(in, code) : findBlack(in, code);
            if (rl >= 0) {
                if (rl < 64) {
                    addRun(rl + s.longrun, s, out);
                    s.white = !s.white;
                    s.longrun = 0;
                } else {
                    s.longrun += rl;
                }
            } else {
                addRun(rl, s, out);
            }
        } while (rl >= 64);
        out.close();
    }