Data
DCPVideo::encode_locally (dcp::NoteHandler note)
{
+ shared_ptr<dcp::OpenJPEGImage> xyz = convert_to_xyz (_frame, note);
+
shared_ptr<JPEG2000Encoder> encoder;
if (Config::instance()->encoder ()) {
encoder = JPEG2000Encoder::from_id (Config::instance()->encoder().get ());
}
JPEG2000EncoderUnavailableException::JPEG2000EncoderUnavailableException (string encoder_name, string message)
- : StringError (String::compose (_("Encoder %1 unavailable: %2"), encoder_name, message))
+ : runtime_error (String::compose (_("Encoder %1 unavailable: %2"), encoder_name, message))
{
}
using std::vector;
using std::string;
using boost::shared_ptr;
+using dcp::Data;
#define LOG_GENERAL(...) log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2016 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
#define DCPOMATIC_JPEG2000_ENCODER_H
#include "types.h"
-#include "data.h"
#include <dcp/types.h>
+#include <dcp/data.h>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
#include <list>
* @return Encoded JPEG2000 data.
*/
- Data encode (
+ dcp::Data encode (
boost::shared_ptr<const dcp::OpenJPEGImage> input,
int bandwidth,
int frame_rate,
protected:
- virtual Data do_encode (
+ virtual dcp::Data do_encode (
boost::shared_ptr<const dcp::OpenJPEGImage> input
) = 0;
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
Adapted from code Copyright (C) 2010-2011 Terrence Meiczinger
This program is free software; you can redistribute it and/or modify
*/
#include "openjpeg_encoder.h"
-#include "data.h"
#include "exceptions.h"
+#include <dcp/data.h>
+#include <dcp/j2k.h>
#include <dcp/openjpeg_image.h>
#include "i18n.h"
using std::string;
using boost::shared_ptr;
+using dcp::Data;
string
OpenJPEGEncoder::name () const
Data
OpenJPEGEncoder::do_encode (shared_ptr<const dcp::OpenJPEGImage> input)
{
- /* Set the max image and component sizes based on frame_rate */
- int max_cs_len = ((float) _bandwidth.get()) / 8 / _frame_rate.get();
- if (_threed.get()) {
- /* 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.get() == RESOLUTION_2K ? CINEMA2K : CINEMA4K;
- if (_resolution.get() == 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.get() == 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 * input->size().width * input->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, input->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, input->opj_image(), 0);
- if (r == 0) {
- opj_cio_close (cio);
- opj_destroy_compress (cinfo);
- throw EncodeError (N_("JPEG2000 encoding failed"));
- }
-
- Data enc (cio->buffer, cio_tell (cio));
-
- opj_cio_close (cio);
- free (parameters.cp_comment);
- opj_destroy_compress (cinfo);
-
- return enc;
+ return dcp::compress_j2k (input, _bandwidth.get(), _frame_rate.get(), _threed.get(), _resolution.get() == RESOLUTION_4K);
}
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 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
}
protected:
- Data do_encode (boost::shared_ptr<const dcp::OpenJPEGImage> input);
+ dcp::Data do_encode (boost::shared_ptr<const dcp::OpenJPEGImage> input);
};
#include "poznan_encoder.h"
#include "exceptions.h"
-#include "data.h"
#include "raw_convert.h"
-#include <poznan/tier2/markers.h>
+#include <poznan-jpeg2k-cth/tier2/markers.h>
#include <dcp/openjpeg_image.h>
+#include <dcp/data.h>
#include <dlfcn.h>
#include <thrust/system/cuda/error.h>
using std::string;
using std::cout;
using boost::shared_ptr;
+using dcp::Data;
PoznanEncoder::PoznanEncoder ()
{
*/
#include "jpeg2000_encoder.h"
-#include <poznan/config/parameters.h>
-#include <poznan/types/image_types.h>
+#include <poznan-jpeg2k-cth/config/parameters.h>
+#include <poznan-jpeg2k-cth/types/image_types.h>
#include <string>
class PoznanEncoder : public JPEG2000Encoder
protected:
- Data do_encode (
+ dcp::Data do_encode (
boost::shared_ptr<const dcp::OpenJPEGImage> input
);
#include "lib/raw_convert.h"
#include "lib/cross.h"
#include "lib/exceptions.h"
+#include "lib/jpeg2000_encoder.h"
#include <dcp/exceptions.h>
#include <dcp/certificate_chain.h>
#include <wx/stdpaths.h>
table->Add (bottom_table, wxGBPosition (r, 0), wxGBSpan (2, 2), wxEXPAND);
++r;
- add_label_to_grid_bag_sizer (table, _panel, _("JPEG2000 encoder"), true, wxGBPosition (r, 0));
+ add_label_to_sizer (table, _panel, _("JPEG2000 encoder"), true, wxGBPosition (r, 0));
_encoder = new wxChoice (_panel, wxID_ANY);
BOOST_FOREACH (shared_ptr<JPEG2000Encoder> i, JPEG2000Encoder::all()) {
_encoder->Append (std_to_wx (i->name ()));
checked_set (_check_for_test_updates, config->check_for_test_updates ());
checked_set (_issuer, config->dcp_issuer ());
checked_set (_creator, config->dcp_creator ());
-<<<<<<< 0f3c2864599f9e5a5ec001266b4aefb0205d1e1f
checked_set (_cinemas_file, config->cinemas_file());
setup_sensitivity ();
-=======
if (!config->encoder ()) {
checked_set (_encoder, 0);
}
}
}
->>>>>>> Basic classes for different JPEG2000 encoders; config to choose one.
}
void setup_sensitivity ()
using std::vector;
using boost::shared_ptr;
+using dcp::Data;
int main ()
{
shared_ptr<JPEG2000Encoder> encoder = JPEG2000Encoder::from_id ("poznan");
- shared_ptr<Image> rgb (new Image (PIX_FMT_RGB24, dcp::Size (1998, 1080), false));
+ shared_ptr<Image> rgb (new Image (AV_PIX_FMT_RGB24, dcp::Size (1998, 1080), false));
int const line_size = 1998 * 3;
conf.find_program('msgfmt', var='MSGFMT')
# Check for headers of poznan JPEG2000 encoding library
- conf.check(header_name="poznan/config/parameters.h")
+ conf.check(header_name="poznan-jpeg2k-cth/config/parameters.h")
datadir = conf.env.DATADIR
if not datadir: