X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Ftest%2Fao_fec_test.c;h=cbced6ae31435fb870ee8c599c02d88f9d564d5a;hp=b94b16dcd91441afb23dad5ffdf2f012cdd0f695;hb=1085ec5d57e0ed5d132f2bbdac1a0b6a32c0ab4a;hpb=939ad8bfd640ed55116703a58f87af06e75ef87e diff --git a/src/test/ao_fec_test.c b/src/test/ao_fec_test.c index b94b16dc..cbced6ae 100644 --- a/src/test/ao_fec_test.c +++ b/src/test/ao_fec_test.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -100,6 +101,7 @@ ao_fuzz (uint8_t *in, int in_len, uint8_t *out, double dev) { int i; int errors = 0; + int s; for (i = 0; i < in_len; i++) { double error = gaussian_random(0, dev); @@ -115,6 +117,24 @@ ao_fuzz (uint8_t *in, int in_len, uint8_t *out, double dev) else byte -= error; } + + /* abcd efgh 8 + * abcd efga 7 + * abcd efab 6 + * abcd eabc 5 + * abcd abcd 4 + * abca bcab 3 + * abab abab 2 + * aaaa aaaa 1 + */ + +#define SAVE 8 +#define SAVE_MASK (((1 << SAVE) - 1) << (8 - SAVE)) + + byte &= SAVE_MASK; + for (s = SAVE; s < 8; s += SAVE) + byte |= byte >> s; + out[i] = byte; } return errors;