X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilter.cc;h=5631af55a8885a5d1e6a02cad27d1cb7e85bd9a8;hb=8044bcbf5ec36ced1d507742c6c3d654dd961ed9;hp=6869d26c99b582d60250870fc9613992eb28cc0a;hpb=a5d004b0773f633401528392fc28e66d70e13ac8;p=dcpomatic.git diff --git a/src/lib/filter.cc b/src/lib/filter.cc index 6869d26c9..5631af55a 100644 --- a/src/lib/filter.cc +++ b/src/lib/filter.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,22 +18,30 @@ */ + /** @file src/filter.cc * @brief A class to describe one of FFmpeg's video or audio filters. */ + #include "filter.h" +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS extern "C" { #include } +DCPOMATIC_ENABLE_WARNINGS #include #include "i18n.h" + using namespace std; + vector Filter::_filters; + /** @param i Our id. * @param n User-visible name. * @param c User-visible category. @@ -48,6 +56,7 @@ Filter::Filter (string i, string n, string c, string f) } + /** @return All available filters */ vector Filter::all () @@ -55,6 +64,7 @@ Filter::all () return _filters; } + /** Set up the static _filters vector; must be called before from_* * methods are used. */ @@ -80,6 +90,7 @@ Filter::setup_filters () maybe_add (N_("ow"), _("Overcomplete wavelet denoiser"), _("Noise reduction"), N_("mp=ow")); } + void Filter::maybe_add (string i, string n, string c, string f) { @@ -89,11 +100,12 @@ Filter::maybe_add (string i, string n, string c, string f) 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)); + if (avfilter_get_by_name(check_name.c_str())) { + _filters.push_back (new Filter(i, n, c, f)); } } + /** @param filters Set of filters. * @return String to pass to FFmpeg for the video filters. */ @@ -112,19 +124,20 @@ 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 (); + auto i = _filters.begin (); while (i != _filters.end() && (*i)->id() != d) { ++i; } if (i == _filters.end ()) { - return 0; + return nullptr; } return *i;