media/libopus/celt/pitch.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libopus/celt/pitch.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,173 @@
     1.4 +/* Copyright (c) 2007-2008 CSIRO
     1.5 +   Copyright (c) 2007-2009 Xiph.Org Foundation
     1.6 +   Written by Jean-Marc Valin */
     1.7 +/**
     1.8 +   @file pitch.h
     1.9 +   @brief Pitch analysis
    1.10 + */
    1.11 +
    1.12 +/*
    1.13 +   Redistribution and use in source and binary forms, with or without
    1.14 +   modification, are permitted provided that the following conditions
    1.15 +   are met:
    1.16 +
    1.17 +   - Redistributions of source code must retain the above copyright
    1.18 +   notice, this list of conditions and the following disclaimer.
    1.19 +
    1.20 +   - Redistributions in binary form must reproduce the above copyright
    1.21 +   notice, this list of conditions and the following disclaimer in the
    1.22 +   documentation and/or other materials provided with the distribution.
    1.23 +
    1.24 +   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.25 +   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.26 +   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.27 +   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
    1.28 +   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1.29 +   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    1.30 +   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    1.31 +   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    1.32 +   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    1.33 +   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    1.34 +   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.35 +*/
    1.36 +
    1.37 +#ifndef PITCH_H
    1.38 +#define PITCH_H
    1.39 +
    1.40 +#include "modes.h"
    1.41 +#include "cpu_support.h"
    1.42 +
    1.43 +#if defined(__SSE__) && !defined(FIXED_POINT)
    1.44 +#include "x86/pitch_sse.h"
    1.45 +#endif
    1.46 +
    1.47 +#if defined(OPUS_ARM_ASM) && defined(FIXED_POINT)
    1.48 +# include "arm/pitch_arm.h"
    1.49 +#endif
    1.50 +
    1.51 +void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp,
    1.52 +      int len, int C, int arch);
    1.53 +
    1.54 +void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y,
    1.55 +                  int len, int max_pitch, int *pitch, int arch);
    1.56 +
    1.57 +opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
    1.58 +      int N, int *T0, int prev_period, opus_val16 prev_gain);
    1.59 +
    1.60 +/* OPT: This is the kernel you really want to optimize. It gets used a lot
    1.61 +   by the prefilter and by the PLC. */
    1.62 +#ifndef OVERRIDE_XCORR_KERNEL
    1.63 +static OPUS_INLINE void xcorr_kernel(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len)
    1.64 +{
    1.65 +   int j;
    1.66 +   opus_val16 y_0, y_1, y_2, y_3;
    1.67 +   celt_assert(len>=3);
    1.68 +   y_3=0; /* gcc doesn't realize that y_3 can't be used uninitialized */
    1.69 +   y_0=*y++;
    1.70 +   y_1=*y++;
    1.71 +   y_2=*y++;
    1.72 +   for (j=0;j<len-3;j+=4)
    1.73 +   {
    1.74 +      opus_val16 tmp;
    1.75 +      tmp = *x++;
    1.76 +      y_3=*y++;
    1.77 +      sum[0] = MAC16_16(sum[0],tmp,y_0);
    1.78 +      sum[1] = MAC16_16(sum[1],tmp,y_1);
    1.79 +      sum[2] = MAC16_16(sum[2],tmp,y_2);
    1.80 +      sum[3] = MAC16_16(sum[3],tmp,y_3);
    1.81 +      tmp=*x++;
    1.82 +      y_0=*y++;
    1.83 +      sum[0] = MAC16_16(sum[0],tmp,y_1);
    1.84 +      sum[1] = MAC16_16(sum[1],tmp,y_2);
    1.85 +      sum[2] = MAC16_16(sum[2],tmp,y_3);
    1.86 +      sum[3] = MAC16_16(sum[3],tmp,y_0);
    1.87 +      tmp=*x++;
    1.88 +      y_1=*y++;
    1.89 +      sum[0] = MAC16_16(sum[0],tmp,y_2);
    1.90 +      sum[1] = MAC16_16(sum[1],tmp,y_3);
    1.91 +      sum[2] = MAC16_16(sum[2],tmp,y_0);
    1.92 +      sum[3] = MAC16_16(sum[3],tmp,y_1);
    1.93 +      tmp=*x++;
    1.94 +      y_2=*y++;
    1.95 +      sum[0] = MAC16_16(sum[0],tmp,y_3);
    1.96 +      sum[1] = MAC16_16(sum[1],tmp,y_0);
    1.97 +      sum[2] = MAC16_16(sum[2],tmp,y_1);
    1.98 +      sum[3] = MAC16_16(sum[3],tmp,y_2);
    1.99 +   }
   1.100 +   if (j++<len)
   1.101 +   {
   1.102 +      opus_val16 tmp = *x++;
   1.103 +      y_3=*y++;
   1.104 +      sum[0] = MAC16_16(sum[0],tmp,y_0);
   1.105 +      sum[1] = MAC16_16(sum[1],tmp,y_1);
   1.106 +      sum[2] = MAC16_16(sum[2],tmp,y_2);
   1.107 +      sum[3] = MAC16_16(sum[3],tmp,y_3);
   1.108 +   }
   1.109 +   if (j++<len)
   1.110 +   {
   1.111 +      opus_val16 tmp=*x++;
   1.112 +      y_0=*y++;
   1.113 +      sum[0] = MAC16_16(sum[0],tmp,y_1);
   1.114 +      sum[1] = MAC16_16(sum[1],tmp,y_2);
   1.115 +      sum[2] = MAC16_16(sum[2],tmp,y_3);
   1.116 +      sum[3] = MAC16_16(sum[3],tmp,y_0);
   1.117 +   }
   1.118 +   if (j<len)
   1.119 +   {
   1.120 +      opus_val16 tmp=*x++;
   1.121 +      y_1=*y++;
   1.122 +      sum[0] = MAC16_16(sum[0],tmp,y_2);
   1.123 +      sum[1] = MAC16_16(sum[1],tmp,y_3);
   1.124 +      sum[2] = MAC16_16(sum[2],tmp,y_0);
   1.125 +      sum[3] = MAC16_16(sum[3],tmp,y_1);
   1.126 +   }
   1.127 +}
   1.128 +#endif /* OVERRIDE_XCORR_KERNEL */
   1.129 +
   1.130 +#ifndef OVERRIDE_DUAL_INNER_PROD
   1.131 +static OPUS_INLINE void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
   1.132 +      int N, opus_val32 *xy1, opus_val32 *xy2)
   1.133 +{
   1.134 +   int i;
   1.135 +   opus_val32 xy01=0;
   1.136 +   opus_val32 xy02=0;
   1.137 +   for (i=0;i<N;i++)
   1.138 +   {
   1.139 +      xy01 = MAC16_16(xy01, x[i], y01[i]);
   1.140 +      xy02 = MAC16_16(xy02, x[i], y02[i]);
   1.141 +   }
   1.142 +   *xy1 = xy01;
   1.143 +   *xy2 = xy02;
   1.144 +}
   1.145 +#endif
   1.146 +
   1.147 +#ifdef FIXED_POINT
   1.148 +opus_val32
   1.149 +#else
   1.150 +void
   1.151 +#endif
   1.152 +celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y,
   1.153 +      opus_val32 *xcorr, int len, int max_pitch);
   1.154 +
   1.155 +#if !defined(OVERRIDE_PITCH_XCORR)
   1.156 +/*Is run-time CPU detection enabled on this platform?*/
   1.157 +# if defined(OPUS_HAVE_RTCD)
   1.158 +extern
   1.159 +#  if defined(FIXED_POINT)
   1.160 +opus_val32
   1.161 +#  else
   1.162 +void
   1.163 +#  endif
   1.164 +(*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
   1.165 +      const opus_val16 *, opus_val32 *, int, int);
   1.166 +
   1.167 +#  define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \
   1.168 +  ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \
   1.169 +        xcorr, len, max_pitch))
   1.170 +# else
   1.171 +#  define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \
   1.172 +  ((void)(arch),celt_pitch_xcorr_c(_x, _y, xcorr, len, max_pitch))
   1.173 +# endif
   1.174 +#endif
   1.175 +
   1.176 +#endif

mercurial