Cleanup: move some methods from util to maths_util.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Jan 2022 21:26:59 +0000 (22:26 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 Jan 2022 18:44:56 +0000 (19:44 +0100)
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 40b51e81791544e70a6bdba7d7466dcfc605d4da..5523c96d56d1df4b5d5ecfb3ae753b44a1a6e1c4 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 17bab64c7ced62330eae5ad53931334f4739ad81..2e1d3fbf58bffb7724861bfe2f5ed0d2f1ea9996 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 5e24dd44f5954ca7c3daa20f672ecfdee526d32a..9b2a8674894988ded6ade6836df0f2d63a7fa643 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 106a565413a965e838688b7d83af58fe8a6a6335..1984ed4766e58473285ae0d41d2fba85d4d51de7 100644 (file)
@@ -1141,20 +1141,6 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::fun
 }
 
 
-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 0f3351dbf864e68c134cf618699af498a4beb227..790feea05242a08a7b4df65a7770fe92bfbe7b62 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 */
@@ -130,15 +126,6 @@ extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm);
 extern boost::filesystem::path default_font_file ();
 extern std::string to_upper (std::string s);
 extern void start_of_thread (std::string name);
-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 87136576601a7815172054a8c6f389c53cbd75ea..17abb6f989e1366af12ac7a891151f2362b4bfce 100644 (file)
@@ -138,6 +138,7 @@ sources = """
           log.cc
           log_entry.cc
           make_dcp.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..3c0212331aaacad985542abb73d4b7a5c8fd94e2 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::vector;
 using std::shared_ptr;
 using std::weak_ptr;
+using boost::bind;
+using boost::optional;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
 #endif