diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-03-25 00:41:05 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-03-25 00:41:05 +0000 |
| commit | 527deef6f18c46badb396e4520d802333997add2 (patch) | |
| tree | c37704455dbbd6453cbf583f97254ea44b37366e /src/lib | |
| parent | b6e388dc3ea1ab37711f50bbc28a93f48de98db3 (diff) | |
Remove Scaler config and use SWS_BICUBIC everywhere.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/config.cc | 1 | ||||
| -rw-r--r-- | src/lib/dcp_video.cc | 3 | ||||
| -rw-r--r-- | src/lib/film.cc | 12 | ||||
| -rw-r--r-- | src/lib/film.h | 9 | ||||
| -rw-r--r-- | src/lib/image.cc | 11 | ||||
| -rw-r--r-- | src/lib/image.h | 5 | ||||
| -rw-r--r-- | src/lib/player.cc | 6 | ||||
| -rw-r--r-- | src/lib/player_video.cc | 8 | ||||
| -rw-r--r-- | src/lib/player_video.h | 3 | ||||
| -rw-r--r-- | src/lib/scaler.cc | 118 | ||||
| -rw-r--r-- | src/lib/scaler.h | 73 | ||||
| -rw-r--r-- | src/lib/server.cc | 1 | ||||
| -rw-r--r-- | src/lib/util.cc | 2 | ||||
| -rw-r--r-- | src/lib/wscript | 1 |
14 files changed, 9 insertions, 244 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 94d8a69a2..bf70f95ac 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -19,7 +19,6 @@ #include "config.h" #include "server.h" -#include "scaler.h" #include "filter.h" #include "ratio.h" #include "dcp_content_type.h" diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index a302c43e6..a2668c4a7 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> Taken from code Copyright (C) 2010-2011 Terrence Meiczinger This program is free software; you can redistribute it and/or modify @@ -33,7 +33,6 @@ #include "exceptions.h" #include "server.h" #include "dcpomatic_socket.h" -#include "scaler.h" #include "image.h" #include "log.h" #include "cross.h" diff --git a/src/lib/film.cc b/src/lib/film.cc index ed7d4cb51..e5904ca1e 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -31,7 +31,6 @@ #include "log.h" #include "exceptions.h" #include "examine_content_job.h" -#include "scaler.h" #include "config.h" #include "ui_signaller.h" #include "playlist.h" @@ -120,7 +119,6 @@ Film::Film (boost::filesystem::path dir, bool log) , _dcp_content_type (Config::instance()->default_dcp_content_type ()) , _container (Config::instance()->default_container ()) , _resolution (RESOLUTION_2K) - , _scaler (Scaler::from_id ("bicubic")) , _signed (true) , _encrypted (false) , _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ()) @@ -186,7 +184,6 @@ Film::video_identifier () const << "_" << resolution_to_string (_resolution) << "_" << _playlist->video_identifier() << "_" << _video_frame_rate - << "_" << scaler()->id() << "_" << j2k_bandwidth(); if (encrypted ()) { @@ -359,7 +356,6 @@ Film::metadata () const } root->add_child("Resolution")->add_child_text (resolution_to_string (_resolution)); - root->add_child("Scaler")->add_child_text (_scaler->id ()); root->add_child("J2KBandwidth")->add_child_text (raw_convert<string> (_j2k_bandwidth)); _isdcf_metadata.as_xml (root->add_child ("ISDCFMetadata")); root->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate)); @@ -431,7 +427,6 @@ Film::read_metadata () } _resolution = string_to_resolution (f.string_child ("Resolution")); - _scaler = Scaler::from_id (f.string_child ("Scaler")); _j2k_bandwidth = f.number_child<int> ("J2KBandwidth"); _video_frame_rate = f.number_child<int> ("VideoFrameRate"); _signed = f.optional_bool_child("Signed").get_value_or (true); @@ -736,13 +731,6 @@ Film::set_resolution (Resolution r) } void -Film::set_scaler (Scaler const * s) -{ - _scaler = s; - signal_changed (SCALER); -} - -void Film::set_j2k_bandwidth (int b) { _j2k_bandwidth = b; diff --git a/src/lib/film.h b/src/lib/film.h index c3ab9f2ff..3d1c02c93 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -45,7 +45,6 @@ class Content; class Player; class Playlist; class AudioContent; -class Scaler; class Screen; struct isdcf_name_test; @@ -159,7 +158,6 @@ public: DCP_CONTENT_TYPE, CONTAINER, RESOLUTION, - SCALER, SIGNED, ENCRYPTED, J2K_BANDWIDTH, @@ -201,10 +199,6 @@ public: return _resolution; } - Scaler const * scaler () const { - return _scaler; - } - /* signed is a reserved word */ bool is_signed () const { return _signed; @@ -262,7 +256,6 @@ public: void set_dcp_content_type (DCPContentType const *); void set_container (Ratio const *); void set_resolution (Resolution); - void set_scaler (Scaler const *); void set_signed (bool); void set_encrypted (bool); void set_j2k_bandwidth (int); @@ -314,8 +307,6 @@ private: Ratio const * _container; /** DCP resolution (2K or 4K) */ Resolution _resolution; - /** Scaler algorithm to use */ - Scaler const * _scaler; bool _signed; bool _encrypted; /** bandwidth for J2K files in bits per second */ diff --git a/src/lib/image.cc b/src/lib/image.cc index 2085b54ee..177219813 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -23,7 +23,6 @@ #include "image.h" #include "exceptions.h" -#include "scaler.h" #include "timer.h" #include "rect.h" #include "util.h" @@ -88,9 +87,8 @@ Image::components () const /** Crop this image, scale it to `inter_size' and then place it in a black frame of `out_size' */ shared_ptr<Image> -Image::crop_scale_window (Crop crop, dcp::Size inter_size, dcp::Size out_size, Scaler const * scaler, AVPixelFormat out_format, bool out_aligned) const +Image::crop_scale_window (Crop crop, dcp::Size inter_size, dcp::Size out_size, AVPixelFormat out_format, bool out_aligned) const { - DCPOMATIC_ASSERT (scaler); /* Empirical testing suggests that sws_scale() will crash if the input image is not aligned. */ @@ -110,7 +108,7 @@ Image::crop_scale_window (Crop crop, dcp::Size inter_size, dcp::Size out_size, S struct SwsContext* scale_context = sws_getContext ( cropped_size.width, cropped_size.height, pixel_format(), inter_size.width, inter_size.height, out_format, - scaler->ffmpeg_id (), 0, 0, 0 + SWS_BICUBIC, 0, 0, 0 ); if (!scale_context) { @@ -144,9 +142,8 @@ Image::crop_scale_window (Crop crop, dcp::Size inter_size, dcp::Size out_size, S } shared_ptr<Image> -Image::scale (dcp::Size out_size, Scaler const * scaler, AVPixelFormat out_format, bool out_aligned) const +Image::scale (dcp::Size out_size, AVPixelFormat out_format, bool out_aligned) const { - DCPOMATIC_ASSERT (scaler); /* Empirical testing suggests that sws_scale() will crash if the input image is not aligned. */ @@ -157,7 +154,7 @@ Image::scale (dcp::Size out_size, Scaler const * scaler, AVPixelFormat out_forma struct SwsContext* scale_context = sws_getContext ( size().width, size().height, pixel_format(), out_size.width, out_size.height, out_format, - scaler->ffmpeg_id (), 0, 0, 0 + SWS_BICUBIC, 0, 0, 0 ); sws_scale ( diff --git a/src/lib/image.h b/src/lib/image.h index b929f4dfc..2e90a89e9 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -35,7 +35,6 @@ extern "C" { #include <boost/function.hpp> #include <string> -class Scaler; class Socket; class Image @@ -58,10 +57,10 @@ public: int line_factor (int) const; int lines (int) const; - boost::shared_ptr<Image> scale (dcp::Size, Scaler const *, AVPixelFormat, bool aligned) const; + boost::shared_ptr<Image> scale (dcp::Size, AVPixelFormat, bool aligned) const; boost::shared_ptr<Image> crop (Crop c, bool aligned) const; - boost::shared_ptr<Image> crop_scale_window (Crop c, dcp::Size, dcp::Size, Scaler const *, AVPixelFormat, bool aligned) const; + boost::shared_ptr<Image> crop_scale_window (Crop c, dcp::Size, dcp::Size, AVPixelFormat, bool aligned) const; void make_black (); void make_transparent (); diff --git a/src/lib/player.cc b/src/lib/player.cc index c9c7de420..e3c85ee56 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -36,7 +36,6 @@ #include "raw_image_proxy.h" #include "ratio.h" #include "log.h" -#include "scaler.h" #include "render_subtitles.h" #include "config.h" #include "content_video.h" @@ -247,7 +246,7 @@ Player::film_changed (Film::Property p) last time we were run. */ - if (p == Film::SCALER || p == Film::CONTAINER || p == Film::VIDEO_FRAME_RATE) { + if (p == Film::CONTAINER || p == Film::VIDEO_FRAME_RATE) { Changed (false); } } @@ -281,7 +280,6 @@ Player::transform_image_subtitles (list<ImageSubtitle> subs) const PositionImage ( i->image->scale ( scaled_size, - Scaler::from_id ("bicubic"), i->image->pixel_format (), true ), @@ -313,7 +311,6 @@ Player::black_player_video_frame (DCPTime time) const optional<float> (), _video_container_size, _video_container_size, - Scaler::from_id ("bicubic"), EYES_BOTH, PART_WHOLE, Config::instance()->colour_conversions().front().conversion @@ -366,7 +363,6 @@ Player::get_video (DCPTime time, bool accurate) content->fade (i->frame), image_size, _video_container_size, - _film->scaler(), i->eyes, i->part, content->colour_conversion () diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index ccd52ea67..f9f06f63a 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -22,7 +22,6 @@ #include "image.h" #include "image_proxy.h" #include "j2k_image_proxy.h" -#include "scaler.h" #include "film.h" using std::string; @@ -39,7 +38,6 @@ PlayerVideo::PlayerVideo ( boost::optional<float> fade, dcp::Size inter_size, dcp::Size out_size, - Scaler const * scaler, Eyes eyes, Part part, optional<ColourConversion> colour_conversion @@ -50,7 +48,6 @@ PlayerVideo::PlayerVideo ( , _fade (fade) , _inter_size (inter_size) , _out_size (out_size) - , _scaler (scaler) , _eyes (eyes) , _part (part) , _colour_conversion (colour_conversion) @@ -66,7 +63,6 @@ PlayerVideo::PlayerVideo (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket _inter_size = dcp::Size (node->number_child<int> ("InterWidth"), node->number_child<int> ("InterHeight")); _out_size = dcp::Size (node->number_child<int> ("OutWidth"), node->number_child<int> ("OutHeight")); - _scaler = Scaler::from_id (node->string_child ("Scaler")); _eyes = (Eyes) node->number_child<int> ("Eyes"); _part = (Part) node->number_child<int> ("Part"); @@ -116,7 +112,7 @@ PlayerVideo::image (AVPixelFormat pixel_format, bool burn_subtitle, dcp::NoteHan break; } - shared_ptr<Image> out = im->crop_scale_window (total_crop, _inter_size, _out_size, _scaler, pixel_format, true); + shared_ptr<Image> out = im->crop_scale_window (total_crop, _inter_size, _out_size, pixel_format, true); if (burn_subtitle && _subtitle.image) { out->alpha_blend (_subtitle.image, _subtitle.position); @@ -142,7 +138,6 @@ PlayerVideo::add_metadata (xmlpp::Node* node, bool send_subtitles) const node->add_child("InterHeight")->add_child_text (raw_convert<string> (_inter_size.height)); node->add_child("OutWidth")->add_child_text (raw_convert<string> (_out_size.width)); node->add_child("OutHeight")->add_child_text (raw_convert<string> (_out_size.height)); - node->add_child("Scaler")->add_child_text (_scaler->id ()); node->add_child("Eyes")->add_child_text (raw_convert<string> (_eyes)); node->add_child("Part")->add_child_text (raw_convert<string> (_part)); if (_colour_conversion) { @@ -203,7 +198,6 @@ PlayerVideo::same (shared_ptr<const PlayerVideo> other) const _fade.get_value_or(0) != other->_fade.get_value_or(0) || _inter_size != other->_inter_size || _out_size != other->_out_size || - _scaler != other->_scaler || _eyes != other->_eyes || _part != other->_part || _colour_conversion != other->_colour_conversion || diff --git a/src/lib/player_video.h b/src/lib/player_video.h index 6762ea8d1..c4537f713 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -28,7 +28,6 @@ extern "C" { class Image; class ImageProxy; -class Scaler; class Socket; class EncodedData; @@ -46,7 +45,6 @@ public: boost::optional<float>, dcp::Size, dcp::Size, - Scaler const *, Eyes, Part, boost::optional<ColourConversion> @@ -93,7 +91,6 @@ private: boost::optional<float> _fade; dcp::Size _inter_size; dcp::Size _out_size; - Scaler const * _scaler; Eyes _eyes; Part _part; boost::optional<ColourConversion> _colour_conversion; diff --git a/src/lib/scaler.cc b/src/lib/scaler.cc deleted file mode 100644 index 43c1ac81c..000000000 --- a/src/lib/scaler.cc +++ /dev/null @@ -1,118 +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/scaler.cc - * @brief A class to describe one of FFmpeg's software scalers. - */ - -#include "dcpomatic_assert.h" -#include "scaler.h" -extern "C" { -#include <libswscale/swscale.h> -} -#include <iostream> -#include <cassert> - -#include "i18n.h" - -using namespace std; - -vector<Scaler const *> Scaler::_scalers; - -/** @param f FFmpeg id. - * @param i Our id. - * @param n User-visible name. - */ -Scaler::Scaler (int f, string i, string n) - : _ffmpeg_id (f) - , _id (i) - , _name (n) -{ - -} - -/** @return All available scalers */ -vector<Scaler const *> -Scaler::all () -{ - return _scalers; -} - -/** Set up the static _scalers vector; must be called before from_* - * methods are used. - */ -void -Scaler::setup_scalers () -{ - _scalers.push_back (new Scaler (SWS_BICUBIC, N_("bicubic"), _("Bicubic"))); - _scalers.push_back (new Scaler (SWS_X, N_("x"), _("X"))); - _scalers.push_back (new Scaler (SWS_AREA, N_("area"), _("Area"))); - _scalers.push_back (new Scaler (SWS_GAUSS, N_("gauss"), _("Gaussian"))); - _scalers.push_back (new Scaler (SWS_LANCZOS, N_("lanczos"), _("Lanczos"))); - _scalers.push_back (new Scaler (SWS_SINC, N_("sinc"), _("Sinc"))); - _scalers.push_back (new Scaler (SWS_SPLINE, N_("spline"), _("Spline"))); - _scalers.push_back (new Scaler (SWS_BILINEAR, N_("bilinear"), _("Bilinear"))); - _scalers.push_back (new Scaler (SWS_FAST_BILINEAR, N_("fastbilinear"), _("Fast Bilinear"))); -} - -/** @param id One of our ids. - * @return Corresponding scaler, or 0. - */ -Scaler const * -Scaler::from_id (string id) -{ - vector<Scaler const *>::iterator i = _scalers.begin (); - while (i != _scalers.end() && (*i)->id() != id) { - ++i; - } - - if (i == _scalers.end ()) { - return 0; - } - - return *i; -} - -/** @param s A scaler from our static list. - * @return Index of the scaler with the list, or -1. - */ -int -Scaler::as_index (Scaler const * s) -{ - vector<Scaler*>::size_type i = 0; - while (i < _scalers.size() && _scalers[i] != s) { - ++i; - } - - if (i == _scalers.size ()) { - return -1; - } - - return i; -} - -/** @param i An index returned from as_index(). - * @return Corresponding scaler. - */ -Scaler const * -Scaler::from_index (int i) -{ - DCPOMATIC_ASSERT (i <= int(_scalers.size ())); - return _scalers[i]; -} diff --git a/src/lib/scaler.h b/src/lib/scaler.h deleted file mode 100644 index 0f0bcb1aa..000000000 --- a/src/lib/scaler.h +++ /dev/null @@ -1,73 +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/scaler.h - * @brief A class to describe one of FFmpeg's software scalers. - */ - -#ifndef DCPOMATIC_SCALER_H -#define DCPOMATIC_SCALER_H - -#include <boost/utility.hpp> -#include <string> -#include <vector> - -/** @class Scaler - * @brief Class to describe one of FFmpeg's software scalers - */ -class Scaler : public boost::noncopyable -{ -public: - Scaler (int f, std::string i, std::string n); - - /** @return id used for calls to FFmpeg's sws_getContext */ - int ffmpeg_id () const { - return _ffmpeg_id; - } - - /** @return id for our use */ - std::string id () const { - return _id; - } - - /** @return user-visible name for this scaler */ - std::string name () const { - return _name; - } - - static std::vector<Scaler const *> all (); - static void setup_scalers (); - static Scaler const * from_id (std::string id); - static Scaler const * from_index (int); - static int as_index (Scaler const *); - -private: - - /** id used for calls to FFmpeg's pp_postprocess */ - int _ffmpeg_id; - /** id for our use */ - std::string _id; - /** user-visible name for this scaler */ - std::string _name; - - /** all available scalers */ - static std::vector<Scaler const *> _scalers; -}; - -#endif diff --git a/src/lib/server.cc b/src/lib/server.cc index 32e1e38b2..ba8580732 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -24,7 +24,6 @@ #include "server.h" #include "dcpomatic_socket.h" -#include "scaler.h" #include "image.h" #include "dcp_video.h" #include "config.h" diff --git a/src/lib/util.cc b/src/lib/util.cc index 2b5eb69fb..6ebdc85d4 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -23,7 +23,6 @@ #include "util.h" #include "exceptions.h" -#include "scaler.h" #include "dcp_content_type.h" #include "filter.h" #include "cinema_sound_processor.h" @@ -327,7 +326,6 @@ dcpomatic_setup () Ratio::setup_ratios (); VideoContentScale::setup_scales (); DCPContentType::setup_dcp_content_types (); - Scaler::setup_scalers (); Filter::setup_filters (); CinemaSoundProcessor::setup_cinema_sound_processors (); AudioProcessor::setup_audio_processors (); diff --git a/src/lib/wscript b/src/lib/wscript index 217c0c86d..24aa7c134 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -74,7 +74,6 @@ sources = """ resampler.cc safe_stringstream.cc scp_dcp_job.cc - scaler.cc scoped_temporary.cc send_kdm_email_job.cc send_problem_report_job.cc |
