7 const float *values,
size_t values_elements,
8 size_t rows,
size_t channels,
size_t row_stride,
9 size_t emitted_frames,
size_t min_frames,
size_t max_frames,
10 size_t stop_id,
size_t suppressed_begin,
size_t suppressed_end,
11 int32_t *selected,
size_t selected_elements)
13 if (!rows || !channels || channels > INT32_MAX || row_stride < channels ||
14 !max_frames || min_frames > max_frames || emitted_frames > max_frames ||
15 stop_id >= channels || suppressed_begin > suppressed_end ||
16 suppressed_end > channels)
18 if (rows - 1 > (SIZE_MAX - channels) / row_stride)
20 const size_t span = (rows - 1) * row_stride + channels;
21 if (span > SIZE_MAX /
sizeof(
float) || values_elements < span ||
22 selected_elements < 1)
24 if (!values || !selected ||
25 (uintptr_t)values % _Alignof(
float) != 0 ||
26 (uintptr_t)selected % _Alignof(int32_t) != 0 ||
27 (uintptr_t)values > UINTPTR_MAX - span *
sizeof(
float) ||
28 (uintptr_t)selected > UINTPTR_MAX -
sizeof(int32_t))
30 const uintptr_t begin = (uintptr_t)values;
31 const uintptr_t
end = begin + span *
sizeof(float);
32 const uintptr_t output = (uintptr_t)selected;
33 if (begin < output +
sizeof(int32_t) && output <
end)
35 if (emitted_frames == max_frames)
38 const float *row = values + (rows - 1) * row_stride;
39 size_t best = SIZE_MAX;
41 for (
size_t index = 0; index < channels; ++index) {
42 const float value = row[index];
43 if (!isfinite(value))
return -3;
44 if ((emitted_frames < min_frames && index == stop_id) ||
45 (index >= suppressed_begin && index < suppressed_end &&
48 if (best == SIZE_MAX || value > maximum) {
53 if (best == SIZE_MAX)
return -2;
54 *selected = (int32_t)best;
int ck_select_next_id_checked_f32(const float *values, size_t values_elements, size_t rows, size_t channels, size_t row_stride, size_t emitted_frames, size_t min_frames, size_t max_frames, size_t stop_id, size_t suppressed_begin, size_t suppressed_end, int32_t *selected, size_t selected_elements)