Rename Data -> ArrayData.
authorCarl Hetherington <cth@carlh.net>
Thu, 29 Oct 2020 23:50:57 +0000 (00:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 1 Nov 2020 23:12:56 +0000 (00:12 +0100)
27 files changed:
benchmark/j2k_transcode.cc
src/array_data.cc [new file with mode: 0644]
src/array_data.h [new file with mode: 0644]
src/data.cc [deleted file]
src/data.h [deleted file]
src/interop_subtitle_asset.cc
src/j2k.cc
src/j2k.h
src/smpte_subtitle_asset.cc
src/subtitle_asset.cc
src/subtitle_asset.h
src/subtitle_asset_internal.h
src/subtitle_image.cc
src/subtitle_image.h
src/util.cc
src/util.h
src/verify.cc
src/wscript
test/frame_info_hash_test.cc
test/make_digest_test.cc
test/read_interop_subtitle_test.cc
test/read_smpte_subtitle_test.cc
test/test.cc
test/test.h
test/verify_test.cc
test/write_subtitle_test.cc
tools/dcpdumpsub.cc

index 1a814b69a765229f568f240f9505a217461b9695..7bdf357d3f99a73c6d42f08849c9cbaff4919a31 100644 (file)
@@ -31,7 +31,8 @@
     files in the program, then also delete it here.
 */
 
-#include "data.h"
+
+#include "array_data.h"
 #include "util.h"
 #include "version.h"
 #include "j2k.h"
@@ -87,12 +88,12 @@ main (int argc, char* argv[])
        int const count = 100;
        int const j2k_bandwidth = 100000000;
 
-       dcp::Data j2k (boost::filesystem::path (argv[1]) / "thx.j2c");
+       dcp::ArrayData j2k (boost::filesystem::path (argv[1]) / "thx.j2c");
 
        Timer decompress;
        Timer compress;
 
-       dcp::Data recomp;
+       dcp::ArrayData recomp;
        for (int i = 0; i < count; ++i) {
                decompress.start ();
                shared_ptr<dcp::OpenJPEGImage> xyz = dcp::decompress_j2k (j2k, 0);
diff --git a/src/array_data.cc b/src/array_data.cc
new file mode 100644 (file)
index 0000000..9d8473b
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+    Copyright (C) 2015-2020 Carl Hetherington <cth@carlh.net>
+
+    This file is part of libdcp.
+
+    libdcp 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.
+
+    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
+
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of portions of this program with the
+    OpenSSL library under certain conditions as described in each
+    individual source file, and distribute linked combinations
+    including the two.
+
+    You must obey the GNU General Public License in all respects
+    for all of the code used other than OpenSSL.  If you modify
+    file(s) with this exception, you may extend this exception to your
+    version of the file(s), but you are not obligated to do so.  If you
+    do not wish to do so, delete this exception statement from your
+    version.  If you delete this exception statement from all source
+    files in the program, then also delete it here.
+*/
+
+#include "array_data.h"
+#include "util.h"
+#include "exceptions.h"
+#include <cstdio>
+#include <cerrno>
+
+using boost::shared_array;
+using namespace dcp;
+
+ArrayData::ArrayData ()
+       : _size (0)
+{
+
+}
+
+ArrayData::ArrayData (int size)
+       : _data (new uint8_t[size])
+       , _size (size)
+{
+
+}
+
+ArrayData::ArrayData (uint8_t const * data, int size)
+       : _data (new uint8_t[size])
+       , _size (size)
+{
+       memcpy (_data.get(), data, size);
+}
+
+ArrayData::ArrayData (shared_array<uint8_t> data, int size)
+       : _data (data)
+       , _size (size)
+{
+
+}
+
+ArrayData::ArrayData (boost::filesystem::path file)
+{
+       _size = boost::filesystem::file_size (file);
+       _data.reset (new uint8_t[_size]);
+
+       FILE* f = fopen_boost (file, "rb");
+       if (!f) {
+               throw FileError ("could not open file for reading", file, errno);
+       }
+
+       size_t const r = fread (_data.get(), 1, _size, f);
+       if (r != size_t (_size)) {
+               fclose (f);
+               throw FileError ("could not read from file", file, errno);
+       }
+
+       fclose (f);
+}
+
+void
+ArrayData::write (boost::filesystem::path file) const
+{
+       FILE* f = fopen_boost (file, "wb");
+       if (!f) {
+               throw FileError ("could not write to file", file, errno);
+       }
+       size_t const r = fwrite (_data.get(), 1, _size, f);
+       if (r != size_t (_size)) {
+               fclose (f);
+               throw FileError ("could not write to file", file, errno);
+       }
+       fclose (f);
+}
+
+void
+ArrayData::write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const
+{
+       write (temp);
+       boost::filesystem::rename (temp, final);
+}
+
+bool
+dcp::operator== (ArrayData const & a, ArrayData const & b)
+{
+       return (a.size() == b.size() && memcmp (a.data().get(), b.data().get(), a.size()) == 0);
+}
diff --git a/src/array_data.h b/src/array_data.h
new file mode 100644 (file)
index 0000000..06ccec2
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+    Copyright (C) 2015-2020 Carl Hetherington <cth@carlh.net>
+
+    This file is part of libdcp.
+
+    libdcp 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.
+
+    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
+
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of portions of this program with the
+    OpenSSL library under certain conditions as described in each
+    individual source file, and distribute linked combinations
+    including the two.
+
+    You must obey the GNU General Public License in all respects
+    for all of the code used other than OpenSSL.  If you modify
+    file(s) with this exception, you may extend this exception to your
+    version of the file(s), but you are not obligated to do so.  If you
+    do not wish to do so, delete this exception statement from your
+    version.  If you delete this exception statement from all source
+    files in the program, then also delete it here.
+*/
+
+#ifndef LIBDCP_ARRAY_DATA_H
+#define LIBDCP_ARRAY_DATA_H
+
+#include <boost/shared_array.hpp>
+#include <boost/filesystem.hpp>
+#include <stdint.h>
+
+namespace dcp {
+
+class ArrayData
+{
+public:
+       ArrayData ();
+       explicit ArrayData (int size);
+       ArrayData (uint8_t const * data, int size);
+       ArrayData (boost::shared_array<uint8_t> data, int size);
+       explicit ArrayData (boost::filesystem::path file);
+
+       virtual ~ArrayData () {}
+
+       void write (boost::filesystem::path file) const;
+       void write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const;
+
+       boost::shared_array<uint8_t> data () const {
+               return _data;
+       }
+
+       int size () const {
+               return _size;
+       }
+
+       void set_size (int s) {
+               _size = s;
+       }
+
+private:
+       boost::shared_array<uint8_t> _data;
+       /** amount of `valid' data in _data; the array may be larger */
+       int _size;
+};
+
+bool operator==(ArrayData const & a, ArrayData const & b);
+
+}
+
+#endif
diff --git a/src/data.cc b/src/data.cc
deleted file mode 100644 (file)
index aed8a4d..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp 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.
-
-    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    In addition, as a special exception, the copyright holders give
-    permission to link the code of portions of this program with the
-    OpenSSL library under certain conditions as described in each
-    individual source file, and distribute linked combinations
-    including the two.
-
-    You must obey the GNU General Public License in all respects
-    for all of the code used other than OpenSSL.  If you modify
-    file(s) with this exception, you may extend this exception to your
-    version of the file(s), but you are not obligated to do so.  If you
-    do not wish to do so, delete this exception statement from your
-    version.  If you delete this exception statement from all source
-    files in the program, then also delete it here.
-*/
-
-#include "data.h"
-#include "util.h"
-#include "exceptions.h"
-#include <cstdio>
-#include <cerrno>
-
-using boost::shared_array;
-using namespace dcp;
-
-Data::Data ()
-       : _size (0)
-{
-
-}
-
-Data::Data (int size)
-       : _data (new uint8_t[size])
-       , _size (size)
-{
-
-}
-
-Data::Data (uint8_t const * data, int size)
-       : _data (new uint8_t[size])
-       , _size (size)
-{
-       memcpy (_data.get(), data, size);
-}
-
-Data::Data (shared_array<uint8_t> data, int size)
-       : _data (data)
-       , _size (size)
-{
-
-}
-
-Data::Data (boost::filesystem::path file)
-{
-       _size = boost::filesystem::file_size (file);
-       _data.reset (new uint8_t[_size]);
-
-       FILE* f = fopen_boost (file, "rb");
-       if (!f) {
-               throw FileError ("could not open file for reading", file, errno);
-       }
-
-       size_t const r = fread (_data.get(), 1, _size, f);
-       if (r != size_t (_size)) {
-               fclose (f);
-               throw FileError ("could not read from file", file, errno);
-       }
-
-       fclose (f);
-}
-
-void
-Data::write (boost::filesystem::path file) const
-{
-       FILE* f = fopen_boost (file, "wb");
-       if (!f) {
-               throw FileError ("could not write to file", file, errno);
-       }
-       size_t const r = fwrite (_data.get(), 1, _size, f);
-       if (r != size_t (_size)) {
-               fclose (f);
-               throw FileError ("could not write to file", file, errno);
-       }
-       fclose (f);
-}
-
-void
-Data::write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const
-{
-       write (temp);
-       boost::filesystem::rename (temp, final);
-}
-
-bool
-dcp::operator== (Data const & a, Data const & b)
-{
-       return (a.size() == b.size() && memcmp (a.data().get(), b.data().get(), a.size()) == 0);
-}
diff --git a/src/data.h b/src/data.h
deleted file mode 100644 (file)
index fd6eb22..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp 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.
-
-    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    In addition, as a special exception, the copyright holders give
-    permission to link the code of portions of this program with the
-    OpenSSL library under certain conditions as described in each
-    individual source file, and distribute linked combinations
-    including the two.
-
-    You must obey the GNU General Public License in all respects
-    for all of the code used other than OpenSSL.  If you modify
-    file(s) with this exception, you may extend this exception to your
-    version of the file(s), but you are not obligated to do so.  If you
-    do not wish to do so, delete this exception statement from your
-    version.  If you delete this exception statement from all source
-    files in the program, then also delete it here.
-*/
-
-#ifndef LIBDCP_DATA_H
-#define LIBDCP_DATA_H
-
-#include <boost/shared_array.hpp>
-#include <boost/filesystem.hpp>
-#include <stdint.h>
-
-namespace dcp {
-
-class Data
-{
-public:
-       Data ();
-       explicit Data (int size);
-       Data (uint8_t const * data, int size);
-       Data (boost::shared_array<uint8_t> data, int size);
-       explicit Data (boost::filesystem::path file);
-
-       virtual ~Data () {}
-
-       void write (boost::filesystem::path file) const;
-       void write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const;
-
-       boost::shared_array<uint8_t> data () const {
-               return _data;
-       }
-
-       int size () const {
-               return _size;
-       }
-
-       void set_size (int s) {
-               _size = s;
-       }
-
-private:
-       boost::shared_array<uint8_t> _data;
-       /** amount of `valid' data in _data; the array may be larger */
-       int _size;
-};
-
-bool operator==(Data const & a, Data const & b);
-
-}
-
-#endif
index f7e3896528cafc8fadd184b39d5a4789cae92c61..316fb08a7c301ce8f8f0bb5104a1e9f73fe480dc 100644 (file)
@@ -271,7 +271,7 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path r
        BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
                shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
                if (im) {
-                       Data png_image = im->png_image ();
+                       ArrayData png_image = im->png_image ();
                        pkl->add_asset (im->id(), optional<string>(), make_digest(png_image), png_image.size(), "image/png");
                }
        }
index fc60acfa54ca197f4042a29451f1eb41cd21a6a5..46359d90958e3c91097785749707ac4ac1af9f0c 100644 (file)
     files in the program, then also delete it here.
 */
 
+
+#include "array_data.h"
 #include "j2k.h"
 #include "exceptions.h"
 #include "openjpeg_image.h"
-#include "data.h"
 #include "dcp_assert.h"
 #include "compose.hpp"
 #include <openjpeg.h>
@@ -49,7 +50,7 @@ using boost::shared_array;
 using namespace dcp;
 
 shared_ptr<dcp::OpenJPEGImage>
-dcp::decompress_j2k (Data data, int reduce)
+dcp::decompress_j2k (ArrayData data, int reduce)
 {
        return dcp::decompress_j2k (data.data().get(), data.size(), reduce);
 }
@@ -242,13 +243,13 @@ public:
                return OPJ_TRUE;
        }
 
