diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-24 22:26:59 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-01-25 19:44:56 +0100 |
| commit | 07befde2cbbad4d979631727fc35399164d0aa1c (patch) | |
| tree | fbc537ff6789d8aabe71e69b4055daf302527cd1 /src/lib | |
| parent | dadde92543ee5039d2dc869c698fcde7ffac5f4b (diff) | |
Cleanup: move some methods from util to maths_util.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_buffers.cc | 2 | ||||
| -rw-r--r-- | src/lib/audio_content.cc | 1 | ||||
| -rw-r--r-- | src/lib/hints.cc | 2 | ||||
| -rw-r--r-- | src/lib/image.cc | 2 | ||||
| -rw-r--r-- | src/lib/maths_util.cc | 37 | ||||
| -rw-r--r-- | src/lib/maths_util.h | 39 | ||||
| -rw-r--r-- | src/lib/player.cc | 1 | ||||
| -rw-r--r-- | src/lib/util.cc | 14 | ||||
| -rw-r--r-- | src/lib/util.h | 13 | ||||
| -rw-r--r-- | src/lib/wscript | 1 |
10 files changed, 83 insertions, 29 deletions
diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc index 9f91810e0..1d3598270 100644 --- a/src/lib/audio_buffers.cc +++ b/src/lib/audio_buffers.cc @@ -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> diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index f2510b494..32e713ff2 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -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> diff --git a/src/lib/hints.cc b/src/lib/hints.cc index 40b51e817..5523c96d5 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -30,11 +30,11 @@ #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> diff --git a/src/lib/image.cc b/src/lib/image.cc index 17bab64c7..2e1d3fbf5 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -25,9 +25,11 @@ #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 index 000000000..35e3879c4 --- /dev/null +++ b/src/lib/maths_util.cc @@ -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 index 000000000..8adefbbc4 --- /dev/null +++ b/src/lib/maths_util.h @@ -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); +} + diff --git a/src/lib/player.cc b/src/lib/player.cc index 5e24dd44f..9b2a86748 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -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" diff --git a/src/lib/util.cc b/src/lib/util.cc index 106a56541..1984ed476 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -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) { diff --git a/src/lib/util.h b/src/lib/util.h index 0f3351dbf..790feea05 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -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 diff --git a/src/lib/wscript b/src/lib/wscript index 871365766..17abb6f98 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -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 |
