Remove thumbnailing stuff.
authorCarl Hetherington <cth@carlh.net>
Sat, 15 Dec 2012 22:39:11 +0000 (22:39 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 15 Dec 2012 22:39:11 +0000 (22:39 +0000)
src/lib/examine_content_job.cc
src/lib/film.cc
src/lib/film.h
src/lib/imagemagick_encoder.cc [deleted file]
src/lib/imagemagick_encoder.h [deleted file]
src/lib/wscript
src/wx/film_editor.cc
test/test.cc

index 8db74801fdd634feed5e2a822c4d4f97691884b6..7e0f7692bea02279e8d9a6fecdf6210a60dc718d 100644 (file)
@@ -26,7 +26,6 @@
 #include "options.h"
 #include "decoder_factory.h"
 #include "decoder.h"
-#include "imagemagick_encoder.h"
 #include "transcoder.h"
 #include "log.h"
 #include "film.h"
@@ -72,7 +71,7 @@ ExamineContentJob::run ()
        o->apply_crop = false;
        o->decode_audio = false;
 
-       descend (0.5);
+       descend (1);
 
        pair<shared_ptr<VideoDecoder>, shared_ptr<AudioDecoder> > decoders = decoder_factory (_film, o, this);
 
@@ -85,59 +84,6 @@ ExamineContentJob::run ()
 
        _film->log()->log (String::compose ("Video length is %1 frames", _film->length()));
 
-       ascend ();
-
-       /* Now make thumbnails for it */
-
-       descend (0.5);
-
-       try {
-               o.reset (new Options (_film->dir ("thumbs"), ".png", ""));
-               o->out_size = _film->size ();
-               o->apply_crop = false;
-               o->decode_audio = false;
-               if (_film->length() > 0) {
-                       o->decode_video_skip = _film->length().get() / 128;
-               } else {
-                       o->decode_video_skip = 0;
-               }
-               o->decode_subtitles = true;
-               shared_ptr<ImageMagickEncoder> e (new ImageMagickEncoder (_film, o));
-               Transcoder w (_film, o, this, e);
-               w.go ();
-               
-       } catch (std::exception& e) {
-
-               ascend ();
-               set_progress (1);
-               set_error (e.what ());
-               set_state (FINISHED_ERROR);
-               return;
-               
-       }
-
-       string const tdir = _film->dir ("thumbs");
-       vector<SourceFrame> thumbs;
-
-       for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (tdir); i != boost::filesystem::directory_iterator(); ++i) {
-
-               /* Aah, the sweet smell of progress */
-#if BOOST_FILESYSTEM_VERSION == 3              
-               string const l = boost::filesystem::path(*i).leaf().generic_string();
-#else
-               string const l = i->leaf ();
-#endif
-               
-               size_t const d = l.find (".png");
-               size_t const t = l.find (".tmp");
-               if (d != string::npos && t == string::npos) {
-                       thumbs.push_back (atoi (l.substr (0, d).c_str()));
-               }
-       }
-
-       sort (thumbs.begin(), thumbs.end());
-       _film->set_thumbs (thumbs);     
-
        ascend ();
        set_progress (1);
        set_state (FINISHED_OK);
index 3f92100802ade784a839bef4a790a939fa547a2b..45af7a2ec2f86742bd1bea21584ce438c2c6894b 100644 (file)
@@ -31,7 +31,6 @@
 #include <boost/date_time.hpp>
 #include "film.h"
 #include "format.h"
-#include "imagemagick_encoder.h"
 #include "job.h"
 #include "filter.h"
 #include "transcoder.h"
@@ -169,7 +168,6 @@ Film::Film (Film const & o)
        , _studio            (o._studio)
        , _facility          (o._facility)
        , _package_type      (o._package_type)
-       , _thumbs            (o._thumbs)
        , _size              (o._size)
        , _length            (o._length)
        , _content_digest    (o._content_digest)
@@ -299,12 +297,6 @@ Film::examine_content ()
                return;
        }
 
-       set_thumbs (vector<SourceFrame> ());
-       boost::filesystem::remove_all (dir ("thumbs"));
-
-       /* This call will recreate the directory */
-       dir ("thumbs");
-       
        _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
        _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this));
        JobManager::instance()->add (_examine_content_job);
