public final int feedBytes(byte[] buf,int off,int len){
  if (len == 0)   return 0;
  if (len < 0)   throw new PngjException("negative length??");
  if (read == 0 && crcn == 0 && crcCheck)   chunkRaw.updateCrc(chunkRaw.idbytes,0,4);
  int bytesForData=chunkRaw.len - read;
  if (bytesForData > len)   bytesForData=len;
  if (bytesForData > 0 || crcn == 0) {
    if (crcCheck && mode != ChunkReaderMode.BUFFER && bytesForData > 0)     chunkRaw.updateCrc(buf,off,bytesForData);
    if (mode == ChunkReaderMode.BUFFER) {
      if (chunkRaw.data != buf && bytesForData > 0) {
        System.arraycopy(buf,off,chunkRaw.data,read,bytesForData);
      }
    }
 else     if (mode == ChunkReaderMode.PROCESS) {
      processData(read,buf,off,bytesForData);
    }
 else {
    }
    read+=bytesForData;
    off+=bytesForData;
    len-=bytesForData;
  }
  int crcRead=0;
  if (read == chunkRaw.len) {
    crcRead=4 - crcn;
    if (crcRead > len)     crcRead=len;
    if (crcRead > 0) {
      if (buf != chunkRaw.crcval)       System.arraycopy(buf,off,chunkRaw.crcval,crcn,crcRead);
      crcn+=crcRead;
      if (crcn == 4) {
        if (crcCheck) {
          if (mode == ChunkReaderMode.BUFFER) {
            chunkRaw.updateCrc(chunkRaw.data,0,chunkRaw.len);
          }
          chunkRaw.checkCrc();
        }
        chunkDone();
      }
    }
  }
  return bytesForData + crcRead;
}

public final int feedBytes ( byte [ ] buf , int off , int len ) { if ( len == 0 ) return 0 ; if ( len < 0 ) throw new PngjException ( "negative length??" ) ; if ( read == 0 && crcn == 0 && crcCheck ) chunkRaw . updateCrc ( chunkRaw . idbytes , 0 , 4 ) ; int bytesForData = chunkRaw . len - read ; if ( bytesForData > len ) bytesForData = len ; if ( bytesForData > 0 || crcn == 0 ) { if ( crcCheck && mode != ChunkReaderMode . BUFFER && bytesForData > 0 ) chunkRaw . updateCrc ( buf , off , bytesForData ) ; if ( mode == ChunkReaderMode . BUFFER ) { if ( chunkRaw . data != buf && bytesForData > 0 ) { System . arraycopy ( buf , off , chunkRaw . data , read , bytesForData ) ; } } else if ( mode == ChunkReaderMode . PROCESS ) { processData ( read , buf , off , bytesForData ) ; } else { } read += bytesForData ; off += bytesForData ; len -= bytesForData ; } int crcRead = 0 ; if ( read == chunkRaw . len ) { crcRead = 4 - crcn ; if ( crcRead > len ) crcRead = len ; if ( crcRead > 0 ) { if ( buf != chunkRaw . crcval ) System . arraycopy ( buf , off , chunkRaw . crcval , crcn , crcRead ) ; crcn += crcRead ; if ( crcn == 4 ) { if ( crcCheck ) { if ( mode == ChunkReaderMode . BUFFER ) { chunkRaw . updateCrc ( chunkRaw . data , 0 , chunkRaw . len ) ; } chunkRaw . checkCrc ( ) ; } chunkDone ( ) ; } } } return bytesForData + crcRead ; }
consumes data for the chunk ( data and crc ) . this never consumes more bytes than for this chunk . in hot_process can call processdata ( ) ( not more than once ) if this ends the chunk ( included crc ) it checks crc ( if checking ) and calls chunkdone ( )
