diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-12-13 01:30:30 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-17 20:13:22 +0100 |
| commit | 197b0139dc0765ef5cd67acf6770ef9037718235 (patch) | |
| tree | 0598b07c4cfabac7a0fc72fd617cc70057b090cc | |
| parent | 0fdccaf9779b376938a1cd795f31f3bc5036333f (diff) | |
Replace dcp::File with dcp::ArrayData.
| -rw-r--r-- | examples/make_dcp.cc | 3 | ||||
| -rw-r--r-- | src/file.cc | 72 | ||||
| -rw-r--r-- | src/file.h | 70 | ||||
| -rw-r--r-- | src/wscript | 1 | ||||
| -rw-r--r-- | test/dcp_test.cc | 5 | ||||
| -rw-r--r-- | test/encryption_test.cc | 3 | ||||
| -rw-r--r-- | test/kdm_test.cc | 3 | ||||
| -rw-r--r-- | test/round_trip_test.cc | 3 | ||||
| -rw-r--r-- | test/test.cc | 3 |
9 files changed, 7 insertions, 156 deletions
diff --git a/examples/make_dcp.cc b/examples/make_dcp.cc index 1705589d..df3dda24 100644 --- a/examples/make_dcp.cc +++ b/examples/make_dcp.cc @@ -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 index ce7a4c5e..00000000 --- a/src/file.cc +++ /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 index 7f10b5b8..00000000 --- a/src/file.h +++ /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 diff --git a/src/wscript b/src/wscript index 1222dbde..4366dca7 100644 --- a/src/wscript +++ b/src/wscript @@ -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 diff --git a/test/dcp_test.cc b/test/dcp_test.cc index cf8d91c8..3f395c53 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -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 ()); } diff --git a/test/encryption_test.cc b/test/encryption_test.cc index 7bf83c4c..0cba37fc 100644 --- a/test/encryption_test.cc +++ b/test/encryption_test.cc @@ -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 ()); } diff --git a/test/kdm_test.cc b/test/kdm_test.cc index 63b65ad8..6e0dcb67 100644 --- a/test/kdm_test.cc +++ b/test/kdm_test.cc @@ -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)); diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc index 2e7984ca..3fa61fd0 100644 --- a/test/round_trip_test.cc +++ b/test/round_trip_test.cc @@ -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 ()); } diff --git a/test/test.cc b/test/test.cc index 9f285dbc..af005e50 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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 ()); } |
