Fix autodetection of SAM input.