-       Data data () const
+       ArrayData data () const
        {
                return _data;
        }
 
 private:
-       Data _data;
+       ArrayData _data;
        OPJ_SIZE_T _offset;
 };
 
@@ -273,7 +274,7 @@ seek_function (OPJ_OFF_T nb_bytes, void* data)
 /** @xyz Picture to compress.  Parts of xyz's data WILL BE OVERWRITTEN by libopenjpeg so xyz cannot be re-used
  *  after this call; see opj_j2k_encode where if l_reuse_data is false it will set l_tilec->data = l_img_comp->data.
  */
-Data
+ArrayData
 dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frames_per_second, bool threed, bool fourk, string comment)
 {
        /* get a J2K compressor handle */
@@ -344,7 +345,7 @@ dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frame
                throw MiscError ("could not end JPEG2000 encoding");
        }
 
-       Data enc (buffer->data ());
+       ArrayData enc (buffer->data ());
 
        opj_stream_destroy (stream);
        opj_destroy_codec (encoder);
@@ -355,7 +356,7 @@ dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frame
 #endif
 
 #ifdef LIBDCP_OPENJPEG1
-Data
+ArrayData
 dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frames_per_second, bool threed, bool fourk)
 {
        /* Set the max image and component sizes based on frame_rate */
@@ -462,7 +463,7 @@ dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frame
                throw MiscError ("JPEG2000 encoding failed");
        }
 
