Replace dcp::File with dcp::ArrayData.
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Dec 2020 00:30:30 +0000 (01:30 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:22 +0000 (20:13 +0100)
examples/make_dcp.cc
src/file.cc [deleted file]
src/file.h [deleted file]
src/wscript
test/dcp_test.cc
test/encryption_test.cc
test/kdm_test.cc
test/round_trip_test.cc
test/test.cc

index 1705589ddea8401b558ea38d8e31b89e18693072..df3dda24967bd7f62a9aade3031a85ebb5e8e64b 100644 (file)
@@ -38,7 +38,6 @@
 #include "sound_asset.h"
 #include "sound_asset_writer.h"
 #include "reel.h"
-#include "file.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_sound_asset.h"
 #include <cmath>
@@ -60,7 +59,7 @@ main ()
        std::shared_ptr<dcp::PictureAssetWriter> picture_writer = picture_asset->start_write ("DCP/picture.mxf", false);
 
        /* Write 24 frames of the same JPEG2000 file */
-       dcp::File picture ("examples/help.j2c");
+       dcp::ArrayData picture ("examples/help.j2c");
        for (int i = 0; i < 24; ++i) {
                picture_writer->write (picture.data(), picture.size());
        }
diff --git a/src/file.cc b/src/file.cc
deleted file mode 100644 (file)
index ce7a4c5..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-    Copyright (C) 2014 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.
-*/
-
-/** @file  src/file.cc
- *  @brief File class.
- */
-
-#include "file.h"
-#include "util.h"
-#include "dcp_assert.h"
-#include "compose.hpp"
-#include <stdio.h>
-
-using namespace dcp;
-
-/** Read a file into memory.
- *  @param file to read.
- */
-File::File (boost::filesystem::path file)
-{
-       _size = boost::filesystem::file_size (file);
-       _data = new uint8_t[_size];
-       FILE* f = dcp::fopen_boost (file, "rb");
-       DCP_ASSERT (f);
-       int const N = fread (_data, 1, _size, f);
-       if (N != _size) {
-               if (ferror(f)) {
-                       fclose (f);
-                       throw FileError (String::compose("fread error %1", errno), file, errno);
-               } else {
-                       fclose (f);
-                       throw FileError ("unexpected short read", file, -1);
-               }
-       }
-       fclose (f);
-}
-
-/** File destructor */
-File::~File ()
-{
-       delete[] _data;
-}
diff --git a/src/file.h b/src/file.h
deleted file mode 100644 (file)
index 7f10b5b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-    Copyright (C) 2014 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.
-*/
-
-/** @file  src/file.h
- *  @brief File class.
- */
-
-#ifndef LIBDCP_FILE_H
-#define LIBDCP_FILE_H
-
-#include <boost/filesystem.hpp>
-#include <boost/noncopyable.hpp>
-
-namespace dcp {
-
-/** @class File
- *  @brief Helper class which loads a file into memory.
- */
-class File : public boost::noncopyable
-{
-public:
-       explicit File (boost::filesystem::path file);
-       ~File ();
-
-       uint8_t* data () const {
-               return _data;
-       }
-
-       int64_t size () const {
-               return _size;
-       }
-
-private:
-       uint8_t* _data; ///< file's data
-       int64_t _size;  ///< data size in bytes
-};
-
-}
-
-#endif
index 1222dbde5186e1e9d73b42b4a767846853be9c70..4366dca766f4902ecf0866e7a9dbd5a77af13d08 100644 (file)
@@ -54,7 +54,6 @@ def build(bld):
              decrypted_kdm_key.cc
              encrypted_kdm.cc
              exceptions.cc
-             file.cc
              font_asset.cc
              fsk.cc
              gamma_transfer_function.cc
index cf8d91c884aae72f3995f631b8abdd551ee19f14..3f395c533835a8874ca46d2f1ce7fa6dc7659f90 100644 (file)
@@ -43,7 +43,6 @@
 #include "atmos_asset.h"
 #include "reel.h"
 #include "test.h"
-#include "file.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_stereo_picture_asset.h"
 #include "reel_sound_asset.h"
@@ -100,7 +99,7 @@ BOOST_AUTO_TEST_CASE (dcp_test2)
        shared_ptr<dcp::StereoPictureAsset> mp (new dcp::StereoPictureAsset (dcp::Fraction (24, 1), dcp::SMPTE));
        mp->set_metadata (mxf_meta);
        shared_ptr<dcp::PictureAssetWriter> picture_writer = mp->start_write ("build/test/DCP/dcp_test2/video.mxf", false);
-       dcp::File j2c ("test/data/flat_red.j2c");
+       dcp::ArrayData j2c ("test/data/flat_red.j2c");
        for (int i = 0; i < 24; ++i) {
                /* Left */
                picture_writer->write (j2c.data (), j2c.size ());
@@ -282,7 +281,7 @@ BOOST_AUTO_TEST_CASE (dcp_test5)
        shared_ptr<dcp::MonoPictureAsset> mp (new dcp::MonoPictureAsset (dcp::Fraction (24, 1), dcp::SMPTE));
        mp->set_metadata (mxf_meta);
        shared_ptr<dcp::PictureAssetWriter> picture_writer = mp->start_write ("build/test/DCP/dcp_test5/video.mxf", false);
-       dcp::File j2c ("test/data/flat_red.j2c");
+       dcp::ArrayData j2c ("test/data/flat_red.j2c");
        for (int i = 0; i < 24; ++i) {
                picture_writer->write (j2c.data (), j2c.size ());
        }
index 7bf83c4c5b889500f5c7636545cd9c5078d0d5da..0cba37fcf67bf2b4dc6da250b14d836d6fc12d8a 100644 (file)
@@ -42,7 +42,6 @@
 #include "sound_asset.h"
 #include "reel.h"
 #include "test.h"
-#include "file.h"
 #include "subtitle_asset.h"
 #include "reel_mono_picture_asset.h"
 #include "reel_sound_asset.h"
@@ -92,7 +91,7 @@ BOOST_AUTO_TEST_CASE (encryption_test)
        mp->set_key (key);
 
        shared_ptr<dcp::PictureAssetWriter> writer = mp->start_write ("build/test/DCP/encryption_test/video.mxf", false);
-       dcp::File j2c ("test/data/flat_red.j2c");
+       dcp::ArrayData j2c ("test/data/flat_red.j2c");
        for (int i = 0; i < 24; ++i) {
                writer->write (j2c.data (), j2c.size ());
        }
index 63b65ad808c26969fe837ab34d58f6348f360153..6e0dcb6766f8c144612eb2b1744c1969eed6ba99 100644 (file)
@@ -40,7 +40,6 @@
 #include "mono_picture_asset.h"
 #include "reel_mono_picture_asset.h"
 #include "reel.h"
-#include "file.h"
 #include "types.h"
 #include "picture_asset_writer.h"
 #include <libcxml/cxml.h>
@@ -241,7 +240,7 @@ BOOST_AUTO_TEST_CASE (validity_period_test1)
        auto asset = make_shared<dcp::MonoPictureAsset>(dcp::Fraction(24, 1), dcp::SMPTE);
        asset->set_key (dcp::Key());
        auto writer = asset->start_write ("build/test/validity_period_test1.mxf", false);
-       dcp::File frame ("test/data/flat_red.j2c");
+       dcp::ArrayData frame ("test/data/flat_red.j2c");
        writer->write (frame.data(), frame.size());
        auto reel = make_shared<dcp::Reel>();
        reel->add(make_shared<dcp::ReelMonoPictureAsset>(asset, 0));
index 2e7984cae23c9732fedbd08a47d4f38bf57e5435..3fa61fd0bd62ddf239280337f9f3ff7b1bcfd235 100644 (file)
@@ -46,7 +46,6 @@
 #include "mono_picture_asset_reader.h"
 #include "reel_picture_asset.h"
 #include "reel_mono_picture_asset.h"
-#include "file.h"
 #include "openjpeg_image.h"
 #include "rgb_xyz.h"
 #include "colour_conversion.h"
@@ -70,7 +69,7 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
 
        shared_ptr<dcp::MonoPictureAsset> asset_A (new dcp::MonoPictureAsset (dcp::Fraction (24, 1), dcp::SMPTE));
        shared_ptr<dcp::PictureAssetWriter> writer = asset_A->start_write (work_dir / "video.mxf", false);
-       dcp::File j2c ("test/data/flat_red.j2c");
+       dcp::ArrayData j2c ("test/data/flat_red.j2c");
        for (int i = 0; i < 24; ++i) {
                writer->write (j2c.data (), j2c.size ());
        }
index 9f285dbcbca81c7f3ba0ca74af770f062e3976a3..af005e50ce9deb16856e0808b285cf1063bcbc3f 100644 (file)
@@ -36,7 +36,6 @@
 #include "compose.hpp"
 #include "cpl.h"
 #include "dcp.h"
-#include "file.h"
 #include "interop_subtitle_asset.h"
 #include "mono_picture_asset.h"
 #include "picture_asset_writer.h"
@@ -267,7 +266,7 @@ simple_picture (boost::filesystem::path path, string suffix)
        shared_ptr<dcp::MonoPictureAsset> mp (new dcp::MonoPictureAsset (dcp::Fraction (24, 1), dcp::SMPTE));
        mp->set_metadata (mxf_meta);
        shared_ptr<dcp::PictureAssetWriter> picture_writer = mp->start_write (path / dcp::String::compose("video%1.mxf", suffix), false);
-       dcp::File j2c ("test/data/flat_red.j2c");
+       dcp::ArrayData j2c ("test/data/flat_red.j2c");
        for (int i = 0; i < 24; ++i) {
                picture_writer->write (j2c.data (), j2c.size ());
        }