| 304 | split = (search_start + search_end) / 2; |
| 305 | } else { |
| 306 | float min_energy = std::numeric_limits<float>::infinity(); |
| 307 | const int64_t upper = search_end - search_start - options.min_energy_window_samples; |
| 308 | for (int64_t i = 0; i < upper; i += options.min_energy_window_samples) { |
| 309 | double sum = 0.0; |
| 310 | for (int64_t j = 0; j < options.min_energy_window_samples; ++j) { |
| 311 | const float value = mono_samples[static_cast<size_t>(search_start + i + j)]; |
| 312 | sum += static_cast<double>(value) * static_cast<double>(value); |
| 313 | } |
| 314 | const float energy = |
| 315 | std::sqrt(static_cast<float>(sum / static_cast<double>(options.min_energy_window_samples))); |
| 316 | if (energy < min_energy) { |
| 317 | min_energy = energy; |
| 318 | split = search_start + i; |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | split = std::max<int64_t>(index + 1, std::min<int64_t>(split, total)); |
| 324 | chunks.push_back({index, split}); |
| 325 | index = split; |
no test coverage detected