private EConvResult convertInternal(byte[] in, Ptr inPtr, int inStop, byte[] out, Ptr outPtr, int outStop, int flags) {
        lastError.reset();

        EConvResult res;
        int len;

        if (numTranscoders == 0) {
            if (inBuf.bytes != null && inBuf.dataStart != inBuf.dataEnd) {
                if (outStop - outPtr.p < inBuf.dataEnd - inBuf.dataStart) {
                    len = outStop - outPtr.p;
                    System.arraycopy(inBuf.bytes, inBuf.dataStart, out, outPtr.p, len);
                    outPtr.p = outStop;
                    inBuf.dataStart += len;
                    return convertInternalResult(EConvResult.DestinationBufferFull, null);
                }
                len = inBuf.dataEnd - inBuf.dataStart;
                System.arraycopy(inBuf.bytes, inBuf.dataStart, out, outPtr.p, len);
                outPtr.p += len;
                inBuf.dataStart = inBuf.dataEnd = inBuf.bufStart;
                if ((flags & AFTER_OUTPUT) != 0) return convertInternalResult(EConvResult.AfterOutput, null);
            }

            if (outStop - outPtr.p < inStop - inPtr.p) {
                len = outStop - outPtr.p;
            } else {
                len = inStop - inPtr.p;
            }

            if (len > 0 && (flags & AFTER_OUTPUT) != 0) {
                out[outPtr.p++] = in[inPtr.p++];
                return convertInternalResult(EConvResult.AfterOutput, null);
            }

            System.arraycopy(in, inPtr.p, out, outPtr.p, len);
            outPtr.p += len;
            inPtr.p += len;

            if (inPtr.p != inStop) {
                res = EConvResult.DestinationBufferFull;
            } else if ((flags & PARTIAL_INPUT) != 0) {
                res = EConvResult.SourceBufferEmpty;
            } else {
                res = EConvResult.Finished;
            }
            return convertInternalResult(res, null);
        }

        boolean hasOutput = false;
        EConvElement elem = elements[numTranscoders - 1];
        if (elem.bytes != null) {
            int dataStart = elem.dataStart;
            int dataEnd = elem.dataEnd;
            byte[] data = elem.bytes;
            if (dataStart != dataEnd) {
                if (outStop - outPtr.p < dataEnd - dataStart) {
                    len = outStop - outPtr.p;
                    System.arraycopy(data, dataStart, out, outPtr.p, len);
                    outPtr.p = outStop;
                    elem.dataStart += len;
                    return convertInternalResult(EConvResult.DestinationBufferFull, null);
                }
                len = dataEnd - dataStart;
                System.arraycopy(data, dataStart, out, outPtr.p, len);
                outPtr.p += len;
                elem.dataStart = elem.dataEnd = elem.bufStart;
                hasOutput = true;
            }
        }

        Ptr resultPosition = new Ptr(0);
        if (inBuf != null && inBuf.dataStart != inBuf.dataEnd) {
            Ptr inDataStartPtr = new Ptr(inBuf.dataStart);
            res = transConv(inBuf.bytes, inDataStartPtr, inBuf.dataEnd, out, outPtr, outStop, (flags & ~AFTER_OUTPUT) | PARTIAL_INPUT, resultPosition);
            inBuf.dataStart = inDataStartPtr.p;
            if (!res.isSourceBufferEmpty()) return convertInternalResult(EConvResult.SourceBufferEmpty, resultPosition);
        }

        if (hasOutput && (flags & AFTER_OUTPUT) != 0 && inPtr.p != inStop) {
            inStop = inPtr.p;
            res = transConv(in, inPtr, inStop, out, outPtr, outStop, flags, resultPosition);
            if (res.isSourceBufferEmpty()) res = EConvResult.AfterOutput;
        } else if ((flags & AFTER_OUTPUT) != 0 || numTranscoders == 1) {
            res = transConv(in, inPtr, inStop, out, outPtr, outStop, flags, resultPosition);
        } else {
            flags |= AFTER_OUTPUT;
            do {
                res = transConv(in, inPtr, inStop, out, outPtr, outStop, flags, resultPosition);
            } while (res.isAfterOutput());
        }

        return convertInternalResult(res, resultPosition);
    }
