@Override
    public boolean process(byte value) throws Exception {
        final byte decodedByte = DECODABET[value & 0xFF];
        if (decodedByte < EQUALS_SIGN_ENC) {
            throw new IllegalArgumentException(
                    "invalid Base64 input character: " + (short) (value & 0xFF) + " (decimal)");
        }

        // Equals sign or better
        if (pos < 3) {
            if (pos < 2 && decodedByte == EQUALS_SIGN_ENC) {
                throw new IllegalArgumentException(
                        "invalid padding position: " + pos + " (expected: 2 or 3)");
            }

            // Needs more bytes.
            last3[pos++] = decodedByte;
            return true;
        }

        // Now we have 4 bytes that are decoded into 1-3 bytes.
        pos = 0;

        final byte b0 = last3[0];
        final byte b1 = last3[1];
        final byte b2 = last3[2];

        final ByteBuf dest = this.dest;
        assert dest != null;

        final byte b3 = decodedByte;
        if (b2 == EQUALS_SIGN_ENC) {
            if (b3 != EQUALS_SIGN_ENC) {
                throw new IllegalArgumentException(
                        "a non padding character can't follow to a padding. character: " + b3);
            }

            // Example: Dk==
            dest.writeByte((b0 & 0xff) << 2 | (b1 & 0xff) >>> 4);
            return true;
        }

        if (b3 == EQUALS_SIGN_ENC) {
            // Example: DkL=
            // Packing bytes into a short to reduce bound and reference count checking.
            // The decodabet bytes are meant to straddle byte boundaries and so we must carefully mask out
            // the bits we care about.
            dest.writeShort(((b0 & 0x3f) << 2 | (b1 & 0xf0) >> 4) << 8 |
                            (b1 & 0xf) << 4 | (b2 & 0xfc) >>> 2);
            return true;
        }

        // Example: DkLE
        dest.writeMedium((b0 & 0x3f) << 18 |
                         (b1 & 0xff) << 12 |
                         (b2 & 0xff) << 6 |
                         b3 & 0xff);
        return true;
    }
A stateful Base64decoder. Unlike {@link io.netty.handler.codec.base64.Base64Decoder}, this decoder does
not end when it meets padding('='), but continues to decode until the end of the {@link ByteBuf} given by
{@link #decode(ByteBuf)}. If the {@link ByteBuf} does not have necessary 4 bytes to decode as 3 bytes,
it stores the remained bytes and prepend them to the next {@link #decode(ByteBuf)} and decode together.
grpc-protocol/src/main/java/com/linecorp/armeria/internal/common/grpc/protocol/Base64Decoder.java