def METHOD_NAME(img, palette, y):
  '''RLE-encode one row of image data.'''
  entries = []
  color = None
  repeats = 0
  for x in range(0, img.size[0]):
    c = quantize(img.getpixel((x, y)), palette)
    if c == color and repeats < 255:
      repeats += 1
    else:
      if color is not None:
        entries.append((repeats, color))
      repeats = 1
      color = c
  if color is not None:
    entries.append((repeats, color))
  return entries