avcodec/pnm: Check magic bytes directly without pnm_get()