Cleanup: move some methods from util to maths_util.
authorCarl Hetherington <cth@carlh.net>
Mon, 4 Apr 2022 20:37:31 +0000 (22:37 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 4 Apr 2022 20:37:31 +0000 (22:37 +0200)
15 files changed:
src/lib/audio_buffers.cc
src/lib/audio_content.cc
src/lib/hints.cc
src/lib/image.cc
src/lib/maths_util.cc [new file with mode: 0644]
src/lib/maths_util.h [new file with mode: 0644]
src/lib/player.cc
src/lib/util.cc
src/lib/util.h
src/lib/wscript
src/wx/audio_dialog.cc
src/wx/audio_gain_dialog.cc
src/wx/audio_mapping_view.cc
src/wx/audio_panel.cc
src/wx/audio_plot.cc

index 9f91810e0c4ab14387b55eef574a1362bf1c6fdf..1d3598270121b48f91fd3303f877cd6f2df0176f 100644 (file)
@@ -19,9 +19,9 @@
 */
 
 
-#include "util.h"
 #include "audio_buffers.h"
 #include "dcpomatic_assert.h"
+#include "maths_util.h"
 #include <cassert>
 #include <cstring>
 #include <cmath>
index f2510b494ea3c75149603013a140b68bcf77f620..32e713ff2eda9cde84caa7260a969b6b20137351 100644 (file)
@@ -25,6 +25,7 @@
 #include "exceptions.h"
 #include "film.h"
 #include "frame_rate_change.h"
+#include "maths_util.h"
 #include <dcp/raw_convert.h>
 #include <libcxml/cxml.h>
 #include <libxml++/libxml++.h>
index 0f1cfece8e2040e8a8a8257a13126b3271e57520..027510eca8015dafa55c9e38c32b04a261fd7fe4 100644 (file)
 #include "font.h"
 #include "font_data.h"
 #include "hints.h"
+#include "maths_util.h"
 #include "player.h"
 #include "ratio.h"
 #include "text_content.h"
 #include "types.h"
-#include "util.h"
 #include "video_content.h"
 #include "writer.h"
 #include <dcp/cpl.h>
index d0878efbd75f81b3bcead98c19a0b2d832f8150e..297578866a37514970b766b1a77a814cf31df5a7 100644 (file)
 
 
 #include "compose.hpp"
+#include "dcpomatic_assert.h"
 #include "dcpomatic_socket.h"
 #include "exceptions.h"
 #include "image.h"
+#include "maths_util.h"
 #include "rect.h"
 #include "timer.h"
 #include "util.h"
diff --git a/src/lib/maths_util.cc b/src/lib/maths_util.cc
new file mode 100644 (file)
index 0000000..35e3879
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include <cmath>
+
+
+double
+db_to_linear (double db)
+{
+       return pow(10, db / 20);
+}
+
+
+double
+linear_to_db (double linear)
+{
+       return 20 * log10(linear);
+}
+
diff --git a/src/lib/maths_util.h b/src/lib/maths_util.h
new file mode 100644 (file)
index 0000000..8adefbb
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include <algorithm>
+
+
+#ifndef M_PI
+#define M_PI (3.14159265358979323846)
+#endif
+
+
+extern double db_to_linear (double db);
+extern double linear_to_db (double linear);
+
+
+template <class T>
+T clamp (T val, T minimum, T maximum)
+{
+       return std::max(std::min(val, maximum), minimum);
+}
+
index 6853048de02d31ef865c759df8ef99526328a041..abd051bedf65afdb0cbfd9ccfaa3b434a2635d37 100644 (file)
@@ -40,6 +40,7 @@
 #include "image_decoder.h"
 #include "job.h"
 #include "log.h"
+#include "maths_util.h"
 #include "piece.h"
 #include "player.h"
 #include "player_video.h"
index 6bcacf9f2bd3733dd09e1f2bafbdeeb100b8fb9e..eeaa4cd91e60ace733362002946cf674d40b6201 100644 (file)
@@ -1085,18 +1085,6 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::fun
        free (buffer);
 }
 
-double
-db_to_linear (double db)
-{
-       return pow(10, db / 20);
-}
-
-double
-linear_to_db (double linear)
-{
-       return 20 * log10(linear);
-}
-
 
 dcp::Size
 scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta)
index bd9eaf96e1664f5286dedd6d5683a48616187e46..fd11fffbda2b5f2fbc41169aa1da3f5c14094e11 100644 (file)
@@ -51,10 +51,6 @@ namespace dcp {
        class SoundAsset;
 }
 
