Hi (just note that there was a mistake
, now I think it is at last corrected)
Think of all the 7-bit bytes, one after the other, similar as what you wrote at the beginning
Each 8-bit byte in the destination array, will be composed of a certain number of bits from one byte, and a certain number of bits of the next byte
this is what is is done in the first line (Bit.Or is a logical OR of two numbers. We have just shifted the first 7 positions to the left for the first byte, and masked the second also with 7 bits (0x7F), just in case)
Dim val as int = Bit.Or( Bit.shiftLeft(src(k),7), Bit.And(src(k+1),0x7F) )
so we have, in val, when k=0, something equivalent to 01234567012345 . Our result is here, but we only want a part of it (the first 01234567) ---> So we shift this result 6 positions to the right (inner operation) and the apply a mask to keep only 8 bits (0xFF) with this line
dst(k) = Bit.And( Bit.ShiftRight( val, 6-k) , 0xFF )
The C++ code does the same, but applying a given mask for each index instead of using a for. Except for mistakes on my part, results should be the same.
--- If you have N groups of 8 bytes, then my code should be applied N times, once for each group, since it behaves differently regarding the start pointer