X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=1f5b29101de78c7657a2341623590eed7b3ad92f;hb=a5f9f8163ecb38a140cf623e141bea1d96866fe5;hp=0ce538cdff2429fbd4f571a57e14e292faddef8e;hpb=fc4956d144ed0869fe2fa1737adc21104bb47836;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index 0ce538cdf..1f5b29101 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -36,6 +36,7 @@ #include "digester.h" #include "audio_processor.h" #include "compose.hpp" +#include "audio_buffers.h" #include #include #include @@ -126,6 +127,22 @@ seconds_to_hms (int s) return buffer; } +string +time_to_hmsf (DCPTime time, Frame rate) +{ + Frame f = time.frames_round (rate); + int s = f / rate; + f -= (s * rate); + int m = s / 60; + s -= m * 60; + int h = m / 60; + m -= h * 60; + + char buffer[64]; + snprintf (buffer, sizeof(buffer), "%d:%02d:%02d.%d", h, m, s, static_cast(f)); + return buffer; +} + /** @param s Number of seconds. * @return String containing an approximate description of s (e.g. "about 2 hours") */ @@ -735,3 +752,25 @@ audio_channel_types (list mapped, int channels) return make_pair (non_lfe, lfe); } + +shared_ptr +remap (shared_ptr input, int output_channels, AudioMapping map) +{ + shared_ptr mapped (new AudioBuffers (output_channels, input->frames())); + mapped->make_silent (); + + for (int i = 0; i < map.input_channels(); ++i) { + for (int j = 0; j < mapped->channels(); ++j) { + if (map.get (i, static_cast (j)) > 0) { + mapped->accumulate_channel ( + input.get(), + i, + static_cast (j), + map.get (i, static_cast (j)) + ); + } + } + } + + return mapped; +}