-#ifndef M_PI
-#define M_PI (3.14159265358979323846)
-#endif
-
 /** The maximum number of audio channels that we can have in a DCP */
 #define MAX_DCP_AUDIO_CHANNELS 16
 /** Message broadcast to find possible encoding servers */
@@ -152,15 +148,4 @@ list_to_vector (std::list<T> v)
        return l;
 }
 
-extern double db_to_linear (double db);
-extern double linear_to_db (double linear);
-
-
-template <class T>
-T clamp (T val, T minimum, T maximum)
-{
-       return std::max(std::min(val, maximum), minimum);
-}
-
-
 #endif
index 914fc69f97bcee93e9a746e3067aac0ded6e251a..6d7e2330e5ebbba3788d531855a709d4c1ec7e65 100644 (file)
@@ -132,6 +132,7 @@ sources = """
           kdm_with_metadata.cc
           log.cc
           log_entry.cc
+          maths_util.cc
           mid_side_decoder.cc
           overlaps.cc
           pixel_quanta.cc
index 9e0d7a30fc197662d40357f313fea93f7f926082..c64f64e31eb4104ce612f9ca24cd98d3212b66f1 100644 (file)
@@ -18,6 +18,7 @@
 
 */
 
+
 #include "audio_dialog.h"
 #include "audio_plot.h"
 #include "check_box.h"
 #include "lib/audio_content.h"
 #include "lib/film.h"
 #include "lib/job_manager.h"
+#include "lib/maths_util.h"
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
 #include <iostream>
 
+
 using std::cout;
 using std::list;
 using std::make_shared;
@@ -48,6 +51,7 @@ using namespace dcpomatic;
 using namespace boost::placeholders;
 #endif
 
+
 /** @param parent Parent window.
  *  @param film Film we are using.
  *  @param content Content to analyse, or 0 to analyse all of the film's audio.
index fb9bd25447b4aba3ad9b01255ae5423d7e7389fb..2c0f17c0a5c6403d27895cd882ebe65db3b4d1a1 100644 (file)
 
 */
 
+
 #include "audio_gain_dialog.h"
 #include "wx_util.h"
-#include "lib/util.h"
-#include <cmath>
+#include "lib/maths_util.h"
 #include <wx/spinctrl.h>
+#include <cmath>
+
 
 AudioGainDialog::AudioGainDialog (wxWindow* parent, int c, int d, float v)
        : TableDialog (parent, _("Channel gain"), 3, 1, true)
index 7c12a16462d52eacad9e9e0e810c65d017ceb345..81fa1a70d722b58bbddfd5bec4412c0302773c05 100644 (file)
  */
 
 
+#include "audio_gain_dialog.h"
 #include "audio_mapping_view.h"
 #include "wx_util.h"
-#include "audio_gain_dialog.h"
 #include "lib/audio_mapping.h"
-#include "lib/util.h"
+#include "lib/maths_util.h"
 #include "lib/warnings.h"
 #include <dcp/locale_convert.h>
 #include <dcp/types.h>
@@ -43,13 +43,13 @@ DCPOMATIC_ENABLE_WARNINGS
 
 using std::cout;
 using std::list;
-using std::string;
-using std::min;
+using std::make_pair;
 using std::max;
-using std::vector;
+using std::min;
 using std::pair;
-using std::make_pair;
 using std::shared_ptr;
+using std::string;
+using std::vector;
 using boost::optional;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
index 75659aebdcd2087c227b4991709d5b21420c6d06..af030e9156af37525aa4ef70cd6fbee23f703758 100644 (file)
@@ -35,6 +35,7 @@
 #include "lib/job_manager.h"
 #include "lib/dcp_content.h"
 #include "lib/audio_content.h"
+#include "lib/maths_util.h"
 #include <wx/spinctrl.h>
 #include <iostream>
 
index 90a4aa91df39b5a5cc468ba8a3850b0b5f4b2ba4..e08e07e0505bb3f6ba4d246c5a4d39f72dd6c364 100644 (file)
 
 
 #include "audio_plot.h"
-#include "wx_util.h"
 #include "film_viewer.h"
+#include "wx_util.h"
 #include "lib/audio_decoder.h"
 #include "lib/audio_analysis.h"
 #include "lib/compose.hpp"
+#include "lib/maths_util.h"
 #include <wx/graphics.h>
 #include <boost/bind/bind.hpp>
-#include <iostream>
 #include <cfloat>
+#include <iostream>
 
 
 using std::cout;
-using std::vector;
 using std::list;
+using std::map;
 using std::max;
 using std::min;
-using std::map;
-using boost::bind;
-using boost::optional;
 using std::shared_ptr;
+using std::vector;
 using std::weak_ptr;
+using boost::bind;
+using boost::optional;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
 #endif