reassembleBytes takes the 4x6-bit chunks from encodedByte, reassembles them into 3 bytes of output, and places them in their appropriate output positions.
(opos int, encodedByte []byte, output []byte)
| 213 | // reassembleBytes takes the 4x6-bit chunks from encodedByte, reassembles them into 3 bytes of |
| 214 | // output, and places them in their appropriate output positions. |
| 215 | func reassembleBytes(opos int, encodedByte []byte, output []byte) int { |
| 216 | opos-- // account for fact that we don't output a 128th byte |
| 217 | x := (encodedByte[0] & 0b0011_1111) | ((encodedByte[1] & 0b0011_0000) << 2) |
| 218 | y := (encodedByte[1] & 0b0000_1111) | ((encodedByte[3] & 0b0000_1111) << 4) |
| 219 | z := (encodedByte[2] & 0b0011_1111) | ((encodedByte[3] & 0b0011_0000) << 2) |
| 220 | // put the re-assembled bytes in their appropriate output locations |
| 221 | output[opos-32] = z |
| 222 | output[opos-(32*2)] = y |
| 223 | output[opos-(32*3)] = x |
| 224 | return opos |
| 225 | } |