2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/j2k_still_encoder.cc
21 * @brief An encoder which writes JPEG2000 files for a single still source image.
28 #include <boost/filesystem.hpp>
31 #include "j2k_still_encoder.h"
34 #include "exceptions.h"
35 #include "dcp_video_frame.h"
38 #include "imagemagick_decoder.h"
43 using boost::shared_ptr;
45 J2KStillEncoder::J2KStillEncoder (shared_ptr<const Film> f, shared_ptr<const EncodeOptions> o)
52 J2KStillEncoder::do_process_video (shared_ptr<Image> yuv, shared_ptr<Subtitle> sub)
54 pair<string, string> const s = Filter::ffmpeg_strings (_film->filters());
55 DCPVideoFrame* f = new DCPVideoFrame (
56 yuv, sub, _opt->out_size, _opt->padding, _film->subtitle_offset(), _film->subtitle_scale(), _film->scaler(), 0, _film->frames_per_second(), s.second,
57 Config::instance()->colour_lut_index(), Config::instance()->j2k_bandwidth(),
61 if (!boost::filesystem::exists (_opt->frame_out_path (0, false))) {
62 boost::shared_ptr<EncodedData> e = f->encode_locally ();
66 string const real = _opt->frame_out_path (0, false);
67 for (int i = 1; i < (_film->still_duration() * 24); ++i) {
68 if (!boost::filesystem::exists (_opt->frame_out_path (i, false))) {
69 string const link = _opt->frame_out_path (i, false);
70 #ifdef DVDOMATIC_POSIX
71 int const r = symlink (real.c_str(), link.c_str());
73 throw EncodeError ("could not create symlink");
76 #ifdef DVDOMATIC_WINDOWS
77 boost::filesystem::copy_file (real, link);