Cleanup: move some methods from util to memory_util
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Jan 2022 21:30:52 +0000 (22:30 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 Jan 2022 18:44:56 +0000 (19:44 +0100)
src/lib/ffmpeg.cc
src/lib/ffmpeg_image_proxy.cc
src/lib/image.cc
src/lib/memory_util.cc [new file with mode: 0644]
src/lib/memory_util.h [new file with mode: 0644]
src/lib/util.cc
src/lib/util.h
src/lib/wscript

index 0f63ea1727ee5374ce3d41ecd3c96a9f874386cf..a54b4fc017def20934c831d5aca7ce548c50144b 100644 (file)
 */
 
 
+#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>
index 4b3c3084c7f2db4a71c529f88b23f8b7c1e1e7f6..94385eabdedf5fbaa8e371530bbd7c2cd0350714 100644 (file)
 
 #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
index 20aece3e8e07818fdc8c2aefd07fdbbce5c085a0..7962802de8047cb962ab19d053583fbcd8673c51 100644 (file)
@@ -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 (file)
index 0000000..95d8275
--- /dev/null
@@ -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 (file)
index 0000000..eccc4a8
--- /dev/null
@@ -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);
index 2767068d4ddb6d41cf477b32a9f94b5b73cf52ca..a6a26ccf7e578afc538bcf3ae913044224965ad4 100644 (file)
@@ -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)
 {
index a369034374a5c38d62205f0e974e5d614f3725af..dbcb9b81e4be48d168e21b025955a34d2ec56136 100644 (file)
@@ -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);
index 17abb6f989e1366af12ac7a891151f2362b4bfce..217bc2f0063b27369ddbdbcffc6046f7ac548103 100644 (file)
@@ -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