MCPcopy Create free account
hub / github.com/NVIDIA/DALI / ProcessOffsetAndLength

Function ProcessOffsetAndLength

dali/operators/decoder/audio/audio_decoder_impl.cc:20–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace dali {
19
20std::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
39TensorShape<> DecodedAudioShape(const AudioMetadata &meta, float target_sample_rate, bool downmix) {
40 bool should_resample = target_sample_rate > 0 && meta.sample_rate != target_sample_rate;

Callers 2

ReadSampleMethod · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68