From 16e8c1c7222796246f74153bf294909c3efe57dc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 15 Mar 2014 13:25:09 +0000 Subject: [PATCH] Remove support for FFmpeg postprocessing filters. --- ChangeLog | 6 +++ src/lib/ffmpeg_content.cc | 4 +- src/lib/ffmpeg_decoder.cc | 5 --- src/lib/filter.cc | 79 +++++++++++---------------------------- src/lib/filter.h | 19 ++++------ src/lib/filter_graph.cc | 2 +- src/lib/image.cc | 45 ---------------------- src/lib/image.h | 1 - src/wx/video_panel.cc | 7 ++-- wscript | 3 -- 10 files changed, 41 insertions(+), 130 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3891521c8..2820a2ff4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-03-15 Carl Hetherington + + * Remove support for FFmpeg post-processing filters as they apparently + do not support > 8bpp. I don't think they are worth the pain of + quantizing and then telling the user what has happened. + 2014-03-12 Carl Hetherington * Version 1.66.1 released. diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 47fe4f807..e52e36f78 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -215,13 +215,13 @@ FFmpegContent::technical_summary () const ss = _subtitle_stream->technical_summary (); } - pair filt = Filter::ffmpeg_strings (_filters); + string filt = Filter::ffmpeg_string (_filters); return Content::technical_summary() + " - " + VideoContent::technical_summary() + " - " + AudioContent::technical_summary() + " - " + String::compose ( - "ffmpeg: audio %1, subtitle %2, filters %3 %4", as, ss, filt.first, filt.second + "ffmpeg: audio %1, subtitle %2, filters %3", as, ss, filt ); } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 347d8cc08..851c64606 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -468,14 +468,9 @@ FFmpegDecoder::decode_video_packet () list, int64_t> > images = graph->process (_frame); - string post_process = Filter::ffmpeg_strings (_ffmpeg_content->filters()).second; - for (list, int64_t> >::iterator i = images.begin(); i != images.end(); ++i) { shared_ptr image = i->first; - if (!post_process.empty ()) { - image = image->post_process (post_process, true); - } if (i->second != AV_NOPTS_VALUE) { diff --git a/src/lib/filter.cc b/src/lib/filter.cc index 640a531e8..a7dd9c5ce 100644 --- a/src/lib/filter.cc +++ b/src/lib/filter.cc @@ -24,7 +24,6 @@ #include "filter.h" extern "C" { #include -#include } #include "i18n.h" @@ -36,15 +35,13 @@ vector Filter::_filters; /** @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) { } @@ -65,75 +62,41 @@ Filter::setup_filters () { /* 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 -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 += 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. diff --git a/src/lib/filter.h b/src/lib/filter.h index 5971cd5cf..258e74991 100644 --- a/src/lib/filter.h +++ b/src/lib/filter.h @@ -29,12 +29,16 @@ #include /** @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 { @@ -51,11 +55,6 @@ public: return _vf; } - /** @return string for a FFmpeg post-processing descriptor */ - std::string pp () const { - return _pp; - } - std::string category () const { return _category; } @@ -63,7 +62,7 @@ public: static std::vector all (); static Filter const * from_id (std::string); static void setup_filters (); - static std::pair ffmpeg_strings (std::vector const &); + static std::string ffmpeg_string (std::vector const &); private: @@ -74,12 +73,10 @@ 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 _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 diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc index cd5d19807..a36a41f43 100644 --- a/src/lib/filter_graph.cc +++ b/src/lib/filter_graph.cc @@ -60,7 +60,7 @@ FilterGraph::FilterGraph (shared_ptr content, libdcp::Size { _frame = av_frame_alloc (); - string filters = Filter::ffmpeg_strings (content->filters()).first; + string filters = Filter::ffmpeg_string (content->filters()); if (filters.empty ()) { filters = "copy"; } diff --git a/src/lib/image.cc b/src/lib/image.cc index c7dfc91cb..25d1ef276 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -167,51 +167,6 @@ Image::scale (libdcp::Size out_size, Scaler const * scaler, AVPixelFormat out_fo 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::post_process (string pp, bool aligned) const -{ - shared_ptr 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::crop (Crop crop, bool aligned) const { diff --git a/src/lib/image.h b/src/lib/image.h index b12db3a14..2d9f32231 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -58,7 +58,6 @@ public: int lines (int) const; boost::shared_ptr scale (libdcp::Size, Scaler const *, AVPixelFormat, bool aligned) const; - boost::shared_ptr post_process (std::string, bool aligned) const; boost::shared_ptr crop (Crop c, bool aligned) const; boost::shared_ptr crop_scale_window (Crop c, libdcp::Size, libdcp::Size, Scaler const *, AVPixelFormat, bool aligned) const; diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index aa0f7d019..38604248c 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -240,12 +240,11 @@ VideoPanel::film_content_changed (int property) _colour_conversion->SetLabel (preset ? std_to_wx (cc[preset.get()].name) : _("Custom")); } else if (property == FFmpegContentProperty::FILTERS) { if (fcs) { - pair p = Filter::ffmpeg_strings (fcs->filters ()); - if (p.first.empty () && p.second.empty ()) { + string const p = Filter::ffmpeg_string (fcs->filters ()); + if (p.empty ()) { _filters->SetLabel (_("None")); } else { - string const b = p.first + " " + p.second; - _filters->SetLabel (std_to_wx (b)); + _filters->SetLabel (std_to_wx (p)); } } } diff --git a/wscript b/wscript index 0274916d5..aa20e9946 100644 --- a/wscript +++ b/wscript @@ -33,8 +33,6 @@ def static_ffmpeg(conf): conf.env.STLIB_SWSCALE = ['swscale'] conf.check_cfg(package='libswresample', args='--cflags', uselib_store='SWRESAMPLE', mandatory=True) conf.env.STLIB_SWRESAMPLE = ['swresample'] - conf.check_cfg(package='libpostproc', args='--cflags', uselib_store='POSTPROC', mandatory=True) - conf.env.STLIB_POSTPROC = ['postproc'] def dynamic_ffmpeg(conf): conf.check_cfg(package='libavformat', args='--cflags --libs', uselib_store='AVFORMAT', mandatory=True) @@ -43,7 +41,6 @@ def dynamic_ffmpeg(conf): conf.check_cfg(package='libavutil', args='--cflags --libs', uselib_store='AVUTIL', mandatory=True) conf.check_cfg(package='libswscale', args='--cflags --libs', uselib_store='SWSCALE', mandatory=True) conf.check_cfg(package='libswresample', args='--cflags --libs', uselib_store='SWRESAMPLE', mandatory=True) - conf.check_cfg(package='libpostproc', args='--cflags --libs', uselib_store='POSTPROC', mandatory=True) def static_openjpeg(conf): conf.check_cfg(package='libopenjpeg', args='--cflags', atleast_version='1.5.0', uselib_store='OPENJPEG', mandatory=True) -- 2.30.2