def convert_coords x,y
      # optimizing this into one switch/case statement gives
      # about 1-2% speed increase (ruby 1.9.3p286)

      if y%2 == 1
        # 7th pass: last height/2 full scanlines
        [x, y/2 + @pass_starts[7]]
      elsif x%2 == 1 && y%2 == 0
        # 6th pass
        [x/2, y/2 + @pass_starts[6]]
      elsif x%8 == 0 && y%8 == 0
        # 1st pass, starts at 0
        [x/8, y/8]
      elsif x%8 == 4 && y%8 == 0
        # 2nd pass
        [x/8, y/8 + @pass_starts[2]]
      elsif x%4 == 0 && y%8 == 4
        # 3rd pass
        [x/4, y/8 + @pass_starts[3]]
      elsif x%4 == 2 && y%4 == 0
        # 4th pass
        [x/4, y/4 + @pass_starts[4]]
      elsif x%2 == 0 && y%4 == 2
        # 5th pass
        [x/2, y/4 + @pass_starts[5]]
      else
        raise "invalid coords"
      end
    end
def convert_coords x,y
      # optimizing this into one switch/case statement gives
      # about 1-2% speed increase (ruby 1.9.3p286)

      if y%2 == 1
        # 7th pass: last height/2 full scanlines
        [x, y/2 + @pass_starts[7]]
      elsif x%2 == 1 && y%2 == 0
        # 6th pass
        [x/2, y/2 + @pass_starts[6]]
      elsif x%8 == 0 && y%8 == 0
        # 1st pass, starts at 0
        [x/8, y/8]
      elsif x%8 == 4 && y%8 == 0
        # 2nd pass
        [x/8, y/8 + @pass_starts[2]]
      elsif x%4 == 0 && y%8 == 4
        # 3rd pass
        [x/4, y/8 + @pass_starts[3]]
      elsif x%4 == 2 && y%4 == 0
        # 4th pass
        [x/4, y/4 + @pass_starts[4]]
      elsif x%2 == 0 && y%4 == 2
        # 5th pass
        [x/2, y/4 + @pass_starts[5]]
      else
        raise "invalid coords"
      end
    end
convert "flat" coords in scanline number & pos in scanline