private EConvResult convertInternal ( byte [ ] in , Ptr inPtr , int inStop , byte [ ] out , Ptr outPtr , int outStop , int flags ) { lastError . reset ( ) ; EConvResult res ; int len ; if ( numTranscoders == 0 ) { if ( inBuf . bytes != null && inBuf . dataStart != inBuf . dataEnd ) { if ( outStop - outPtr . p < inBuf . dataEnd - inBuf . dataStart ) { len = outStop - outPtr . p ; System . arraycopy ( inBuf . bytes , inBuf . dataStart , out , outPtr . p , len ) ; outPtr . p = outStop ; inBuf . dataStart += len ; return convertInternalResult ( EConvResult . DestinationBufferFull , null ) ; } len = inBuf . dataEnd - inBuf . dataStart ; System . arraycopy ( inBuf . bytes , inBuf . dataStart , out , outPtr . p , len ) ; outPtr . p += len ; inBuf . dataStart = inBuf . dataEnd = inBuf . bufStart ; if ( ( flags & AFTER_OUTPUT ) != 0 ) return convertInternalResult ( EConvResult . AfterOutput , null ) ; } if ( outStop - outPtr . p < inStop - inPtr . p ) { len = outStop - outPtr . p ; } else { len = inStop - inPtr . p ; } if ( len > 0 && ( flags & AFTER_OUTPUT ) != 0 ) { out [ outPtr . p ++ ] = in [ inPtr . p ++ ] ; return convertInternalResult ( EConvResult . AfterOutput , null ) ; } System . arraycopy ( in , inPtr . p , out , outPtr . p , len ) ; outPtr . p += len ; inPtr . p += len ; if ( inPtr . p != inStop ) { res = EConvResult . DestinationBufferFull ; } else if ( ( flags & PARTIAL_INPUT ) != 0 ) { res = EConvResult . SourceBufferEmpty ; } else { res = EConvResult . Finished ; } return convertInternalResult ( res , null ) ; } boolean hasOutput = false ; EConvElement elem = elements [ numTranscoders - 1 ] ; if ( elem . bytes != null ) { int dataStart = elem . dataStart ; int dataEnd = elem . dataEnd ; byte [ ] data = elem . bytes ; if ( dataStart != dataEnd ) { if ( outStop - outPtr . p < dataEnd - dataStart ) { len = outStop - outPtr . p ; System . arraycopy ( data , dataStart , out , outPtr . p , len ) ; outPtr . p = outStop ; elem . dataStart += len ; return convertInternalResult ( EConvResult . DestinationBufferFull , null ) ; } len = dataEnd - dataStart ; System . arraycopy ( data , dataStart , out , outPtr . p , len ) ; outPtr . p += len ; elem . dataStart = elem . dataEnd = elem . bufStart ; hasOutput = true ; } } Ptr resultPosition = new Ptr ( 0 ) ; if ( inBuf != null && inBuf . dataStart != inBuf . dataEnd ) { Ptr inDataStartPtr = new Ptr ( inBuf . dataStart ) ; res = transConv ( inBuf . bytes , inDataStartPtr , inBuf . dataEnd , out , outPtr , outStop , ( flags & ~ AFTER_OUTPUT ) | PARTIAL_INPUT , resultPosition ) ; inBuf . dataStart = inDataStartPtr . p ; if ( ! res . isSourceBufferEmpty ( ) ) return convertInternalResult ( EConvResult . SourceBufferEmpty , resultPosition ) ; } if ( hasOutput && ( flags & AFTER_OUTPUT ) != 0 && inPtr . p != inStop ) { inStop = inPtr . p ; res = transConv ( in , inPtr , inStop , out , outPtr , outStop , flags , resultPosition ) ; if ( res . isSourceBufferEmpty ( ) ) res = EConvResult . AfterOutput ; } else if ( ( flags & AFTER_OUTPUT ) != 0 || numTranscoders == 1 ) { res = transConv ( in , inPtr , inStop , out , outPtr , outStop , flags , resultPosition ) ; } else { flags |= AFTER_OUTPUT ; do { res = transConv ( in , inPtr , inStop , out , outPtr , outStop , flags , resultPosition ) ; } while ( res . isAfterOutput ( ) ) ; } return convertInternalResult ( res , resultPosition ) ; }
/* rb_econv_convert0