Merge still/moving image classes.
authorCarl Hetherington <cth@carlh.net>
Fri, 22 Nov 2013 18:42:46 +0000 (18:42 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 22 Nov 2013 18:42:46 +0000 (18:42 +0000)
31 files changed:
src/lib/content.cc
src/lib/content_factory.cc
src/lib/image_content.cc [new file with mode: 0644]
src/lib/image_content.h [new file with mode: 0644]
src/lib/image_decoder.cc [new file with mode: 0644]
src/lib/image_decoder.h [new file with mode: 0644]
src/lib/image_examiner.cc [new file with mode: 0644]
src/lib/image_examiner.h [new file with mode: 0644]
src/lib/moving_image.h [deleted file]
src/lib/moving_image_content.cc [deleted file]
src/lib/moving_image_content.h [deleted file]
src/lib/moving_image_decoder.cc [deleted file]
src/lib/moving_image_decoder.h [deleted file]
src/lib/moving_image_examiner.cc [deleted file]
src/lib/moving_image_examiner.h [deleted file]
src/lib/player.cc
src/lib/playlist.cc
src/lib/still_image.h [deleted file]
src/lib/still_image_content.cc [deleted file]
src/lib/still_image_content.h [deleted file]
src/lib/still_image_decoder.cc [deleted file]
src/lib/still_image_decoder.h [deleted file]
src/lib/still_image_examiner.cc [deleted file]
src/lib/still_image_examiner.h [deleted file]
src/lib/wscript
src/wx/content_menu.cc
src/wx/film_editor.cc
src/wx/film_viewer.cc
src/wx/timing_panel.cc
test/black_fill_test.cc
test/scaling_test.cc

index 4e54533ed29189c5b9500c3404ddc0cf843b62f0..a565edb527c7339096c6accd932289e806e87c45 100644 (file)
@@ -28,6 +28,7 @@
 using std::string;
 using std::stringstream;
 using std::set;
+using std::cout;
 using boost::shared_ptr;
 using boost::lexical_cast;
 
index ed9a9e7699da3c22fcef43a854b5c4b9c2edf316..e800628c161dec79fdb68dc5a4fb8645353ff930 100644 (file)
@@ -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/image_content.cc b/src/lib/image_content.cc
new file mode 100644 (file)
index 0000000..9259242
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+    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 "image_content.h"
+#include "image_examiner.h"
+#include "config.h"
+#include "compose.hpp"
+#include "film.h"
+#include "job.h"
+
+#include "i18n.h"
+
+using std::string;
+using std::cout;
+using std::stringstream;
+using boost::shared_ptr;
+
+ImageContent::ImageContent (shared_ptr<const Film> f, boost::filesystem::path p)
+       : Content (f)
+       , VideoContent (f)
+{
+       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());
+       }
+}
+
+
+ImageContent::ImageContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
+       : Content (f, node)
+       , VideoContent (f, node)
+{
+       
+}
+
+string
+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
+ImageContent::technical_summary () const
+{
+       string s = Content::technical_summary() + " - "
+               + VideoContent::technical_summary() + " - ";
+
+       if (still ()) {
+               s += _("still");
+       } else {
+               s += _("moving");
+       }
+
+       return s;
+}
+
+void
+ImageContent::as_xml (xmlpp::Node* node) const
+{
+       node->add_child("Type")->add_child_text ("Image");
+       Content::as_xml (node);
+       VideoContent::as_xml (node);
+}
+
+void
+ImageContent::examine (shared_ptr<Job> job)
+{
+       job->sub (_("Computing digest"));
+       Content::examine (job);
+
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
+       
+       shared_ptr<ImageExaminer> examiner (new ImageExaminer (film, shared_from_this(), job));
+
+       take_from_video_examiner (examiner);
+       set_video_length (examiner->video_length ());
+}
+
+void
+ImageContent::set_video_length (VideoContent::Frame len)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _video_length = len;
+       }
+
+       signal_changed (ContentProperty::LENGTH);
+}
+
+Time
+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
+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/image_content.h b/src/lib/image_content.h
new file mode 100644 (file)
index 0000000..3da7827
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+    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_IMAGE_CONTENT_H
+#define DCPOMATIC_IMAGE_CONTENT_H
+
+#include <boost/enable_shared_from_this.hpp>
+#include "video_content.h"
+
+namespace cxml {
+       class Node;
+}
+
+class ImageContent : public VideoContent
+{
+public:
+       ImageContent (boost::shared_ptr<const Film>, boost::filesystem::path);
+       ImageContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
+
+       boost::shared_ptr<ImageContent> shared_from_this () {
+               return boost::dynamic_pointer_cast<ImageContent> (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;
+       
+       void set_video_length (VideoContent::Frame);
+       bool still () const;
+};
+
+#endif
diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc
new file mode 100644 (file)
index 0000000..498ff2e
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+    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 "image_content.h"
+#include "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;
+
+ImageDecoder::ImageDecoder (shared_ptr<const Film> f, shared_ptr<const ImageContent> c)
+       : Decoder (f)
+       , VideoDecoder (f, c)
+       , _image_content (c)
+{
+
+}
+
+void
+ImageDecoder::pass ()
+{
+       if (_video_position >= _image_content->video_length ()) {
+               return;
+       }
+
+       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());
+
+       _image.reset (new Image (PIX_FMT_RGB24, size, true));
+
+       using namespace MagickCore;
+       
+       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) {
+                       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
+ImageDecoder::seek (VideoContent::Frame frame, bool)
+{
+       _video_position = frame;
+}
+
+bool
+ImageDecoder::done () const
+{
+       return _video_position >= _image_content->video_length ();
+}
diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h
new file mode 100644 (file)
index 0000000..c750024
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+    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"
+
+namespace Magick {
+       class Image;
+}
+
+class ImageContent;
+
+class ImageDecoder : public VideoDecoder
+{
+public:
+       ImageDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const ImageContent>);
+
+       boost::shared_ptr<const ImageContent> content () {
+               return _image_content;
+       }
+
+       /* Decoder */
+
+       void pass ();
+       void seek (VideoContent::Frame, bool);
+       bool done () const;
+
+private:
+       boost::shared_ptr<const ImageContent> _image_content;
+       boost::shared_ptr<Image> _image;
+};
+
diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc
new file mode 100644 (file)
index 0000000..2d15058
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+    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 <boost/lexical_cast.hpp>
+#include <Magick++.h>
+#include "image_content.h"
+#include "image_examiner.h"
+#include "film.h"
+#include "job.h"
+#include "exceptions.h"
+#include "config.h"
+
+#include "i18n.h"
+
+using std::cout;
+using std::list;
+using std::sort;
+using boost::shared_ptr;
+using boost::lexical_cast;
+using boost::bad_lexical_cast;
+
+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 ();
+
+       for (size_t i = 0; i < N; ++i) {
+               boost::filesystem::path const p = content->path (i);
+               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;
+                       Magick::Image* image = new Magick::Image (p.string());
+                       _video_size = libdcp::Size (image->columns(), image->rows());
+                       delete image;
+               }
+       
+               job->set_progress (float (i) / N);
+       }
+
+       frames.sort ();
+       
+       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 (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 ()));
+       }
+
+       if (content->still ()) {
+               _video_length = Config::instance()->default_still_length() * video_frame_rate();
+       } else {
+               _video_length = _image_content->number_of_paths ();
+       }
+}
+
+libdcp::Size
+ImageExaminer::video_size () const
+{
+       return _video_size.get ();
+}
+
+float
+ImageExaminer::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/image_examiner.h b/src/lib/image_examiner.h
new file mode 100644 (file)
index 0000000..8887f0d
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+    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 "video_examiner.h"
+
+namespace Magick {
+       class Image;
+}
+
+class ImageContent;
+
+class ImageExaminer : public VideoExaminer
+{
+public:
+       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 {
+               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 (file)
index a81403d..0000000
+++ /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.cc b/src/lib/moving_image_content.cc
deleted file mode 100644 (file)
index 23d1824..0000000
+++ /dev/null
@@ -1,114 +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 "moving_image_content.h"
-#include "moving_image_examiner.h"
-#include "config.h"
-#include "compose.hpp"
-#include "film.h"
-#include "job.h"
-
-#include "i18n.h"
-
-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)
-       : 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 ());
-               }
-       }
-
-       sort (_paths.begin(), _paths.end());
-}
-
-MovingImageContent::MovingImageContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
-       : Content (f, node)
-       , VideoContent (f, node)
-{
-       
-}
-
-string
-MovingImageContent::summary () const
-{
-       /* Get the string() here so that the name does not have quotes around it */
-       return String::compose (_("%1 [moving images]"), path().filename().string());
-}
-
-string
-MovingImageContent::technical_summary () const
-{
-       return Content::technical_summary() + " - "
-               + VideoContent::technical_summary() + " - "
-               + "moving";
-}
-
-void
-MovingImageContent::as_xml (xmlpp::Node* node) const
-{
-       node->add_child("Type")->add_child_text ("MovingImage");
-       Content::as_xml (node);
-       VideoContent::as_xml (node);
-}
-
-void
-MovingImageContent::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));
-
-       take_from_video_examiner (examiner);
-
-       _video_length = number_of_paths ();
-}
-
-Time
-MovingImageContent::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
-{
-       stringstream s;
-       s << VideoContent::identifier ();
-       s << "_" << video_length();
-       return s.str ();
-}
diff --git a/src/lib/moving_image_content.h b/src/lib/moving_image_content.h
deleted file mode 100644 (file)
index f6a7778..0000000
+++ /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.cc b/src/lib/moving_image_decoder.cc
deleted file mode 100644 (file)
index 4bfc7c1..0000000
+++ /dev/null
@@ -1,84 +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 "moving_image_content.h"
-#include "moving_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;
-
-MovingImageDecoder::MovingImageDecoder (shared_ptr<const Film> f, shared_ptr<const MovingImageContent> c)
-       : Decoder (f)
-       , VideoDecoder (f, c)
-       , MovingImage (c)
-{
-
-}
-
-void
-MovingImageDecoder::pass ()
-{
-       if (_video_position >= _moving_image_content->video_length ()) {
-               return;
-       }
-
-       Magick::Image* magick_image = new Magick::Image (_moving_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));
-
-       using namespace MagickCore;
-       
-       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) {
-                       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
-MovingImageDecoder::seek (VideoContent::Frame frame, bool)
-{
-       _video_position = frame;
-}
-
-bool
-MovingImageDecoder::done () const
-{
-       return _video_position >= _moving_image_content->video_length ();
-}
diff --git a/src/lib/moving_image_decoder.h b/src/lib/moving_image_decoder.h
deleted file mode 100644 (file)
index 5cc8b32..0000000
+++ /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/moving_image_examiner.cc b/src/lib/moving_image_examiner.cc
deleted file mode 100644 (file)
index 029c441..0000000
+++ /dev/null
@@ -1,94 +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 <boost/lexical_cast.hpp>
-#include <Magick++.h>
-#include "moving_image_content.h"
-#include "moving_image_examiner.h"
-#include "film.h"
-#include "job.h"
-#include "exceptions.h"
-
-#include "i18n.h"
-
-using std::cout;
-using std::list;
-using std::sort;
-using boost::shared_ptr;
-using boost::lexical_cast;
-
-MovingImageExaminer::MovingImageExaminer (shared_ptr<const Film> film, shared_ptr<const MovingImageContent> content, shared_ptr<Job> job)
-       : MovingImage (content)
-       , _film (film)
-       , _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()));
-               
-               if (!_video_size) {
-                       using namespace MagickCore;
-                       Magick::Image* image = new Magick::Image (p.string());
-                       _video_size = libdcp::Size (image->columns(), image->rows());
-                       delete image;
-               }
-       
-               job->set_progress (float (i) / N);
-       }
-
-       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) {
-               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)) {
-               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 ();
-}
-
-libdcp::Size
-MovingImageExaminer::video_size () const
-{
-       return _video_size.get ();
-}
-
-int
-MovingImageExaminer::video_length () const
-{
-       return _video_length;
-}
-
-float
-MovingImageExaminer::video_frame_rate () const
-{
-       return 24;
-}
-
diff --git a/src/lib/moving_image_examiner.h b/src/lib/moving_image_examiner.h
deleted file mode 100644 (file)
index 4c2cfa0..0000000
+++ /dev/null
@@ -1,42 +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 "moving_image.h"
-#include "video_examiner.h"
-
-namespace Magick {
-       class Image;
-}
-
-class MovingImageContent;
-
-class MovingImageExaminer : public MovingImage, public VideoExaminer
-{
-public:
-       MovingImageExaminer (boost::shared_ptr<const Film>, boost::shared_ptr<const MovingImageContent>, boost::shared_ptr<Job>);
-
-       float video_frame_rate () const;
-       libdcp::Size video_size () const;
-       VideoContent::Frame video_length () const;
-
-private:
-       boost::weak_ptr<const Film> _film;
-       boost::optional<libdcp::Size> _video_size;
-       VideoContent::Frame _video_length;
-};
index b5a96163182b458acf00a58661be273251ceab60..87b10a3989a2021be3e04c0971f14f7e7fe166fa 100644 (file)
 #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);
