2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/scaler.cc
21 * @brief A class to describe one of FFmpeg's software scalers.
24 #include "dcpomatic_assert.h"
27 #include <libswscale/swscale.h>
36 vector<Scaler const *> Scaler::_scalers;
38 /** @param f FFmpeg id.
40 * @param n User-visible name.
42 Scaler::Scaler (int f, string i, string n)
50 /** @return All available scalers */
51 vector<Scaler const *>
57 /** Set up the static _scalers vector; must be called before from_*
61 Scaler::setup_scalers ()
63 _scalers.push_back (new Scaler (SWS_BICUBIC, N_("bicubic"), _("Bicubic")));
64 _scalers.push_back (new Scaler (SWS_X, N_("x"), _("X")));
65 _scalers.push_back (new Scaler (SWS_AREA, N_("area"), _("Area")));
66 _scalers.push_back (new Scaler (SWS_GAUSS, N_("gauss"), _("Gaussian")));
67 _scalers.push_back (new Scaler (SWS_LANCZOS, N_("lanczos"), _("Lanczos")));
68 _scalers.push_back (new Scaler (SWS_SINC, N_("sinc"), _("Sinc")));
69 _scalers.push_back (new Scaler (SWS_SPLINE, N_("spline"), _("Spline")));
70 _scalers.push_back (new Scaler (SWS_BILINEAR, N_("bilinear"), _("Bilinear")));
71 _scalers.push_back (new Scaler (SWS_FAST_BILINEAR, N_("fastbilinear"), _("Fast Bilinear")));
74 /** @param id One of our ids.
75 * @return Corresponding scaler, or 0.
78 Scaler::from_id (string id)
80 vector<Scaler const *>::iterator i = _scalers.begin ();
81 while (i != _scalers.end() && (*i)->id() != id) {
85 if (i == _scalers.end ()) {
92 /** @param s A scaler from our static list.
93 * @return Index of the scaler with the list, or -1.
96 Scaler::as_index (Scaler const * s)
98 vector<Scaler*>::size_type i = 0;
99 while (i < _scalers.size() && _scalers[i] != s) {
103 if (i == _scalers.size ()) {
110 /** @param i An index returned from as_index().
111 * @return Corresponding scaler.
114 Scaler::from_index (int i)
116 DCPOMATIC_ASSERT (i <= int(_scalers.size ()));