T: modify extract_input_subframe to dump several subframes
This commit is contained in:
@@ -12,7 +12,9 @@ void usage(void)
|
|||||||
"usage: [options] <file> <frame> <subframe>\n"
|
"usage: [options] <file> <frame> <subframe>\n"
|
||||||
"options:\n"
|
"options:\n"
|
||||||
" -d <database file> this option is mandatory\n"
|
" -d <database file> this option is mandatory\n"
|
||||||
|
" -o <output file> this option is mandatory\n"
|
||||||
" -v verbose\n"
|
" -v verbose\n"
|
||||||
|
" -c <number of subframes> default to 1\n"
|
||||||
);
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -25,15 +27,23 @@ int main(int n, char **v)
|
|||||||
int input_event_id;
|
int input_event_id;
|
||||||
database_event_format f;
|
database_event_format f;
|
||||||
char *file = NULL;
|
char *file = NULL;
|
||||||
|
char *output_file = NULL;
|
||||||
|
FILE *out;
|
||||||
int fd;
|
int fd;
|
||||||
int frame = -1, subframe = -1;
|
int frame = -1, subframe = -1;
|
||||||
int frame_arg, subframe_arg, buffer_arg;
|
int frame_arg, subframe_arg, buffer_arg;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
int number_of_subframes = 1;
|
||||||
|
int processed_subframes = 0;
|
||||||
|
|
||||||
for (i = 1; i < n; i++) {
|
for (i = 1; i < n; i++) {
|
||||||
if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
|
if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
|
||||||
if (!strcmp(v[i], "-d"))
|
if (!strcmp(v[i], "-d"))
|
||||||
{ if (i > n-2) usage(); database_filename = v[++i]; continue; }
|
{ if (i > n-2) usage(); database_filename = v[++i]; continue; }
|
||||||
|
if (!strcmp(v[i], "-o"))
|
||||||
|
{ if (i > n-2) usage(); output_file = v[++i]; continue; }
|
||||||
|
if (!strcmp(v[i], "-c"))
|
||||||
|
{ if (i > n-2) usage(); number_of_subframes = atoi(v[++i]); continue; }
|
||||||
if (!strcmp(v[i], "-v")) { verbose = 1; continue; }
|
if (!strcmp(v[i], "-v")) { verbose = 1; continue; }
|
||||||
if (file == NULL) { file = v[i]; continue; }
|
if (file == NULL) { file = v[i]; continue; }
|
||||||
if (frame == -1) { frame = atoi(v[i]); continue; }
|
if (frame == -1) { frame = atoi(v[i]); continue; }
|
||||||
@@ -47,6 +57,19 @@ int main(int n, char **v)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (number_of_subframes < 1) {
|
||||||
|
printf("bad value for option -c, must be at least 1 and is %d\n",
|
||||||
|
number_of_subframes);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output_file == NULL) {
|
||||||
|
printf("gimme -o <output file>, thanks\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
out = fopen(output_file, "w"); if(out==NULL){perror(output_file);exit(1);}
|
||||||
|
|
||||||
database = parse_database(database_filename);
|
database = parse_database(database_filename);
|
||||||
|
|
||||||
load_config_file(database_filename);
|
load_config_file(database_filename);
|
||||||
@@ -99,11 +122,22 @@ short *x = e.e[buffer_arg].b;
|
|||||||
x[i] *= 14;
|
x[i] *= 14;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fwrite(e.e[buffer_arg].b, e.e[buffer_arg].bsize, 1, stdout);
|
if (fwrite(e.e[buffer_arg].b, e.e[buffer_arg].bsize, 1, out) != 1)
|
||||||
fflush(stdout);
|
{ perror(output_file); exit(1); }
|
||||||
return 0;
|
processed_subframes++;
|
||||||
|
number_of_subframes--;
|
||||||
|
if (!number_of_subframes) {
|
||||||
|
if (fclose(out)) perror(output_file);
|
||||||
|
printf("%d subframes dumped\n", processed_subframes);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
subframe++;
|
||||||
|
if (subframe == 10) { subframe = 0; frame=(frame+1)%1024; }
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("frame %d subframe %d not found\n", frame, subframe);
|
printf("frame %d subframe %d not found\n", frame, subframe);
|
||||||
|
printf("%d subframes dumped\n", processed_subframes);
|
||||||
|
fclose(out);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user