ivi_common: check ref_tile size, fix out of array accesses