index 8f40c9e6d7eed254ca6af288b70fff091d6c0aaa..e2a3c34861a0e7f148c9e39fe34f55ddbb1eedd2 100644 (file)
@@ -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 (file)
index 366d693..0000000
+++ /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 (file)
index 0cf80b5..0000000
+++ /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_content.h b/src/lib/still_image_content.h
deleted file mode 100644 (file)
index ccd7fbc..0000000
+++ /dev/null
@@ -1,52 +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_STILL_IMAGE_CONTENT_H
-#define DCPOMATIC_STILL_IMAGE_CONTENT_H
-
-#include <boost/enable_shared_from_this.hpp>
-#include "video_content.h"
-
-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
-{
-public:
-       StillImageContent (boost::shared_ptr<const Film>, boost::filesystem::path);
-       StillImageContent (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 ());
-       };
-
-       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;
-       
-       void set_video_length (VideoContent::Frame);
-};
-
-#endif
diff --git a/src/lib/still_image_decoder.cc b/src/lib/still_image_decoder.cc
deleted file mode 100644 (file)
index 6e82f9a..0000000
+++ /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_decoder.h b/src/lib/still_image_decoder.h
deleted file mode 100644 (file)
index db41b03..0000000
+++ /dev/null
@@ -1,44 +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 "still_image.h"
-
-namespace Magick {
-       class Image;
-}
-
-class StillImageContent;
-
-class StillImageDecoder : public VideoDecoder, public StillImage
-{
-public:
-       StillImageDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const StillImageContent>);
-
-       /* Decoder */
-
-       void pass ();
-       void seek (VideoContent::Frame, bool);
-       bool done () const;
-
-private:
-       boost::shared_ptr<Image> _image;
-       mutable boost::optional<libdcp::Size> _video_size;
-};
-
diff --git a/src/lib/still_image_examiner.cc b/src/lib/still_image_examiner.cc
deleted file mode 100644 (file)
index 5f45d63..0000000
+++ /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 (file)
index fa3456e..0000000
+++ /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;
-};
index 852bb1aed57e60240b3b15adf0a578c5609b1f8b..1e88e6e62cca1997c227728a13cd741835905f23 100644 (file)
@@ -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
index 6183e344470fc496871746c80a8aa83d84891808..6a8e5cd4a76a3fa08c4e98f81857bd2794041c55 100644 (file)
@@ -21,7 +21,7 @@
 #include <wx/dirdlg.h>
 #include "lib/playlist.h"
 #include "lib/film.h"
