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"
42 using namespace boost;
44 J2KStillEncoder::J2KStillEncoder (shared_ptr<const Film> f, shared_ptr<const Options> o)
51 J2KStillEncoder::process_video (shared_ptr<Image> yuv, int frame, shared_ptr<Subtitle> sub)
53 pair<string, string> const s = Filter::ffmpeg_strings (_film->filters());
54 DCPVideoFrame* f = new DCPVideoFrame (
55 yuv, sub, _opt->out_size, _opt->padding, _film->subtitle_offset(), _film->subtitle_scale(), _film->scaler(), 0, _film->frames_per_second(), s.second,
56 Config::instance()->colour_lut_index(), Config::instance()->j2k_bandwidth(),
60 if (!boost::filesystem::exists (_opt->frame_out_path (0, false))) {
61 boost::shared_ptr<EncodedData> e = f->encode_locally ();
65 string const real = _opt->frame_out_path (0, false);
66 for (int i = 1; i < (_film->still_duration() * ImageMagickDecoder::static_frames_per_second()); ++i) {
67 if (!boost::filesystem::exists (_opt->frame_out_path (i, false))) {
68 string const link = _opt->frame_out_path (i, false);
69 #ifdef DVDOMATIC_POSIX
70 int const r = symlink (real.c_str(), link.c_str());
72 throw EncodeError ("could not create symlink");
75 #ifdef DVDOMATIC_WINDOWS
76 filesystem::copy_file (real, link);