@@ -355,35 +347,6 @@ Film::encoded_frames () const
        return N;
 }
 
-/** Return the filename of a subtitle image if one exists for a given thumb index.
- *  @param Thumbnail index.
- *  @return Position of the image within the source frame, and the image filename, if one exists.
- *  Otherwise the filename will be empty.
- */
-pair<Position, string>
-Film::thumb_subtitle (int n) const
-{
-       string sub_file = thumb_base(n) + ".sub";
-       if (!boost::filesystem::exists (sub_file)) {
-               return pair<Position, string> ();
-       }
-
-       pair<Position, string> sub;
-       
-       ifstream f (sub_file.c_str ());
-       multimap<string, string> kv = read_key_value (f);
-       for (map<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
-               if (i->first == "x") {
-                       sub.first.x = lexical_cast<int> (i->second);
-               } else if (i->first == "y") {
-                       sub.first.y = lexical_cast<int> (i->second);
-                       sub.second = String::compose ("%1.sub.png", thumb_base(n));
-               }
-       }
-       
-       return sub;
-}
-
 /** Write state to our `metadata' file */
 void
 Film::write_metadata () const
@@ -445,12 +408,6 @@ Film::write_metadata () const
        f << "facility " << _facility << "\n";
        f << "package_type " << _package_type << "\n";
 
-       /* Cached stuff; this is information about our content; we could
-          look it up each time, but that's slow.
-       */
-       for (vector<SourceFrame>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
-               f << "thumb " << *i << "\n";
-       }
        f << "width " << _size.width << "\n";
        f << "height " << _size.height << "\n";
        f << "length " << _length.get_value_or(0) << "\n";
@@ -478,7 +435,6 @@ Film::read_metadata ()
        boost::mutex::scoped_lock lm (_state_mutex);
 
        _external_audio.clear ();
-       _thumbs.clear ();
        _content_audio_streams.clear ();
        _subtitle_streams.clear ();
 
@@ -580,13 +536,7 @@ Film::read_metadata ()
                }
                
                /* Cached stuff */
