| 1 |
/* Copyright (C) 2004 Jean-Marc Valin */ |
| 2 |
/** |
| 3 |
@file cb_search_sse.h |
| 4 |
@brief Fixed codebook functions (SSE version) |
| 5 |
*/ |
| 6 |
/* |
| 7 |
Redistribution and use in source and binary forms, with or without |
| 8 |
modification, are permitted provided that the following conditions |
| 9 |
are met: |
| 10 |
|
| 11 |
- Redistributions of source code must retain the above copyright |
| 12 |
notice, this list of conditions and the following disclaimer. |
| 13 |
|
| 14 |
- Redistributions in binary form must reproduce the above copyright |
| 15 |
notice, this list of conditions and the following disclaimer in the |
| 16 |
documentation and/or other materials provided with the distribution. |
| 17 |
|
| 18 |
- Neither the name of the Xiph.org Foundation nor the names of its |
| 19 |
contributors may be used to endorse or promote products derived from |
| 20 |
this software without specific prior written permission. |
| 21 |
|
| 22 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 |
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| 26 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 27 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 28 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 29 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 30 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 31 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 32 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 |
*/ |
| 34 |
|
| 35 |
#include <xmmintrin.h> |
| 36 |
|
| 37 |
static inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W) |
| 38 |
{ |
| 39 |
union { |
| 40 |
float __a[4]; |
| 41 |
__m128 __v; |
| 42 |
} __u; |
| 43 |
|
| 44 |
__u.__v = U; |
| 45 |
|
| 46 |
*__Z = __u.__a[0]; |
| 47 |
*__Y = __u.__a[1]; |
| 48 |
*__X = __u.__a[2]; |
| 49 |
*__W = __u.__a[3]; |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK |
| 54 |
static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, float *resp, __m128 *resp2, __m128 *E, int shape_cb_size, int subvect_size, char *stack) |
| 55 |
{ |
| 56 |
int i, j, k; |
| 57 |
__m128 resj, EE; |
| 58 |
VARDECL(__m128 *r); |
| 59 |
VARDECL(__m128 *shape); |
| 60 |
ALLOC(r, subvect_size, __m128); |
| 61 |
ALLOC(shape, subvect_size, __m128); |
| 62 |
for(j=0;j<subvect_size;j++) |
| 63 |
r[j] = _mm_load_ps1(_r+j); |
| 64 |
for (i=0;i<shape_cb_size;i+=4) |
| 65 |
{ |
| 66 |
float *_res = resp+i*subvect_size; |
| 67 |
const signed char *_shape = shape_cb+i*subvect_size; |
| 68 |
EE = _mm_setzero_ps(); |
| 69 |
for(j=0;j<subvect_size;j++) |
| 70 |
{ |
| 71 |
shape[j] = _mm_setr_ps(0.03125*_shape[j], 0.03125*_shape[subvect_size+j], 0.03125*_shape[2*subvect_size+j], 0.03125*_shape[3*subvect_size+j]); |
| 72 |
} |
| 73 |
for(j=0;j<subvect_size;j++) |
| 74 |
{ |
| 75 |
resj = _mm_setzero_ps(); |
| 76 |
for (k=0;k<=j;k++) |
| 77 |
resj = _mm_add_ps(resj, _mm_mul_ps(shape[k],r[j-k])); |
| 78 |
_spx_mm_getr_ps(resj, _res+j, _res+subvect_size+j, _res+2*subvect_size+j, _res+3*subvect_size+j); |
| 79 |
*resp2++ = resj; |
| 80 |
EE = _mm_add_ps(EE, _mm_mul_ps(resj, resj)); |
| 81 |
} |
| 82 |
E[i>>2] = EE; |
| 83 |
} |
| 84 |
} |