Skip to content

Instantly share code, notes, and snippets.

@ranma
ranma / gist:441c47cd3e7b6ecf727504a797b1bb15
Created April 5, 2021 11:37
lookup-table driven SPDIF biphase mark decoding
uint32_t x0 = spdif_dmaring.peekword(0);
uint32_t x1 = spdif_dmaring.peekword(32);
spdif_dmaring.advance(64);
uint32_t state = BMC_DECODE_START;
uint32_t out = 0;
uint32_t tmp = x0;
state = bmc_decode[(state & 0x700) | (tmp & 0xff)]; tmp >>= 8; out >>= 4; out |= state << 28;
state = bmc_decode[(state & 0x700) | (tmp & 0xff)]; tmp >>= 8; out >>= 4; out |= state << 28;
state = bmc_decode[(state & 0x700) | (tmp & 0xff)]; tmp >>= 8; out >>= 4; out |= state << 28;