Interleaved input assumes you have two channels encoded within continuous buffer as sequence pairs: [<left>, <right>...]
Hence, number of samples is always data.len() / 2.
If it is not your case, encoding will panic in debug mode, but otherwise you most likely to get incomplete output.