GCC Code Coverage Report


Directory: csrc/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 37 / 0 / 37
Functions: 100.0% 2 / 0 / 2
Branches: -% 0 / 0 / 0

aer.c
Line Branch Exec Source
1 #include "evutils/aer.h"
2
3 typedef struct aer_state_s {
4 uint64_t t_next; /* timestamp of the next decoded event (sequential) */
5 uint64_t t_step; /* timestamp increment per event (sequential) */
6 int32_t mode; /* AER_TS_ZERO / AER_TS_SEQUENTIAL */
7 } aer_state_t;
8
9 13 size_t AER_state_size(void) {
10 13 return sizeof(aer_state_t);
11 }
12
13 15 void AER_state_configure(aer_state_t *state, int32_t mode,
14 uint64_t t_next, uint64_t t_step) {
15 15 state->mode = mode;
16 15 state->t_next = t_next;
17 15 state->t_step = t_step;
18 15 }
19
20 EVUTILS_TARGET_CLONES
21 12 parser_result_t AER_parse_chunk_soa(
22 aer_state_t *state,
23 const aer_input_buffer_t *input_buffer,
24 event_buffer_soa_t *event_buffer,
25 trigger_buffer_soa_t *trigger_buffer) {
26
27 (void)trigger_buffer; /* AER carries no triggers */
28
29 12 const uint32_t *restrict current = input_buffer->begin;
30 12 const uint32_t *restrict end = input_buffer->end;
31
32 12 timestamp_t* restrict out_ts = event_buffer->t;
33 12 uint16_t* restrict out_x = event_buffer->x;
34 12 uint16_t* restrict out_y = event_buffer->y;
35 12 uint8_t* restrict out_p = event_buffer->p;
36
37 12 size_t n = event_buffer->size;
38 12 const size_t capacity = event_buffer->capacity;
39
40 12 if (state->mode == AER_TS_SEQUENTIAL) {
41 3 uint64_t t = state->t_next;
42 3 const uint64_t step = state->t_step;
43 3003 while (current < end && n < capacity) {
44 3000 uint32_t w = *current++;
45 3000 out_ts[n] = t;
46 3000 t += step;
47 3000 out_x[n] = (uint16_t)((w >> 9) & 0x1FF);
48 3000 out_y[n] = (uint16_t)(w & 0x1FF);
49 3000 out_p[n] = (uint8_t)((w >> 18) & 0x1);
50 3000 n++;
51 }
52 3 state->t_next = t;
53 } else {
54 28109 while (current < end && n < capacity) {
55 28100 uint32_t w = *current++;
56 28100 out_ts[n] = 0; /* AER has no timestamps */
57 28100 out_x[n] = (uint16_t)((w >> 9) & 0x1FF);
58 28100 out_y[n] = (uint16_t)(w & 0x1FF);
59 28100 out_p[n] = (uint8_t)((w >> 18) & 0x1);
60 28100 n++;
61 }
62 }
63
64 12 event_buffer->size = n;
65
66 12 return (parser_result_t){
67 .current = (const void *)current,
68 .status = EVUTILS_PARSE_OK
69 };
70 }
71