-#include "lib/moving_image_content.h"
+#include "lib/image_content.h"
 #include "lib/content_factory.h"
 #include "lib/examine_content_job.h"
 #include "lib/job_manager.h"
@@ -126,11 +126,12 @@ ContentMenu::find_missing ()
        shared_ptr<Content> content;
 
        /* XXX: a bit nasty */
-       if (dynamic_pointer_cast<MovingImageContent> (_content.front ())) {
+       shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (_content.front ());
+       if (ic && !ic->still ()) {
                wxDirDialog* d = new wxDirDialog (0, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
                int const r = d->ShowModal ();
                if (r == wxID_OK) {
-                       content.reset (new MovingImageContent (film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
+                       content.reset (new ImageContent (film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
                }
                d->Destroy ();
        } else {
index 9cf840614535a7847d774977d3cdb2d396039788..b3d28db5fcd823fa8918c70a18ffd98421d544b7 100644 (file)
@@ -36,8 +36,7 @@
 #include "lib/filter.h"
 #include "lib/ratio.h"
 #include "lib/config.h"
-#include "lib/still_image_content.h"
-#include "lib/moving_image_content.h"
+#include "lib/image_content.h"
 #include "lib/ffmpeg_content.h"
 #include "lib/sndfile_content.h"
 #include "lib/dcp_content_type.h"
@@ -761,8 +760,8 @@ FilmEditor::content_add_folder_clicked ()
        }
 
        _film->examine_and_add_content (
-               shared_ptr<MovingImageContent> (
-                       new MovingImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ())))
+               shared_ptr<ImageContent> (
+                       new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ())))
                        )
                );
 }
