]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '52730e0f867fe77b7d2353d8b44e92edb7079ca5'
authorClément Bœsch <u@pkh.me>
Mon, 20 Mar 2017 10:26:00 +0000 (11:26 +0100)
committerClément Bœsch <u@pkh.me>
Mon, 20 Mar 2017 10:27:48 +0000 (11:27 +0100)
* commit '52730e0f867fe77b7d2353d8b44e92edb7079ca5':
  iir_filter: Change type of array stride parameters to ptrdiff_t

The merge also updates the MIPS code and drop the extra log.h include.

Merged-by: Clément Bœsch <u@pkh.me>
1  2 
libavcodec/iirfilter.c
libavcodec/iirfilter.h
libavcodec/mips/iirfilter_mips.c

Simple merge
index 6f7bba67ac3b0a9adef9b124bd98c95b30e91868,052a4b386d657822917836fad855055ac2d2bf00..5ffa1ce53abd27a044dedbf7749989f77542420c
@@@ -47,29 -48,6 +48,29 @@@ enum IIRFilterMode
      FF_FILTER_MODE_BANDSTOP,
  };
  
-                         const float *src, int sstep, float *dst, int dstep);
 +typedef struct FFIIRFilterContext {
 +    /**
 +    * Perform IIR filtering on floating-point input samples.
 +    *
 +    * @param coeffs pointer to filter coefficients
 +    * @param state  pointer to filter state
 +    * @param size   input length
 +    * @param src    source samples
 +    * @param sstep  source stride
 +    * @param dst    filtered samples (destination may be the same as input)
 +    * @param dstep  destination stride
 +    */
 +    void (*filter_flt)(const struct FFIIRFilterCoeffs *coeffs,
 +                        struct FFIIRFilterState *state, int size,
++                        const float *src, ptrdiff_t sstep, float *dst, ptrdiff_t dstep);
 +} FFIIRFilterContext;
 +
 +/**
 + * Initialize FFIIRFilterContext
 + */
 +void ff_iir_filter_init(FFIIRFilterContext *f);
 +void ff_iir_filter_init_mips(FFIIRFilterContext *f);
 +
  /**
   * Initialize filter coefficients.
   *
index 87db9ffe55b2ecf83da410bd3081ba0ff8cf4a81,0000000000000000000000000000000000000000..74f036fde6f96a806ed7800cd09d3abf4e89e4ce
mode 100644,000000..100644
--- /dev/null
@@@ -1,208 -1,0 +1,208 @@@
- static void ff_iir_filter_flt_mips(const struct FFIIRFilterCoeffs *c,
-                                    struct FFIIRFilterState *s, int size,
-                                    const float *src, int sstep, float *dst, int dstep)
 +/*
 + * Copyright (c) 2012
 + *      MIPS Technologies, Inc., California.
 + *
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *    notice, this list of conditions and the following disclaimer.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *    notice, this list of conditions and the following disclaimer in the
 + *    documentation and/or other materials provided with the distribution.
 + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
 + *    contributors may be used to endorse or promote products derived from
 + *    this software without specific prior written permission.
 + *
 + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 + * SUCH DAMAGE.
 + *
 + * Author:  Bojan Zivkovic (bojan@mips.com)
 + *
 + * IIR filter optimized for MIPS floating-point architecture
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 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
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser 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
 + * Reference: libavcodec/iirfilter.c
 + */
 +
 +#include "libavcodec/iirfilter.h"
 +
 +#if HAVE_INLINE_ASM
 +#if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
 +typedef struct FFIIRFilterCoeffs {
 +    int   order;
 +    float gain;
 +    int   *cx;
 +    float *cy;
 +} FFIIRFilterCoeffs;
 +
 +typedef struct FFIIRFilterState {
 +    float x[1];
 +} FFIIRFilterState;
 +
