#include "filter.h"
extern "C" {
#include <libavfilter/avfilter.h>
-#include <libpostproc/postprocess.h>
}
#include "i18n.h"
/** @param i Our id.
* @param n User-visible name.
* @param c User-visible category.
- * @param v String for a FFmpeg video filter descriptor, or "".
- * @param p String for a FFmpeg post-processing descriptor, or "".
+ * @param v String for a FFmpeg video filter descriptor.
*/
-Filter::Filter (string i, string n, string c, string v, string p)
+Filter::Filter (string i, string n, string c, string v)
: _id (i)
, _name (n)
, _category (c)
, _vf (v)
- , _pp (p)
{
}
{
/* Note: "none" is a magic id name, so don't use it here */
- maybe_add (N_("pphb"), _("Horizontal deblocking filter"), _("De-blocking"), N_(""), N_("hb"));
- maybe_add (N_("ppvb"), _("Vertical deblocking filter"), _("De-blocking"), N_(""), N_("vb"));
- maybe_add (N_("ppha"), _("Horizontal deblocking filter A"), _("De-blocking"), N_(""), N_("ha"));
- maybe_add (N_("ppva"), _("Vertical deblocking filter A"), _("De-blocking"), N_(""), N_("va"));
- maybe_add (N_("pph1"), _("Experimental horizontal deblocking filter 1"), _("De-blocking"), N_(""), N_("h1"));
- maybe_add (N_("pphv"), _("Experimental vertical deblocking filter 1"), _("De-blocking"), N_(""), N_("v1"));
- maybe_add (N_("ppdr"), _("Deringing filter"), _("Misc"), N_(""), N_("dr"));
- maybe_add (N_("pplb"), _("Linear blend deinterlacer"), _("De-interlacing"), N_(""), N_("lb"));
- maybe_add (N_("ppli"), _("Linear interpolating deinterlacer"), _("De-interlacing"), N_(""), N_("li"));
- maybe_add (N_("ppci"), _("Cubic interpolating deinterlacer"), _("De-interlacing"), N_(""), N_("ci"));
- maybe_add (N_("ppmd"), _("Median deinterlacer"), _("De-interlacing"), N_(""), N_("md"));
- maybe_add (N_("ppfd"), _("FFMPEG deinterlacer"), _("De-interlacing"), N_(""), N_("fd"));
- maybe_add (N_("ppl5"), _("FIR low-pass deinterlacer"), _("De-interlacing"), N_(""), N_("l5"));
- maybe_add (N_("mcdeint"), _("Motion compensating deinterlacer"), _("De-interlacing"), N_("mcdeint"), N_(""));
- maybe_add (N_("kerndeint"), _("Kernel deinterlacer"), _("De-interlacing"), N_("kerndeint"), N_(""));
- maybe_add (N_("yadif"), _("Yet Another Deinterlacing Filter"), _("De-interlacing"), N_("yadif"), N_(""));
- maybe_add (N_("pptn"), _("Temporal noise reducer"), _("Noise reduction"), N_(""), N_("tn"));
- maybe_add (N_("ppfq"), _("Force quantizer"), _("Misc"), N_(""), N_("fq"));
- maybe_add (N_("gradfun"), _("Gradient debander"), _("Misc"), N_("gradfun"), N_(""));
- maybe_add (N_("unsharp"), _("Unsharp mask and Gaussian blur"), _("Misc"), N_("unsharp"), N_(""));
- maybe_add (N_("denoise3d"), _("3D denoiser"), _("Noise reduction"), N_("denoise3d"), N_(""));
- maybe_add (N_("hqdn3d"), _("High quality 3D denoiser"), _("Noise reduction"), N_("hqdn3d"), N_(""));
- maybe_add (N_("telecine"), _("Telecine filter"), _("Misc"), N_("telecine"), N_(""));
- maybe_add (N_("ow"), _("Overcomplete wavelet denoiser"), _("Noise reduction"), N_("mp=ow"), N_(""));
+ 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"));
}
void
-Filter::maybe_add (string i, string n, string c, string v, string p)
+Filter::maybe_add (string i, string n, string c, string v)
{
- if (!v.empty ()) {
- if (avfilter_get_by_name (i.c_str())) {
- _filters.push_back (new Filter (i, n, c, v, p));
- }
- } else if (!p.empty ()) {
- pp_mode* m = pp_get_mode_by_name_and_quality (p.c_str(), PP_QUALITY_MAX);
- if (m) {
- _filters.push_back (new Filter (i, n, c, v, p));
- pp_free_mode (m);
- }
+ if (avfilter_get_by_name (i.c_str())) {
+ _filters.push_back (new Filter (i, n, c, v));
}
}
/** @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<string, string>
-Filter::ffmpeg_strings (vector<Filter const *> const & filters)
+string
+Filter::ffmpeg_string (vector<Filter const *> const & filters)
{
string vf;
- string pp;
for (vector<Filter const *>::const_iterator i = filters.begin(); i != filters.end(); ++i) {
- if (!(*i)->vf().empty ()) {
- if (!vf.empty ()) {
- vf += N_(",");
- }
- vf += (*i)->vf ();
- }
-
- if (!(*i)->pp().empty ()) {
- if (!pp.empty()) {
- pp += N_(",");
- }
- pp += (*i)->pp ();
+ if (!vf.empty ()) {
+ vf += N_(",");
}
+ vf += (*i)->vf ();
}
- return make_pair (vf, pp);
+ return vf;
}
/** @param d Our id.
#include <boost/utility.hpp>
/** @class Filter
- * @brief A class to describe one of FFmpeg's video or post-processing filters.
+ * @brief A class to describe one of FFmpeg's video filters.
+ *
+ * We don't support FFmpeg's post-processing filters here as they cannot cope with greater than
+ * 8bpp. FFmpeg quantizes e.g. yuv422p10le down to yuv422p before running such filters, which
+ * we don't really want to do.
*/
class Filter : public boost::noncopyable
{
public:
- Filter (std::string, std::string, std::string, std::string, std::string);
+ Filter (std::string, std::string, std::string, std::string);
/** @return our id */
std::string id () const {
return _vf;
}
- /** @return string for a FFmpeg post-processing descriptor */
- std::string pp () const {
- return _pp;
- }
-
std::string category () const {
return _category;
}
static std::vector<Filter const *> all ();
static Filter const * from_id (std::string);
static void setup_filters ();
- static std::pair<std::string, std::string> ffmpeg_strings (std::vector<Filter const *> const &);
+ static std::string ffmpeg_string (std::vector<Filter const *> const &);
private:
std::string _category;
/** string for a FFmpeg video filter descriptor */
std::string _vf;
- /** string for a FFmpeg post-processing descriptor */
- std::string _pp;
/** all available filters */
static std::vector<Filter const *> _filters;
- static void maybe_add (std::string, std::string, std::string, std::string, std::string);
+ static void maybe_add (std::string, std::string, std::string, std::string);
};
#endif
return scaled;
}
-/** Run a FFmpeg post-process on this image and return the processed version.
- * @param pp Flags for the required set of post processes.
- * @return Post-processed image.
- */
-shared_ptr<Image>
-Image::post_process (string pp, bool aligned) const
-{
- shared_ptr<Image> out (new Image (pixel_format(), size (), aligned));
-
- int pp_format = 0;
- switch (pixel_format()) {
- case PIX_FMT_YUV420P:
- pp_format = PP_FORMAT_420;
- break;
- case PIX_FMT_YUV422P10LE:
- case PIX_FMT_YUV422P:
- case PIX_FMT_UYVY422:
- pp_format = PP_FORMAT_422;
- break;
- case PIX_FMT_YUV444P:
- case PIX_FMT_YUV444P9BE:
- case PIX_FMT_YUV444P9LE:
- case PIX_FMT_YUV444P10BE:
- case PIX_FMT_YUV444P10LE:
- pp_format = PP_FORMAT_444;
- default:
- throw PixelFormatError ("post_process", pixel_format());
- }
-
- pp_mode* mode = pp_get_mode_by_name_and_quality (pp.c_str (), PP_QUALITY_MAX);
- pp_context* context = pp_get_context (size().width, size().height, pp_format | PP_CPU_CAPS_MMX2);
-
- pp_postprocess (
- (const uint8_t **) data(), stride(),
- out->data(), out->stride(),
- size().width, size().height,
- 0, 0, mode, context, 0
- );
-
- pp_free_mode (mode);
- pp_free_context (context);
-
- return out;
-}
-
shared_ptr<Image>
Image::crop (Crop crop, bool aligned) const
{