1cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar/*********************************************************************** 2d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovCopyright (c) 2006-2011, Skype Limited. All rights reserved. 3d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovRedistribution and use in source and binary forms, with or without 4d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovmodification, are permitted provided that the following conditions 5d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovare met: 6d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov- Redistributions of source code must retain the above copyright notice, 7d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovthis list of conditions and the following disclaimer. 8d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov- Redistributions in binary form must reproduce the above copyright 9d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovnotice, this list of conditions and the following disclaimer in the 10d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovdocumentation and/or other materials provided with the distribution. 11d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov- Neither the name of Internet Society, IETF or IETF Trust, nor the 12d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovnames of specific contributors, may be used to endorse or promote 13d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovproducts derived from this software without specific prior written 1437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hinespermission. 1537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen HinesTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 242d24e2a396a1d211baaeedf32148a3b657240170David BlaikieARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 252d24e2a396a1d211baaeedf32148a3b657240170David BlaikiePOSSIBILITY OF SUCH DAMAGE. 26d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov***********************************************************************/ 27d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov 28d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov#ifdef HAVE_CONFIG_H 29d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov#include "config.h" 3006ccca5f70ef5f9c3e4add60b6fc842916705029Anton Korobeynikov#endif 3106ccca5f70ef5f9c3e4add60b6fc842916705029Anton Korobeynikov 3206ccca5f70ef5f9c3e4add60b6fc842916705029Anton Korobeynikov#include "define.h" 330ae61240341ca76e1329f251c64d2f475fa89278Anton Korobeynikov#include "SigProc_FIX.h" 340ae61240341ca76e1329f251c64d2f475fa89278Anton Korobeynikov 350ae61240341ca76e1329f251c64d2f475fa89278Anton Korobeynikov/* 36d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovR. Laroia, N. Phamdo and N. Farvardin, "Robust and Efficient Quantization of Speech LSP 37d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovParameters Using Structured Vector Quantization", Proc. IEEE Int. Conf. Acoust., Speech, 38d5047cb9f7f207798e1729911daa6d3752b668e3Anton KorobeynikovSignal Processing, pp. 641-644, 1991. 392392efef1bd2599231ab659dd6ba4233bf5df94cDan Gohman*/ 4006ccca5f70ef5f9c3e4add60b6fc842916705029Anton Korobeynikov 41d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov/* Laroia low complexity NLSF weights */ 42d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikovvoid silk_NLSF_VQ_weights_laroia( 43d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */ 4406ccca5f70ef5f9c3e4add60b6fc842916705029Anton Korobeynikov const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */ 4506ccca5f70ef5f9c3e4add60b6fc842916705029Anton Korobeynikov const opus_int D /* I Input vector dimension (even) */ 4606ccca5f70ef5f9c3e4add60b6fc842916705029Anton Korobeynikov) 470ae61240341ca76e1329f251c64d2f475fa89278Anton Korobeynikov{ 480ae61240341ca76e1329f251c64d2f475fa89278Anton Korobeynikov opus_int k; 490ae61240341ca76e1329f251c64d2f475fa89278Anton Korobeynikov opus_int32 tmp1_int, tmp2_int; 50d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov 51d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov silk_assert( D > 0 ); 52d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov silk_assert( ( D & 1 ) == 0 ); 53d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov 54d5047cb9f7f207798e1729911daa6d3752b668e3Anton Korobeynikov /* First value */ 55 tmp1_int = silk_max_int( pNLSF_Q15[ 0 ], 1 ); 56 tmp1_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp1_int ); 57 tmp2_int = silk_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], 1 ); 58 tmp2_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp2_int ); 59 pNLSFW_Q_OUT[ 0 ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); 60 silk_assert( pNLSFW_Q_OUT[ 0 ] > 0 ); 61 62 /* Main loop */ 63 for( k = 1; k < D - 1; k += 2 ) { 64 tmp1_int = silk_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], 1 ); 65 tmp1_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp1_int ); 66 pNLSFW_Q_OUT[ k ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); 67 silk_assert( pNLSFW_Q_OUT[ k ] > 0 ); 68 69 tmp2_int = silk_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], 1 ); 70 tmp2_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp2_int ); 71 pNLSFW_Q_OUT[ k + 1 ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); 72 silk_assert( pNLSFW_Q_OUT[ k + 1 ] > 0 ); 73 } 74 75 /* Last value */ 76 tmp1_int = silk_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], 1 ); 77 tmp1_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp1_int ); 78 pNLSFW_Q_OUT[ D - 1 ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); 79 silk_assert( pNLSFW_Q_OUT[ D - 1 ] > 0 ); 80} 81