Electronic structures of normal and inverse spinel ferrites from first principles