summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-10-30 00:50:57 +0100
committerCarl Hetherington <cth@carlh.net>2020-11-02 00:12:56 +0100
commitda15bff6e278d351301c9c50a4c96737ae4b5545 (patch)
tree86057f3d8cbca41130fe170791ef341e18bc6283 /src
parentec82ce2d44d5ba492a3dfa6e740ff21549d438e1 (diff)
Rename Data -> ArrayData.
Diffstat (limited to 'src')
-rw-r--r--src/array_data.cc (renamed from src/data.cc)20
-rw-r--r--src/array_data.h (renamed from src/data.h)22
-rw-r--r--src/interop_subtitle_asset.cc2
-rw-r--r--src/j2k.cc17
-rw-r--r--src/j2k.h7
-rw-r--r--src/smpte_subtitle_asset.cc4
-rw-r--r--src/subtitle_asset.cc6
-rw-r--r--src/subtitle_asset.h9
-rw-r--r--src/subtitle_asset_internal.h7
-rw-r--r--src/subtitle_image.cc6
-rw-r--r--src/subtitle_image.h13
-rw-r--r--src/util.cc2
-rw-r--r--src/util.h5
-rw-r--r--src/verify.cc2
-rw-r--r--src/wscript6
15 files changed, 67 insertions, 61 deletions
diff --git a/src/data.cc b/src/array_data.cc
index aed8a4d2..9d8473b8 100644
--- a/src/data.cc
+++ b/src/array_data.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2020 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -31,7 +31,7 @@
files in the program, then also delete it here.
*/
-#include "data.h"
+#include "array_data.h"
#include "util.h"
#include "exceptions.h"
#include <cstdio>
@@ -40,34 +40,34 @@
using boost::shared_array;
using namespace dcp;
-Data::Data ()
+ArrayData::ArrayData ()
: _size (0)
{
}
-Data::Data (int size)
+ArrayData::ArrayData (int size)
: _data (new uint8_t[size])
, _size (size)
{
}
-Data::Data (uint8_t const * data, int size)
+ArrayData::ArrayData (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)
+ArrayData::ArrayData (shared_array<uint8_t> data, int size)
: _data (data)
, _size (size)
{
}
-Data::Data (boost::filesystem::path file)
+ArrayData::ArrayData (boost::filesystem::path file)
{
_size = boost::filesystem::file_size (file);
_data.reset (new uint8_t[_size]);
@@ -87,7 +87,7 @@ Data::Data (boost::filesystem::path file)
}
void
-Data::write (boost::filesystem::path file) const
+ArrayData::write (boost::filesystem::path file) const
{
FILE* f = fopen_boost (file, "wb");
if (!f) {
@@ -102,14 +102,14 @@ Data::write (boost::filesystem::path file) const
}
void
-Data::write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const
+ArrayData::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)
+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/data.h b/src/array_data.h
index fd6eb22b..06ccec27 100644
--- a/src/data.h
+++ b/src/array_data.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2020 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -31,8 +31,8 @@
files in the program, then also delete it here.
*/
-#ifndef LIBDCP_DATA_H
-#define LIBDCP_DATA_H
+#ifndef LIBDCP_ARRAY_DATA_H
+#define LIBDCP_ARRAY_DATA_H
#include <boost/shared_array.hpp>
#include <boost/filesystem.hpp>
@@ -40,16 +40,16 @@
namespace dcp {
-class Data
+class ArrayData
{
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);
+ 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 ~Data () {}
+ virtual ~ArrayData () {}
void write (boost::filesystem::path file) const;
void write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const;
@@ -72,7 +72,7 @@ private:
int _size;
};
-bool operator==(Data const & a, Data const & b);
+bool operator==(ArrayData const & a, ArrayData const & b);
}
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index f7e38965..316fb08a 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -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");
}
}
diff --git a/src/j2k.cc b/src/j2k.cc
index fc60acfa..46359d90 100644
--- a/src/j2k.cc
+++ b/src/j2k.cc
@@ -31,10 +31,11 @@
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);
diff --git a/src/j2k.h b/src/j2k.h
index 9ca5147b..fcaa28e2 100644
--- 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");
}
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index cf0ed6c0..c9545052 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -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;
}
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index 02350f00..c6d2e790 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -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;
}
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index b66e88b1..063a2dfd 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -34,10 +34,11 @@
#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;
};
diff --git a/src/subtitle_asset_internal.h b/src/subtitle_asset_internal.h
index 366123c5..e5c8e141 100644
--- a/src/subtitle_asset_internal.h
+++ b/src/subtitle_asset_internal.h
@@ -34,10 +34,11 @@
#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;
diff --git a/src/subtitle_image.cc b/src/subtitle_image.cc
index e1f123bc..d8215850 100644
--- a/src/subtitle_image.cc
+++ b/src/subtitle_image.cc
@@ -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
diff --git a/src/subtitle_image.h b/src/subtitle_image.h
index 3c4b3fe8..76c34765 100644
--- a/src/subtitle_image.h
+++ b/src/subtitle_image.h
@@ -38,9 +38,10 @@
#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;
};
diff --git a/src/util.cc b/src/util.cc
index 211f03f8..b62def07 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -98,7 +98,7 @@ dcp::make_uuid ()
}
string
-dcp::make_digest (Data data)
+dcp::make_digest (ArrayData data)
{
SHA_CTX sha;
SHA1_Init (&sha);
diff --git a/src/util.h b/src/util.h
index 07e4f782..523794e4 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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);
diff --git a/src/verify.cc b/src/verify.cc
index aad6952f..55da95b6 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -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));
}
}
diff --git a/src/wscript b/src/wscript
index 38aa784c..85d4a6cb 100644
--- a/src/wscript
+++ b/src/wscript
@@ -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