summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-03-24 23:30:08 +0000
committerCarl Hetherington <cth@carlh.net>2015-03-24 23:30:08 +0000
commit86aaba4f392c35ccf28221049f87b8cdba868777 (patch)
tree9809348c4b13f1f8a0d1f3701f829cda50b98db5 /src/lib
parent11d68f1cda11ecf5983451c10a73a37692b025bb (diff)
Hand-apply a2f81da6d9afc5d3b5e647e1e05ca5d4507af42c from master;
allow "deletion" of the audio part of a FFmpeg file from the timeline; delete unmaps the audio (#316).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/audio_mapping.cc35
-rw-r--r--src/lib/audio_mapping.h5
2 files changed, 38 insertions, 2 deletions
diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc
index 5b3e36f25..35e4c036c 100644
--- a/src/lib/audio_mapping.cc
+++ b/src/lib/audio_mapping.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@ using std::make_pair;
using std::pair;
using std::string;
using std::min;
+using std::vector;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using dcp::raw_convert;
@@ -144,3 +145,35 @@ AudioMapping::digest () const
return digester.get ();
}
+
+list<dcp::Channel>
+AudioMapping::mapped_dcp_channels () const
+{
+ static float const minus_96_db = 0.000015849;
+
+ list<dcp::Channel> mapped;
+
+ for (vector<vector<float> >::const_iterator i = _gain.begin(); i != _gain.end(); ++i) {
+ for (size_t j = 0; j < i->size(); ++j) {
+ if (abs ((*i)[j]) > minus_96_db) {
+ mapped.push_back ((dcp::Channel) j);
+ }
+ }
+ }
+
+ mapped.sort ();
+ mapped.unique ();
+
+ return mapped;
+}
+
+void
+AudioMapping::unmap_all ()
+{
+ for (vector<vector<float> >::iterator i = _gain.begin(); i != _gain.end(); ++i) {
+ for (vector<float>::iterator j = i->begin(); j != i->end(); ++j) {
+ *j = 0;
+ }
+ }
+}
+
diff --git a/src/lib/audio_mapping.h b/src/lib/audio_mapping.h
index fdb23df8b..bac2b10b0 100644
--- a/src/lib/audio_mapping.h
+++ b/src/lib/audio_mapping.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -65,6 +65,9 @@ public:
}
std::string digest () const;
+
+ std::list<dcp::Channel> mapped_dcp_channels () const;
+ void unmap_all ();
private:
void setup (int);