-       Data enc (cio->buffer, cio_tell (cio));
+       ArrayData enc (cio->buffer, cio_tell (cio));
 
        opj_cio_close (cio);
        free (parameters.cp_comment);
index 9ca5147b77574d99c2a2311eafd1b3281c9508c8..fcaa28e28c28a7903c886c4f64077df7599b13dc 100644 (file)
--- a/src/j2k.h
+++ b/src/j2k.h
@@ -31,7 +31,8 @@
     files in the program, then also delete it here.
 */
 
-#include "data.h"
+
+#include "array_data.h"
 #include <boost/shared_ptr.hpp>
 #include <stdint.h>
 
@@ -40,7 +41,7 @@ namespace dcp {
 class OpenJPEGImage;
 
 extern boost::shared_ptr<OpenJPEGImage> decompress_j2k (uint8_t* data, int64_t size, int reduce);
-extern boost::shared_ptr<OpenJPEGImage> decompress_j2k (Data data, int reduce);
-extern Data compress_j2k (boost::shared_ptr<const OpenJPEGImage>, int bandwith, int frames_per_second, bool threed, bool fourk, std::string comment = "libdcp");
+extern boost::shared_ptr<OpenJPEGImage> decompress_j2k (ArrayData data, int reduce);
+extern ArrayData compress_j2k (boost::shared_ptr<const OpenJPEGImage>, int bandwith, int frames_per_second, bool threed, bool fourk, std::string comment = "libdcp");
 
 }
