/** * Interleave for FEC. * @param data * @param size * @return */ public static byte[] fecInterleave(byte[] data, int size) { byte[] inter = new byte[data.length]; int cycle = (int) Math.ceil(data.length / (double) size); for (int i = 0; i < cycle; i++) { for (int j = 0; j < size; j++) { inter[j * cycle + i] = data[i * size + j]; } } return inter; } /** * Reverse interleave for FEC. * @param data * @param size * @return */ public static byte[] fecDeinterleave(byte[] data, int size) { return Ts.fecInterleave(data, (int) Math.ceil(data.length / (double) size)); }