diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-04 22:37:31 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-04-04 22:37:31 +0200 |
| commit | cf2ed48d21ddbc32bda262064480e88e69dc031a (patch) | |
| tree | 039a981cebf24e1e7ca34478d35cd3c70b280bab /src/lib | |
| parent | 4b74bd9f359b9fe4f841cd9a361f3b2b24c2351e (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 | 12 | ||||
| -rw-r--r-- | src/lib/util.h | 15 | ||||
| -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 0f1cfece8..027510eca 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -31,11 +31,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 d0878efbd..297578866 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 6853048de..abd051bed 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 6bcacf9f2..eeaa4cd91 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -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) diff --git a/src/lib/util.h b/src/lib/util.h index bd9eaf96e..fd11fffbd 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 */ @@ -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 diff --git a/src/lib/wscript b/src/lib/wscript index 914fc69f9..6d7e2330e 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -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 |
