lib/parsers/jpeg_parser.rb
def read_next_marker
    # We need to find a sequence of two bytes - the first one is 0xFF, the other is anything but 0xFF
    a = read_char
    (MUST_FIND_NEXT_MARKER_WITHIN_BYTES - 1).times do
      b = read_char
      return b if a == 0xFF && b != 0xFF # Caught the marker
      a = b # Shift the tuple one byte forward
    end
    nil # Nothing found
  end
# Read a byte, if it is 0xFF then skip bytes as long as they are also 0xFF (byte stuffing)
# and return the first byte scanned that is not 0xFF. Also applies limits so that we do not
# read for inordinate amount of time should we encounter a file where we _do_ have a SOI
# marker at the start and then no markers for a _very_ long time (happened with some PSDs)
Read a byte, if it is 0xFF then skip bytes as long as they are also 0xFF (byte stuffing)
and return the first byte scanned that is not 0xFF. Also applies limits so that we do not
read for inordinate amount of time should we encounter a file where we _do_ have a SOI
marker at the start and then no markers for a _very_ long time (happened with some PSDs)
Read a byte if it is 0xFF then skip bytes as long as they are also 0xFF ( byte stuffing ) and return the first byte scanned that is not 0xFF . Also applies limits so that we do not read for inordinate amount of time should we encounter a file where we _do_ have a SOI marker at the start and then no markers for a _very_ long time ( happened with some PSDs )
def read_next_marker
    a = read_char
    (MUST_FIND_NEXT_MARKER_WITHIN_BYTES - 1).times do
      b = read_char
      return b if a == 0xFF && b != 0xFF 
      a = b 
    end
    nil 
  end
def read_next_marker a = read_char ( MUST_FIND_NEXT_MARKER_WITHIN_BYTES - 1 ) . times do b = read_char return b if a == 0xFF && b != 0xFF a = b end nil end
Read a byte, if it is 0xFF then skip bytes as long as they are also 0xFF (byte stuffing)
and return the first byte scanned that is not 0xFF.
Read a byte if it is 0xFF then skip bytes as long as they are also 0xFF ( byte stuffing ) and return the first byte scanned that is not 0xFF .
# We need to find a sequence of two bytes - the first one is 0xFF, the other is anything but 0xFF # Caught the marker # Shift the tuple one byte forward # Nothing found