#define NUM_HIST 8
#define MOD_HIST(b) ((b) & 7)
+#define V_0 0xc0
+#define V_1 0x40
+
static const struct ao_soft_sym ao_fec_decode_table[NUM_STATE][2] = {
/* next 0 1 state */
- { { 0x00, 0x00 }, { 0xff, 0xff } } , /* 000 */
- { { 0x00, 0xff }, { 0xff, 0x00 } }, /* 001 */
- { { 0xff, 0xff }, { 0x00, 0x00 } }, /* 010 */
- { { 0xff, 0x00 }, { 0x00, 0xff } }, /* 011 */
- { { 0xff, 0xff }, { 0x00, 0x00 } }, /* 100 */
- { { 0xff, 0x00 }, { 0x00, 0xff } }, /* 101 */
- { { 0x00, 0x00 }, { 0xff, 0xff } }, /* 110 */
- { { 0x00, 0xff }, { 0xff, 0x00 } } /* 111 */
+ { { V_0, V_0 }, { V_1, V_1 } } , /* 000 */
+ { { V_0, V_1 }, { V_1, V_0 } }, /* 001 */
+ { { V_1, V_1 }, { V_0, V_0 } }, /* 010 */
+ { { V_1, V_0 }, { V_0, V_1 } }, /* 011 */
+ { { V_1, V_1 }, { V_0, V_0 } }, /* 100 */
+ { { V_1, V_0 }, { V_0, V_1 } }, /* 101 */
+ { { V_0, V_0 }, { V_1, V_1 } }, /* 110 */
+ { { V_0, V_1 }, { V_1, V_0 } } /* 111 */
};
static inline uint8_t
*/
uint8_t
-ao_fec_decode(uint8_t *in, uint16_t len, uint8_t *out)
+ao_fec_decode(uint8_t *in, uint16_t len, uint8_t *out, uint8_t out_len)
{
static uint16_t cost[2][NUM_STATE]; /* path cost */
static uint16_t bits[2][NUM_STATE]; /* save bits to quickly output them */
printf ("\tbit %3d min_cost %5d old bit %3d old_state %x bits %02x whiten %0x\n",
i/2, min_cost, o + 8, min_state, (bits[p][min_state] >> dist) & 0xff, *whiten);
#endif
- *out++ = (bits[p][min_state] >> dist) ^ *whiten++;
+ if (out_len) {
+ *out++ = (bits[p][min_state] >> dist) ^ *whiten++;
+ --out_len;
+ }
o += 8;
}
}