| 1428 | |
| 1429 | std::vector<int32_t> slice_codes_bqt( |
| 1430 | const std::vector<int32_t> & codes_bqt, |
| 1431 | int64_t codebooks, |
| 1432 | int64_t frames, |
| 1433 | int64_t start, |
| 1434 | int64_t length) { |
| 1435 | if (start < 0 || length <= 0 || start + length > frames || |
| 1436 | static_cast<int64_t>(codes_bqt.size()) != codebooks * frames) { |
| 1437 | throw std::runtime_error("HeartCodec code slice range mismatch"); |
| 1438 | } |
| 1439 | std::vector<int32_t> out(static_cast<size_t>(codebooks * length), 0); |
| 1440 | for (int64_t q = 0; q < codebooks; ++q) { |
| 1441 | std::copy( |
| 1442 | codes_bqt.begin() + static_cast<std::ptrdiff_t>(q * frames + start), |
| 1443 | codes_bqt.begin() + static_cast<std::ptrdiff_t>(q * frames + start + length), |
| 1444 | out.begin() + static_cast<std::ptrdiff_t>(q * length)); |
| 1445 | } |
| 1446 | return out; |
| 1447 | } |