throw exception on invalid formats in bytes_per_sample, marked as const
removed extra const from size_t return type