diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-11-22 18:42:46 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-11-22 18:42:46 +0000 |
| commit | ef4cd174472dc1c4694d4451dc60b9292c60666b (patch) | |
| tree | 216d46bad240478d4dd9f289e0b542c2dc76dcbd /src/lib | |
| parent | af474db6af17d468b42fbae8bd4c3e80dcfd0588 (diff) | |
Merge still/moving image classes.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/content.cc | 1 | ||||
| -rw-r--r-- | src/lib/content_factory.cc | 11 | ||||
| -rw-r--r-- | src/lib/image_content.cc (renamed from src/lib/moving_image_content.cc) | 81 | ||||
| -rw-r--r-- | src/lib/image_content.h (renamed from src/lib/still_image_content.h) | 16 | ||||
| -rw-r--r-- | src/lib/image_decoder.cc (renamed from src/lib/moving_image_decoder.cc) | 33 | ||||
| -rw-r--r-- | src/lib/image_decoder.h (renamed from src/lib/still_image_decoder.h) | 13 | ||||
| -rw-r--r-- | src/lib/image_examiner.cc (renamed from src/lib/moving_image_examiner.cc) | 51 | ||||
| -rw-r--r-- | src/lib/image_examiner.h (renamed from src/lib/moving_image_examiner.h) | 12 | ||||
| -rw-r--r-- | src/lib/moving_image.h | 35 | ||||
| -rw-r--r-- | src/lib/moving_image_content.h | 50 | ||||
| -rw-r--r-- | src/lib/moving_image_decoder.h | 40 | ||||
| -rw-r--r-- | src/lib/player.cc | 36 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 3 | ||||
| -rw-r--r-- | src/lib/still_image.h | 40 | ||||
| -rw-r--r-- | src/lib/still_image_content.cc | 113 | ||||
| -rw-r--r-- | src/lib/still_image_decoder.cc | 89 | ||||
| -rw-r--r-- | src/lib/still_image_examiner.cc | 63 | ||||
| -rw-r--r-- | src/lib/still_image_examiner.h | 41 | ||||
| -rw-r--r-- | src/lib/wscript | 9 |
19 files changed, 144 insertions, 593 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc index 4e54533ed..a565edb52 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -28,6 +28,7 @@ using std::string; using std::stringstream; using std::set; +using std::cout; using boost::shared_ptr; using boost::lexical_cast; diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index ed9a9e769..e800628c1 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -19,8 +19,7 @@ #include <libcxml/cxml.h> #include "ffmpeg_content.h" -#include "still_image_content.h" -#include "moving_image_content.h" +#include "image_content.h" #include "sndfile_content.h" #include "util.h" @@ -36,10 +35,8 @@ content_factory (shared_ptr<const Film> film, cxml::NodePtr node) if (type == "FFmpeg") { content.reset (new FFmpegContent (film, node)); - } else if (type == "StillImage") { - content.reset (new StillImageContent (film, node)); - } else if (type == "MovingImage") { - content.reset (new MovingImageContent (film, node)); + } else if (type == "Image") { + content.reset (new ImageContent (film, node)); } else if (type == "Sndfile") { content.reset (new SndfileContent (film, node)); } @@ -53,7 +50,7 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path) shared_ptr<Content> content; if (valid_image_file (path)) { - content.reset (new StillImageContent (film, path)); + content.reset (new ImageContent (film, path)); } else if (SndfileContent::valid_file (path)) { content.reset (new SndfileContent (film, path)); } else { diff --git a/src/lib/moving_image_content.cc b/src/lib/image_content.cc index 23d18240b..9259242a0 100644 --- a/src/lib/moving_image_content.cc +++ b/src/lib/image_content.cc @@ -18,8 +18,8 @@ */ #include <libcxml/cxml.h> -#include "moving_image_content.h" -#include "moving_image_examiner.h" +#include "image_content.h" +#include "image_examiner.h" #include "config.h" #include "compose.hpp" #include "film.h" @@ -29,25 +29,28 @@ using std::string; using std::cout; -using std::list; using std::stringstream; -using std::vector; using boost::shared_ptr; -MovingImageContent::MovingImageContent (shared_ptr<const Film> f, boost::filesystem::path p) +ImageContent::ImageContent (shared_ptr<const Film> f, boost::filesystem::path p) : Content (f) , VideoContent (f) { - for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) { - if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) { - _paths.push_back (i->path ()); + if (boost::filesystem::is_regular_file (p)) { + _paths.push_back (p); + } else { + for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) { + if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) { + _paths.push_back (i->path ()); + } } + + sort (_paths.begin(), _paths.end()); } - - sort (_paths.begin(), _paths.end()); } -MovingImageContent::MovingImageContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node) + +ImageContent::ImageContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node) : Content (f, node) , VideoContent (f, node) { @@ -55,60 +58,86 @@ MovingImageContent::MovingImageContent (shared_ptr<const Film> f, shared_ptr<con } string -MovingImageContent::summary () const +ImageContent::summary () const { /* Get the string() here so that the name does not have quotes around it */ + if (still ()) { + return String::compose (_("%1 [still]"), path().filename().string()); + } + return String::compose (_("%1 [moving images]"), path().filename().string()); } string -MovingImageContent::technical_summary () const +ImageContent::technical_summary () const { - return Content::technical_summary() + " - " - + VideoContent::technical_summary() + " - " - + "moving"; + string s = Content::technical_summary() + " - " + + VideoContent::technical_summary() + " - "; + + if (still ()) { + s += _("still"); + } else { + s += _("moving"); + } + + return s; } void -MovingImageContent::as_xml (xmlpp::Node* node) const +ImageContent::as_xml (xmlpp::Node* node) const { - node->add_child("Type")->add_child_text ("MovingImage"); + node->add_child("Type")->add_child_text ("Image"); Content::as_xml (node); VideoContent::as_xml (node); } void -MovingImageContent::examine (shared_ptr<Job> job) +ImageContent::examine (shared_ptr<Job> job) { job->sub (_("Computing digest")); Content::examine (job); shared_ptr<const Film> film = _film.lock (); assert (film); - - job->sub (_("Examining content")); - shared_ptr<MovingImageExaminer> examiner (new MovingImageExaminer (film, shared_from_this(), job)); + + shared_ptr<ImageExaminer> examiner (new ImageExaminer (film, shared_from_this(), job)); take_from_video_examiner (examiner); + set_video_length (examiner->video_length ()); +} - _video_length = number_of_paths (); +void +ImageContent::set_video_length (VideoContent::Frame len) +{ + { + boost::mutex::scoped_lock lm (_mutex); + _video_length = len; + } + + signal_changed (ContentProperty::LENGTH); } Time -MovingImageContent::full_length () const +ImageContent::full_length () const { shared_ptr<const Film> film = _film.lock (); assert (film); - + FrameRateConversion frc (video_frame_rate(), film->video_frame_rate ()); return video_length() * frc.factor() * TIME_HZ / video_frame_rate(); } string -MovingImageContent::identifier () const +ImageContent::identifier () const { stringstream s; s << VideoContent::identifier (); s << "_" << video_length(); return s.str (); } + +bool +ImageContent::still () const +{ + return number_of_paths() == 1; +} diff --git a/src/lib/still_image_content.h b/src/lib/image_content.h index ccd7fbc03..3da782725 100644 --- a/src/lib/still_image_content.h +++ b/src/lib/image_content.h @@ -17,8 +17,8 @@ */ -#ifndef DCPOMATIC_STILL_IMAGE_CONTENT_H -#define DCPOMATIC_STILL_IMAGE_CONTENT_H +#ifndef DCPOMATIC_IMAGE_CONTENT_H +#define DCPOMATIC_IMAGE_CONTENT_H #include <boost/enable_shared_from_this.hpp> #include "video_content.h" @@ -27,15 +27,14 @@ namespace cxml { class Node; } -/** A single image which is to be held on screen for some time (i.e. a slide) */ -class StillImageContent : public VideoContent +class ImageContent : public VideoContent { public: - StillImageContent (boost::shared_ptr<const Film>, boost::filesystem::path); - StillImageContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>); + ImageContent (boost::shared_ptr<const Film>, boost::filesystem::path); + ImageContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>); - boost::shared_ptr<StillImageContent> shared_from_this () { - return boost::dynamic_pointer_cast<StillImageContent> (Content::shared_from_this ()); + boost::shared_ptr<ImageContent> shared_from_this () { + return boost::dynamic_pointer_cast<ImageContent> (Content::shared_from_this ()); }; void examine (boost::shared_ptr<Job>); @@ -47,6 +46,7 @@ public: std::string identifier () const; void set_video_length (VideoContent::Frame); + bool still () const; }; #endif diff --git a/src/lib/moving_image_decoder.cc b/src/lib/image_decoder.cc index 4bfc7c130..498ff2e25 100644 --- a/src/lib/moving_image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -20,8 +20,8 @@ #include <iostream> #include <boost/filesystem.hpp> #include <Magick++.h> -#include "moving_image_content.h" -#include "moving_image_decoder.h" +#include "image_content.h" +#include "image_decoder.h" #include "image.h" #include "film.h" #include "exceptions.h" @@ -32,29 +32,34 @@ using std::cout; using boost::shared_ptr; using libdcp::Size; -MovingImageDecoder::MovingImageDecoder (shared_ptr<const Film> f, shared_ptr<const MovingImageContent> c) +ImageDecoder::ImageDecoder (shared_ptr<const Film> f, shared_ptr<const ImageContent> c) : Decoder (f) , VideoDecoder (f, c) - , MovingImage (c) + , _image_content (c) { } void -MovingImageDecoder::pass () +ImageDecoder::pass () { - if (_video_position >= _moving_image_content->video_length ()) { + if (_video_position >= _image_content->video_length ()) { return; } - Magick::Image* magick_image = new Magick::Image (_moving_image_content->path(_video_position).string ()); + if (_image && _image_content->still ()) { + video (_image, true, _video_position); + return; + } + + Magick::Image* magick_image = new Magick::Image (_image_content->path(_video_position).string ()); libdcp::Size size (magick_image->columns(), magick_image->rows()); - shared_ptr<Image> image (new Image (PIX_FMT_RGB24, size, true)); + _image.reset (new Image (PIX_FMT_RGB24, size, true)); using namespace MagickCore; - uint8_t* p = image->data()[0]; + uint8_t* p = _image->data()[0]; for (int y = 0; y < size.height; ++y) { uint8_t* q = p; for (int x = 0; x < size.width; ++x) { @@ -63,22 +68,22 @@ MovingImageDecoder::pass () *q++ = c.greenQuantum() * 255 / QuantumRange; *q++ = c.blueQuantum() * 255 / QuantumRange; } - p += image->stride()[0]; + p += _image->stride()[0]; } delete magick_image; - video (image, false, _video_position); + video (_image, false, _video_position); } void -MovingImageDecoder::seek (VideoContent::Frame frame, bool) +ImageDecoder::seek (VideoContent::Frame frame, bool) { _video_position = frame; } bool -MovingImageDecoder::done () const +ImageDecoder::done () const { - return _video_position >= _moving_image_content->video_length (); + return _video_position >= _image_content->video_length (); } diff --git a/src/lib/still_image_decoder.h b/src/lib/image_decoder.h index db41b0357..c7500243e 100644 --- a/src/lib/still_image_decoder.h +++ b/src/lib/image_decoder.h @@ -18,18 +18,21 @@ */ #include "video_decoder.h" -#include "still_image.h" namespace Magick { class Image; } -class StillImageContent; +class ImageContent; -class StillImageDecoder : public VideoDecoder, public StillImage +class ImageDecoder : public VideoDecoder { public: - StillImageDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const StillImageContent>); + ImageDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const ImageContent>); + + boost::shared_ptr<const ImageContent> content () { + return _image_content; + } /* Decoder */ @@ -38,7 +41,7 @@ public: bool done () const; private: + boost::shared_ptr<const ImageContent> _image_content; boost::shared_ptr<Image> _image; - mutable boost::optional<libdcp::Size> _video_size; }; diff --git a/src/lib/moving_image_examiner.cc b/src/lib/image_examiner.cc index 029c44104..2d150583a 100644 --- a/src/lib/moving_image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -20,11 +20,12 @@ #include <iostream> #include <boost/lexical_cast.hpp> #include <Magick++.h> -#include "moving_image_content.h" -#include "moving_image_examiner.h" +#include "image_content.h" +#include "image_examiner.h" #include "film.h" #include "job.h" #include "exceptions.h" +#include "config.h" #include "i18n.h" @@ -33,19 +34,23 @@ using std::list; using std::sort; using boost::shared_ptr; using boost::lexical_cast; +using boost::bad_lexical_cast; -MovingImageExaminer::MovingImageExaminer (shared_ptr<const Film> film, shared_ptr<const MovingImageContent> content, shared_ptr<Job> job) - : MovingImage (content) - , _film (film) +ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const ImageContent> content, shared_ptr<Job> job) + : _film (film) + , _image_content (content) , _video_length (0) { list<unsigned int> frames; size_t const N = content->number_of_paths (); - int j = 0; for (size_t i = 0; i < N; ++i) { boost::filesystem::path const p = content->path (i); - frames.push_back (lexical_cast<int> (p.stem().string())); + try { + frames.push_back (lexical_cast<int> (p.stem().string())); + } catch (bad_lexical_cast &) { + /* We couldn't turn that filename into a number; never mind */ + } if (!_video_size) { using namespace MagickCore; @@ -59,36 +64,34 @@ MovingImageExaminer::MovingImageExaminer (shared_ptr<const Film> film, shared_pt frames.sort (); - if (frames.size() < 2) { - throw StringError (String::compose (_("only %1 file(s) found in moving image directory"), frames.size ())); - } - - if (frames.front() != 0 && frames.front() != 1) { + if (N > 1 && frames.front() != 0 && frames.front() != 1) { throw StringError (String::compose (_("first frame in moving image directory is number %1"), frames.front ())); } - if (frames.back() != frames.size() && frames.back() != (frames.size() - 1)) { + if (N > 1 && frames.back() != frames.size() && frames.back() != (frames.size() - 1)) { throw StringError (String::compose (_("there are %1 images in the directory but the last one is number %2"), frames.size(), frames.back ())); } - _video_length = frames.size (); + if (content->still ()) { + _video_length = Config::instance()->default_still_length() * video_frame_rate(); + } else { + _video_length = _image_content->number_of_paths (); + } } libdcp::Size -MovingImageExaminer::video_size () const +ImageExaminer::video_size () const { return _video_size.get (); } -int -MovingImageExaminer::video_length () const -{ - return _video_length; -} - float -MovingImageExaminer::video_frame_rate () const +ImageExaminer::video_frame_rate () const { - return 24; -} + boost::shared_ptr<const Film> f = _film.lock (); + if (!f) { + return 24; + } + return f->video_frame_rate (); +} diff --git a/src/lib/moving_image_examiner.h b/src/lib/image_examiner.h index 4c2cfa003..8887f0d3d 100644 --- a/src/lib/moving_image_examiner.h +++ b/src/lib/image_examiner.h @@ -17,26 +17,28 @@ */ -#include "moving_image.h" #include "video_examiner.h" namespace Magick { class Image; } -class MovingImageContent; +class ImageContent; -class MovingImageExaminer : public MovingImage, public VideoExaminer +class ImageExaminer : public VideoExaminer { public: - MovingImageExaminer (boost::shared_ptr<const Film>, boost::shared_ptr<const MovingImageContent>, boost::shared_ptr<Job>); + ImageExaminer (boost::shared_ptr<const Film>, boost::shared_ptr<const ImageContent>, boost::shared_ptr<Job>); float video_frame_rate () const; libdcp::Size video_size () const; - VideoContent::Frame video_length () const; + VideoContent::Frame video_length () const { + return _video_length; + } private: boost::weak_ptr<const Film> _film; + boost::shared_ptr<const ImageContent> _image_content; boost::optional<libdcp::Size> _video_size; VideoContent::Frame _video_length; }; diff --git a/src/lib/moving_image.h b/src/lib/moving_image.h deleted file mode 100644 index a81403dbd..000000000 --- a/src/lib/moving_image.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2012 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. - -*/ - -class MovingImageContent; - -class MovingImage -{ -public: - MovingImage (boost::shared_ptr<const MovingImageContent> c) - : _moving_image_content (c) - {} - - boost::shared_ptr<const MovingImageContent> content () const { - return _moving_image_content; - } - -protected: - boost::shared_ptr<const MovingImageContent> _moving_image_content; -}; diff --git a/src/lib/moving_image_content.h b/src/lib/moving_image_content.h deleted file mode 100644 index f6a7778be..000000000 --- a/src/lib/moving_image_content.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2013 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_MOVING_IMAGE_CONTENT_H -#define DCPOMATIC_MOVING_IMAGE_CONTENT_H - -#include <boost/enable_shared_from_this.hpp> -#include "video_content.h" - -namespace cxml { - class Node; -} - -/** A directory of image files which are to be presented as a movie */ -class MovingImageContent : public VideoContent -{ -public: - MovingImageContent (boost::shared_ptr<const Film>, boost::filesystem::path); - MovingImageContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>); - - boost::shared_ptr<MovingImageContent> shared_from_this () { - return boost::dynamic_pointer_cast<MovingImageContent> (Content::shared_from_this ()); - }; - - void examine (boost::shared_ptr<Job>); - std::string summary () const; - std::string technical_summary () const; - void as_xml (xmlpp::Node *) const; - Time full_length () const; - - std::string identifier () const; -}; - -#endif diff --git a/src/lib/moving_image_decoder.h b/src/lib/moving_image_decoder.h deleted file mode 100644 index 5cc8b32b9..000000000 --- a/src/lib/moving_image_decoder.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2012-2013 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 "video_decoder.h" -#include "moving_image.h" - -namespace Magick { - class Image; -} - -class MovingImageContent; - -class MovingImageDecoder : public VideoDecoder, public MovingImage -{ -public: - MovingImageDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const MovingImageContent>); - - /* Decoder */ - - void pass (); - void seek (VideoContent::Frame, bool); - bool done () const; -}; - diff --git a/src/lib/player.cc b/src/lib/player.cc index b5a961631..87b10a398 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -22,10 +22,8 @@ #include "film.h" #include "ffmpeg_decoder.h" #include "ffmpeg_content.h" -#include "still_image_decoder.h" -#include "still_image_content.h" -#include "moving_image_decoder.h" -#include "moving_image_content.h" +#include "image_decoder.h" +#include "image_content.h" #include "sndfile_decoder.h" #include "sndfile_content.h" #include "subtitle_content.h" @@ -466,36 +464,24 @@ Player::setup_pieces () piece->decoder = fd; } - shared_ptr<const StillImageContent> ic = dynamic_pointer_cast<const StillImageContent> (*i); + shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (*i); if (ic) { - shared_ptr<StillImageDecoder> id; + bool reusing = false; - /* See if we can re-use an old StillImageDecoder */ + /* See if we can re-use an old ImageDecoder */ for (list<shared_ptr<Piece> >::const_iterator j = old_pieces.begin(); j != old_pieces.end(); ++j) { - shared_ptr<StillImageDecoder> imd = dynamic_pointer_cast<StillImageDecoder> ((*j)->decoder); + shared_ptr<ImageDecoder> imd = dynamic_pointer_cast<ImageDecoder> ((*j)->decoder); if (imd && imd->content() == ic) { - id = imd; + piece = *j; + reusing = true; } } - if (!id) { - id.reset (new StillImageDecoder (_film, ic)); + if (!reusing) { + shared_ptr<ImageDecoder> id (new ImageDecoder (_film, ic)); id->Video.connect (bind (&Player::process_video, this, weak_ptr<Piece> (piece), _1, _2, _3, _4, 0)); + piece->decoder = id; } - - piece->decoder = id; - } - - shared_ptr<const MovingImageContent> mc = dynamic_pointer_cast<const MovingImageContent> (*i); - if (mc) { - shared_ptr<MovingImageDecoder> md; - - if (!md) { - md.reset (new MovingImageDecoder (_film, mc)); - md->Video.connect (bind (&Player::process_video, this, weak_ptr<Piece> (piece), _1, _2, _3, _4, 0)); - } - - piece->decoder = md; } shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (*i); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 8f40c9e6d..e2a3c3486 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -26,8 +26,7 @@ #include "video_content.h" #include "ffmpeg_decoder.h" #include "ffmpeg_content.h" -#include "still_image_decoder.h" -#include "still_image_content.h" +#include "image_decoder.h" #include "content_factory.h" #include "job.h" #include "config.h" diff --git a/src/lib/still_image.h b/src/lib/still_image.h deleted file mode 100644 index 366d69331..000000000 --- a/src/lib/still_image.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2012 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_STILL_IMAGE_H -#define DCPOMATIC_STILL_IMAGE_H - -class StillImageContent; - -class StillImage -{ -public: - StillImage (boost::shared_ptr<const StillImageContent> c) - : _still_image_content (c) - {} - - boost::shared_ptr<const StillImageContent> content () const { - return _still_image_content; - } - -protected: - boost::shared_ptr<const StillImageContent> _still_image_content; -}; - -#endif diff --git a/src/lib/still_image_content.cc b/src/lib/still_image_content.cc deleted file mode 100644 index 0cf80b546..000000000 --- a/src/lib/still_image_content.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - Copyright (C) 2013 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 <libcxml/cxml.h> -#include "still_image_content.h" -#include "still_image_examiner.h" -#include "config.h" -#include "compose.hpp" -#include "film.h" - -#include "i18n.h" - -using std::string; -using std::cout; -using std::stringstream; -using boost::shared_ptr; - -StillImageContent::StillImageContent (shared_ptr<const Film> f, boost::filesystem::path p) - : Content (f, p) - , VideoContent (f, p) -{ - -} - -StillImageContent::StillImageContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node) - : Content (f, node) - , VideoContent (f, node) -{ - -} - -string -StillImageContent::summary () const -{ - /* Get the string() here so that the name does not have quotes around it */ - return String::compose (_("%1 [still]"), path().filename().string()); -} - -string -StillImageContent::technical_summary () const -{ - return Content::technical_summary() + " - " - + VideoContent::technical_summary() + " - " - + "still"; -} - -void -StillImageContent::as_xml (xmlpp::Node* node) const -{ - node->add_child("Type")->add_child_text ("StillImage"); - Content::as_xml (node); - VideoContent::as_xml (node); -} - -void -StillImageContent::examine (shared_ptr<Job> job) -{ - Content::examine (job); - - shared_ptr<const Film> film = _film.lock (); - assert (film); - - shared_ptr<StillImageExaminer> examiner (new StillImageExaminer (film, shared_from_this())); - - take_from_video_examiner (examiner); - set_video_length (Config::instance()->default_still_length() * video_frame_rate()); -} - -void -StillImageContent::set_video_length (VideoContent::Frame len) -{ - { - boost::mutex::scoped_lock lm (_mutex); - _video_length = len; - } - - signal_changed (ContentProperty::LENGTH); -} - -Time -StillImageContent::full_length () const -{ - shared_ptr<const Film> film = _film.lock (); - assert (film); - - FrameRateConversion frc (video_frame_rate(), film->video_frame_rate ()); - return video_length() * frc.factor() * TIME_HZ / video_frame_rate(); -} - -string -StillImageContent::identifier () const -{ - stringstream s; - s << VideoContent::identifier (); - s << "_" << video_length(); - return s.str (); -} diff --git a/src/lib/still_image_decoder.cc b/src/lib/still_image_decoder.cc deleted file mode 100644 index 6e82f9a55..000000000 --- a/src/lib/still_image_decoder.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright (C) 2012-2013 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 <iostream> -#include <boost/filesystem.hpp> -#include <Magick++.h> -#include "still_image_content.h" -#include "still_image_decoder.h" -#include "image.h" -#include "film.h" -#include "exceptions.h" - -#include "i18n.h" - -using std::cout; -using boost::shared_ptr; -using libdcp::Size; - -StillImageDecoder::StillImageDecoder (shared_ptr<const Film> f, shared_ptr<const StillImageContent> c) - : Decoder (f) - , VideoDecoder (f, c) - , StillImage (c) -{ - -} - -void -StillImageDecoder::pass () -{ - if (_video_position >= _still_image_content->video_length ()) { - return; - } - - if (_image) { - video (_image, true, _video_position); - return; - } - - Magick::Image* magick_image = new Magick::Image (_still_image_content->path().string ()); - _video_size = libdcp::Size (magick_image->columns(), magick_image->rows()); - - _image.reset (new Image (PIX_FMT_RGB24, _video_size.get(), true)); - - using namespace MagickCore; - - uint8_t* p = _image->data()[0]; - for (int y = 0; y < _video_size->height; ++y) { - uint8_t* q = p; - for (int x = 0; x < _video_size->width; ++x) { - Magick::Color c = magick_image->pixelColor (x, y); - *q++ = c.redQuantum() * 255 / QuantumRange; - *q++ = c.greenQuantum() * 255 / QuantumRange; - *q++ = c.blueQuantum() * 255 / QuantumRange; - } - p += _image->stride()[0]; - } - - delete magick_image; - - video (_image, false, _video_position); -} - -void -StillImageDecoder::seek (VideoContent::Frame frame, bool) -{ - _video_position = frame; -} - -bool -StillImageDecoder::done () const -{ - return _video_position >= _still_image_content->video_length (); -} diff --git a/src/lib/still_image_examiner.cc b/src/lib/still_image_examiner.cc deleted file mode 100644 index 5f45d6365..000000000 --- a/src/lib/still_image_examiner.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2013 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 <iostream> -#include <Magick++.h> -#include "still_image_content.h" -#include "still_image_examiner.h" -#include "film.h" - -#include "i18n.h" - -using std::cout; -using boost::shared_ptr; - -StillImageExaminer::StillImageExaminer (shared_ptr<const Film> f, shared_ptr<const StillImageContent> c) - : StillImage (c) - , _film (f) -{ - using namespace MagickCore; - Magick::Image* image = new Magick::Image (_still_image_content->path().string()); - _video_size = libdcp::Size (image->columns(), image->rows()); - delete image; -} - -libdcp::Size -StillImageExaminer::video_size () const -{ - return _video_size; -} - -int -StillImageExaminer::video_length () const -{ - return _still_image_content->video_length (); -} - -float -StillImageExaminer::video_frame_rate () const -{ - boost::shared_ptr<const Film> f = _film.lock (); - if (!f) { - return 24; - } - - return f->video_frame_rate (); -} - diff --git a/src/lib/still_image_examiner.h b/src/lib/still_image_examiner.h deleted file mode 100644 index fa3456e8a..000000000 --- a/src/lib/still_image_examiner.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2013 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 "still_image.h" -#include "video_examiner.h" - -namespace Magick { - class Image; -} - -class StillImageContent; - -class StillImageExaminer : public StillImage, public VideoExaminer -{ -public: - StillImageExaminer (boost::shared_ptr<const Film>, boost::shared_ptr<const StillImageContent>); - - float video_frame_rate () const; - libdcp::Size video_size () const; - VideoContent::Frame video_length () const; - -private: - boost::weak_ptr<const Film> _film; - libdcp::Size _video_size; -}; diff --git a/src/lib/wscript b/src/lib/wscript index 852bb1aed..1e88e6e62 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -30,13 +30,13 @@ sources = """ film.cc filter.cc image.cc + image_content.cc + image_decoder.cc + image_examiner.cc job.cc job_manager.cc kdm.cc log.cc - moving_image_content.cc - moving_image_decoder.cc - moving_image_examiner.cc player.cc playlist.cc ratio.cc @@ -48,9 +48,6 @@ sources = """ sndfile_content.cc sndfile_decoder.cc sound_processor.cc - still_image_content.cc - still_image_decoder.cc - still_image_examiner.cc subtitle_content.cc subtitle_decoder.cc timer.cc |
