57main (
int argc,
char *argv[] )
59 short m, k, column_weight;
67 char matrix_fname[32];
69 while ( ( c = getopt ( argc, argv,
"cf:gk:m:o:t:w:")) != -1 ) {
72 column_weight = atoi ( optarg );
77 fprintf (stderr,
"Only one of the options 'c' 'g' can be chosen.\n" );
83 frame_size = atoi ( optarg );
88 fprintf (stderr,
"Only one of the options 'c' 'g' can be chosen.\n" );
100 sprintf(fname, optarg, 32);
103 sprintf(matrix_fname, optarg, 32);
106 if ( optopt ==
'c' || optopt ==
'k' || optopt ==
'm' )
107 fprintf ( stderr,
"Option -%c requires an argument.\n", optopt);
108 else if ( isprint ( optopt))
109 fprintf ( stderr,
"Unknown option '-%c'.\n", optopt);
111 fprintf ( stderr,
"Uknown option character '\\x%x'.\n", optopt);
119 demo( k, m, frame_size, matrix_fname, fname, cpu, gpu);
166demo(
int k,
int m,
int frame_size,
char* matrix_fname,
char* data_fname,
int cpu,
int gpu )
187 int e = posix_memalign(&data, 16, frame_size);
190 fprintf ( stderr,
"Unable to allocate memory using posix_memalign.\n");
194 for (
int i = 0; i < frame_size; ++i)
195 memset((
char*)data+i, rand() % 256, 1);
233 map<int, int> valid_data;
242 printf (
"encoding\n" );
243 output = coding_session_cpu->
encode_frame ( (
char*) data, frame_size, &buf_size );
249 for (
int j = 0; j < buf_size ; j += ps) {
251 if(j + ps > buf_size) {
255 valid_data.insert(pair<int,int>(j, size));
259 fprintf(stderr,
"Dropping first packet!!!!!!!!!!!!\n");
261 memset(output + j, 0x0, size);
266 printf (
"received bytes: %d\n", total );
267 printf (
"decoding\n" );
268 decoded = coding_session_cpu_2->
decode_frame(output, buf_size, &f_size, valid_data);
269 printf (
"f_size: %d\n", f_size );
272 if(f_size) good++;
else bad++;
273 fprintf(stderr,
"good: %d bad: %d\n", good, bad);
275 for (
int x= 0; x < f_size; ++x) {
276 if(((
char *)data)[x] != decoded[x]) {
277 fprintf(stderr,
"Different character %d / %d (original size %d)\n", x, f_size, frame_size);
301 out.open(data_fname, ios::out | ios::app);
309 unsigned char bytes[4];
312 memcpy(&(fs.bytes), output, 4);
323 delete coding_session_cpu;
324 delete coding_session_cpu_2;
void fillParityMatrix(char **matrix, int height, int width)
void printData(char *data, int count, int packet_size)
int demo(int m, int k, int frame_size, char *matrix_fname, char *data_fname, int cpu, int gpu)
void printMatrix(char **m, int height, int width)
void compare_int_arrays(int *a, int *b, int size)