summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-12-15 22:39:11 +0000
committerCarl Hetherington <cth@carlh.net>2012-12-15 22:39:11 +0000
commit70c1332e9476d887dd875c386961c8a33d2496fd (patch)
tree59a051ee99604b623ca0ae4fedea8b61f4677dbb /src/lib
parentacc9e7c26a5e5659e49f238cda24ff400e587350 (diff)
Remove thumbnailing stuff.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/examine_content_job.cc56
-rw-r--r--src/lib/film.cc117
-rw-r--r--src/lib/film.h16
-rw-r--r--src/lib/imagemagick_encoder.cc91
-rw-r--r--src/lib/imagemagick_encoder.h42
-rw-r--r--src/lib/wscript1
6 files changed, 2 insertions, 321 deletions
diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc
index 8db74801f..7e0f7692b 100644
--- a/src/lib/examine_content_job.cc
+++ b/src/lib/examine_content_job.cc
@@ -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);
@@ -86,59 +85,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);
}
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 3f9210080..45af7a2ec 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -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
{
@@ -1305,16 +1200,6 @@ Film::set_package_type (string p)
}
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)
{
{
diff --git a/src/lib/film.h b/src/lib/film.h
index 2e81575e4..c7ebdef12 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -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
index 480dec8bc..000000000
--- a/src/lib/imagemagick_encoder.cc
+++ /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
index dfc741cb2..000000000
--- a/src/lib/imagemagick_encoder.h
+++ /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>) {}
-};
diff --git a/src/lib/wscript b/src/lib/wscript
index c1786bb81..5d3fbb906 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -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