xref: /aosp_15_r20/external/libopus/silk/x86/x86_silk_map.c (revision a58d3d2adb790c104798cd88c8a3aff4fa8b82cc)
1 /* Copyright (c) 2014, Cisco Systems, INC
2    Written by XiangMingZhu WeiZhou MinPeng YanWang
3 
4    Redistribution and use in source and binary forms, with or without
5    modification, are permitted provided that the following conditions
6    are met:
7 
8    - Redistributions of source code must retain the above copyright
9    notice, this list of conditions and the following disclaimer.
10 
11    - Redistributions in binary form must reproduce the above copyright
12    notice, this list of conditions and the following disclaimer in the
13    documentation and/or other materials provided with the distribution.
14 
15    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #if defined(HAVE_CONFIG_H)
29 #include "config.h"
30 #endif
31 
32 #include "celt/x86/x86cpu.h"
33 #include "structs.h"
34 #include "SigProc_FIX.h"
35 #ifndef FIXED_POINT
36 #include "SigProc_FLP.h"
37 #endif
38 #include "pitch.h"
39 #include "main.h"
40 
41 #if defined(OPUS_HAVE_RTCD) && !defined(OPUS_X86_PRESUME_AVX2)
42 
43 #if defined(FIXED_POINT)
44 
45 #include "fixed/main_FIX.h"
46 
47 opus_int64 (*const SILK_INNER_PROD16_IMPL[ OPUS_ARCHMASK + 1 ] )(
48     const opus_int16 *inVec1,
49     const opus_int16 *inVec2,
50     const opus_int   len
51 ) = {
52   silk_inner_prod16_c,                  /* non-sse */
53   silk_inner_prod16_c,
54   silk_inner_prod16_c,
55   MAY_HAVE_SSE4_1( silk_inner_prod16 ), /* sse4.1 */
56   MAY_HAVE_SSE4_1( silk_inner_prod16 )  /* avx */
57 };
58 
59 #endif
60 
61 opus_int (*const SILK_VAD_GETSA_Q8_IMPL[ OPUS_ARCHMASK + 1 ] )(
62     silk_encoder_state *psEncC,
63     const opus_int16   pIn[]
64 ) = {
65   silk_VAD_GetSA_Q8_c,                  /* non-sse */
66   silk_VAD_GetSA_Q8_c,
67   silk_VAD_GetSA_Q8_c,
68   MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 ), /* sse4.1 */
69   MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 )  /* avx */
70 };
71 
72 void (*const SILK_NSQ_IMPL[ OPUS_ARCHMASK + 1 ] )(
73     const silk_encoder_state    *psEncC,                                      /* I    Encoder State                   */
74     silk_nsq_state              *NSQ,                                         /* I/O  NSQ state                       */
75     SideInfoIndices             *psIndices,                                   /* I/O  Quantization Indices            */
76     const opus_int16            x16[],                                        /* I    Input                           */
77     opus_int8                   pulses[],                                     /* O    Quantized pulse signal          */
78     const opus_int16            *PredCoef_Q12,                                /* I    Short term prediction coefs     */
79     const opus_int16            LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],      /* I    Long term prediction coefs      */
80     const opus_int16            AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I    Noise shaping coefs             */
81     const opus_int              HarmShapeGain_Q14[ MAX_NB_SUBFR ],            /* I    Long term shaping coefs         */
82     const opus_int              Tilt_Q14[ MAX_NB_SUBFR ],                     /* I    Spectral tilt                   */
83     const opus_int32            LF_shp_Q14[ MAX_NB_SUBFR ],                   /* I    Low frequency shaping coefs     */
84     const opus_int32            Gains_Q16[ MAX_NB_SUBFR ],                    /* I    Quantization step sizes         */
85     const opus_int              pitchL[ MAX_NB_SUBFR ],                       /* I    Pitch lags                      */
86     const opus_int              Lambda_Q10,                                   /* I    Rate/distortion tradeoff        */
87     const opus_int              LTP_scale_Q14                                 /* I    LTP state scaling               */
88 ) = {
89   silk_NSQ_c,                  /* non-sse */
90   silk_NSQ_c,
91   silk_NSQ_c,
92   MAY_HAVE_SSE4_1( silk_NSQ ), /* sse4.1 */
93   MAY_HAVE_SSE4_1( silk_NSQ )  /* avx */
94 };
95 
96 void (*const SILK_VQ_WMAT_EC_IMPL[ OPUS_ARCHMASK + 1 ] )(
97     opus_int8                   *ind,                           /* O    index of best codebook vector               */
98     opus_int32                  *res_nrg_Q15,                   /* O    best residual energy                        */
99     opus_int32                  *rate_dist_Q8,                  /* O    best total bitrate                          */
100     opus_int                    *gain_Q7,                       /* O    sum of absolute LTP coefficients            */
101     const opus_int32            *XX_Q17,                        /* I    correlation matrix                          */
102     const opus_int32            *xX_Q17,                        /* I    correlation vector                          */
103     const opus_int8             *cb_Q7,                         /* I    codebook                                    */
104     const opus_uint8            *cb_gain_Q7,                    /* I    codebook effective gain                     */
105     const opus_uint8            *cl_Q5,                         /* I    code length for each codebook vector        */
106     const opus_int              subfr_len,                      /* I    number of samples per subframe              */
107     const opus_int32            max_gain_Q7,                    /* I    maximum sum of absolute LTP coefficients    */
108     const opus_int              L                               /* I    number of vectors in codebook               */
109 ) = {
110   silk_VQ_WMat_EC_c,                  /* non-sse */
111   silk_VQ_WMat_EC_c,
112   silk_VQ_WMat_EC_c,
113   MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ), /* sse4.1 */
114   MAY_HAVE_SSE4_1( silk_VQ_WMat_EC )  /* avx */
115 };
116 
117 void (*const SILK_NSQ_DEL_DEC_IMPL[ OPUS_ARCHMASK + 1 ] )(
118     const silk_encoder_state    *psEncC,                                      /* I    Encoder State                   */
119     silk_nsq_state              *NSQ,                                         /* I/O  NSQ state                       */
120     SideInfoIndices             *psIndices,                                   /* I/O  Quantization Indices            */
121     const opus_int16            x16[],                                        /* I    Input                           */
122     opus_int8                   pulses[],                                     /* O    Quantized pulse signal          */
123     const opus_int16            *PredCoef_Q12,                                /* I    Short term prediction coefs     */
124     const opus_int16            LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],      /* I    Long term prediction coefs      */
125     const opus_int16            AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I    Noise shaping coefs             */
126     const opus_int              HarmShapeGain_Q14[ MAX_NB_SUBFR ],            /* I    Long term shaping coefs         */
127     const opus_int              Tilt_Q14[ MAX_NB_SUBFR ],                     /* I    Spectral tilt                   */
128     const opus_int32            LF_shp_Q14[ MAX_NB_SUBFR ],                   /* I    Low frequency shaping coefs     */
129     const opus_int32            Gains_Q16[ MAX_NB_SUBFR ],                    /* I    Quantization step sizes         */
130     const opus_int              pitchL[ MAX_NB_SUBFR ],                       /* I    Pitch lags                      */
131     const opus_int              Lambda_Q10,                                   /* I    Rate/distortion tradeoff        */
132     const opus_int              LTP_scale_Q14                                 /* I    LTP state scaling               */
133 ) = {
134   silk_NSQ_del_dec_c,                  /* non-sse */
135   silk_NSQ_del_dec_c,
136   silk_NSQ_del_dec_c,
137   MAY_HAVE_SSE4_1( silk_NSQ_del_dec ), /* sse4.1 */
138   MAY_HAVE_AVX2( silk_NSQ_del_dec )  /* avx */
139 };
140 
141 #if defined(FIXED_POINT)
142 
143 void (*const SILK_BURG_MODIFIED_IMPL[ OPUS_ARCHMASK + 1 ] )(
144     opus_int32                  *res_nrg,           /* O    Residual energy                                             */
145     opus_int                    *res_nrg_Q,         /* O    Residual energy Q value                                     */
146     opus_int32                  A_Q16[],            /* O    Prediction coefficients (length order)                      */
147     const opus_int16            x[],                /* I    Input signal, length: nb_subfr * ( D + subfr_length )       */
148     const opus_int32            minInvGain_Q30,     /* I    Inverse of max prediction gain                              */
149     const opus_int              subfr_length,       /* I    Input signal subframe length (incl. D preceding samples)    */
150     const opus_int              nb_subfr,           /* I    Number of subframes stacked in x                            */
151     const opus_int              D,                  /* I    Order                                                       */
152     int                         arch                /* I    Run-time architecture                                       */
153 ) = {
154   silk_burg_modified_c,                  /* non-sse */
155   silk_burg_modified_c,
156   silk_burg_modified_c,
157   MAY_HAVE_SSE4_1( silk_burg_modified ), /* sse4.1 */
158   MAY_HAVE_SSE4_1( silk_burg_modified )  /* avx */
159 };
160 
161 #endif
162 
163 #ifndef FIXED_POINT
164 
165 double (*const SILK_INNER_PRODUCT_FLP_IMPL[ OPUS_ARCHMASK + 1 ] )(
166     const silk_float    *data1,
167     const silk_float    *data2,
168     opus_int            dataSize
169 ) = {
170   silk_inner_product_FLP_c,                  /* non-sse */
171   silk_inner_product_FLP_c,
172   silk_inner_product_FLP_c,
173   silk_inner_product_FLP_c, /* sse4.1 */
174   MAY_HAVE_AVX2( silk_inner_product_FLP )  /* avx */
175 };
176 
177 #endif
178 
179 #endif
180