X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilter.cc;h=9158cba5c10b6741995433ea767c2a3899611920;hb=62c03e3d3493df8a31361b3281c443cac35decb0;hp=d0e8c8fa4e3e825db89604c32489cb00718e76cb;hpb=67705b5665715abebfdd33e9f36797f040bc3e79;p=dcpomatic.git diff --git a/src/lib/filter.cc b/src/lib/filter.cc index d0e8c8fa4..9158cba5c 100644 --- a/src/lib/filter.cc +++ b/src/lib/filter.cc @@ -1,37 +1,45 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2021 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 audio filters. */ + #include "filter.h" +#include +LIBDCP_DISABLE_WARNINGS extern "C" { #include } -#include +LIBDCP_ENABLE_WARNINGS #include "i18n.h" + using namespace std; -vector Filter::_filters; + +vector Filter::_filters; + /** @param i Our id. * @param n User-visible name. @@ -47,13 +55,19 @@ Filter::Filter (string i, string n, string c, string f) } + /** @return All available filters */ vector Filter::all () { - return _filters; + vector raw; + for (auto& filter: _filters) { + raw.push_back (&filter); + } + return raw; } + /** Set up the static _filters vector; must be called before from_* * methods are used. */ @@ -62,25 +76,39 @@ Filter::setup_filters () { /* Note: "none" is a magic id name, so don't use it here */ - 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_("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")); + 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) { - if (avfilter_get_by_name (i.c_str())) { - _filters.push_back (new Filter (i, n, c, 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 (Filter(i, n, c, f)); } } + /** @param filters Set of filters. * @return String to pass to FFmpeg for the video filters. */ @@ -89,7 +117,7 @@ Filter::ffmpeg_string (vector const & filters) { string ff; - BOOST_FOREACH (Filter const * i, filters) { + for (auto const i: filters) { if (!ff.empty ()) { ff += N_(","); } @@ -99,20 +127,21 @@ Filter::ffmpeg_string (vector const & filters) return ff; } + /** @param d Our id. * @return Corresponding Filter, or 0. */ Filter const * Filter::from_id (string d) { - vector::iterator i = _filters.begin (); - while (i != _filters.end() && (*i)->id() != d) { + auto i = _filters.begin (); + while (i != _filters.end() && i->id() != d) { ++i; } if (i == _filters.end ()) { - return 0; + return nullptr; } - return *i; + return &(*i); }