| 18 | namespace dali { |
| 19 | |
| 20 | std::pair<int64_t, int64_t> ProcessOffsetAndLength(const AudioMetadata &meta, |
| 21 | double offset_sec, double length_sec) { |
| 22 | int64_t offset = 0; |
| 23 | int64_t length = meta.length; |
| 24 | if (offset_sec >= 0.0) { |
| 25 | offset = static_cast<int64_t>(offset_sec * meta.sample_rate); |
| 26 | } |
| 27 | |
| 28 | if (length_sec >= 0.0) { |
| 29 | length = static_cast<int64_t>(length_sec * meta.sample_rate); |
| 30 | } |
| 31 | |
| 32 | // Limit the duration to the bounds of the input |
| 33 | if ((offset + length) > meta.length) { |
| 34 | length = meta.length - offset; |
| 35 | } |
| 36 | return {offset, length}; |
| 37 | } |
| 38 | |
| 39 | TensorShape<> DecodedAudioShape(const AudioMetadata &meta, float target_sample_rate, bool downmix) { |
| 40 | bool should_resample = target_sample_rate > 0 && meta.sample_rate != target_sample_rate; |
no outgoing calls