X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Ffilter.cc;h=663d1454742e63f388af460430f048cf68abd4b0;hp=446cc111dcdeeb7f0e22027969213aab6353a4fc;hb=386e25f3b9d3fa59cbdeed458d9b3e0d21e338b8;hpb=009a58293bf2e9727d544d1a2648422cc395d81e diff --git a/src/lib/filter.cc b/src/lib/filter.cc index 446cc111d..663d14547 100644 --- a/src/lib/filter.cc +++ b/src/lib/filter.cc @@ -1,27 +1,35 @@ /* Copyright (C) 2012 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic 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, + DCP-o-matic 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. + along with DCP-o-matic. If not, see . */ /** @file src/filter.cc - * @brief A class to describe one of FFmpeg's video or post-processing filters. + * @brief A class to describe one of FFmpeg's video or audio filters. */ #include "filter.h" +extern "C" { +#include +} +#include +#include + +#include "i18n.h" using namespace std; @@ -29,14 +37,14 @@ vector Filter::_filters; /** @param i Our id. * @param n User-visible name. - * @param v String for a FFmpeg video filter descriptor, or "". - * @param p String for a FFmpeg post-processing descriptor, or "". + * @param c User-visible category. + * @param f String for a FFmpeg filter descriptor. */ -Filter::Filter (string i, string n, string v, string p) +Filter::Filter (string i, string n, string c, string f) : _id (i) , _name (n) - , _vf (v) - , _pp (p) + , _category (c) + , _ffmpeg (f) { } @@ -48,7 +56,6 @@ Filter::all () return _filters; } - /** Set up the static _filters vector; must be called before from_* * methods are used. */ @@ -56,60 +63,54 @@ void Filter::setup_filters () { /* Note: "none" is a magic id name, so don't use it here */ - - _filters.push_back (new Filter ("pphb", "Horizontal deblocking filter", "", "hb")); - _filters.push_back (new Filter ("ppvb", "Vertical deblocking filter", "", "vb")); - _filters.push_back (new Filter ("ppha", "Horizontal deblocking filter A", "", "ha")); - _filters.push_back (new Filter ("ppva", "Vertical deblocking filter A", "", "va")); - _filters.push_back (new Filter ("pph1", "Experimental horizontal deblocking filter 1", "", "h1")); - _filters.push_back (new Filter ("pphv", "Experimental vertical deblocking filter 1", "", "v1")); - _filters.push_back (new Filter ("ppdr", "Deringing filter", "", "dr")); - _filters.push_back (new Filter ("pplb", "Linear blend deinterlacer", "", "lb")); - _filters.push_back (new Filter ("ppli", "Linear interpolating deinterlacer", "", "li")); - _filters.push_back (new Filter ("ppci", "Cubic interpolating deinterlacer", "", "ci")); - _filters.push_back (new Filter ("ppmd", "Median deinterlacer", "", "md")); - _filters.push_back (new Filter ("ppfd", "FFMPEG deinterlacer", "", "fd")); - _filters.push_back (new Filter ("ppl5", "FIR low-pass deinterlacer", "", "l5")); - _filters.push_back (new Filter ("mcdeint", "Motion compensating deinterlacer", "mcdeint", "")); - _filters.push_back (new Filter ("kerndeint", "Kernel deinterlacer", "kerndeint", "")); - _filters.push_back (new Filter ("yadif", "Yet Another Deinterlacing Filter", "yadif", "")); - _filters.push_back (new Filter ("pptn", "Temporal noise reducer", "", "tn")); - _filters.push_back (new Filter ("ppfq", "Force quantizer", "", "fq")); - _filters.push_back (new Filter ("gradfun", "Gradient debander", "gradfun", "")); - _filters.push_back (new Filter ("unsharp", "Unsharp mask and Gaussian blur", "unsharp", "")); - _filters.push_back (new Filter ("denoise3d", "3D denoiser", "denoise3d", "")); - _filters.push_back (new Filter ("hqdn3d", "High quality 3D denoiser", "hqdn3d", "")); - _filters.push_back (new Filter ("telecine", "Telecine filter", "telecine", "")); - _filters.push_back (new Filter ("ow", "Overcomplete wavelet denoiser", "mp=ow", "")); + + maybe_add (N_("vflip"), _("Vertical flip"), _("Orientation"), N_("vflip")); + maybe_add (N_("hflip"), _("Horizontal flip"), _("Orientation"), N_("hflip")); + maybe_add (N_("90clock"), _("Rotate 90 degrees clockwise"), _("Orientation"), N_("transpose=dir=clock")); + maybe_add (N_("90anticlock"), _("Rotate 90 degrees anti-clockwise"), _("Orientation"), N_("transpose=dir=cclock")); + maybe_add (N_("mcdeint"), _("Motion compensating deinterlacer"), _("De-interlacing"), N_("mcdeint")); + maybe_add (N_("kerndeint"), _("Kernel deinterlacer"), _("De-interlacing"), N_("kerndeint")); + maybe_add (N_("yadif"), _("Yet Another Deinterlacing Filter"), _("De-interlacing"), N_("yadif")); + maybe_add (N_("bwdif"), _("Bob Weaver Deinterlacing Filter"), _("De-interlacing"), N_("bwdif")); + maybe_add (N_("weave"), _("Weave filter"), _("De-interlacing"), N_("weave")); + maybe_add (N_("gradfun"), _("Gradient debander"), _("Misc"), N_("gradfun")); + maybe_add (N_("unsharp"), _("Unsharp mask and Gaussian blur"), _("Misc"), N_("unsharp")); + maybe_add (N_("denoise3d"), _("3D denoiser"), _("Noise reduction"), N_("denoise3d")); + maybe_add (N_("hqdn3d"), _("High quality 3D denoiser"), _("Noise reduction"), N_("hqdn3d")); + maybe_add (N_("telecine"), _("Telecine filter"), _("Misc"), N_("telecine")); + maybe_add (N_("ow"), _("Overcomplete wavelet denoiser"), _("Noise reduction"), N_("mp=ow")); +} + +void +Filter::maybe_add (string i, string n, string c, string f) +{ + string check_name = f; + size_t end = check_name.find("="); + if (end != string::npos) { + check_name = check_name.substr (0, end); + } + + if (avfilter_get_by_name (check_name.c_str())) { + _filters.push_back (new Filter (i, n, c, f)); + } } /** @param filters Set of filters. - * @return A pair; .first is a string to pass to FFmpeg for the video filters, - * .second is a string to pass for the post-processors. + * @return String to pass to FFmpeg for the video filters. */ -pair -Filter::ffmpeg_strings (vector const & filters) +string +Filter::ffmpeg_string (vector const & filters) { - string vf; - string pp; - - for (vector::const_iterator i = filters.begin(); i != filters.end(); ++i) { - if (!(*i)->vf().empty ()) { - if (!vf.empty ()) { - vf += ","; - } - vf += (*i)->vf (); - } - - if (!(*i)->pp().empty ()) { - if (!pp.empty()) { - pp += ","; - } - pp += (*i)->pp (); + string ff; + + BOOST_FOREACH (Filter const * i, filters) { + if (!ff.empty ()) { + ff += N_(","); } + ff += i->ffmpeg (); } - return make_pair (vf, pp); + return ff; } /** @param d Our id. @@ -129,4 +130,3 @@ Filter::from_id (string d) return *i; } -