| 19 | throw std::runtime_error(std::string("Audio chunker requires positive ") + name); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | int64_t reflect_index(int64_t index, int64_t length) { |
| 24 | require_positive(length, "reflect length"); |
| 25 | if (length == 1) { |
| 26 | return 0; |
| 27 | } |
| 28 | while (index < 0 || index >= length) { |
| 29 | if (index < 0) { |
| 30 | index = -index; |
| 31 | } else { |
| 32 | index = 2 * length - index - 2; |
| 33 | } |
| 34 | } |
| 35 | return index; |
| 36 | } |
| 37 |
no test coverage detected