-               if (k == "thumb") {
-                       int const n = atoi (v.c_str ());
-                       /* Only add it to the list if it still exists */
-                       if (boost::filesystem::exists (thumb_file_for_frame (n))) {
-                               _thumbs.push_back (n);
-                       }
-               } else if (k == "width") {
+               if (k == "width") {
                        _size.width = atoi (v.c_str ());
                } else if (k == "height") {
                        _size.height = atoi (v.c_str ());
@@ -630,61 +580,6 @@ Film::read_metadata ()
        _dirty = false;
 }
 
-/** @param n A thumb index.
- *  @return The path to the thumb's image file.
- */
-string
-Film::thumb_file (int n) const
-{
-       return thumb_file_for_frame (thumb_frame (n));
-}
-
-/** @param n A frame index within the Film's source.
- *  @return The path to the thumb's image file for this frame;
- *  we assume that it exists.
- */
-string
-Film::thumb_file_for_frame (SourceFrame n) const
-{
-       return thumb_base_for_frame(n) + ".png";
-}
-
-/** @param n Thumb index.
- *  Must not be called with the _state_mutex locked.
- */
-string
-Film::thumb_base (int n) const
-{
-       return thumb_base_for_frame (thumb_frame (n));
-}
-
-string
-Film::thumb_base_for_frame (SourceFrame n) const
-{
-       stringstream s;
-       s.width (8);
-       s << setfill('0') << n;
-       
-       boost::filesystem::path p;
-       p /= dir ("thumbs");
-       p /= s.str ();
-               
-       return p.string ();
-}
-
-/** @param n A thumb index.
- *  @return The frame within the Film's source that it is for.
- *
- *  Must not be called with the _state_mutex locked.
- */
-SourceFrame
-Film::thumb_frame (int n) const
-{
-       boost::mutex::scoped_lock lm (_state_mutex);
-       assert (n < int (_thumbs.size ()));
-       return _thumbs[n];
-}
-
 Size
 Film::cropped_size (Size s) const
 {
@@ -1304,16 +1199,6 @@ Film::set_package_type (string p)
        signal_changed (DCI_METADATA);
 }
 
-void
-Film::set_thumbs (vector<SourceFrame> t)
-{
-       {
-               boost::mutex::scoped_lock lm (_state_mutex);
-               _thumbs = t;
-       }
-       signal_changed (THUMBS);
-}
-
 void
 Film::set_size (Size s)
 {
index 2e81575e4710ef3fce0cee5ce9440eb1b4805387..c7ebdef12d66d7bf3f199fd49e149efd969f7483 100644 (file)
@@ -61,7 +61,6 @@ public:
 
        std::string j2k_dir () const;
        std::vector<std::string> audio_files () const;
-       std::pair<Position, std::string> thumb_subtitle (int) const;
 
        void examine_content ();
        void send_dcp_to_tms ();
@@ -83,10 +82,6 @@ public:
        std::string content_path () const;
        ContentType content_type () const;
        
-       std::string thumb_file (int) const;
-       std::string thumb_base (int) const;
-       SourceFrame thumb_frame (int) const;
-
        int target_audio_sample_rate () const;
        
        void write_metadata () const;
@@ -129,7 +124,6 @@ public:
                SUBTITLE_OFFSET,
                SUBTITLE_SCALE,
                DCI_METADATA,
-               THUMBS,
                SIZE,
                LENGTH,
                CONTENT_AUDIO_STREAMS,
@@ -285,11 +279,6 @@ public:
                return _package_type;
        }
 
-       std::vector<SourceFrame> thumbs () const {
-               boost::mutex::scoped_lock lm (_state_mutex);
-               return _thumbs;
-       }
-       
        Size size () const {
                boost::mutex::scoped_lock lm (_state_mutex);
                return _size;
@@ -358,7 +347,6 @@ public:
        void set_studio (std::string);
        void set_facility (std::string);
        void set_package_type (std::string);
-       void set_thumbs (std::vector<SourceFrame>);
        void set_size (Size);
        void set_length (SourceFrame);
        void unset_length ();
@@ -384,8 +372,6 @@ private:
        /** The date that we should use in a DCI name */
        boost::gregorian::date _dci_date;
 
-       std::string thumb_file_for_frame (SourceFrame) const;
-       std::string thumb_base_for_frame (SourceFrame) const;
        void signal_changed (Property);
        void examine_content_finished ();
 
@@ -458,8 +444,6 @@ private:
 
        /* Data which are cached to speed things up */
 
-       /** Vector of frame indices for each of our `thumbnails' */
-       std::vector<SourceFrame> _thumbs;
        /** Size, in pixels, of the source (ignoring cropping) */
        Size _size;
        /** Actual length of the source (in video frames) from examining it */
diff --git a/src/lib/imagemagick_encoder.cc b/src/lib/imagemagick_encoder.cc
deleted file mode 100644 (file)
index 480dec8..0000000
+++ /dev/null
@@ -1,91 +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.
-
-*/
-
-/** @file src/imagemagick_encoder.cc
- *  @brief An encoder that writes image files using ImageMagick (and does nothing with audio).
- */
-
-#include <stdexcept>
-#include <vector>
-#include <sstream>
-#include <iomanip>
-#include <iostream>
-#include <fstream>
-#include <boost/filesystem.hpp>
-#include <Magick++/Image.h>
-#include "imagemagick_encoder.h"
-#include "film.h"
-#include "options.h"
-#include "exceptions.h"
-#include "image.h"
-#include "subtitle.h"
-
-using std::string;
-using std::ofstream;
-using boost::shared_ptr;
-
-/** @param f Film that we are encoding.
- *  @param o Options.
- */
-ImageMagickEncoder::ImageMagickEncoder (shared_ptr<const Film> f, shared_ptr<const Options> o)
-       : Encoder (f, o)
-{
-       
-}
-
-void
-ImageMagickEncoder::do_process_video (shared_ptr<Image> image, shared_ptr<Subtitle> sub)
-{
-       shared_ptr<Image> scaled = image->scale_and_convert_to_rgb (_opt->out_size, _opt->padding, _film->scaler());
-       shared_ptr<Image> compact (new CompactImage (scaled));
-
-       string tmp_file = _opt->frame_out_path (_video_frame, true);
-       Magick::Image thumb (compact->size().width, compact->size().height, "RGB", MagickCore::CharPixel, compact->data()[0]);
-       thumb.magick ("PNG");
-       thumb.write (tmp_file);
-       boost::filesystem::rename (tmp_file, _opt->frame_out_path (_video_frame, false));
-
-       if (sub) {
-               float const x_scale = float (_opt->out_size.width) / _film->size().width;
-               float const y_scale = float (_opt->out_size.height) / _film->size().height;
-
-               string tmp_metadata_file = _opt->frame_out_path (_video_frame, false, ".sub");
-               ofstream metadata (tmp_metadata_file.c_str ());
-               
-               Size new_size = sub->image()->size ();
-               new_size.width *= x_scale;
-               new_size.height *= y_scale;
-               shared_ptr<Image> scaled = sub->image()->scale (new_size, _film->scaler());
-               shared_ptr<Image> compact (new CompactImage (scaled));
-               
-               string tmp_sub_file = _opt->frame_out_path (_video_frame, true, ".sub.png");
-               Magick::Image sub_thumb (compact->size().width, compact->size().height, "RGBA", MagickCore::CharPixel, compact->data()[0]);
-               sub_thumb.magick ("PNG");
-               sub_thumb.write (tmp_sub_file);
-               boost::filesystem::rename (tmp_sub_file, _opt->frame_out_path (_video_frame, false, ".sub.png"));
-
-               metadata << "x " << sub->position().x << "\n"
-                        << "y " << sub->position().y << "\n";
-
-               metadata.close ();
-               boost::filesystem::rename (tmp_metadata_file, _opt->frame_out_path (_video_frame, false, ".sub"));
-       }
-       
-       frame_done ();
-}
diff --git a/src/lib/imagemagick_encoder.h b/src/lib/imagemagick_encoder.h
deleted file mode 100644 (file)
index dfc741c..0000000
+++ /dev/null
@@ -1,42 +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.
-
-*/
-
-/** @file src/imagemagick_encoder.h
- *  @brief An encoder that writes image files using ImageMagick (and does nothing with audio).
- */
-
-#include <string>
-#include <sndfile.h>
-#include "encoder.h"
-
-class FilmState;
-class Log;
-
-/** @class ImageMagickEncoder
- *  @brief An encoder that writes image files using ImageMagick files (and does nothing with audio).
- */
-class ImageMagickEncoder : public Encoder
-{
-public:
-       ImageMagickEncoder (boost::shared_ptr<const Film> f, boost::shared_ptr<const Options> o);
-
-private:       
-       void do_process_video (boost::shared_ptr<Image>, boost::shared_ptr<Subtitle>);
-       void do_process_audio (boost::shared_ptr<AudioBuffers>) {}
-};
index c1786bb818b6566ee85b0c4cddff299cfd5f543a..5d3fbb906f4c39b22a97ebddc9fbabb8297ce5fb 100644 (file)
@@ -37,7 +37,6 @@ def build(bld):
                  gain.cc
                  image.cc
                  imagemagick_decoder.cc
-                 imagemagick_encoder.cc
                 j2k_still_encoder.cc
                 j2k_wav_encoder.cc
                 job.cc
index 2528f49db7b5fed47a08a303c8fd378821c04007..7083290c536281bc8f15e2f34f3d658452b0e8d2 100644 (file)
@@ -569,8 +569,6 @@ FilmEditor::film_changed (Film::Property p)
                checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
                _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
                break;
-       case Film::THUMBS:
-               break;
        case Film::DCP_AB:
                checked_set (_dcp_ab, _film->dcp_ab ());
                break;
index e2f9f41ee9c2802df295e6ca2700f62072bb2743..2bbf4f08a91d034705cdc89e31a058d7c8aac06d 100644 (file)
@@ -307,10 +307,6 @@ BOOST_AUTO_TEST_CASE (paths_test)
 {
        shared_ptr<Film> f = new_test_film ("paths_test");
        f->set_directory ("build/test/a/b/c/d/e");
-       vector<SourceFrame> thumbs;
-       thumbs.push_back (42);
-       f->set_thumbs (thumbs);
-       BOOST_CHECK_EQUAL (f->thumb_file (0), "build/test/a/b/c/d/e/thumbs/00000042.png");
 
        f->_content = "/foo/bar/baz";
        BOOST_CHECK_EQUAL (f->content_path(), "/foo/bar/baz");