[FFmpeg-devel] [PATCH] lavfi: add spp filter.
Michael Niedermayer
michaelni at gmx.at
Mon Jun 10 14:58:08 CEST 2013
On Sat, Jun 08, 2013 at 10:29:23PM +0200, Clément Bœsch wrote:
> TODO: minor bump
>
> ---
>
> I plan to drop mp={fspp,pp7,spp,uspp} filters after this filter is
> integrated.
> ---
> Changelog | 1 +
> LICENSE | 1 +
> configure | 1 +
> doc/filters.texi | 34 +++
> libavfilter/Makefile | 1 +
> libavfilter/allfilters.c | 1 +
> libavfilter/libmpcodecs/vf_spp.c | 3 +
> libavfilter/vf_spp.c | 434 +++++++++++++++++++++++++++++++++++++++
> libavfilter/vf_spp.h | 59 ++++++
> libavfilter/x86/Makefile | 1 +
> libavfilter/x86/vf_spp.c | 233 +++++++++++++++++++++
> 11 files changed, 769 insertions(+)
> create mode 100644 libavfilter/vf_spp.c
> create mode 100644 libavfilter/vf_spp.h
> create mode 100644 libavfilter/x86/vf_spp.c
>
> diff --git a/Changelog b/Changelog
> index 14202f3..96c6086 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -65,6 +65,7 @@ version <next>:
> - mcdeint filter ported from libmpcodecs
> - sab filter ported from libmpcodecs
> - ffprobe -show_chapters option
> +- spp filter ported from libmpcodecs
>
>
> version 1.2:
> diff --git a/LICENSE b/LICENSE
> index a4b4006..13e73ce 100644
> --- a/LICENSE
> +++ b/LICENSE
> @@ -42,6 +42,7 @@ Specifically, the GPL parts of FFmpeg are
> - vf_pp.c
> - vf_sab.c
> - vf_smartblur.c
> + - vf_spp.c
> - vf_stereo3d.c
> - vf_super2xsai.c
> - vf_tinterlace.c
> diff --git a/configure b/configure
> index 93970a1..07081c9 100755
> --- a/configure
> +++ b/configure
> @@ -2172,6 +2172,7 @@ sab_filter_deps="gpl swscale"
> scale_filter_deps="swscale"
> smartblur_filter_deps="gpl swscale"
> showspectrum_filter_deps="avcodec rdft"
> +spp_filter_deps="gpl avcodec fft"
> stereo3d_filter_deps="gpl"
> subtitles_filter_deps="avformat avcodec libass"
> super2xsai_filter_deps="gpl"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 4cb6710..20434b1 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -6351,6 +6351,40 @@ stereo3d=abl:sbsr
> @end example
> @end itemize
>
> + at section spp
> +
> +Apply a simple postprocessing filter that compresses and decompresses the image
> +at several (or - in the case of @option{quality} level @code{6} - all) shifts
> +and averages the results.
> +
> +The filters accept the following options:
> +
> + at table @option
> + at item quality
> +Set quality. This option defines the number of level for averaging. It accepts
> +an integer in the range 0-6. If set to @code{0}, the filter will have no
> +effect. A value of @code{6} means the higher quality. Default value is
> + at code{3}.
something like "for each +1 the speed drops by a factor of 2"
should be added
> +
> + at item qp
> +Force a constant quantization parameter. If not set, the filter will use the QP
> +from the video stream (if available).
> +
> + at item mode
> +Set thresholding mode. Available modes are:
> +
> + at table @samp
> + at item hard
> +Set hard thresholding (default).
> + at item soft
> +Set soft thresholding (better de-ringing effect, but blurrier).
> + at end table
> +
> + at item use_bframe_qp
> +Enable the use of the QP from the B-Frames. Using this option may cause flicker
> +since the B-Frames have often larger QP. Default is @code{0} (not enabled).
> + at end table
> +
> @anchor{subtitles}
> @section subtitles
>
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 2d2ea45..ad43a46 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -181,6 +181,7 @@ OBJS-$(CONFIG_SETTB_FILTER) += f_settb.o
> OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o
> OBJS-$(CONFIG_SMARTBLUR_FILTER) += vf_smartblur.o
> OBJS-$(CONFIG_SPLIT_FILTER) += split.o
> +OBJS-$(CONFIG_SPP_FILTER) += vf_spp.o
> OBJS-$(CONFIG_STEREO3D_FILTER) += vf_stereo3d.o
> OBJS-$(CONFIG_SUBTITLES_FILTER) += vf_subtitles.o
> OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index f9d9391..881f133 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -176,6 +176,7 @@ void avfilter_register_all(void)
> REGISTER_FILTER(SHOWINFO, showinfo, vf);
> REGISTER_FILTER(SMARTBLUR, smartblur, vf);
> REGISTER_FILTER(SPLIT, split, vf);
> + REGISTER_FILTER(SPP, spp, vf);
> REGISTER_FILTER(STEREO3D, stereo3d, vf);
> REGISTER_FILTER(SUBTITLES, subtitles, vf);
> REGISTER_FILTER(SUPER2XSAI, super2xsai, vf);
> diff --git a/libavfilter/libmpcodecs/vf_spp.c b/libavfilter/libmpcodecs/vf_spp.c
> index 75ede23..2d36648 100644
> --- a/libavfilter/libmpcodecs/vf_spp.c
> +++ b/libavfilter/libmpcodecs/vf_spp.c
> @@ -481,6 +481,8 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
> }
>
> vf->priv->mpeg2= mpi->qscale_type;
> + av_log(0,0,"pict_type=%d qscale=%p qp=%d\n",
> + mpi->pict_type, mpi->qscale, vf->priv->qp);
> if(mpi->pict_type != 3 && mpi->qscale && !vf->priv->qp){
> int w = mpi->qstride;
> int h = (mpi->h + 15) >> 4;
> @@ -488,6 +490,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
> w = (mpi->w + 15) >> 4;
> h = 1;
> }
> + av_log(0,0,"qp_stride=%d w=%d h=%d\n", mpi->qstride, w, h);
> if(!vf->priv->non_b_qp)
> vf->priv->non_b_qp= malloc(w*h);
> fast_memcpy(vf->priv->non_b_qp, mpi->qscale, w*h);
> diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
> new file mode 100644
> index 0000000..bab5749
> --- /dev/null
> +++ b/libavfilter/vf_spp.c
> @@ -0,0 +1,434 @@
> +/*
> + * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
> + * Copyright (c) 2013 Clément Bœsch <ubitux at gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg 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.
> + *
> + * FFmpeg 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 FFmpeg; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +/**
> + * @file
> + * Simple post processing filter
> + *
> + * This implementation is based on an algorithm described in
> + * "Aria Nosratinia Embedded Post-Processing for
> + * Enhancement of Compressed Images (1999)"
> + */
> +
> +#include "libavcodec/dsputil.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +#include "internal.h"
> +#include "vf_spp.h"
> +
> +enum mode {
> + MODE_HARD,
> + MODE_SOFT,
> + NB_MODES
> +};
> +
> +#define OFFSET(x) offsetof(SPPContext, x)
> +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
> +static const AVOption spp_options[] = {
> + { "quality", "set quality", OFFSET(log2_count), AV_OPT_TYPE_INT, {.i64 = 3}, 0, MAX_LEVEL, FLAGS },
> + { "qp", "force a constant quantizer parameter", OFFSET(qp), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
INT_MAX seems a bit high
patch should be ok otherwise if it gives same resukts & same speed
as mp-spp
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130610/988fc329/attachment.asc>
More information about the ffmpeg-devel
mailing list