-     f->filter_flt = ff_iir_filter_flt_mips;
++static void iir_filter_flt_mips(const struct FFIIRFilterCoeffs *c,
++                                struct FFIIRFilterState *s, int size,
++                                const float *src, ptrdiff_t sstep, float *dst, ptrdiff_t dstep)
 +{
 +    if (c->order == 2) {
 +        int i;
 +        const float *src0 = src;
 +        float       *dst0 = dst;
 +        for (i = 0; i < size; i++) {
 +            float in = *src0 * c->gain  + s->x[0] * c->cy[0] + s->x[1] * c->cy[1];
 +            *dst0 = s->x[0] + in + s->x[1] * c->cx[1];
 +            s->x[0] = s->x[1];
 +            s->x[1] = in;
 +            src0 += sstep;
 +            dst0 += dstep;
 +        }
 +    } else if (c->order == 4) {
 +        int i;
 +        const float *src0 = src;
 +        float       *dst0 = dst;
 +        float four = 4.0;
 +        float six  = 6.0;
 +        for (i = 0; i < size; i += 4) {
 +            float in1, in2, in3, in4;
 +            float res1, res2, res3, res4;
 +            float *x  = s->x;
 +            float *cy = c->cy;
 +            float gain = c->gain;
 +            float src0_0 = src0[0      ];
 +            float src0_1 = src0[sstep  ];
 +            float src0_2 = src0[2*sstep];
 +            float src0_3 = src0[3*sstep];
 +
 +            __asm__ volatile (
 +                "lwc1   $f0,        0(%[cy])                    \n\t"
 +                "lwc1   $f4,        0(%[x])                     \n\t"
 +                "lwc1   $f5,        4(%[x])                     \n\t"
 +                "lwc1   $f6,        8(%[x])                     \n\t"
 +                "lwc1   $f7,        12(%[x])                    \n\t"
 +                "mul.s  %[in1],     %[src0_0],  %[gain]         \n\t"
 +                "mul.s  %[in2],     %[src0_1],  %[gain]         \n\t"
 +                "mul.s  %[in3],     %[src0_2],  %[gain]         \n\t"
 +                "mul.s  %[in4],     %[src0_3],  %[gain]         \n\t"
 +                "lwc1   $f1,        4(%[cy])                    \n\t"
 +                "madd.s %[in1],     %[in1],     $f0,    $f4     \n\t"
 +                "madd.s %[in2],     %[in2],     $f0,    $f5     \n\t"
 +                "madd.s %[in3],     %[in3],     $f0,    $f6     \n\t"
 +                "madd.s %[in4],     %[in4],     $f0,    $f7     \n\t"
 +                "lwc1   $f2,        8(%[cy])                    \n\t"
 +                "madd.s %[in1],     %[in1],     $f1,    $f5     \n\t"
 +                "madd.s %[in2],     %[in2],     $f1,    $f6     \n\t"
 +                "madd.s %[in3],     %[in3],     $f1,    $f7     \n\t"
 +                "lwc1   $f3,        12(%[cy])                   \n\t"
 +                "add.s  $f8,        $f5,        $f7             \n\t"
 +                "madd.s %[in1],     %[in1],     $f2,    $f6     \n\t"
 +                "madd.s %[in2],     %[in2],     $f2,    $f7     \n\t"
 +                "mul.s  $f9,        $f6,        %[six]          \n\t"
 +                "mul.s  $f10,       $f7,        %[six]          \n\t"
 +                "madd.s %[in1],     %[in1],     $f3,    $f7     \n\t"
 +                "madd.s %[in2],     %[in2],     $f3,    %[in1]  \n\t"
 +                "madd.s %[in3],     %[in3],     $f2,    %[in1]  \n\t"
 +                "madd.s %[in4],     %[in4],     $f1,    %[in1]  \n\t"
 +                "add.s  %[res1],    $f4,        %[in1]          \n\t"
 +                "swc1   %[in1],     0(%[x])                     \n\t"
 +                "add.s  $f0,        $f6,        %[in1]          \n\t"
 +                "madd.s %[in3],     %[in3],     $f3,    %[in2]  \n\t"
 +                "madd.s %[in4],     %[in4],     $f2,    %[in2]  \n\t"
 +                "add.s  %[res2],    $f5,        %[in2]          \n\t"
 +                "madd.s %[res1],    %[res1],    $f8,    %[four] \n\t"
 +                "add.s  $f8,        $f7,        %[in2]          \n\t"
 +                "swc1   %[in2],     4(%[x])                     \n\t"
 +                "madd.s %[in4],     %[in4],     $f3,    %[in3]  \n\t"
 +                "add.s  %[res3],    $f6,        %[in3]          \n\t"
 +                "add.s  %[res1],    %[res1],    $f9             \n\t"
 +                "madd.s %[res2],    %[res2],    $f0,    %[four] \n\t"
 +                "swc1   %[in3],     8(%[x])                     \n\t"
 +                "add.s  %[res4],    $f7,        %[in4]          \n\t"
 +                "madd.s %[res3],    %[res3],    $f8,    %[four] \n\t"
 +                "swc1   %[in4],     12(%[x])                    \n\t"
 +                "add.s  %[res2],    %[res2],    $f10            \n\t"
 +                "add.s  $f8,        %[in1],     %[in3]          \n\t"
 +                "madd.s %[res3],    %[res3],    %[in1], %[six]  \n\t"
 +                "madd.s %[res4],    %[res4],    $f8,    %[four] \n\t"
 +                "madd.s %[res4],    %[res4],    %[in2], %[six]  \n\t"
 +
 +                : [in1]"=&f"(in1), [in2]"=&f"(in2),
 +                  [in3]"=&f"(in3), [in4]"=&f"(in4),
 +                  [res1]"=&f"(res1), [res2]"=&f"(res2),
 +                  [res3]"=&f"(res3), [res4]"=&f"(res4)
 +                : [src0_0]"f"(src0_0), [src0_1]"f"(src0_1),
 +                  [src0_2]"f"(src0_2), [src0_3]"f"(src0_3),
 +                  [gain]"f"(gain), [x]"r"(x), [cy]"r"(cy),
 +                  [four]"f"(four), [six]"f"(six)
 +                : "$f0", "$f1", "$f2", "$f3",
 +                  "$f4", "$f5", "$f6", "$f7",
 +                  "$f8", "$f9", "$f10",
 +                  "memory"
 +            );
 +
 +            dst0[0      ] = res1;
 +            dst0[sstep  ] = res2;
 +            dst0[2*sstep] = res3;
 +            dst0[3*sstep] = res4;
 +
 +            src0 += 4*sstep;
 +            dst0 += 4*dstep;
 +        }
 +    } else {
 +        int i;
 +        const float *src0 = src;
 +        float       *dst0 = dst;
 +        for (i = 0; i < size; i++) {
 +            int j;
 +            float in, res;
 +            in = *src0 * c->gain;
 +            for(j = 0; j < c->order; j++)
 +                in += c->cy[j] * s->x[j];
 +            res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1];
 +            for(j = 1; j < c->order >> 1; j++)
 +                res += (s->x[j] + s->x[c->order - j]) * c->cx[j];
 +            for(j = 0; j < c->order - 1; j++)
 +                s->x[j] = s->x[j + 1];
 +            *dst0 = res;
 +            s->x[c->order - 1] = in;
 +            src0 += sstep;
 +            dst0 += dstep;
 +        }
 +    }
 +}
 +#endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
 +#endif /* HAVE_INLINE_ASM */
 +
 +void ff_iir_filter_init_mips(FFIIRFilterContext *f) {
 +#if HAVE_INLINE_ASM
 +#if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
++    f->filter_flt = iir_filter_flt_mips;
 +#endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
 +#endif /* HAVE_INLINE_ASM */
 +}