45
46
-c, --clear-frame Clear the frame for each iteration\n");
48
static void process_file(const char *filename, int rows, int clear_frame, int verbose)
53
uint16_t *pixels = (uint16_t *) malloc(2048 * 1088 * sizeof(uint16_t));
54
uint32_t num_rows, frame_number, time_stamp, old_time_stamp = 0;
56
struct timeval start, end;
57
long seconds = 0L, useconds = 0L;
58
int error = read_raw_file(filename, &buffer, &num_bytes);
50
print_meta_data (UfoDecoderMeta *meta)
52
printf(" frame_number = %i\n", meta->frame_number);
53
printf(" time_stamp = %i\n", meta->time_stamp);
54
printf(" n_rows = %i\n", meta->n_rows);
55
printf(" n_skipped_rows = %i\n", meta->n_skipped_rows);
58
printf(" fsm_master_readout = %i\n", meta->status1.desc.fsm_master_readout);
59
printf(" fsm_daq = %i\n", meta->status1.desc.fsm_daq);
60
printf(" pixel_full = %i\n", meta->status1.desc.pixel_full);
61
printf(" control_lock = %i\n", meta->status1.desc.control_lock);
62
printf(" data_lock = %i\n", meta->status1.desc.data_lock);
65
printf(" end_of_frames = %i\n", meta->status2.desc.end_of_frames);
66
printf(" busy_or = %i\n", meta->status2.desc.busy_or);
67
printf(" busy_ddr = %i\n", meta->status2.desc.busy_ddr);
68
printf(" busy_interl = %i\n", meta->status2.desc.busy_interl);
69
printf(" error_status = %i\n", meta->status2.desc.error_status);
70
printf(" data_fifo_read_count = %i\n", meta->status2.desc.data_fifo_read_count);
71
printf(" data_fifo_full = %i\n", meta->status2.desc.data_fifo_full);
72
printf(" data_fifo_empty = %i\n", meta->status2.desc.data_fifo_empty);
73
printf(" ddr_fifo_write_count = %i\n", meta->status2.desc.ddr_fifo_write_count);
74
printf(" ddr_fifo_full = %i\n", meta->status2.desc.ddr_fifo_full);
75
printf(" ddr_fifo_empty = %i\n", meta->status2.desc.ddr_fifo_empty);
78
printf(" row_counter = %i\n", meta->status3.desc.row_counter);
79
printf(" pixel_counter = %i\n", meta->status3.desc.pixel_counter);
80
printf(" ddr_read = %i\n", meta->status3.desc.ddr_read);
81
printf(" ddr_write = %i\n", meta->status3.desc.ddr_write);
82
printf(" ddr_arbiter = %i\n", meta->status3.desc.ddr_arbiter);
95
Timer *t = (Timer *) malloc (sizeof (Timer));
96
t->seconds = t->useconds = 0L;
101
timer_destroy (Timer *t)
107
timer_start (Timer *t)
109
gettimeofday(&t->start, NULL);
113
timer_stop (Timer *t)
117
gettimeofday(&end, NULL);
118
t->seconds += end.tv_sec - t->start.tv_sec;
119
t->useconds += end.tv_usec - t->start.tv_usec;
123
process_file(const char *filename, int rows, int clear_frame, int verbose)
126
UfoDecoderMeta meta = {0};
132
uint32_t time_stamp, old_time_stamp;
135
char output_name[256];
137
error = read_raw_file(filename, &buffer, &num_bytes);
61
140
fprintf(stderr, "Error reading %s: %s\n", filename, strerror(error));
65
ufo_decoder decoder = ufo_decoder_new(rows, 2048, (uint32_t *) buffer, num_bytes);
144
decoder = ufo_decoder_new(rows, 2048, (uint32_t *) buffer, num_bytes);
146
if (decoder == NULL) {
68
147
fprintf(stderr, "Failed to initialize decoder\n");
72
char output_name[256];
73
151
snprintf(output_name, 256, "%s.raw", filename);
74
FILE *fp = fopen(output_name, "wb");
152
fp = fopen(output_name, "wb");
77
155
fprintf(stderr, "Failed to open file for writing\n");
159
timer = timer_new ();
160
pixels = (uint16_t *) malloc(2048 * 1088 * sizeof(uint16_t));
163
while (error != EIO) {
83
165
memset(pixels, 0, 2048 * 1088 * sizeof(uint16_t));
85
gettimeofday(&start, NULL);
86
err = ufo_decoder_get_next_frame(decoder, &pixels, &num_rows, &frame_number, &time_stamp, NULL);
87
gettimeofday(&end, NULL);
90
int time_stamp_diff = 80 * (time_stamp - old_time_stamp);
92
if (time_stamp_diff != 0)
93
printf(" %d\t %d\n", 1000000000 / time_stamp_diff, num_rows);
95
old_time_stamp = time_stamp;
100
seconds += end.tv_sec - start.tv_sec;
101
useconds += end.tv_usec - start.tv_usec;
168
error = ufo_decoder_get_next_frame(decoder, &pixels, &meta);
173
printf("Status for frame %i\n", n_frames);
174
print_meta_data (&meta);
102
178
fwrite(pixels, sizeof(uint16_t), 2048 * 1088, fp);
105
fprintf(stderr, "Failed to decode frame %i\n", num_frames);
180
else if (error != EIO)
181
fprintf(stderr, "Failed to decode frame %i\n", n_frames);
110
float mtime = seconds * 1000.0 + useconds / 1000.0;
111
printf("Decoded %i frames in %.5fms\n", num_frames, mtime);
186
float mtime = timer->seconds * 1000.0 + timer->useconds / 1000.0;
187
printf("Decoded %i frames in %.5fms\n", n_frames, mtime);
191
timer_destroy (timer);
114
192
ufo_decoder_free(decoder);
118
195
int main(int argc, char const* argv[])