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/filter.cc
21 * @brief A class to describe one of FFmpeg's video or post-processing filters.
26 #include <libavfilter/avfilter.h>
33 vector<Filter const *> Filter::_filters;
36 * @param n User-visible name.
37 * @param c User-visible category.
38 * @param v String for a FFmpeg video filter descriptor.
40 Filter::Filter (string i, string n, string c, string v)
49 /** @return All available filters */
50 vector<Filter const *>
57 /** Set up the static _filters vector; must be called before from_*
61 Filter::setup_filters ()
63 /* Note: "none" is a magic id name, so don't use it here */
65 maybe_add (N_("mcdeint"), _("Motion compensating deinterlacer"), _("De-interlacing"), N_("mcdeint"));
66 maybe_add (N_("kerndeint"), _("Kernel deinterlacer"), _("De-interlacing"), N_("kerndeint"));
67 maybe_add (N_("yadif"), _("Yet Another Deinterlacing Filter"), _("De-interlacing"), N_("yadif"));
68 maybe_add (N_("gradfun"), _("Gradient debander"), _("Misc"), N_("gradfun"));
69 maybe_add (N_("unsharp"), _("Unsharp mask and Gaussian blur"), _("Misc"), N_("unsharp"));
70 maybe_add (N_("denoise3d"), _("3D denoiser"), _("Noise reduction"), N_("denoise3d"));
71 maybe_add (N_("hqdn3d"), _("High quality 3D denoiser"), _("Noise reduction"), N_("hqdn3d"));
72 maybe_add (N_("telecine"), _("Telecine filter"), _("Misc"), N_("telecine"));
73 maybe_add (N_("ow"), _("Overcomplete wavelet denoiser"), _("Noise reduction"), N_("mp=ow"));
77 Filter::maybe_add (string i, string n, string c, string v)
79 if (avfilter_get_by_name (i.c_str())) {
80 _filters.push_back (new Filter (i, n, c, v));
84 /** @param filters Set of filters.
85 * @return String to pass to FFmpeg for the video filters.
88 Filter::ffmpeg_string (vector<Filter const *> const & filters)
92 for (vector<Filter const *>::const_iterator i = filters.begin(); i != filters.end(); ++i) {
103 * @return Corresponding Filter, or 0.
106 Filter::from_id (string d)
108 vector<Filter const *>::iterator i = _filters.begin ();
109 while (i != _filters.end() && (*i)->id() != d) {
113 if (i == _filters.end ()) {