+++ /dev/null
-/*
- Copyright (C) 2015 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "data.h"
-#include "cross.h"
-#include "exceptions.h"
-#include <cstdio>
-
-#include "i18n.h"
-
-using boost::shared_array;
-
-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 (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);
- }
-
- 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);
- }
-
- fclose (f);
-}
-
-void
-Data::write (boost::filesystem::path file) const
-{
- FILE* f = fopen_boost (file, "wb");
- if (!f) {
- throw WriteFileError (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);
- }
- fclose (f);
-}
-
-void
-Data::write_via_temp (boost::filesystem::path temp, boost::filesystem::path final) const
-{
- write (temp);
- boost::filesystem::rename (temp, final);
-}
+++ /dev/null
-/*
- Copyright (C) 2015 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef DCPOMATIC_DATA_H
-#define DCPOMATIC_DATA_H
-
-#include <boost/shared_array.hpp>
-#include <boost/filesystem.hpp>
-#include <stdint.h>
-
-class Data
-{
-public:
- Data ();
- Data (int size);
- Data (uint8_t const * data, int size);
- 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;
- }
-
-private:
- boost::shared_array<uint8_t> _data;
- int _size;
-};
-
-#endif
#include "cross.h"
#include "player_video.h"
#include "raw_convert.h"
-#include "data.h"
#include "compose.hpp"
#include <libcxml/cxml.h>
#include <dcp/openjpeg_image.h>
#include <dcp/rgb_xyz.h>
+#include <dcp/j2k.h>
#include <dcp/colour_matrix.h>
#include <openjpeg.h>
#include <libxml++/libxml++.h>
using std::cout;
using boost::shared_ptr;
using dcp::Size;
+using dcp::Data;
#define DCI_COEFFICENT (48.0 / 52.37)
{
shared_ptr<dcp::OpenJPEGImage> xyz = convert_to_xyz (_frame, note);
- /* Set the max image and component sizes based on frame_rate */
- int max_cs_len = ((float) _j2k_bandwidth) / 8 / _frames_per_second;
- if (_frame->eyes() == EYES_LEFT || _frame->eyes() == EYES_RIGHT) {
- /* In 3D we have only half the normal bandwidth per eye */
- max_cs_len /= 2;
- }
- int const max_comp_size = max_cs_len / 1.25;
-
- /* get a J2K compressor handle */
- opj_cinfo_t* cinfo = opj_create_compress (CODEC_J2K);
- if (cinfo == 0) {
- throw EncodeError (N_("could not create JPEG2000 encoder"));
- }
-
- /* Set encoding parameters to default values */
- opj_cparameters_t parameters;
- opj_set_default_encoder_parameters (¶meters);
-
- /* Set default cinema parameters */
- parameters.tile_size_on = false;
- parameters.cp_tdx = 1;
- parameters.cp_tdy = 1;
-
- /* Tile part */
- parameters.tp_flag = 'C';
- parameters.tp_on = 1;
-
- /* Tile and Image shall be at (0,0) */
- parameters.cp_tx0 = 0;
- parameters.cp_ty0 = 0;
- parameters.image_offset_x0 = 0;
- parameters.image_offset_y0 = 0;
-
- /* Codeblock size = 32x32 */
- parameters.cblockw_init = 32;
- parameters.cblockh_init = 32;
- parameters.csty |= 0x01;
-
- /* The progression order shall be CPRL */
- parameters.prog_order = CPRL;
-
- /* No ROI */
- parameters.roi_compno = -1;
-
- parameters.subsampling_dx = 1;
- parameters.subsampling_dy = 1;
-
- /* 9-7 transform */
- parameters.irreversible = 1;
-
- parameters.tcp_rates[0] = 0;
- parameters.tcp_numlayers++;
- parameters.cp_disto_alloc = 1;
- parameters.cp_rsiz = _resolution == RESOLUTION_2K ? CINEMA2K : CINEMA4K;
- if (_resolution == RESOLUTION_4K) {
- parameters.numpocs = 2;
- parameters.POC[0].tile = 1;
- parameters.POC[0].resno0 = 0;
- parameters.POC[0].compno0 = 0;
- parameters.POC[0].layno1 = 1;
- parameters.POC[0].resno1 = parameters.numresolution - 1;
- parameters.POC[0].compno1 = 3;
- parameters.POC[0].prg1 = CPRL;
- parameters.POC[1].tile = 1;
- parameters.POC[1].resno0 = parameters.numresolution - 1;
- parameters.POC[1].compno0 = 0;
- parameters.POC[1].layno1 = 1;
- parameters.POC[1].resno1 = parameters.numresolution;
- parameters.POC[1].compno1 = 3;
- parameters.POC[1].prg1 = CPRL;
- }
-
- parameters.cp_comment = strdup (N_("DCP-o-matic"));
- parameters.cp_cinema = _resolution == RESOLUTION_2K ? CINEMA2K_24 : CINEMA4K_24;
-
- /* 3 components, so use MCT */
- parameters.tcp_mct = 1;
-
- /* set max image */
- parameters.max_comp_size = max_comp_size;
- parameters.tcp_rates[0] = ((float) (3 * xyz->size().width * xyz->size().height * 12)) / (max_cs_len * 8);
-
- /* Set event manager to null (openjpeg 1.3 bug) */
- cinfo->event_mgr = 0;
-
- /* Setup the encoder parameters using the current image and user parameters */
- opj_setup_encoder (cinfo, ¶meters, xyz->opj_image ());
-
- opj_cio_t* cio = opj_cio_open ((opj_common_ptr) cinfo, 0, 0);
- if (cio == 0) {
- opj_destroy_compress (cinfo);
- throw EncodeError (N_("could not open JPEG2000 stream"));
- }
-
- int const r = opj_encode (cinfo, cio, xyz->opj_image(), 0);
- if (r == 0) {
- opj_cio_close (cio);
- opj_destroy_compress (cinfo);
- throw EncodeError (N_("JPEG2000 encoding failed"));
- }
+ Data enc = compress_j2k (
+ convert_to_xyz (_frame, note),
+ _j2k_bandwidth,
+ _frames_per_second,
+ _frame->eyes() == EYES_LEFT || _frame->eyes() == EYES_RIGHT,
+ _resolution == RESOLUTION_4K
+ );
switch (_frame->eyes()) {
case EYES_BOTH:
break;
}
- Data enc (cio->buffer, cio_tell (cio));
-
- opj_cio_close (cio);
- free (parameters.cp_comment);
- opj_destroy_compress (cinfo);
-
return enc;
}
*/
#include "types.h"
-#include "data.h"
#include "server_description.h"
#include <libcxml/cxml.h>
+#include <dcp/data.h>
/** @file src/dcp_video_frame.h
* @brief A single frame of video destined for a DCP.
DCPVideo (boost::shared_ptr<const PlayerVideo>, int, int, int, Resolution, boost::shared_ptr<Log>);
DCPVideo (boost::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr, boost::shared_ptr<Log>);
- Data encode_locally (dcp::NoteHandler note);
- Data encode_remotely (ServerDescription);
+ dcp::Data encode_locally (dcp::NoteHandler note);
+ dcp::Data encode_remotely (ServerDescription);
int index () const {
return _index;
*/
#include "compose.hpp"
-#include "data.h"
#include "config.h"
#include "emailer.h"
#include "exceptions.h"
using std::cout;
using std::pair;
using boost::shared_ptr;
+using dcp::Data;
Emailer::Emailer (string from, list<string> to, string subject, string body)
: _from (from)
#include "server_finder.h"
#include "player.h"
#include "player_video.h"
-#include "data.h"
#include "server_description.h"
#include "compose.hpp"
#include <libcxml/cxml.h>
using boost::shared_ptr;
using boost::weak_ptr;
using boost::optional;
+using dcp::Data;
int const Encoder::_history_size = 25;
#include "j2k_image_proxy.h"
#include "dcpomatic_socket.h"
#include "image.h"
-#include "data.h"
#include "raw_convert.h"
#include <dcp/openjpeg_image.h>
#include <dcp/mono_picture_frame.h>
#include <dcp/stereo_picture_frame.h>
#include <dcp/colour_conversion.h>
#include <dcp/rgb_xyz.h>
+#include <dcp/j2k.h>
#include <libcxml/cxml.h>
#include <openjpeg.h>
#include <libxml++/libxml++.h>
using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
+using dcp::Data;
/** Construct a J2KImageProxy from a JPEG2000 file */
J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size)
*/
#include "image_proxy.h"
-#include "data.h"
#include <dcp/util.h>
namespace dcp {
class MonoPictureFrame;
class StereoPictureFrame;
+ class Data;
}
-class Data;
-
class J2KImageProxy : public ImageProxy
{
public:
bool same (boost::shared_ptr<const ImageProxy>) const;
AVPixelFormat pixel_format () const;
- Data j2k () const {
+ dcp::Data j2k () const {
return _data;
}
friend struct client_server_test_j2k;
/* For tests */
- J2KImageProxy (Data data, dcp::Size size);
+ J2KImageProxy (dcp::Data data, dcp::Size size);
void ensure_j2k () const;
- Data _data;
+ dcp::Data _data;
dcp::Size _size;
boost::optional<dcp::Eye> _eye;
mutable boost::shared_ptr<dcp::OpenJPEGImage> _j2k;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::optional;
+using dcp::Data;
PlayerVideo::PlayerVideo (
shared_ptr<const ImageProxy> in,
#include "dcpomatic_time.h"
#include "colour_conversion.h"
#include "position_image.h"
-#include "data.h"
extern "C" {
#include <libavutil/pixfmt.h>
}
void send_binary (boost::shared_ptr<Socket> socket) const;
bool has_j2k () const;
- Data j2k () const;
+ dcp::Data j2k () const;
DCPTime time () const {
return _time;
using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
+using dcp::Data;
int const ReelWriter::_info_size = 48;
*/
#include "types.h"
-#include "data.h"
#include "dcpomatic_time.h"
#include "referenced_reel_asset.h"
#include "player_subtitles.h"
public:
ReelWriter (boost::shared_ptr<const Film> film, DCPTimePeriod period, boost::shared_ptr<Job> job);
- void write (boost::optional<Data> encoded, Frame frame, Eyes eyes);
+ void write (boost::optional<dcp::Data> encoded, Frame frame, Eyes eyes);
void fake_write (Frame frame, Eyes eyes, int size);
void repeat_write (Frame frame, Eyes eyes);
void write (boost::shared_ptr<const AudioBuffers> audio);
/** the first frame index that does not already exist in our MXF */
int _first_nonexistant_frame;
/** the data of the last written frame, if there is one */
- boost::optional<Data> _last_written[EYES_COUNT];
+ boost::optional<dcp::Data> _last_written[EYES_COUNT];
/** the index of the last written video frame within the reel */
int _last_written_video_frame;
Eyes _last_written_eyes;
#include "config.h"
#include "cross.h"
#include "player_video.h"
-#include "data.h"
#include "safe_stringstream.h"
#include "raw_convert.h"
#include "compose.hpp"
using boost::scoped_array;
using boost::optional;
using dcp::Size;
+using dcp::Data;
Server::Server (shared_ptr<Log> log, bool verbose)
: _terminate (false)
#include "cross.h"
#include "exceptions.h"
#include "subrip_content.h"
-#include "data.h"
#include <sub/subrip_reader.h>
#include <sub/collect.h>
#include <unicode/ucsdet.h>
using std::string;
using boost::shared_ptr;
using boost::scoped_array;
+using dcp::Data;
SubRip::SubRip (shared_ptr<const SubRipContent> content)
{
#include "cross.h"
#include "audio_buffers.h"
#include "md5_digester.h"
-#include "data.h"
#include "version.h"
#include "font.h"
#include "util.h"
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
+using dcp::Data;
Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
: _film (film)
#include "types.h"
#include "player_subtitles.h"
-#include "data.h"
#include "exception_store.h"
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/thread/condition.hpp>
#include <list>
+namespace dcp {
+ class Data;
+}
+
class Film;
-class Data;
class AudioBuffers;
class Job;
class Font;
} type;
/** encoded data for FULL */
- boost::optional<Data> encoded;
+ boost::optional<dcp::Data> encoded;
/** size of data for FAKE */
int size;
/** reel index */
bool can_fake_write (Frame) const;
- void write (Data, Frame, Eyes);
+ void write (dcp::Data, Frame, Eyes);
void fake_write (Frame, Eyes);
bool can_repeat (Frame) const;
void repeat (Frame, Eyes);
content_factory.cc
cross.cc
curl_uploader.cc
- data.cc
dcp_content.cc
dcp_content_type.cc
dcp_decoder.cc
#include "lib/video_decoder.h"
#include "lib/player.h"
#include "lib/player_video.h"
-#include "lib/data.h"
#include "lib/server_description.h"
#include <getopt.h>
#include <iostream>
using std::string;
using std::pair;
using boost::shared_ptr;
+using dcp::Data;
static shared_ptr<Film> film;
static ServerDescription* server;
#include "lib/player_video.h"
#include "lib/raw_image_proxy.h"
#include "lib/j2k_image_proxy.h"
-#include "lib/data.h"
#include "lib/server_description.h"
#include "lib/file_log.h"
#include <boost/test/unit_test.hpp>
using boost::shared_ptr;
using boost::thread;
using boost::optional;
+using dcp::Data;
void
do_remote_encode (shared_ptr<DCPVideo> frame, ServerDescription description, Data locally_encoded)