private boolean doParseMoreData(final InputStream inputStream){
  final int oldBestScanNumber=mBestScanNumber;
  try {
    int nextByte;
    while (mParserState != NOT_A_JPEG && (nextByte=inputStream.read()) != -1) {
      mBytesParsed++;
switch (mParserState) {
case READ_FIRST_JPEG_BYTE:
        if (nextByte == JfifUtil.MARKER_FIRST_BYTE) {
          mParserState=READ_SECOND_JPEG_BYTE;
        }
 else {
          mParserState=NOT_A_JPEG;
        }
      break;
case READ_SECOND_JPEG_BYTE:
    if (nextByte == JfifUtil.MARKER_SOI) {
      mParserState=READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA;
    }
 else {
      mParserState=NOT_A_JPEG;
    }
  break;
case READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA:
if (nextByte == JfifUtil.MARKER_FIRST_BYTE) {
  mParserState=READ_MARKER_SECOND_BYTE;
}
break;
case READ_MARKER_SECOND_BYTE:
if (nextByte == JfifUtil.MARKER_FIRST_BYTE) {
mParserState=READ_MARKER_SECOND_BYTE;
}
 else if (nextByte == JfifUtil.MARKER_ESCAPE_BYTE) {
mParserState=READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA;
}
 else {
if (nextByte == JfifUtil.MARKER_SOS || nextByte == JfifUtil.MARKER_EOI) {
newScanOrImageEndFound(mBytesParsed - 2);
}
if (doesMarkerStartSegment(nextByte)) {
mParserState=READ_SIZE_FIRST_BYTE;
}
 else {
mParserState=READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA;
}
}
break;
case READ_SIZE_FIRST_BYTE:
mParserState=READ_SIZE_SECOND_BYTE;
break;
case READ_SIZE_SECOND_BYTE:
final int size=(mLastByteRead << 8) + nextByte;
final int bytesToSkip=size - 2;
StreamUtil.skip(inputStream,bytesToSkip);
mBytesParsed+=bytesToSkip;
mParserState=READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA;
break;
case NOT_A_JPEG:
default :
Preconditions.checkState(false);
}
mLastByteRead=nextByte;
}
}
 catch (IOException ioe) {
Throwables.propagate(ioe);
}
return mParserState != NOT_A_JPEG && mBestScanNumber != oldBestScanNumber;
}

private boolean doParseMoreData ( final InputStream inputStream ) { final int oldBestScanNumber = mBestScanNumber ; try { int nextByte ; while ( mParserState != NOT_A_JPEG && ( nextByte = inputStream . read ( ) ) != - 1 ) { mBytesParsed ++ ; switch ( mParserState ) { case READ_FIRST_JPEG_BYTE : if ( nextByte == JfifUtil . MARKER_FIRST_BYTE ) { mParserState = READ_SECOND_JPEG_BYTE ; } else { mParserState = NOT_A_JPEG ; } break ; case READ_SECOND_JPEG_BYTE : if ( nextByte == JfifUtil . MARKER_SOI ) { mParserState = READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA ; } else { mParserState = NOT_A_JPEG ; } break ; case READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA : if ( nextByte == JfifUtil . MARKER_FIRST_BYTE ) { mParserState = READ_MARKER_SECOND_BYTE ; } break ; case READ_MARKER_SECOND_BYTE : if ( nextByte == JfifUtil . MARKER_FIRST_BYTE ) { mParserState = READ_MARKER_SECOND_BYTE ; } else if ( nextByte == JfifUtil . MARKER_ESCAPE_BYTE ) { mParserState = READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA ; } else { if ( nextByte == JfifUtil . MARKER_SOS || nextByte == JfifUtil . MARKER_EOI ) { newScanOrImageEndFound ( mBytesParsed - 2 ) ; } if ( doesMarkerStartSegment ( nextByte ) ) { mParserState = READ_SIZE_FIRST_BYTE ; } else { mParserState = READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA ; } } break ; case READ_SIZE_FIRST_BYTE : mParserState = READ_SIZE_SECOND_BYTE ; break ; case READ_SIZE_SECOND_BYTE : final int size = ( mLastByteRead << 8 ) + nextByte ; final int bytesToSkip = size - 2 ; StreamUtil . skip ( inputStream , bytesToSkip ) ; mBytesParsed += bytesToSkip ; mParserState = READ_MARKER_FIRST_BYTE_OR_ENTROPY_DATA ; break ; case NOT_A_JPEG : default : Preconditions . checkState ( false ) ; } mLastByteRead = nextByte ; } } catch ( IOException ioe ) { Throwables . propagate ( ioe ) ; } return mParserState != NOT_A_JPEG && mBestScanNumber != oldBestScanNumber ; }
parses more data from inputstream .
