| Index: silk/x86/VQ_WMat_EC_sse.c
|
| diff --git a/silk/VQ_WMat_EC.c b/silk/x86/VQ_WMat_EC_sse.c
|
| similarity index 55%
|
| copy from silk/VQ_WMat_EC.c
|
| copy to silk/x86/VQ_WMat_EC_sse.c
|
| index 13d5d34eddbb5504407635af7b865c57c487342e..74d6c6d0ec6e4e9a7414cd4de87de9727ac20688 100644
|
| --- a/silk/VQ_WMat_EC.c
|
| +++ b/silk/x86/VQ_WMat_EC_sse.c
|
| @@ -1,38 +1,42 @@
|
| -/***********************************************************************
|
| -Copyright (c) 2006-2011, Skype Limited. All rights reserved.
|
| -Redistribution and use in source and binary forms, with or without
|
| -modification, are permitted provided that the following conditions
|
| -are met:
|
| -- Redistributions of source code must retain the above copyright notice,
|
| -this list of conditions and the following disclaimer.
|
| -- 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.
|
| -- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
| -names of specific contributors, may be used to endorse or promote
|
| -products derived from this software without specific prior written
|
| -permission.
|
| -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
| -***********************************************************************/
|
| +/* Copyright (c) 2014, Cisco Systems, INC
|
| + Written by XiangMingZhu WeiZhou MinPeng YanWang
|
| +
|
| + Redistribution and use in source and binary forms, with or without
|
| + modification, are permitted provided that the following conditions
|
| + are met:
|
| +
|
| + - Redistributions of source code must retain the above copyright
|
| + notice, this list of conditions and the following disclaimer.
|
| +
|
| + - 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.
|
| +
|
| + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| + ``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 COPYRIGHT OWNER
|
| + OR CONTRIBUTORS 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.
|
| +*/
|
|
|
| #ifdef HAVE_CONFIG_H
|
| #include "config.h"
|
| #endif
|
|
|
| +#include <xmmintrin.h>
|
| +#include <emmintrin.h>
|
| +#include <smmintrin.h>
|
| #include "main.h"
|
| +#include "celt/x86/x86cpu.h"
|
|
|
| /* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */
|
| -void silk_VQ_WMat_EC(
|
| +void silk_VQ_WMat_EC_sse4_1(
|
| opus_int8 *ind, /* O index of best codebook vector */
|
| opus_int32 *rate_dist_Q14, /* O best weighted quant error + mu * rate */
|
| opus_int *gain_Q7, /* O sum of absolute LTP coefficients */
|
| @@ -51,32 +55,50 @@ void silk_VQ_WMat_EC(
|
| opus_int16 diff_Q14[ 5 ];
|
| opus_int32 sum1_Q14, sum2_Q16;
|
|
|
| + __m128i C_tmp1, C_tmp2, C_tmp3, C_tmp4, C_tmp5;
|
| /* Loop over codebook */
|
| *rate_dist_Q14 = silk_int32_MAX;
|
| cb_row_Q7 = cb_Q7;
|
| for( k = 0; k < L; k++ ) {
|
| - gain_tmp_Q7 = cb_gain_Q7[k];
|
| + gain_tmp_Q7 = cb_gain_Q7[k];
|
|
|
| diff_Q14[ 0 ] = in_Q14[ 0 ] - silk_LSHIFT( cb_row_Q7[ 0 ], 7 );
|
| - diff_Q14[ 1 ] = in_Q14[ 1 ] - silk_LSHIFT( cb_row_Q7[ 1 ], 7 );
|
| - diff_Q14[ 2 ] = in_Q14[ 2 ] - silk_LSHIFT( cb_row_Q7[ 2 ], 7 );
|
| - diff_Q14[ 3 ] = in_Q14[ 3 ] - silk_LSHIFT( cb_row_Q7[ 3 ], 7 );
|
| - diff_Q14[ 4 ] = in_Q14[ 4 ] - silk_LSHIFT( cb_row_Q7[ 4 ], 7 );
|
| +
|
| + C_tmp1 = OP_CVTEPI16_EPI32_M64( &in_Q14[ 1 ] );
|
| + C_tmp2 = OP_CVTEPI8_EPI32_M32( &cb_row_Q7[ 1 ] );
|
| + C_tmp2 = _mm_slli_epi32( C_tmp2, 7 );
|
| + C_tmp1 = _mm_sub_epi32( C_tmp1, C_tmp2 );
|
| +
|
| + diff_Q14[ 1 ] = _mm_extract_epi16( C_tmp1, 0 );
|
| + diff_Q14[ 2 ] = _mm_extract_epi16( C_tmp1, 2 );
|
| + diff_Q14[ 3 ] = _mm_extract_epi16( C_tmp1, 4 );
|
| + diff_Q14[ 4 ] = _mm_extract_epi16( C_tmp1, 6 );
|
|
|
| /* Weighted rate */
|
| sum1_Q14 = silk_SMULBB( mu_Q9, cl_Q5[ k ] );
|
|
|
| - /* Penalty for too large gain */
|
| - sum1_Q14 = silk_ADD_LSHIFT32( sum1_Q14, silk_max( silk_SUB32( gain_tmp_Q7, max_gain_Q7 ), 0 ), 10 );
|
| + /* Penalty for too large gain */
|
| + sum1_Q14 = silk_ADD_LSHIFT32( sum1_Q14, silk_max( silk_SUB32( gain_tmp_Q7, max_gain_Q7 ), 0 ), 10 );
|
|
|
| silk_assert( sum1_Q14 >= 0 );
|
|
|
| /* first row of W_Q18 */
|
| - sum2_Q16 = silk_SMULWB( W_Q18[ 1 ], diff_Q14[ 1 ] );
|
| - sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 2 ], diff_Q14[ 2 ] );
|
| - sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 3 ], diff_Q14[ 3 ] );
|
| - sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 4 ], diff_Q14[ 4 ] );
|
| - sum2_Q16 = silk_LSHIFT( sum2_Q16, 1 );
|
| + C_tmp3 = _mm_loadu_si128( (__m128i *)(&W_Q18[ 1 ] ) );
|
| + C_tmp4 = _mm_mul_epi32( C_tmp3, C_tmp1 );
|
| + C_tmp4 = _mm_srli_si128( C_tmp4, 2 );
|
| +
|
| + C_tmp1 = _mm_shuffle_epi32( C_tmp1, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* shift right 4 bytes */
|
| + C_tmp3 = _mm_shuffle_epi32( C_tmp3, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* shift right 4 bytes */
|
| +
|
| + C_tmp5 = _mm_mul_epi32( C_tmp3, C_tmp1 );
|
| + C_tmp5 = _mm_srli_si128( C_tmp5, 2 );
|
| +
|
| + C_tmp5 = _mm_add_epi32( C_tmp4, C_tmp5 );
|
| + C_tmp5 = _mm_slli_epi32( C_tmp5, 1 );
|
| +
|
| + C_tmp5 = _mm_add_epi32( C_tmp5, _mm_shuffle_epi32( C_tmp5, _MM_SHUFFLE( 0, 0, 0, 2 ) ) );
|
| + sum2_Q16 = _mm_cvtsi128_si32( C_tmp5 );
|
| +
|
| sum2_Q16 = silk_SMLAWB( sum2_Q16, W_Q18[ 0 ], diff_Q14[ 0 ] );
|
| sum1_Q14 = silk_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 0 ] );
|
|
|
| @@ -111,7 +133,7 @@ void silk_VQ_WMat_EC(
|
| if( sum1_Q14 < *rate_dist_Q14 ) {
|
| *rate_dist_Q14 = sum1_Q14;
|
| *ind = (opus_int8)k;
|
| - *gain_Q7 = gain_tmp_Q7;
|
| + *gain_Q7 = gain_tmp_Q7;
|
| }
|
|
|
| /* Go to next cbk vector */
|
|
|