code: func Factor(w, h, sw, sh int) int {
  	switch {
  	case w>>3 >= sw && h>>3 >= sh:
  		return 8
  	case w>>2 >= sw && h>>2 >= sh:
  		return 4
  	case w>>1 >= sw && h>>1 >= sh:
  		return 2
  	}
  	return 1
  }
docs: // Factor returns the sample factor DecodeSample should use to generate a
  // sampled image greater than or equal to sw x sh pixels given a source image
  // of w x h pixels.