tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

arm_celt_map.c (8041B)


      1 /* Copyright (c) 2010 Xiph.Org Foundation
      2 * Copyright (c) 2013 Parrot
      3 * Copyright (c) 2024 Arm Limited */
      4 /*
      5   Redistribution and use in source and binary forms, with or without
      6   modification, are permitted provided that the following conditions
      7   are met:
      8 
      9   - Redistributions of source code must retain the above copyright
     10   notice, this list of conditions and the following disclaimer.
     11 
     12   - Redistributions in binary form must reproduce the above copyright
     13   notice, this list of conditions and the following disclaimer in the
     14   documentation and/or other materials provided with the distribution.
     15 
     16   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
     20   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     21   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     22   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     23   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     24   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     25   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     26   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28 
     29 #ifdef HAVE_CONFIG_H
     30 #include "config.h"
     31 #endif
     32 
     33 #include "kiss_fft.h"
     34 #include "mathops.h"
     35 #include "mdct.h"
     36 #include "pitch.h"
     37 
     38 #if defined(OPUS_HAVE_RTCD)
     39 
     40 # if !defined(DISABLE_FLOAT_API)
     41 #  if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)
     42 void (*const CELT_FLOAT2INT16_IMPL[OPUS_ARCHMASK+1])(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt) = {
     43  celt_float2int16_c,   /* ARMv4 */
     44  celt_float2int16_c,   /* EDSP */
     45  celt_float2int16_c,   /* Media */
     46  celt_float2int16_neon,/* NEON */
     47  celt_float2int16_neon /* DOTPROD */
     48 };
     49 
     50 int (*const OPUS_LIMIT2_CHECKWITHIN1_IMPL[OPUS_ARCHMASK+1])(float * samples, int cnt) = {
     51  opus_limit2_checkwithin1_c,   /* ARMv4 */
     52  opus_limit2_checkwithin1_c,   /* EDSP */
     53  opus_limit2_checkwithin1_c,   /* Media */
     54  opus_limit2_checkwithin1_neon,/* NEON */
     55  opus_limit2_checkwithin1_neon /* DOTPROD */
     56 };
     57 #  endif
     58 # endif
     59 
     60 # if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)
     61 opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y, int N) = {
     62  celt_inner_prod_c,   /* ARMv4 */
     63  celt_inner_prod_c,   /* EDSP */
     64  celt_inner_prod_c,   /* Media */
     65  celt_inner_prod_neon,/* NEON */
     66  celt_inner_prod_neon /* DOTPROD */
     67 };
     68 
     69 void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
     70      int N, opus_val32 *xy1, opus_val32 *xy2) = {
     71  dual_inner_prod_c,   /* ARMv4 */
     72  dual_inner_prod_c,   /* EDSP */
     73  dual_inner_prod_c,   /* Media */
     74  dual_inner_prod_neon,/* NEON */
     75  dual_inner_prod_neon /* DOTPROD */
     76 };
     77 # endif
     78 
     79 # if defined(FIXED_POINT)
     80 #  if ((defined(OPUS_ARM_MAY_HAVE_NEON) && !defined(OPUS_ARM_PRESUME_NEON)) || \
     81    (defined(OPUS_ARM_MAY_HAVE_MEDIA) && !defined(OPUS_ARM_PRESUME_MEDIA)) || \
     82    (defined(OPUS_ARM_MAY_HAVE_EDSP) && !defined(OPUS_ARM_PRESUME_EDSP)))
     83 opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
     84    const opus_val16 *, opus_val32 *, int, int, int) = {
     85  celt_pitch_xcorr_c,               /* ARMv4 */
     86  MAY_HAVE_EDSP(celt_pitch_xcorr),  /* EDSP */
     87  MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */
     88  MAY_HAVE_NEON(celt_pitch_xcorr),  /* NEON */
     89  MAY_HAVE_NEON(celt_pitch_xcorr)   /* DOTPROD */
     90 };
     91 
     92 #  endif
     93 # else /* !FIXED_POINT */
     94 #  if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)
     95 void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
     96    const opus_val16 *, opus_val32 *, int, int, int) = {
     97  celt_pitch_xcorr_c,              /* ARMv4 */
     98  celt_pitch_xcorr_c,              /* EDSP */
     99  celt_pitch_xcorr_c,              /* Media */
    100  celt_pitch_xcorr_float_neon,     /* Neon */
    101  celt_pitch_xcorr_float_neon      /* DOTPROD */
    102 };
    103 #  endif
    104 # endif /* FIXED_POINT */
    105 
    106 #if defined(FIXED_POINT) && defined(OPUS_HAVE_RTCD) && \
    107 defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)
    108 
    109 void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])(
    110         const opus_val16 *x,
    111         const opus_val16 *y,
    112         opus_val32       sum[4],
    113         int              len
    114 ) = {
    115  xcorr_kernel_c,                /* ARMv4 */
    116  xcorr_kernel_c,                /* EDSP */
    117  xcorr_kernel_c,                /* Media */
    118  xcorr_kernel_neon_fixed,       /* Neon */
    119  xcorr_kernel_neon_fixed        /* DOTPROD */
    120 };
    121 
    122 #endif
    123 
    124 # if defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
    125 #  if defined(HAVE_ARM_NE10)
    126 #   if defined(CUSTOM_MODES)
    127 int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
    128   opus_fft_alloc_arch_c,        /* ARMv4 */
    129   opus_fft_alloc_arch_c,        /* EDSP */
    130   opus_fft_alloc_arch_c,        /* Media */
    131   opus_fft_alloc_arm_neon,      /* Neon with NE10 library support */
    132   opus_fft_alloc_arm_neon       /* DOTPROD with NE10 library support */
    133 };
    134 
    135 void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
    136   opus_fft_free_arch_c,         /* ARMv4 */
    137   opus_fft_free_arch_c,         /* EDSP */
    138   opus_fft_free_arch_c,         /* Media */
    139   opus_fft_free_arm_neon,       /* Neon with NE10 */
    140   opus_fft_free_arm_neon        /* DOTPROD with NE10 */
    141 };
    142 #   endif /* CUSTOM_MODES */
    143 
    144 void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
    145                                        const kiss_fft_cpx *fin,
    146                                        kiss_fft_cpx *fout) = {
    147   opus_fft_c,                   /* ARMv4 */
    148   opus_fft_c,                   /* EDSP */
    149   opus_fft_c,                   /* Media */
    150   opus_fft_neon,                /* Neon with NE10 */
    151   opus_fft_neon                 /* DOTPROD with NE10 */
    152 };
    153 
    154 void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
    155                                         const kiss_fft_cpx *fin,
    156                                         kiss_fft_cpx *fout) = {
    157   opus_ifft_c,                   /* ARMv4 */
    158   opus_ifft_c,                   /* EDSP */
    159   opus_ifft_c,                   /* Media */
    160   opus_ifft_neon,                /* Neon with NE10 */
    161   opus_ifft_neon                 /* DOTPROD with NE10 */
    162 };
    163 
    164 void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
    165                                                     kiss_fft_scalar *in,
    166                                                     kiss_fft_scalar * OPUS_RESTRICT out,
    167                                                     const opus_val16 *window,
    168                                                     int overlap, int shift,
    169                                                     int stride, int arch) = {
    170   clt_mdct_forward_c,           /* ARMv4 */
    171   clt_mdct_forward_c,           /* EDSP */
    172   clt_mdct_forward_c,           /* Media */
    173   clt_mdct_forward_neon,        /* Neon with NE10 */
    174   clt_mdct_forward_neon         /* DOTPROD with NE10 */
    175 };
    176 
    177 void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
    178                                                      kiss_fft_scalar *in,
    179                                                      kiss_fft_scalar * OPUS_RESTRICT out,
    180                                                      const opus_val16 *window,
    181                                                      int overlap, int shift,
    182                                                      int stride, int arch) = {
    183   clt_mdct_backward_c,           /* ARMv4 */
    184   clt_mdct_backward_c,           /* EDSP */
    185   clt_mdct_backward_c,           /* Media */
    186   clt_mdct_backward_neon,        /* Neon with NE10 */
    187   clt_mdct_backward_neon         /* DOTPROD with NE10 */
    188 };
    189 
    190 #  endif /* HAVE_ARM_NE10 */
    191 # endif /* OPUS_ARM_MAY_HAVE_NEON_INTR */
    192 
    193 #endif /* OPUS_HAVE_RTCD */