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.
27 #include <libswscale/swscale.h>
33 vector<Scaler const *> Scaler::_scalers;
35 /** @param f FFmpeg id.
37 * @param n User-visible name.
39 Scaler::Scaler (int f, string i, string n)
47 /** @return All available scalers */
48 vector<Scaler const *>
54 /** Set up the static _scalers vector; must be called before from_*
58 Scaler::setup_scalers ()
60 _scalers.push_back (new Scaler (SWS_BICUBIC, "bicubic", "Bicubic"));
61 _scalers.push_back (new Scaler (SWS_X, "x", "X"));
62 _scalers.push_back (new Scaler (SWS_AREA, "area", "Area"));
63 _scalers.push_back (new Scaler (SWS_GAUSS, "gauss", "Gaussian"));
64 _scalers.push_back (new Scaler (SWS_LANCZOS, "lanczos", "Lanczos"));
65 _scalers.push_back (new Scaler (SWS_SINC, "sinc", "Sinc"));
66 _scalers.push_back (new Scaler (SWS_SPLINE, "spline", "Spline"));
67 _scalers.push_back (new Scaler (SWS_BILINEAR, "bilinear", "Bilinear"));
68 _scalers.push_back (new Scaler (SWS_FAST_BILINEAR, "fastbilinear", "Fast Bilinear"));
71 /** @param id One of our ids.
72 * @return Corresponding scaler, or 0.
75 Scaler::from_id (string id)
77 vector<Scaler const *>::iterator i = _scalers.begin ();
78 while (i != _scalers.end() && (*i)->id() != id) {
82 if (i == _scalers.end ()) {
89 /** @param s A scaler from our static list.
90 * @return Index of the scaler with the list, or -1.
93 Scaler::as_index (Scaler const * s)
95 vector<Scaler*>::size_type i = 0;
96 while (i < _scalers.size() && _scalers[i] != s) {
100 if (i == _scalers.size ()) {
107 /** @param i An index returned from as_index().
108 * @return Corresponding scaler.
111 Scaler::from_index (int i)
113 assert (i <= int(_scalers.size ()));