summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-01-24 22:30:52 +0100
committerCarl Hetherington <cth@carlh.net>2022-01-25 19:44:56 +0100
commit9c8d2ed2e112596f7bb970d20f9240ec4519ec3e (patch)
tree17a3572aea8c28bc48af0c25055408336090e988
parentf471db4e8dc7f3dd1eb7a9cf4d8d11e7d340df65 (diff)
Cleanup: move some methods from util to memory_util
-rw-r--r--src/lib/ffmpeg.cc17
-rw-r--r--src/lib/ffmpeg_image_proxy.cc3
-rw-r--r--src/lib/image.cc2
-rw-r--r--src/lib/memory_util.cc40
-rw-r--r--src/lib/memory_util.h22
-rw-r--r--src/lib/util.cc11
-rw-r--r--src/lib/util.h1
-rw-r--r--src/lib/wscript1
8 files changed, 75 insertions, 22 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc
index 0f63ea172..a54b4fc01 100644
--- a/src/lib/ffmpeg.cc
+++ b/src/lib/ffmpeg.cc
@@ -19,18 +19,19 @@
*/
+#include "compose.hpp"
+#include "config.h"
+#include "dcpomatic_log.h"
+#include "digester.h"
+#include "exceptions.h"
#include "ffmpeg.h"
+#include "ffmpeg_audio_stream.h"
#include "ffmpeg_content.h"
+#include "ffmpeg_subtitle_stream.h"
#include "film.h"
-#include "exceptions.h"
-#include "util.h"
#include "log.h"
-#include "dcpomatic_log.h"
-#include "ffmpeg_subtitle_stream.h"
-#include "ffmpeg_audio_stream.h"
-#include "digester.h"
-#include "compose.hpp"
-#include "config.h"
+#include "memory_util.h"
+#include "util.h"
#include <dcp/raw_convert.h>
extern "C" {
#include <libavcodec/avcodec.h>
diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc
index 4b3c3084c..94385eabd 100644
--- a/src/lib/ffmpeg_image_proxy.cc
+++ b/src/lib/ffmpeg_image_proxy.cc
@@ -21,11 +21,12 @@
#include "compose.hpp"
#include "cross.h"
+#include "dcpomatic_assert.h"
#include "dcpomatic_socket.h"
#include "exceptions.h"
#include "ffmpeg_image_proxy.h"
#include "image.h"
-#include "util.h"
+#include "memory_util.h"
#include "warnings.h"
#include <dcp/raw_convert.h>
DCPOMATIC_DISABLE_WARNINGS
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 20aece3e8..7962802de 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -30,9 +30,9 @@
#include "exceptions.h"
#include "image.h"
#include "maths_util.h"
+#include "memory_util.h"
#include "rect.h"
#include "timer.h"
-#include "util.h"
#include "warnings.h"
#include <dcp/rgb_xyz.h>
#include <dcp/transfer_function.h>
diff --git a/src/lib/memory_util.cc b/src/lib/memory_util.cc
new file mode 100644
index 000000000..95d8275b1
--- /dev/null
+++ b/src/lib/memory_util.cc
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2012-2022 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 "warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
+extern "C" {
+#include <libavutil/avutil.h>
+}
+DCPOMATIC_ENABLE_WARNINGS
+#include <stdexcept>
+
+
+void *
+wrapped_av_malloc (size_t s)
+{
+ auto p = av_malloc (s);
+ if (!p) {
+ throw std::bad_alloc ();
+ }
+ return p;
+}
+
diff --git a/src/lib/memory_util.h b/src/lib/memory_util.h
new file mode 100644
index 000000000..eccc4a857
--- /dev/null
+++ b/src/lib/memory_util.h
@@ -0,0 +1,22 @@
+/*
+ Copyright (C) 2012-2022 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/>.
+
+*/
+
+
+extern void* wrapped_av_malloc (size_t);
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 2767068d4..a6a26ccf7 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -680,17 +680,6 @@ fit_ratio_within (float ratio, dcp::Size full_frame)
}
-void *
-wrapped_av_malloc (size_t s)
-{
- auto p = av_malloc (s);
- if (!p) {
- throw bad_alloc ();
- }
- return p;
-}
-
-
map<string, string>
split_get_request (string url)
{
diff --git a/src/lib/util.h b/src/lib/util.h
index a36903437..dbcb9b81e 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -102,7 +102,6 @@ extern boost::filesystem::path mo_path ();
#endif
extern std::string tidy_for_filename (std::string);
extern dcp::Size fit_ratio_within (float ratio, dcp::Size);
-extern void* wrapped_av_malloc (size_t);
extern void set_backtrace_file (boost::filesystem::path);
extern std::map<std::string, std::string> split_get_request (std::string url);
extern std::string video_asset_filename (std::shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
diff --git a/src/lib/wscript b/src/lib/wscript
index 17abb6f98..217bc2f00 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -139,6 +139,7 @@ sources = """
log_entry.cc
make_dcp.cc
maths_util.cc
+ memory_util.cc
mid_side_decoder.cc
overlaps.cc
pixel_quanta.cc