index cf0ed6c0c38616f8f0ad16c733f6358b795d3dad..c9545052fe67e0ed40364e044ff0b2a7f26b6219 100644 (file)
@@ -227,7 +227,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader>
                        }
 
                        if (j != _load_font_nodes.end ()) {
-                               _fonts.push_back (Font ((*j)->id, (*j)->urn, Data (data, buffer.Size ())));
+                               _fonts.push_back (Font ((*j)->id, (*j)->urn, ArrayData (data, buffer.Size ())));
                        }
                        break;
                }
@@ -239,7 +239,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader>
                        }
 
                        if (j != _subtitles.end()) {
-                               dynamic_pointer_cast<SubtitleImage>(*j)->set_png_image (Data(data, buffer.Size()));
+                               dynamic_pointer_cast<SubtitleImage>(*j)->set_png_image (ArrayData(data, buffer.Size()));
                        }
                        break;
                }
index 02350f00d681d18edf9e9c2afd9985048feb17d3..c6d2e7908f81113e52b736723d5048709f0a4c20 100644 (file)
@@ -390,7 +390,7 @@ SubtitleAsset::maybe_add_subtitle (string text, list<ParseState> const & parse_s
                _subtitles.push_back (
                        shared_ptr<Subtitle> (
                                new SubtitleImage (
-                                       Data (),
+                                       ArrayData (),
                                        standard == INTEROP ? text.substr(0, text.size() - 4) : text,
                                        ps.in.get(),
                                        ps.out.get(),
@@ -647,10 +647,10 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, S
        root->write_xml (xml_root, context);
 }
 
-map<string, Data>
+map<string, ArrayData>
 SubtitleAsset::font_data () const
 {
-       map<string, Data> out;
+       map<string, ArrayData> out;
        BOOST_FOREACH (Font const & i, _fonts) {
                out[i.load_id] = i.data;
        }
index b66e88b10706379f1fe84cfe47e3687c3bba5c56..063a2dfdf64ee6ea2d784d4f9f45f66a12e047b2 100644 (file)
 #ifndef LIBDCP_SUBTITLE_ASSET_H
 #define LIBDCP_SUBTITLE_ASSET_H
 
+
+#include "array_data.h"
 #include "asset.h"
 #include "dcp_time.h"
 #include "subtitle_string.h"
-#include "data.h"
 #include <libcxml/cxml.h>
 #include <boost/shared_array.hpp>
 #include <map>
@@ -94,7 +95,7 @@ public:
 
        virtual void add (boost::shared_ptr<Subtitle>);
        virtual void add_font (std::string id, boost::filesystem::path file) = 0;
-       std::map<std::string, Data> font_data () const;
+       std::map<std::string, ArrayData> font_data () const;
        std::map<std::string, boost::filesystem::path> font_filenames () const;
 
        virtual void write (boost::filesystem::path) const = 0;
@@ -163,7 +164,7 @@ protected:
                        , file (file_)
                {}
 
-               Font (std::string load_id_, std::string uuid_, Data data_)
+               Font (std::string load_id_, std::string uuid_, ArrayData data_)
                        : load_id (load_id_)
                        , uuid (uuid_)
                        , data (data_)
@@ -171,7 +172,7 @@ protected:
 
                std::string load_id;
                std::string uuid;
-               Data data;
+               ArrayData data;
                /** .ttf file that this data was last written to, if applicable */
                mutable boost::optional<boost::filesystem::path> file;
        };
index 366123c51afaaa8a4f9f1068fd22db51459109fd..e5c8e141ad165ad1bd02fd4e176fa143b2840d5e 100644 (file)
 #ifndef LIBDCP_SUBTITLE_ASSET_INTERNAL_H
 #define LIBDCP_SUBTITLE_ASSET_INTERNAL_H
 
+
+#include "array_data.h"
 #include "raw_convert.h"
 #include "types.h"
 #include "dcp_time.h"
-#include "data.h"
 #include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
 
@@ -167,7 +168,7 @@ private:
 class Image : public Part
 {
 public:
-       Image (boost::shared_ptr<Part> parent, std::string id, Data png_data, HAlign h_align, float h_position, VAlign v_align, float v_position)
+       Image (boost::shared_ptr<Part> parent, std::string id, ArrayData png_data, HAlign h_align, float h_position, VAlign v_align, float v_position)
                : Part (parent)
                , _png_data (png_data)
                , _id (id)
@@ -180,7 +181,7 @@ public:
        xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const;
 
 private:
-       Data _png_data;
+       ArrayData _png_data;
        std::string _id; ///< the ID of this image
        HAlign _h_align;
        float _h_position;
index e1f123bc916933f92ceaea1797847fbfbdf71923..d8215850784e6abb1c1255165e7fcd3bdf6b2dc5 100644 (file)
@@ -39,7 +39,7 @@ using std::string;
 using namespace dcp;
 
 SubtitleImage::SubtitleImage (
-       Data png_image,
+       ArrayData png_image,
        Time in,
        Time out,
        float h_position,
@@ -57,7 +57,7 @@ SubtitleImage::SubtitleImage (
 }
 
 SubtitleImage::SubtitleImage (
-       Data png_image,
+       ArrayData png_image,
        string id,
        Time in,
        Time out,
@@ -79,7 +79,7 @@ void
 SubtitleImage::read_png_file (boost::filesystem::path file)
 {
        _file = file;
-       _png_image = Data (file);
+       _png_image = ArrayData (file);
 }
 
 void
index 3c4b3fe8b7a07e193483036a281eeea6ebb864a1..76c347653c1626c602c273d79f5e90deb0988ede 100644 (file)
 #ifndef LIBDCP_SUBTITLE_IMAGE_H
 #define LIBDCP_SUBTITLE_IMAGE_H
 
+
+#include "array_data.h"
 #include "types.h"
 #include "subtitle.h"
-#include "data.h"
 #include "dcp_time.h"
 #include <boost/optional.hpp>
 #include <string>
@@ -54,7 +55,7 @@ class SubtitleImage : public Subtitle
 {
 public:
        SubtitleImage (
-               Data png_image,
+               ArrayData png_image,
                Time in,
                Time out,
                float h_position,
@@ -66,7 +67,7 @@ public:
                );
 
        SubtitleImage (
-               Data png_image,
+               ArrayData png_image,
                std::string id,
                Time in,
                Time out,
@@ -78,11 +79,11 @@ public:
                Time fade_down_time
                );
 
-       Data png_image () const {
+       ArrayData png_image () const {
                return _png_image;
        }
 
-       void set_png_image (Data png) {
+       void set_png_image (ArrayData png) {
                _png_image = png;
        }
 
@@ -99,7 +100,7 @@ public:
        }
 
 private:
-       Data _png_image;
+       ArrayData _png_image;
        std::string _id;
        mutable boost::optional<boost::filesystem::path> _file;
 };
index 211f03f8ccda87742a7532c1ad03368026bcb555..b62def07f9e1d55d8a5b79a37f5ca04ad7937634 100644 (file)
@@ -98,7 +98,7 @@ dcp::make_uuid ()
 }
 
 string
-dcp::make_digest (Data data)
+dcp::make_digest (ArrayData data)
 {
        SHA_CTX sha;
        SHA1_Init (&sha);
index 07e4f782f58393a2acacda0480d14d5442914512..523794e40ca955c98a7563b11b8a7dfaf8eea7ac 100644 (file)
@@ -38,8 +38,9 @@
  *  @brief Utility methods.
  */
 
+
+#include "array_data.h"
 #include "types.h"
-#include "data.h"
 #include "local_time.h"
 #include <asdcp/KM_log.h>
 #include <boost/shared_ptr.hpp>
@@ -64,7 +65,7 @@ class OpenJPEGImage;
 
 extern std::string make_uuid ();
 extern std::string make_digest (boost::filesystem::path filename, boost::function<void (float)>);
-extern std::string make_digest (Data data);
+extern std::string make_digest (ArrayData data);
 extern bool empty_or_white_space (std::string s);
 extern bool ids_equal (std::string a, std::string b);
 extern std::string remove_urn_uuid (std::string raw);
index aad6952f6c9b06575a7d8dc9181a4403a8e42ff5..55da95b6e9efeb29a11b549c058fd482e0c1e4b4 100644 (file)
@@ -598,7 +598,7 @@ dcp::verify (
                        /* Check that the CPL's hash corresponds to the PKL */
                        BOOST_FOREACH (shared_ptr<PKL> i, dcp->pkls()) {
                                optional<string> h = i->hash(cpl->id());
-                               if (h && make_digest(Data(*cpl->file())) != *h) {
+                               if (h && make_digest(ArrayData(*cpl->file())) != *h) {
                                        notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::CPL_HASH_INCORRECT));
                                }
                        }
index 38aa784c6cb7da31a9d753a6efc0cd5dd0571d97..85d4a6cb23e79681882b8b14a80cbf20399f997d 100644 (file)
@@ -1,5 +1,5 @@
 #
-#    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+#    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@ from waflib import TaskGen
 
 def build(bld):
     source = """
+             array_data.cc
              asset.cc
              asset_factory.cc
              asset_writer.cc
@@ -46,7 +47,6 @@ def build(bld):
              colour_conversion.cc
              combine.cc
              cpl.cc
-             data.cc
              dcp.cc
              dcp_time.cc
              decrypted_kdm.cc
@@ -113,6 +113,7 @@ def build(bld):
              """
 
     headers = """
+              array_data.h
               asset.h
               asset_reader.h
               asset_writer.h
@@ -131,7 +132,6 @@ def build(bld):
               dcp.h
               dcp_assert.h
               dcp_time.h
-              data.h
               decrypted_kdm.h
               decrypted_kdm_key.h
               encrypted_kdm.h
index ed440af5a5024016d65672c1ef4ba4f378e14aef..3070ecd633a043b12b3d1825f120e3c305fe1d68 100644 (file)
@@ -50,7 +50,7 @@ check (unsigned int* seed, shared_ptr<dcp::PictureAssetWriter> writer, string ha
                }
        }
 
-       dcp::Data data = dcp::compress_j2k (xyz, 100000000, 24, false, false);
+       dcp::ArrayData data = dcp::compress_j2k (xyz, 100000000, 24, false, false);
 
        dcp::FrameInfo info = writer->write (data.data().get(), data.size());
        BOOST_CHECK_EQUAL (info.hash, hash);
index ec54c93c87ccf0f2197b48dcd45e16bf7444b2fc..11c410d0ebb3c140b785352b9d80bc43cdf91739 100644 (file)
@@ -31,7 +31,8 @@
     files in the program, then also delete it here.
 */
 
-#include "data.h"
+
+#include "array_data.h"
 #include "util.h"
 #include <boost/bind.hpp>
 #include <boost/test/unit_test.hpp>
@@ -48,7 +49,7 @@ BOOST_AUTO_TEST_CASE (make_digest_test)
        /* Make a big file with some random data */
        srand (1);
        int const N = 256 * 1024 * 1024;
-       dcp::Data data (N);
+       dcp::ArrayData data (N);
        uint8_t* p = data.data().get();
        for (int i = 0; i < N; ++i) {
                *p++ = rand() & 0xff;
index 19d1cad804b975501a07f0a1b71f5776ea8d6fa3..2860a725f6ef0739e6111bb776243c5207701877 100644 (file)
@@ -620,5 +620,5 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test3)
        BOOST_REQUIRE_EQUAL (subs.subtitles().size(), 1);
        shared_ptr<dcp::SubtitleImage> si = dynamic_pointer_cast<dcp::SubtitleImage>(subs.subtitles().front());
        BOOST_REQUIRE (si);
-       BOOST_CHECK (si->png_image() == dcp::Data("test/data/sub.png"));
+       BOOST_CHECK (si->png_image() == dcp::ArrayData("test/data/sub.png"));
 }
index ca08e117fc13d9d5e5d0ac4e1307017847714417..9cf1451dae633c1b414ae458ac4ac775447a7cb3 100644 (file)
@@ -129,5 +129,5 @@ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test3)
        BOOST_REQUIRE_EQUAL (subs.subtitles().size(), 1);
        shared_ptr<dcp::SubtitleImage> si = dynamic_pointer_cast<dcp::SubtitleImage>(subs.subtitles().front());
        BOOST_REQUIRE (si);
-       BOOST_CHECK (si->png_image() == dcp::Data("test/data/sub.png"));
+       BOOST_CHECK (si->png_image() == dcp::ArrayData("test/data/sub.png"));
 }
index 25d7726dbe6d28d4d77ebe66ead1b31ab3dfb44b..245dd91c629753a58288f180a2c55e4a20295969 100644 (file)
@@ -344,7 +344,7 @@ make_simple_with_interop_subs (boost::filesystem::path path)
        subs->add (simple_subtitle());
 
        boost::filesystem::create_directory (path / "subs");
-       dcp::Data data(4096);
+       dcp::ArrayData data(4096);
        data.write (path / "subs" / "font.ttf");
        subs->add_font ("afont", path / "subs" / "font.ttf");
        subs->write (path / "subs" / "subs.xml");
@@ -364,7 +364,7 @@ make_simple_with_smpte_subs (boost::filesystem::path path)
        shared_ptr<dcp::SMPTESubtitleAsset> subs(new dcp::SMPTESubtitleAsset());
        subs->add (simple_subtitle());
 
-       dcp::Data data(4096);
+       dcp::ArrayData data(4096);
        subs->write (path / "subs.mxf");
 
        shared_ptr<dcp::ReelSubtitleAsset> reel_subs(new dcp::ReelSubtitleAsset(subs, dcp::Fraction(24, 1), 240, 0));
@@ -422,7 +422,7 @@ shared_ptr<dcp::ReelAsset>
 black_picture_asset (boost::filesystem::path dir, int frames)
 {
        shared_ptr<dcp::OpenJPEGImage> image = black_image ();
-       dcp::Data frame = dcp::compress_j2k (image, 100000000, 24, false, false);
+       dcp::ArrayData frame = dcp::compress_j2k (image, 100000000, 24, false, false);
        BOOST_REQUIRE (frame.size() < 230000000 / (24 * 8));
 
        shared_ptr<dcp::MonoPictureAsset> asset(new dcp::MonoPictureAsset(dcp::Fraction(24, 1), dcp::SMPTE));
index 9009a58bcdcbdc7388a111561bee076e6a6c2a5e..ea697e4000260ec3f09909d70cff2a4ae052a9af 100644 (file)
@@ -19,7 +19,6 @@
 
 
 #include "cpl.h"
-#include "data.h"
 #include "dcp.h"
 #include "reel.h"
 #include "reel_subtitle_asset.h"
index 645393a0f6fba1616e5874425e9aa5d2cc1d98c5..3e2a665fb79455ae72d4b46c65106ed59b79b435 100644 (file)
@@ -509,7 +509,7 @@ BOOST_AUTO_TEST_CASE (verify_test14)
 
 static
 void
-dcp_from_frame (dcp::Data const& frame, boost::filesystem::path dir)
+dcp_from_frame (dcp::ArrayData const& frame, boost::filesystem::path dir)
 {
        shared_ptr<dcp::MonoPictureAsset> asset(new dcp::MonoPictureAsset(dcp::Fraction(24, 1), dcp::SMPTE));
        boost::filesystem::create_directories (dir);
@@ -537,11 +537,11 @@ BOOST_AUTO_TEST_CASE (verify_test15)
 
        /* Compress a black image */
        shared_ptr<dcp::OpenJPEGImage> image = black_image ();
-       dcp::Data frame = dcp::compress_j2k (image, 100000000, 24, false, false);
+       dcp::ArrayData frame = dcp::compress_j2k (image, 100000000, 24, false, false);
        BOOST_REQUIRE (frame.size() < too_big);
 
        /* Place it in a bigger block with some zero padding at the end */
-       dcp::Data oversized_frame(too_big);
+       dcp::ArrayData oversized_frame(too_big);
        memcpy (oversized_frame.data().get(), frame.data().get(), frame.size());
        memset (oversized_frame.data().get() + frame.size(), 0, too_big - frame.size());
 
@@ -564,11 +564,11 @@ BOOST_AUTO_TEST_CASE (verify_test16)
 
        /* Compress a black image */
        shared_ptr<dcp::OpenJPEGImage> image = black_image ();
-       dcp::Data frame = dcp::compress_j2k (image, 100000000, 24, false, false);
+       dcp::ArrayData frame = dcp::compress_j2k (image, 100000000, 24, false, false);
        BOOST_REQUIRE (frame.size() < nearly_too_big);
 
        /* Place it in a bigger block with some zero padding at the end */
-       dcp::Data oversized_frame(nearly_too_big);
+       dcp::ArrayData oversized_frame(nearly_too_big);
        memcpy (oversized_frame.data().get(), frame.data().get(), frame.size());
        memset (oversized_frame.data().get() + frame.size(), 0, nearly_too_big - frame.size());
 
@@ -589,7 +589,7 @@ BOOST_AUTO_TEST_CASE (verify_test17)
 {
        /* Compress a black image */
        shared_ptr<dcp::OpenJPEGImage> image = black_image ();
-       dcp::Data frame = dcp::compress_j2k (image, 100000000, 24, false, false);
+       dcp::ArrayData frame = dcp::compress_j2k (image, 100000000, 24, false, false);
        BOOST_REQUIRE (frame.size() < 230000000 / (24 * 8));
 
        boost::filesystem::path const dir("build/test/verify_test17");
@@ -716,7 +716,7 @@ BOOST_AUTO_TEST_CASE (verify_test22)
        boost::filesystem::create_directories (ov_dir);
 
        shared_ptr<dcp::OpenJPEGImage> image = black_image ();
-       dcp::Data frame = dcp::compress_j2k (image, 100000000, 24, false, false);
+       dcp::ArrayData frame = dcp::compress_j2k (image, 100000000, 24, false, false);
        BOOST_REQUIRE (frame.size() < 230000000 / (24 * 8));
        dcp_from_frame (frame, ov_dir);
 
index 4bdc6e9d04995f027bfc6bc97c51536d3dd5eb6d..1f5ded21c7d4e11f3be2af6ab41838e003fce714 100644 (file)
@@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
        c->add (
                shared_ptr<dcp::Subtitle> (
                        new dcp::SubtitleImage (
-                               dcp::Data ("test/data/sub.png"),
+                               dcp::ArrayData ("test/data/sub.png"),
                                dcp::Time (0, 4,  9, 22, 24),
                                dcp::Time (0, 4, 11, 22, 24),
                                0,
@@ -705,7 +705,7 @@ BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test3)
        c.add (
                shared_ptr<dcp::Subtitle> (
                        new dcp::SubtitleImage (
-                               dcp::Data ("test/data/sub.png"),
+                               dcp::ArrayData ("test/data/sub.png"),
                                dcp::Time (0, 4,  9, 22, 24),
                                dcp::Time (0, 4, 11, 22, 24),
                                0,
index 6f0c5f6f3c53c0be01c8866e67b849d8d324ac0c..026b1a4dd7f61a7a122c48b6b193b8b4d762dd01 100644 (file)
@@ -130,8 +130,8 @@ main (int argc, char* argv[])
        cout << sub.xml_as_string() << "\n";
 
        if (extract_fonts) {
-               map<string, dcp::Data> fonts = sub.font_data ();
-               for (map<string, dcp::Data>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
+               map<string, dcp::ArrayData> fonts = sub.font_data ();
+               for (map<string, dcp::ArrayData>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
                        FILE* f = dcp::fopen_boost (i->first + ".ttf", "wb");
                        if (!f) {
                                cerr << "Could not open font file " << i->first << ".ttf for writing";