[FFmpeg-devel] [PATCH] lavfi: Port fspp to FFmpeg

Clément Bœsch u at pkh.me
Tue Dec 16 22:08:52 CET 2014


On Tue, Dec 16, 2014 at 07:51:57PM +0530, arwa arif wrote:
> 

> From 993cac2530263bd99691016cc2ad8e6ac7be6b2a Mon Sep 17 00:00:00 2001
> From: Arwa Arif <arwaarif1994 at gmail.com>
> Date: Sun, 14 Dec 2014 12:03:31 +0530
> Subject: [PATCH] Port fspp to FFmpeg
> 
> ---
>  configure                         |    1 +
>  doc/filters.texi                  |   25 +
>  libavfilter/Makefile              |    1 +
>  libavfilter/allfilters.c          |    1 +
>  libavfilter/libmpcodecs/vf_fspp.c |    4 +-
>  libavfilter/version.h             |    4 +-
>  libavfilter/vf_fspp.c             |  667 ++++++++++++++++++
>  libavfilter/vf_fspp.h             |   95 +++
>  libavfilter/x86/Makefile          |    1 +
>  libavfilter/x86/vf_fspp.c         | 1397 +++++++++++++++++++++++++++++++++++++
>  10 files changed, 2192 insertions(+), 4 deletions(-)
>  create mode 100644 libavfilter/vf_fspp.c
>  create mode 100644 libavfilter/vf_fspp.h
>  create mode 100644 libavfilter/x86/vf_fspp.c
> 

I suppose no code can be shared easily with spp filter?

[...]
> diff --git a/libavfilter/libmpcodecs/vf_fspp.c b/libavfilter/libmpcodecs/vf_fspp.c
> index d457859..3a80dc2 100644
> --- a/libavfilter/libmpcodecs/vf_fspp.c
> +++ b/libavfilter/libmpcodecs/vf_fspp.c
> @@ -710,8 +710,8 @@ const vf_info_t ff_vf_info_fspp = {
>  #if HAVE_MMX_INLINE
>  
>  DECLARE_ASM_CONST(8, uint64_t, MM_FIX_0_382683433)=FIX64(0.382683433, 14);
> -DECLARE_ALIGNED(8, uint64_t, ff_MM_FIX_0_541196100)=FIX64(0.541196100, 14);
> -DECLARE_ALIGNED(8, uint64_t, ff_MM_FIX_0_707106781)=FIX64(0.707106781, 14);
> +extern uint64_t ff_MM_FIX_0_707106781;
> +extern uint64_t ff_MM_FIX_0_541196100;
>  DECLARE_ASM_CONST(8, uint64_t, MM_FIX_1_306562965)=FIX64(1.306562965, 14);
>  
>  DECLARE_ASM_CONST(8, uint64_t, MM_FIX_1_414213562_A)=FIX64(1.414213562, 14);
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index 4bd18f3..28112b3 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -30,8 +30,8 @@
>  #include "libavutil/version.h"
>  
>  #define LIBAVFILTER_VERSION_MAJOR  5
> -#define LIBAVFILTER_VERSION_MINOR  2
> -#define LIBAVFILTER_VERSION_MICRO 104
> +#define LIBAVFILTER_VERSION_MINOR  3

> +#define LIBAVFILTER_VERSION_MICRO 103

this needs to be set to 0

>  
>  #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
>                                                 LIBAVFILTER_VERSION_MINOR, \
> diff --git a/libavfilter/vf_fspp.c b/libavfilter/vf_fspp.c
> new file mode 100644
> index 0000000..0560dfa
> --- /dev/null
> +++ b/libavfilter/vf_fspp.c
> @@ -0,0 +1,667 @@
> +/*
> + * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
> + * Copyright (C) 2005 Nikolaj Poroshin <porosh3 at psu.ru>
> + * Copyright (c) 2014 Arwa Arif <arwaarif1994 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
> + * Fast Simple Post-processing filter
> + * This implementation is based on an algorithm described in
> + * "Aria Nosratinia Embedded Post-Processing for
> + * Enhancement of Compressed Images (1999)"

> + * (http://citeseer.nj.nec.com/nosratinia99embedded.html)

This url is dead; can you find a web archive link or a link that works?

> + * Further, with splitting (i)dct into hor/ver passes, one of them can be
> + * performed once per block, not pixel. This allows for much better speed.
> + *
> + * Originally written by Michael Niedermayer and Nikolaj for the MPlayer
> + * project, and ported by Arwa Arif for FFmpeg.
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +#include "internal.h"

> +#include "libavcodec/avcodec.h"

is this necessary?

[...]
> +//This func reads from 1 slice, 1 and clears 0 & 1
> +static void store_slice_c (uint8_t *dst , int16_t *src , int dst_stride , int src_stride , int width , int height , int log2_scale) {
> +    int y, x;
> +#define STORE(pos)                                                             \
> +    temp = (src[x + pos] + (d[pos] >> log2_scale)) >> (6 - log2_scale);        \
> +    src[x + pos] = src[x + pos - 8 * src_stride] = 0;                          \
> +    if(temp & 0x100) temp= ~(temp >> 31);                                      \
> +    dst[x + pos] = temp;
> +

> +    for (y = 0 ; y < height ; y++) {

I don't know where you saw this style, but it's not correct.

Please look at 73d88109c08e4a6b65672a1dc10e098f45813f4d and fix the style
(of the whole file) accordingly. You might want to have a look at the
later commits by the way.

[...]
> +static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> +{
> +    AVFilterContext *ctx = inlink->dst;
> +    FSPPContext *fspp = ctx->priv;
> +    AVFilterLink *outlink = ctx->outputs[0];
> +    AVFrame *out = in;
> +
> +    int qp_stride = 0;
> +    uint8_t *qp_table = NULL;
> +
> +    /* if we are not in a constant user quantizer mode and we don't want to use
> +     * the quantizers from the B-frames (B-frames often have a higher QP), we
> +     * need to save the qp table from the last non B-frame; this is what the
> +     * following code block does */
> +    if (!fspp->qp) {
> +        qp_table = av_frame_get_qp_table(in, &qp_stride, &fspp->qscale_type);
> +
> +        if (qp_table && !fspp->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
> +            int w, h;
> +
> +            /* if the qp stride is not set, it means the QP are only defined on
> +             * a line basis */
> +            if (!qp_stride) {
> +                w = FF_CEIL_RSHIFT(inlink->w, 4);
> +                h = 1;
> +            } else {

> +            	w = qp_stride;

Here and in other places you have tabs; this can't be committed to the
repository

[...]

I'll make a more extensive review at the next iteration.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141216/2bf802d0/attachment.asc>


More information about the ffmpeg-devel mailing list