index 03e8419a091f16b5fa95c7085af4f376824ff5a9..0e1fe3ea0ab87baf7453e175c6c30ad204efe0b2 100644 (file)
@@ -35,8 +35,6 @@
 #include "lib/filter.h"
 #include "lib/player.h"
 #include "lib/video_content.h"
-#include "lib/ffmpeg_content.h"
-#include "lib/still_image_content.h"
 #include "lib/video_decoder.h"
 #include "film_viewer.h"
 #include "wx_util.h"
index 57eb96af0e5e68bb70c03f33211b1ebc4da32ff1..b5a0c43d4981ce28bc094a9bec220475d4c727d9 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "lib/content.h"
-#include "lib/still_image_content.h"
+#include "lib/image_content.h"
 #include "timing_panel.h"
 #include "wx_util.h"
 #include "timecode.h"
@@ -88,7 +88,8 @@ TimingPanel::film_content_changed (int property)
                }
        }       
 
-       _length->set_editable (dynamic_pointer_cast<StillImageContent> (content));
+       shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (content);
+       _length->set_editable (ic && ic->still ());
 }
 
 void
@@ -105,8 +106,8 @@ TimingPanel::length_changed ()
 {
        ContentList c = _editor->selected_content ();
        if (c.size() == 1) {
-               shared_ptr<StillImageContent> ic = dynamic_pointer_cast<StillImageContent> (c.front ());
-               if (ic) {
+               shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (c.front ());
+               if (ic && ic->still ()) {
                        ic->set_video_length (rint (_length->get (_editor->film()->video_frame_rate()) * ic->video_frame_rate() / TIME_HZ));
                }
        }
index 2c239e767fcf99bc4856224e5cedb42895b1b332..9e8aa381bbd0cb0832006fe2a7d6108b71699bac 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include <boost/test/unit_test.hpp>
-#include "lib/still_image_content.h"
+#include "lib/image_content.h"
 #include "lib/dcp_content_type.h"
 #include "lib/film.h"
 #include "lib/ratio.h"
@@ -37,9 +37,9 @@ BOOST_AUTO_TEST_CASE (black_fill_test)
        film->set_name ("black_fill_test");
        film->set_container (Ratio::from_id ("185"));
        film->set_sequence_video (false);
-       shared_ptr<StillImageContent> contentA (new StillImageContent (film, "test/data/simple_testcard_640x480.png"));
+       shared_ptr<ImageContent> contentA (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
        contentA->set_ratio (Ratio::from_id ("185"));
-       shared_ptr<StillImageContent> contentB (new StillImageContent (film, "test/data/simple_testcard_640x480.png"));
+       shared_ptr<ImageContent> contentB (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
        contentB->set_ratio (Ratio::from_id ("185"));
 
        film->examine_and_add_content (contentA);
index 8d00be72a33cee4df2cb482a62c092e1f1b4b8ca..c936fe8d45fa4175e8c774d1782238e35a28b6bf 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include <boost/test/unit_test.hpp>
-#include "lib/still_image_content.h"
+#include "lib/image_content.h"
 #include "lib/ratio.h"
 #include "lib/film.h"
 #include "lib/dcp_content_type.h"
@@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE (scaling_test)
        shared_ptr<Film> film = new_test_film ("scaling_test");
        film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR"));
        film->set_name ("scaling_test");
-       shared_ptr<StillImageContent> imc (new StillImageContent (film, "test/data/simple_testcard_640x480.png"));
+       shared_ptr<ImageContent> imc (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
 
        film->examine_and_add_content (imc);