public static RadioLog.Common.SafeBitArray interleave(RadioLog.Common.SafeBitArray message, int start, int end) { RadioLog.Common.SafeBitArray original = message.CloneFromIndexToIndex(start, end); /* Clear block bits in source message */ message.ClearRange(start, end); /* Iterate only the set bits in the original message and apply * the deinterleave -- we don't have to evaluate the 0 bits */ for (int i = original.nextSetBit(0); i >= 0 && i < INTERLEAVE.Length; i = original.nextSetBit(i + 1)) { message.SetBit(start + INTERLEAVE[i]); } return message; }
public void decode(RadioLog.Common.SafeBitArray message, int start, int end) { /* load each of the nodes with deinterleaved constellations */ for (int index = 0; index < 49; index++) { Constellation c = getConstellation(message, index * 4); mConstellationNodes[index].setConstellation(c); } /* test to see if constellations are correct - otherwise correct them */ ConstellationNode firstNode = mConstellationNodes[0]; if (!firstNode.startsWith(Dibit.D0) || !firstNode.isCorrect()) { firstNode.correctTo(Dibit.D0); } /* clear constellations from original message */ message.ClearRange(start, end - start); /* replace with decoded values from the nodes */ for (int index = 0; index < 49; index++) { ConstellationNode node = mConstellationNodes[index]; if (node.firstBit()) { message.SetBit(start + (index * 2)); } if (node.secondBit()) { message.SetBit(start + (index * 2) + 1); } } }