ref: 103302b3752609e28cb6ba4f706a6f6e49ffef68
parent: c77b96333b471c7b8a89852ee941e6a8987751b4
author: Jean-Marc Valin <jean-marc.valin@octasic.com>
date: Thu May 19 13:17:44 EDT 2011
Squashed commit of the following: commit 5b64cf7c4d67af9050bc959996ef976ce6326888 Author: Jean-Marc Valin <jean-marc.valin@octasic.com> Date: Thu May 19 16:40:35 2011 -0400 Fixes a few bugs introduced in the latest update commit b91eb86025d2de3c4cf04f4fb1aa48a28ad676a3 Author: Timothy B. Terriberry <tterribe@xiph.org> Date: Thu May 19 16:12:02 2011 -0400 build_draft.sh fixes commit 0b10c30db7ad60ff7d4bfc1139bdb86e0543c035 Author: Jean-Marc Valin <jean-marc.valin@octasic.com> Date: Thu May 19 15:30:21 2011 -0400 Fixes the draft build commit 164424cded5978e657105104e171ac202dde5e5b Author: Jean-Marc Valin <jean-marc.valin@octasic.com> Date: Thu May 19 15:00:23 2011 -0400 Updated build system commit 188d9fcba8c3a1b1ad67c67c430e1b37e3658a40 Author: Koen Vos <koen.vos@skype.net> Date: Thu May 19 17:14:57 2011 -0400 SILK/Opus update
--- a/doc/build_draft.sh
+++ b/doc/build_draft.sh
@@ -11,16 +11,23 @@
echo packaging source code
rm -rf "${destdir}"
mkdir "${destdir}"
+mkdir "${destdir}/src"
+mkdir "${destdir}/silk"
+mkdir "${destdir}/silk/float"
+mkdir "${destdir}/silk/fixed"
+mkdir "${destdir}/libcelt"
for f in `cat "${toplevel}"/opus_sources.mk "${toplevel}"/celt_sources.mk \
"${toplevel}"/silk_sources.mk "${toplevel}"/opus_headers.txt \
"${toplevel}"/celt_headers.txt "${toplevel}"/silk_headers.txt \
| grep '\.[ch]' | sed -e 's/^.*=//' -e 's/\\\\//'` ; do
- cp -a "${toplevel}/${f}" "${destdir}"
+ cp -a "${toplevel}/${f}" "${destdir}/${f}"
done
+cp -a "${toplevel}"/src/test_opus.c "${destdir}"/src/
cp -a "${toplevel}"/Makefile.draft "${destdir}"/Makefile
cp -a "${toplevel}"/opus_sources.mk "${destdir}"/
cp -a "${toplevel}"/celt_sources.mk "${destdir}"/
-cp -a "${toplevel}"/silk_sources.mk "${destdir}"/
+cat "${toplevel}"/silk_sources.mk | sed 's/^if /ifdef /' \
+ > "${destdir}"/silk_sources.mk
cp -a "${toplevel}"/README.draft "${destdir}"/README
cp -a "${toplevel}"/COPYING "${destdir}"/COPYING
--- a/libcelt/celt_header.h
+++ /dev/null
@@ -1,66 +1,0 @@
-/* Copyright (c) 2007 CSIRO
- Copyright (c) 2007-2008 Xiph.Org Foundation
- Written by Jean-Marc Valin */
-/*
- 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 FOUNDATION 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.
-*/
-
-#ifndef CELT_HEADER_H
-#define CELT_HEADER_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "celt.h"
-#include "celt_types.h"
-
-/** Header data to be used for Ogg files (or possibly other encapsulation)
- @brief Header data
- */
-typedef struct {
- char codec_id[8]; /**< MUST be "CELT " (four spaces) */
- char codec_version[20]; /**< Version used (as string) */
- celt_int32 version_id; /**< Version id (negative for until stream is frozen) */
- celt_int32 header_size; /**< Size of this header */
- celt_int32 sample_rate; /**< Sampling rate of the original audio */
- celt_int32 nb_channels; /**< Number of channels */
- celt_int32 frame_size; /**< Samples per frame (per channel) */
- celt_int32 overlap; /**< Overlapping samples (per channel) */
- celt_int32 bytes_per_packet; /**< Number of bytes per compressed packet (0 if unknown) */
- celt_int32 extra_headers; /**< Number of additional headers that follow this header */
-} CELTHeader;
-
-/** Creates a basic header struct */
-EXPORT int celt_header_init(CELTHeader *header, const CELTMode *m, int frame_size, int channels);
-
-EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32 size);
-
-EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32 size, CELTHeader *header);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CELT_HEADER_H */
--- a/libcelt/libcelt.vcxproj
+++ b/libcelt/libcelt.vcxproj
@@ -75,7 +75,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\win32\config.h" />
- <ClInclude Include="..\msvc\config.h" />
<ClInclude Include="arch.h" />
<ClInclude Include="bands.h" />
<ClInclude Include="celt.h" />
@@ -109,7 +108,6 @@
<ClCompile Include="entcode.c" />
<ClCompile Include="entdec.c" />
<ClCompile Include="entenc.c" />
- <ClCompile Include="header.c" />
<ClCompile Include="kiss_fft.c" />
<ClCompile Include="laplace.c" />
<ClCompile Include="mathops.c" />
--- a/libcelt/libcelt.vcxproj.filters
+++ b/libcelt/libcelt.vcxproj.filters
@@ -93,9 +93,6 @@
<ClInclude Include="vq.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\msvc\config.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\win32\config.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -117,9 +114,6 @@
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="entenc.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="header.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="kiss_fft.c">
--- a/opus.sln
+++ b/opus.sln
@@ -2,12 +2,30 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_common", "silk\silk_common.vcxproj", "{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}"
+ ProjectSection(ProjectDependencies) = postProject
+ {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus", "src\opus.vcxproj", "{219EC965-228A-1824-174D-96449D05F88A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {8484C90D-1561-402F-A91D-2DB10F8C5171} = {8484C90D-1561-402F-A91D-2DB10F8C5171}
+ {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} = {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}
+ {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF}
+ {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_fixed", "silk\fixed\silk_fixed.vcxproj", "{8484C90D-1561-402F-A91D-2DB10F8C5171}"
+ ProjectSection(ProjectDependencies) = postProject
+ {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF}
+ {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_float", "silk\float\silk_float.vcxproj", "{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}"
+ ProjectSection(ProjectDependencies) = postProject
+ {8484C90D-1561-402F-A91D-2DB10F8C5171} = {8484C90D-1561-402F-A91D-2DB10F8C5171}
+ {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF}
+ {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcelt", "libcelt\libcelt.vcxproj", "{245603E3-F580-41A5-9632-B25FE3372CBF}"
EndProject
--- a/silk/SKP_Silk_A2NLSF.c
+++ /dev/null
@@ -1,279 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* Conversion between prediction filter coefficients and NLSFs */
-/* Requires the order to be an even number */
-/* A piecewise linear approximation maps LSF <-> cos(LSF) */
-/* Therefore the result is not accurate NLSFs, but the two */
-/* function are accurate inverses of each other */
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Number of binary divisions, when not in low complexity mode */
-#define BIN_DIV_STEPS_A2NLSF_FIX 3 /* must be no higher than 16 - log2( LSF_COS_TAB_SZ_FIX ) */
-#define QPoly 16
-#define MAX_ITERATIONS_A2NLSF_FIX 30
-
-/* Flag for using 2x as many cosine sampling points, reduces the risk of missing a root */
-#define OVERSAMPLE_COSINE_TABLE 0
-
-/* Helper function for A2NLSF(..) */
-/* Transforms polynomials from cos(n*f) to cos(f)^n */
-SKP_INLINE void SKP_Silk_A2NLSF_trans_poly(
- SKP_int32 *p, /* I/O Polynomial */
- const SKP_int dd /* I Polynomial order (= filter order / 2 ) */
-)
-{
- SKP_int k, n;
-
- for( k = 2; k <= dd; k++ ) {
- for( n = dd; n > k; n-- ) {
- p[ n - 2 ] -= p[ n ];
- }
- p[ k - 2 ] -= SKP_LSHIFT( p[ k ], 1 );
- }
-}
-/* Helper function for A2NLSF(..) */
-/* Polynomial evaluation */
-SKP_INLINE SKP_int32 SKP_Silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */
- SKP_int32 *p, /* I Polynomial, QPoly */
- const SKP_int32 x, /* I Evaluation point, Q12 */
- const SKP_int dd /* I Order */
-)
-{
- SKP_int n;
- SKP_int32 x_Q16, y32;
-
- y32 = p[ dd ]; /* QPoly */
- x_Q16 = SKP_LSHIFT( x, 4 );
- for( n = dd - 1; n >= 0; n-- ) {
- y32 = SKP_SMLAWW( p[ n ], y32, x_Q16 ); /* QPoly */
- }
- return y32;
-}
-
-SKP_INLINE void SKP_Silk_A2NLSF_init(
- const SKP_int32 *a_Q16,
- SKP_int32 *P,
- SKP_int32 *Q,
- const SKP_int dd
-)
-{
- SKP_int k;
-
- /* Convert filter coefs to even and odd polynomials */
- P[dd] = SKP_LSHIFT( 1, QPoly );
- Q[dd] = SKP_LSHIFT( 1, QPoly );
- for( k = 0; k < dd; k++ ) {
-#if( QPoly < 16 )
- P[ k ] = SKP_RSHIFT_ROUND( -a_Q16[ dd - k - 1 ] - a_Q16[ dd + k ], 16 - QPoly ); /* QPoly */
- Q[ k ] = SKP_RSHIFT_ROUND( -a_Q16[ dd - k - 1 ] + a_Q16[ dd + k ], 16 - QPoly ); /* QPoly */
-#elif( Qpoly == 16 )
- P[ k ] = -a_Q16[ dd - k - 1 ] - a_Q16[ dd + k ]; // QPoly
- Q[ k ] = -a_Q16[ dd - k - 1 ] + a_Q16[ dd + k ]; // QPoly
-#else
- P[ k ] = SKP_LSHIFT( -a_Q16[ dd - k - 1 ] - a_Q16[ dd + k ], QPoly - 16 ); /* QPoly */
- Q[ k ] = SKP_LSHIFT( -a_Q16[ dd - k - 1 ] + a_Q16[ dd + k ], QPoly - 16 ); /* QPoly */
-#endif
- }
-
- /* Divide out zeros as we have that for even filter orders, */
- /* z = 1 is always a root in Q, and */
- /* z = -1 is always a root in P */
- for( k = dd; k > 0; k-- ) {
- P[ k - 1 ] -= P[ k ];
- Q[ k - 1 ] += Q[ k ];
- }
-
- /* Transform polynomials from cos(n*f) to cos(f)^n */
- SKP_Silk_A2NLSF_trans_poly( P, dd );
- SKP_Silk_A2NLSF_trans_poly( Q, dd );
-}
-
-/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */
-/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */
-void SKP_Silk_A2NLSF(
- SKP_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
- SKP_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
- const SKP_int d /* I Filter order (must be even) */
-)
-{
- SKP_int i, k, m, dd, root_ix, ffrac;
- SKP_int32 xlo, xhi, xmid;
- SKP_int32 ylo, yhi, ymid;
- SKP_int32 nom, den;
- SKP_int32 P[ SKP_Silk_MAX_ORDER_LPC / 2 + 1 ];
- SKP_int32 Q[ SKP_Silk_MAX_ORDER_LPC / 2 + 1 ];
- SKP_int32 *PQ[ 2 ];
- SKP_int32 *p;
-
- /* Store pointers to array */
- PQ[ 0 ] = P;
- PQ[ 1 ] = Q;
-
- dd = SKP_RSHIFT( d, 1 );
-
- SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd );
-
- /* Find roots, alternating between P and Q */
- p = P; /* Pointer to polynomial */
-
- xlo = SKP_Silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12
- ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd );
-
- if( ylo < 0 ) {
- /* Set the first NLSF to zero and move on to the next */
- NLSF[ 0 ] = 0;
- p = Q; /* Pointer to polynomial */
- ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd );
- root_ix = 1; /* Index of current root */
- } else {
- root_ix = 0; /* Index of current root */
- }
- k = 1; /* Loop counter */
- i = 0; /* Counter for bandwidth expansions applied */
- while( 1 ) {
- /* Evaluate polynomial */
-#if OVERSAMPLE_COSINE_TABLE
- xhi = SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] +
- ( ( SKP_Silk_LSFCosTab_FIX_Q12[ ( k + 1 ) >> 1 ] -
- SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] ) >> 1 ); /* Q12 */
-#else
- xhi = SKP_Silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */
-#endif
- yhi = SKP_Silk_A2NLSF_eval_poly( p, xhi, dd );
-
- /* Detect zero crossing */
- if( ( ylo <= 0 && yhi >= 0 ) || ( ylo >= 0 && yhi <= 0 ) ) {
- /* Binary division */
-#if OVERSAMPLE_COSINE_TABLE
- ffrac = -128;
-#else
- ffrac = -256;
-#endif
- for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) {
- /* Evaluate polynomial */
- xmid = SKP_RSHIFT_ROUND( xlo + xhi, 1 );
- ymid = SKP_Silk_A2NLSF_eval_poly( p, xmid, dd );
-
- /* Detect zero crossing */
- if( ( ylo <= 0 && ymid >= 0 ) || ( ylo >= 0 && ymid <= 0 ) ) {
- /* Reduce frequency */
- xhi = xmid;
- yhi = ymid;
- } else {
- /* Increase frequency */
- xlo = xmid;
- ylo = ymid;
-#if OVERSAMPLE_COSINE_TABLE
- ffrac = SKP_ADD_RSHIFT( ffrac, 64, m );
-#else
- ffrac = SKP_ADD_RSHIFT( ffrac, 128, m );
-#endif
- }
- }
-
- /* Interpolate */
- if( SKP_abs( ylo ) < 65536 ) {
- /* Avoid dividing by zero */
- den = ylo - yhi;
- nom = SKP_LSHIFT( ylo, 8 - BIN_DIV_STEPS_A2NLSF_FIX ) + SKP_RSHIFT( den, 1 );
- if( den != 0 ) {
- ffrac += SKP_DIV32( nom, den );
- }
- } else {
- /* No risk of dividing by zero because abs(ylo - yhi) >= abs(ylo) >= 65536 */
- ffrac += SKP_DIV32( ylo, SKP_RSHIFT( ylo - yhi, 8 - BIN_DIV_STEPS_A2NLSF_FIX ) );
- }
-#if OVERSAMPLE_COSINE_TABLE
- NLSF[ root_ix ] = (SKP_int16)SKP_min_32( SKP_LSHIFT( (SKP_int32)k, 7 ) + ffrac, SKP_int16_MAX );
-#else
- NLSF[ root_ix ] = (SKP_int16)SKP_min_32( SKP_LSHIFT( (SKP_int32)k, 8 ) + ffrac, SKP_int16_MAX );
-#endif
-
- SKP_assert( NLSF[ root_ix ] >= 0 );
- SKP_assert( NLSF[ root_ix ] <= 32767 );
-
- root_ix++; /* Next root */
- if( root_ix >= d ) {
- /* Found all roots */
- break;
- }
- /* Alternate pointer to polynomial */
- p = PQ[ root_ix & 1 ];
-
- /* Evaluate polynomial */
-#if OVERSAMPLE_COSINE_TABLE
- xlo = SKP_Silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] +
- ( ( SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] -
- SKP_Silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] ) >> 1 ); // Q12
-#else
- xlo = SKP_Silk_LSFCosTab_FIX_Q12[ k - 1 ]; // Q12
-#endif
- ylo = SKP_LSHIFT( 1 - ( root_ix & 2 ), 12 );
- } else {
- /* Increment loop counter */
- k++;
- xlo = xhi;
- ylo = yhi;
-
-#if OVERSAMPLE_COSINE_TABLE
- if( k > 2 * LSF_COS_TAB_SZ_FIX ) {
-#else
- if( k > LSF_COS_TAB_SZ_FIX ) {
-#endif
- i++;
- if( i > MAX_ITERATIONS_A2NLSF_FIX ) {
- /* Set NLSFs to white spectrum and exit */
- NLSF[ 0 ] = (SKP_int16)SKP_DIV32_16( 1 << 15, d + 1 );
- for( k = 1; k < d; k++ ) {
- NLSF[ k ] = (SKP_int16)SKP_SMULBB( k + 1, NLSF[ 0 ] );
- }
- return;
- }
-
- /* Error: Apply progressively more bandwidth expansion and run again */
- SKP_Silk_bwexpander_32( a_Q16, d, 65536 - SKP_SMULBB( 10 + i, i ) ); // 10_Q16 = 0.00015
-
- SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd );
- p = P; /* Pointer to polynomial */
- xlo = SKP_Silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12
- ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd );
- if( ylo < 0 ) {
- /* Set the first NLSF to zero and move on to the next */
- NLSF[ 0 ] = 0;
- p = Q; /* Pointer to polynomial */
- ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd );
- root_ix = 1; /* Index of current root */
- } else {
- root_ix = 0; /* Index of current root */
- }
- k = 1; /* Reset loop counter */
- }
- }
- }
-}
--- a/silk/SKP_Silk_CNG.c
+++ /dev/null
@@ -1,149 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Generates excitation for CNG LPC synthesis */
-SKP_INLINE void SKP_Silk_CNG_exc(
- SKP_int16 residual[], /* O CNG residual signal Q0 */
- SKP_int32 exc_buf_Q10[], /* I Random samples buffer Q10 */
- SKP_int32 Gain_Q16, /* I Gain to apply */
- SKP_int length, /* I Length */
- SKP_int32 *rand_seed /* I/O Seed to random index generator */
-)
-{
- SKP_int32 seed;
- SKP_int i, idx, exc_mask;
-
- exc_mask = CNG_BUF_MASK_MAX;
- while( exc_mask > length ) {
- exc_mask = SKP_RSHIFT( exc_mask, 1 );
- }
-
- seed = *rand_seed;
- for( i = 0; i < length; i++ ) {
- seed = SKP_RAND( seed );
- idx = ( SKP_int )( SKP_RSHIFT( seed, 24 ) & exc_mask );
- SKP_assert( idx >= 0 );
- SKP_assert( idx <= CNG_BUF_MASK_MAX );
- residual[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( exc_buf_Q10[ idx ], Gain_Q16 ), 10 ) );
- }
- *rand_seed = seed;
-}
-
-void SKP_Silk_CNG_Reset(
- SKP_Silk_decoder_state *psDec /* I/O Decoder state */
-)
-{
- SKP_int i, NLSF_step_Q15, NLSF_acc_Q15;
-
- NLSF_step_Q15 = SKP_DIV32_16( SKP_int16_MAX, psDec->LPC_order + 1 );
- NLSF_acc_Q15 = 0;
- for( i = 0; i < psDec->LPC_order; i++ ) {
- NLSF_acc_Q15 += NLSF_step_Q15;
- psDec->sCNG.CNG_smth_NLSF_Q15[ i ] = NLSF_acc_Q15;
- }
- psDec->sCNG.CNG_smth_Gain_Q16 = 0;
- psDec->sCNG.rand_seed = 3176576;
-}
-
-/* Updates CNG estimate, and applies the CNG when packet was lost */
-void SKP_Silk_CNG(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[], /* I/O Signal */
- SKP_int length /* I Length of residual */
-)
-{
- SKP_int i, subfr;
- SKP_int32 tmp_32, Gain_Q26, max_Gain_Q16;
- SKP_int16 LPC_buf[ MAX_LPC_ORDER ];
- SKP_int16 CNG_sig[ MAX_FRAME_LENGTH ];
- SKP_Silk_CNG_struct *psCNG;
- psCNG = &psDec->sCNG;
-
- if( psDec->fs_kHz != psCNG->fs_kHz ) {
- /* Reset state */
- SKP_Silk_CNG_Reset( psDec );
-
- psCNG->fs_kHz = psDec->fs_kHz;
- }
- if( psDec->lossCnt == 0 && psDec->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) {
- /* Update CNG parameters */
-
- /* Smoothing of LSF's */
- for( i = 0; i < psDec->LPC_order; i++ ) {
- psCNG->CNG_smth_NLSF_Q15[ i ] += SKP_SMULWB( psDec->prevNLSF_Q15[ i ] - psCNG->CNG_smth_NLSF_Q15[ i ], CNG_NLSF_SMTH_Q16 );
- }
- /* Find the subframe with the highest gain */
- max_Gain_Q16 = 0;
- subfr = 0;
- for( i = 0; i < psDec->nb_subfr; i++ ) {
- if( psDecCtrl->Gains_Q16[ i ] > max_Gain_Q16 ) {
- max_Gain_Q16 = psDecCtrl->Gains_Q16[ i ];
- subfr = i;
- }
- }
- /* Update CNG excitation buffer with excitation from this subframe */
- SKP_memmove( &psCNG->CNG_exc_buf_Q10[ psDec->subfr_length ], psCNG->CNG_exc_buf_Q10, ( psDec->nb_subfr - 1 ) * psDec->subfr_length * sizeof( SKP_int32 ) );
- SKP_memcpy( psCNG->CNG_exc_buf_Q10, &psDec->exc_Q10[ subfr * psDec->subfr_length ], psDec->subfr_length * sizeof( SKP_int32 ) );
-
- /* Smooth gains */
- for( i = 0; i < psDec->nb_subfr; i++ ) {
- psCNG->CNG_smth_Gain_Q16 += SKP_SMULWB( psDecCtrl->Gains_Q16[ i ] - psCNG->CNG_smth_Gain_Q16, CNG_GAIN_SMTH_Q16 );
- }
- }
-
- /* Add CNG when packet is lost and / or when low speech activity */
- if( psDec->lossCnt ) {
-
- /* Generate CNG excitation */
- SKP_Silk_CNG_exc( CNG_sig, psCNG->CNG_exc_buf_Q10,
- psCNG->CNG_smth_Gain_Q16, length, &psCNG->rand_seed );
-
- /* Convert CNG NLSF to filter representation */
- SKP_Silk_NLSF2A_stable( LPC_buf, psCNG->CNG_smth_NLSF_Q15, psDec->LPC_order );
-
- Gain_Q26 = ( SKP_int32 )1 << 26; /* 1.0 */
-
- /* Generate CNG signal, by synthesis filtering */
- if( psDec->LPC_order == 16 ) {
- SKP_Silk_LPC_synthesis_order16( CNG_sig, LPC_buf,
- Gain_Q26, psCNG->CNG_synth_state, CNG_sig, length );
- } else {
- SKP_Silk_LPC_synthesis_filter( CNG_sig, LPC_buf,
- Gain_Q26, psCNG->CNG_synth_state, CNG_sig, length, psDec->LPC_order );
- }
- /* Mix with signal */
- for( i = 0; i < length; i++ ) {
- tmp_32 = signal[ i ] + CNG_sig[ i ];
- signal[ i ] = SKP_SAT16( tmp_32 );
- }
- } else {
- SKP_memset( psCNG->CNG_synth_state, 0, psDec->LPC_order * sizeof( SKP_int32 ) );
- }
-}
--- a/silk/SKP_Silk_HP_variable_cutoff.c
+++ /dev/null
@@ -1,117 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main_FIX.h"
-#include "SKP_Silk_tuning_parameters.h"
-
-#define SKP_RADIANS_CONSTANT_Q19 1482 // 0.45f * 2.0f * 3.14159265359 / 1000
-#define SKP_LOG2_VARIABLE_HP_MIN_FREQ_Q7 809 // log(80) in Q7
-
-/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
-void SKP_Silk_HP_variable_cutoff(
- SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
- SKP_int16 *out, /* O high-pass filtered output signal */
- const SKP_int16 *in, /* I input signal */
- const SKP_int frame_length /* I length of input */
-)
-{
- SKP_int quality_Q15;
- SKP_float pitch_freq_low_Hz;
- SKP_int32 B_Q28[ 3 ], A_Q28[ 2 ];
- SKP_int32 Fc_Q19, r_Q28, r_Q22;
- SKP_int32 pitch_freq_Hz_Q16, pitch_freq_log_Q7, delta_freq_Q7;
-
- /*********************************************/
- /* Estimate Low End of Pitch Frequency Range */
- /*********************************************/
- if( psEncC->prevSignalType == TYPE_VOICED ) {
- /* difference, in log domain */
- pitch_freq_Hz_Q16 = SKP_DIV32_16( SKP_LSHIFT( SKP_MUL( psEncC->fs_kHz, 1000 ), 16 ), psEncC->prevLag );
- pitch_freq_log_Q7 = SKP_Silk_lin2log( pitch_freq_Hz_Q16 ) - ( 16 << 7 ); //0x70
-
- /* adjustment based on quality */
- quality_Q15 = psEncC->input_quality_bands_Q15[ 0 ];
- pitch_freq_log_Q7 = SKP_SUB32( pitch_freq_log_Q7, SKP_SMULWB( SKP_SMULWB( SKP_LSHIFT( quality_Q15, 2 ), quality_Q15 ),
- pitch_freq_log_Q7 - SKP_LOG2_VARIABLE_HP_MIN_FREQ_Q7 ) );
- pitch_freq_log_Q7 = SKP_ADD32( pitch_freq_log_Q7, SKP_RSHIFT( SKP_FIX_CONST( 0.6, 15 ) - quality_Q15, 9 ) );
-
- //delta_freq = pitch_freq_log - psEnc->variable_HP_smth1;
- delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEncC->variable_HP_smth1_Q15, 8 );
- if( delta_freq_Q7 < 0 ) {
- /* less smoothing for decreasing pitch frequency, to track something close to the minimum */
- delta_freq_Q7 = SKP_MUL( delta_freq_Q7, 3 );
- }
-
- /* limit delta, to reduce impact of outliers */
- delta_freq_Q7 = SKP_LIMIT_32( delta_freq_Q7, -SKP_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ), SKP_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ) );
-
- /* update smoother */
- psEncC->variable_HP_smth1_Q15 = SKP_SMLAWB( psEncC->variable_HP_smth1_Q15,
- SKP_MUL( SKP_LSHIFT( psEncC->speech_activity_Q8, 1 ), delta_freq_Q7 ), SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF1, 16 ) );
- }
-
- /* second smoother */
- psEncC->variable_HP_smth2_Q15 = SKP_SMLAWB( psEncC->variable_HP_smth2_Q15,
- psEncC->variable_HP_smth1_Q15 - psEncC->variable_HP_smth2_Q15, SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF2, 16 ) );
-
- /* convert from log scale to Hertz */
- pitch_freq_low_Hz = SKP_Silk_log2lin( SKP_RSHIFT( psEncC->variable_HP_smth2_Q15, 8 ) );
-
- /* limit frequency range */
- pitch_freq_low_Hz = SKP_LIMIT_32( pitch_freq_low_Hz, SKP_FIX_CONST( VARIABLE_HP_MIN_FREQ, 0 ), SKP_FIX_CONST( VARIABLE_HP_MAX_FREQ, 0 ) );
-
- /********************************/
- /* Compute Filter Coefficients */
- /********************************/
- /* compute cut-off frequency, in radians */
- //Fc_num = (SKP_float)( 0.45f * 2.0f * 3.14159265359 * pitch_freq_low_Hz );
- //Fc_denom = (SKP_float)( 1e3f * psEncC->fs_kHz );
- SKP_assert( pitch_freq_low_Hz <= SKP_int32_MAX / SKP_RADIANS_CONSTANT_Q19 );
- Fc_Q19 = SKP_DIV32_16( SKP_SMULBB( SKP_RADIANS_CONSTANT_Q19, pitch_freq_low_Hz ), psEncC->fs_kHz ); // range: 3704 - 27787, 11-15 bits
- SKP_assert( Fc_Q19 >= 3704 );
- SKP_assert( Fc_Q19 <= 27787 );
-
- r_Q28 = SKP_FIX_CONST( 1.0, 28 ) - SKP_MUL( SKP_FIX_CONST( 0.92, 9 ), Fc_Q19 );
- SKP_assert( r_Q28 >= 255347779 );
- SKP_assert( r_Q28 <= 266690872 );
-
- /* b = r * [ 1; -2; 1 ]; */
- /* a = [ 1; -2 * r * ( 1 - 0.5 * Fc^2 ); r^2 ]; */
- B_Q28[ 0 ] = r_Q28;
- B_Q28[ 1 ] = SKP_LSHIFT( -r_Q28, 1 );
- B_Q28[ 2 ] = r_Q28;
-
- // -r * ( 2 - Fc * Fc );
- r_Q22 = SKP_RSHIFT( r_Q28, 6 );
- A_Q28[ 0 ] = SKP_SMULWW( r_Q22, SKP_SMULWW( Fc_Q19, Fc_Q19 ) - SKP_FIX_CONST( 2.0, 22 ) );
- A_Q28[ 1 ] = SKP_SMULWW( r_Q22, r_Q22 );
-
- /********************************/
- /* High-Pass Filter */
- /********************************/
- SKP_Silk_biquad_alt( in, B_Q28, A_Q28, psEncC->In_HP_State, out, frame_length );
-}
--- a/silk/SKP_Silk_Inlines.h
+++ /dev/null
@@ -1,212 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/*! \file SKP_Silk_Inlines.h
- * \brief SKP_Silk_Inlines.h defines inline signal processing functions.
- */
-
-#ifndef _SKP_SILK_FIX_INLINES_H_
-#define _SKP_SILK_FIX_INLINES_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* count leading zeros of SKP_int64 */
-SKP_INLINE SKP_int32 SKP_Silk_CLZ64(SKP_int64 in)
-{
- SKP_int32 in_upper;
-
- in_upper = (SKP_int32)SKP_RSHIFT64(in, 32);
- if (in_upper == 0) {
- /* Search in the lower 32 bits */
- return 32 + SKP_Silk_CLZ32( (SKP_int32) in );
- } else {
- /* Search in the upper 32 bits */
- return SKP_Silk_CLZ32( in_upper );
- }
-}
-
-/* get number of leading zeros and fractional part (the bits right after the leading one */
-SKP_INLINE void SKP_Silk_CLZ_FRAC(SKP_int32 in, /* I: input */
- SKP_int32 *lz, /* O: number of leading zeros */
- SKP_int32 *frac_Q7) /* O: the 7 bits right after the leading one */
-{
- SKP_int32 lzeros = SKP_Silk_CLZ32(in);
-
- * lz = lzeros;
- * frac_Q7 = SKP_ROR32(in, 24 - lzeros) & 0x7f;
-}
-
-/* Approximation of square root */
-/* Accuracy: < +/- 10% for output values > 15 */
-/* < +/- 2.5% for output values > 120 */
-SKP_INLINE SKP_int32 SKP_Silk_SQRT_APPROX(SKP_int32 x)
-{
- SKP_int32 y, lz, frac_Q7;
-
- if( x <= 0 ) {
- return 0;
- }
-
- SKP_Silk_CLZ_FRAC(x, &lz, &frac_Q7);
-
- if( lz & 1 ) {
- y = 32768;
- } else {
- y = 46214; /* 46214 = sqrt(2) * 32768 */
- }
-
- /* get scaling right */
- y >>= SKP_RSHIFT(lz, 1);
-
- /* increment using fractional part of input */
- y = SKP_SMLAWB(y, y, SKP_SMULBB(213, frac_Q7));
-
- return y;
-}
-
-/* returns the number of left shifts before overflow for a 16 bit number (ITU definition with norm(0)=0) */
-SKP_INLINE SKP_int32 SKP_Silk_norm16(SKP_int16 a) {
-
- SKP_int32 a32;
-
- /* if ((a == 0) || (a == SKP_int16_MIN)) return(0); */
- if ((a << 1) == 0) return(0);
-
- a32 = a;
- /* if (a32 < 0) a32 = -a32 - 1; */
- a32 ^= SKP_RSHIFT(a32, 31);
-
- return SKP_Silk_CLZ32(a32) - 17;
-}
-
-/* returns the number of left shifts before overflow for a 32 bit number (ITU definition with norm(0)=0) */
-SKP_INLINE SKP_int32 SKP_Silk_norm32(SKP_int32 a) {
-
- /* if ((a == 0) || (a == SKP_int32_MIN)) return(0); */
- if ((a << 1) == 0) return(0);
-
- /* if (a < 0) a = -a - 1; */
- a ^= SKP_RSHIFT(a, 31);
-
- return SKP_Silk_CLZ32(a) - 1;
-}
-
-/* Divide two int32 values and return result as int32 in a given Q-domain */
-SKP_INLINE SKP_int32 SKP_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */
- const SKP_int32 a32, /* I numerator (Q0) */
- const SKP_int32 b32, /* I denominator (Q0) */
- const SKP_int Qres /* I Q-domain of result (>= 0) */
-)
-{
- SKP_int a_headrm, b_headrm, lshift;
- SKP_int32 b32_inv, a32_nrm, b32_nrm, result;
-
- SKP_assert( b32 != 0 );
- SKP_assert( Qres >= 0 );
-
- /* Compute number of bits head room and normalize inputs */
- a_headrm = SKP_Silk_CLZ32( SKP_abs(a32) ) - 1;
- a32_nrm = SKP_LSHIFT(a32, a_headrm); /* Q: a_headrm */
- b_headrm = SKP_Silk_CLZ32( SKP_abs(b32) ) - 1;
- b32_nrm = SKP_LSHIFT(b32, b_headrm); /* Q: b_headrm */
-
- /* Inverse of b32, with 14 bits of precision */
- b32_inv = SKP_DIV32_16( SKP_int32_MAX >> 2, SKP_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */
-
- /* First approximation */
- result = SKP_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */
-
- /* Compute residual by subtracting product of denominator and first approximation */
- a32_nrm -= SKP_LSHIFT_ovflw( SKP_SMMUL(b32_nrm, result), 3 ); /* Q: a_headrm */
-
- /* Refinement */
- result = SKP_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */
-
- /* Convert to Qres domain */
- lshift = 29 + a_headrm - b_headrm - Qres;
- if( lshift < 0 ) {
- return SKP_LSHIFT_SAT32(result, -lshift);
- } else {
- if( lshift < 32){
- return SKP_RSHIFT(result, lshift);
- } else {
- /* Avoid undefined result */
- return 0;
- }
- }
-}
-
-/* Invert int32 value and return result as int32 in a given Q-domain */
-SKP_INLINE SKP_int32 SKP_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */
- const SKP_int32 b32, /* I denominator (Q0) */
- const SKP_int Qres /* I Q-domain of result (> 0) */
-)
-{
- SKP_int b_headrm, lshift;
- SKP_int32 b32_inv, b32_nrm, err_Q32, result;
-
- SKP_assert( b32 != 0 );
- SKP_assert( Qres > 0 );
-
- /* Compute number of bits head room and normalize input */
- b_headrm = SKP_Silk_CLZ32( SKP_abs(b32) ) - 1;
- b32_nrm = SKP_LSHIFT(b32, b_headrm); /* Q: b_headrm */
-
- /* Inverse of b32, with 14 bits of precision */
- b32_inv = SKP_DIV32_16( SKP_int32_MAX >> 2, SKP_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */
-
- /* First approximation */
- result = SKP_LSHIFT(b32_inv, 16); /* Q: 61 - b_headrm */
-
- /* Compute residual by subtracting product of denominator and first approximation from one */
- err_Q32 = SKP_LSHIFT_ovflw( -SKP_SMULWB(b32_nrm, b32_inv), 3 ); /* Q32 */
-
- /* Refinement */
- result = SKP_SMLAWW(result, err_Q32, b32_inv); /* Q: 61 - b_headrm */
-
- /* Convert to Qres domain */
- lshift = 61 - b_headrm - Qres;
- if( lshift <= 0 ) {
- return SKP_LSHIFT_SAT32(result, -lshift);
- } else {
- if( lshift < 32){
- return SKP_RSHIFT(result, lshift);
- }else{
- /* Avoid undefined result */
- return 0;
- }
- }
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //_SKP_SILK_FIX_INLINES_H_
--- a/silk/SKP_Silk_LPC_analysis_filter.c
+++ /dev/null
@@ -1,76 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/*******************************************/
-/* LPC analysis filter */
-/* NB! State is kept internally and the */
-/* filter always starts with zero state */
-/* first Order output samples are not set */
-/*******************************************/
-
-void SKP_Silk_LPC_analysis_filter(
- SKP_int16 *out, /* O: Output signal */
- const SKP_int16 *in, /* I: Input signal */
- const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
- const SKP_int32 len, /* I: Signal length */
- const SKP_int32 d /* I: Filter order */
-)
-{
- SKP_int ix, j;
- SKP_int32 out32_Q12, out32;
- const SKP_int16 *in_ptr;
-
- SKP_assert( d >= 6 );
- SKP_assert( (d & 1) == 0 );
- SKP_assert( d <= len );
-
- for ( ix = d; ix < len; ix++) {
- in_ptr = &in[ ix - 1 ];
-
- out32_Q12 = SKP_SMULBB( in_ptr[ 0 ], B[ 0 ] );
- out32_Q12 = SKP_SMLABB( out32_Q12, in_ptr[ -1 ], B[ 1 ] );
- out32_Q12 = SKP_SMLABB( out32_Q12, in_ptr[ -2 ], B[ 2 ] );
- out32_Q12 = SKP_SMLABB( out32_Q12, in_ptr[ -3 ], B[ 3 ] );
- out32_Q12 = SKP_SMLABB( out32_Q12, in_ptr[ -4 ], B[ 4 ] );
- out32_Q12 = SKP_SMLABB( out32_Q12, in_ptr[ -5 ], B[ 5 ] );
- for( j = 6; j < d; j += 2 ) {
- out32_Q12 = SKP_SMLABB( out32_Q12, in_ptr[ -j ], B[ j ] );
- out32_Q12 = SKP_SMLABB( out32_Q12, in_ptr[ -j - 1 ], B[ j + 1 ] );
- }
-
- /* Subtract prediction */
- out32_Q12 = SKP_SUB32( SKP_LSHIFT( (SKP_int32)in_ptr[ 1 ], 12 ), out32_Q12 );
-
- /* Scale to Q0 */
- out32 = SKP_RSHIFT_ROUND( out32_Q12, 12 );
-
- /* Saturate output */
- out[ ix ] = ( SKP_int16 )SKP_SAT16( out32 );
- }
-}
--- a/silk/SKP_Silk_LPC_inv_pred_gain.c
+++ /dev/null
@@ -1,175 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_Silk_LPC_inverse_pred_gain.c *
- * *
- * Compute inverse of LPC prediction gain, and *
- * test if LPC coefficients are stable (all poles within unit circle) *
- * *
- * Copyright 2008 (c), Skype Limited *
- * */
-#include "SKP_Silk_SigProc_FIX.h"
-
-#define QA 16
-#define A_LIMIT SKP_FIX_CONST( 0.99975, QA )
-
-/* Compute inverse of LPC prediction gain, and */
-/* test if LPC coefficients are stable (all poles within unit circle) */
-static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, otherwise 0 */
- SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
- SKP_int32 A_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ],
- /* I: Prediction coefficients */
- const SKP_int order /* I: Prediction order */
-)
-{
- SKP_int k, n, headrm;
- SKP_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16, tmp_QA;
- SKP_int32 *Aold_QA, *Anew_QA;
-
- Anew_QA = A_QA[ order & 1 ];
-
- *invGain_Q30 = ( 1 << 30 );
- for( k = order - 1; k > 0; k-- ) {
- /* Check for stability */
- if( ( Anew_QA[ k ] > A_LIMIT ) || ( Anew_QA[ k ] < -A_LIMIT ) ) {
- return 1;
- }
-
- /* Set RC equal to negated AR coef */
- rc_Q31 = -SKP_LSHIFT( Anew_QA[ k ], 31 - QA );
-
- /* rc_mult1_Q30 range: [ 1 : 2^30-1 ] */
- rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );
- SKP_assert( rc_mult1_Q30 > ( 1 << 15 ) ); /* reduce A_LIMIT if fails */
- SKP_assert( rc_mult1_Q30 < ( 1 << 30 ) );
-
- /* rc_mult2_Q16 range: [ 2^16 : SKP_int32_MAX ] */
- rc_mult2_Q16 = SKP_INVERSE32_varQ( rc_mult1_Q30, 46 ); /* 16 = 46 - 30 */
-
- /* Update inverse gain */
- /* invGain_Q30 range: [ 0 : 2^30 ] */
- *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );
- SKP_assert( *invGain_Q30 >= 0 );
- SKP_assert( *invGain_Q30 <= ( 1 << 30 ) );
-
- /* Swap pointers */
- Aold_QA = Anew_QA;
- Anew_QA = A_QA[ k & 1 ];
-
- /* Update AR coefficient */
- headrm = SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1;
- rc_mult2_Q16 = SKP_LSHIFT( rc_mult2_Q16, headrm ); /* Q: 16 + headrm */
- for( n = 0; n < k; n++ ) {
- tmp_QA = Aold_QA[ n ] - SKP_LSHIFT( SKP_SMMUL( Aold_QA[ k - n - 1 ], rc_Q31 ), 1 );
- Anew_QA[ n ] = SKP_LSHIFT( SKP_SMMUL( tmp_QA, rc_mult2_Q16 ), 16 - headrm );
- }
- }
-
- /* Check for stability */
- if( ( Anew_QA[ 0 ] > A_LIMIT ) || ( Anew_QA[ 0 ] < -A_LIMIT ) ) {
- return 1;
- }
-
- /* Set RC equal to negated AR coef */
- rc_Q31 = -SKP_LSHIFT( Anew_QA[ 0 ], 31 - QA );
-
- /* Range: [ 1 : 2^30 ] */
- rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );
-
- /* Update inverse gain */
- /* Range: [ 0 : 2^30 ] */
- *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );
- SKP_assert( *invGain_Q30 >= 0 );
- SKP_assert( *invGain_Q30 <= 1<<30 );
-
- return 0;
-}
-
-/* For input in Q12 domain */
-SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
- SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
- const SKP_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
- const SKP_int order /* I: Prediction order */
-)
-{
- SKP_int k;
- SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ];
- SKP_int32 *Anew_QA;
-
- Anew_QA = Atmp_QA[ order & 1 ];
-
- /* Increase Q domain of the AR coefficients */
- for( k = 0; k < order; k++ ) {
- Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q12[ k ], QA - 12 );
- }
-
- return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
-}
-
-/* For input in Q13 domain */
-SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13( /* O: Returns 1 if unstable, otherwise 0 */
- SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
- const SKP_int16 *A_Q13, /* I: Prediction coefficients, Q13 [order] */
- const SKP_int order /* I: Prediction order */
-)
-{
- SKP_int k;
- SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ];
- SKP_int32 *Anew_QA;
-
- Anew_QA = Atmp_QA[ order & 1 ];
-
- /* Increase Q domain of the AR coefficients */
- for( k = 0; k < order; k++ ) {
- Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q13[ k ], QA - 13 );
- }
-
- return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
-}
-
-/* For input in Q24 domain */
-SKP_int SKP_Silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
- SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
- const SKP_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
- const SKP_int order /* I: Prediction order */
-)
-{
- SKP_int k;
- SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ];
- SKP_int32 *Anew_QA;
-
- Anew_QA = Atmp_QA[ order & 1 ];
-
- /* Increase Q domain of the AR coefficients */
- for( k = 0; k < order; k++ ) {
- Anew_QA[ k ] = SKP_RSHIFT_ROUND( A_Q24[ k ], 24 - QA );
- }
-
- return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
-}
-
--- a/silk/SKP_Silk_LPC_stabilize.c
+++ /dev/null
@@ -1,134 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_typedef.h"
-#include "SKP_Silk_SigProc_FIX.h"
-
-#define LPC_STABILIZE_LPC_MAX_ABS_VALUE_Q16 ( ( (SKP_int32)SKP_int16_MAX ) << 4 )
-
-/* LPC stabilizer, for a single input data vector */
-void SKP_Silk_LPC_stabilize(
- SKP_int16 *a_Q12, /* O stabilized LPC vector [L] */
- SKP_int32 *a_Q16, /* I LPC vector [L] */
- const SKP_int32 bwe_Q16, /* I Bandwidth expansion factor */
- const SKP_int L /* I Number of LPC parameters in the input vector */
-)
-{
- SKP_int32 maxabs, absval, sc_Q16;
- SKP_int i, idx = 0;
- SKP_int32 invGain_Q30;
-
- SKP_Silk_bwexpander_32( a_Q16, L, bwe_Q16 );
-
- /***************************/
- /* Limit range of the LPCs */
- /***************************/
- /* Limit the maximum absolute value of the prediction coefficients */
- while( SKP_TRUE ) {
- /* Find maximum absolute value and its index */
- maxabs = SKP_int32_MIN;
- for( i = 0; i < L; i++ ) {
- absval = SKP_abs( a_Q16[ i ] );
- if( absval > maxabs ) {
- maxabs = absval;
- idx = i;
- }
- }
-
- if( maxabs >= LPC_STABILIZE_LPC_MAX_ABS_VALUE_Q16 ) {
- /* Reduce magnitude of prediction coefficients */
- sc_Q16 = SKP_DIV32( SKP_int32_MAX, SKP_RSHIFT( maxabs, 4 ) );
- sc_Q16 = 65536 - sc_Q16;
- sc_Q16 = SKP_DIV32( sc_Q16, idx + 1 );
- sc_Q16 = 65536 - sc_Q16;
- sc_Q16 = SKP_LSHIFT( SKP_SMULWB( sc_Q16, 32604 ), 1 ); // 0.995 in Q16
- SKP_Silk_bwexpander_32( a_Q16, L, sc_Q16 );
- } else {
- break;
- }
- }
-
- /* Convert to 16 bit Q12 */
- for( i = 0; i < L; i++ ) {
- a_Q12[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( a_Q16[ i ], 4 );
- }
-
- /**********************/
- /* Ensure stable LPCs */
- /**********************/
- while( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, a_Q12, L ) == 1 ) {
- SKP_Silk_bwexpander( a_Q12, L, 65339 ); // 0.997 in Q16
- }
-}
-
-void SKP_Silk_LPC_fit(
- SKP_int16 *a_QQ, /* O Stabilized LPC vector, Q(24-rshift) [L] */
- SKP_int32 *a_Q24, /* I LPC vector [L] */
- const SKP_int QQ, /* I Q domain of output LPC vector */
- const SKP_int L /* I Number of LPC parameters in the input vector */
-)
-{
- SKP_int i, rshift, idx = 0;
- SKP_int32 maxabs, absval, sc_Q16;
-
- rshift = 24 - QQ;
-
- /***************************/
- /* Limit range of the LPCs */
- /***************************/
- /* Limit the maximum absolute value of the prediction coefficients */
- while( SKP_TRUE ) {
- /* Find maximum absolute value and its index; assumes stable coefficients */
- /* so that only the first half need to be tested */
- maxabs = SKP_int32_MIN;
- for( i = 1; i < L / 2; i++ ) {
- absval = SKP_abs( a_Q24[ i ] );
- if( absval > maxabs ) {
- maxabs = absval;
- idx = i;
- }
- }
-
- maxabs = SKP_RSHIFT( maxabs, rshift );
- if( maxabs >= SKP_int16_MAX ) {
- /* Reduce magnitude of prediction coefficients */
- maxabs = SKP_min( maxabs, 98369 ); // ( SKP_int32_MAX / ( 65470 >> 2 ) ) + SKP_int16_MAX = 98369
- sc_Q16 = 65470 - SKP_DIV32( SKP_MUL( 65470 >> 2, maxabs - SKP_int16_MAX ),
- SKP_RSHIFT32( SKP_MUL( maxabs, idx + 1), 2 ) );
- SKP_Silk_bwexpander_32( a_Q24, L, sc_Q16 );
- } else {
- break;
- }
- }
-
- /* Convert to 16 bit Q(24-rshift) */
- SKP_assert( rshift > 0 );
- SKP_assert( rshift < 31 );
- for( i = 0; i < L; i++ ) {
- a_QQ[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( a_Q24[ i ], rshift );
- }
-}
--- a/silk/SKP_Silk_LPC_synthesis_filter.c
+++ /dev/null
@@ -1,84 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_Silk_LPC_synthesis_filter.c *
- * Coefficients are in Q12 *
- * *
- * even order AR filter *
- * */
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* even order AR filter */
-void SKP_Silk_LPC_synthesis_filter(
- const SKP_int16 *in, /* I: excitation signal */
- const SKP_int16 *A_Q12, /* I: AR coefficients [Order], between -8_Q0 and 8_Q0 */
- const SKP_int32 Gain_Q26, /* I: gain */
- SKP_int32 *S, /* I/O: state vector [Order] */
- SKP_int16 *out, /* O: output signal */
- const SKP_int32 len, /* I: signal length */
- const SKP_int Order /* I: filter order, must be even */
-)
-{
- SKP_int k, j, idx, Order_half = SKP_RSHIFT( Order, 1 );
- SKP_int32 SA, SB, out32_Q10, out32;
-
- /* Order must be even */
- SKP_assert( 2 * Order_half == Order );
-
- /* S[] values are in Q14 */
- for( k = 0; k < len; k++ ) {
- SA = S[ Order - 1 ];
- out32_Q10 = 0;
- for( j = 0; j < ( Order_half - 1 ); j++ ) {
- idx = SKP_SMULBB( 2, j ) + 1;
- SB = S[ Order - 1 - idx ];
- S[ Order - 1 - idx ] = SA;
- out32_Q10 = SKP_SMLAWB( out32_Q10, SA, A_Q12[ ( j << 1 ) ] );
- out32_Q10 = SKP_SMLAWB( out32_Q10, SB, A_Q12[ ( j << 1 ) + 1 ] );
- SA = S[ Order - 2 - idx ];
- S[ Order - 2 - idx ] = SB;
- }
-
- /* unrolled loop: epilog */
- SB = S[ 0 ];
- S[ 0 ] = SA;
- out32_Q10 = SKP_SMLAWB( out32_Q10, SA, A_Q12[ Order - 2 ] );
- out32_Q10 = SKP_SMLAWB( out32_Q10, SB, A_Q12[ Order - 1 ] );
- /* apply gain to excitation signal and add to prediction */
- out32_Q10 = SKP_ADD_SAT32( out32_Q10, SKP_SMULWB( Gain_Q26, in[ k ] ) );
-
- /* scale to Q0 */
- out32 = SKP_RSHIFT_ROUND( out32_Q10, 10 );
-
- /* saturate output */
- out[ k ] = ( SKP_int16 )SKP_SAT16( out32 );
-
- /* move result into delay line */
- S[ Order - 1 ] = SKP_LSHIFT_SAT32( out32_Q10, 4 );
- }
-}
--- a/silk/SKP_Silk_LPC_synthesis_order16.c
+++ /dev/null
@@ -1,122 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_Silk_LPC_synthesis_order16.c *
- * Coefficients are in Q12 *
- * *
- * 16th order AR filter *
- * */
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* 16th order AR filter */
-void SKP_Silk_LPC_synthesis_order16(const SKP_int16 *in, /* I: excitation signal */
- const SKP_int16 *A_Q12, /* I: AR coefficients [16], between -8_Q0 and 8_Q0 */
- const SKP_int32 Gain_Q26, /* I: gain */
- SKP_int32 *S, /* I/O: state vector [16] */
- SKP_int16 *out, /* O: output signal */
- const SKP_int32 len /* I: signal length, must be multiple of 16 */
-)
-{
- SKP_int k;
- SKP_int32 SA, SB, out32_Q10, out32;
- for( k = 0; k < len; k++ ) {
- /* unrolled loop: prolog */
- /* multiply-add two prediction coefficients per iteration */
- SA = S[ 15 ];
- SB = S[ 14 ];
- S[ 14 ] = SA;
- out32_Q10 = SKP_SMULWB( SA, A_Q12[ 0 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 1 ] );
- SA = S[ 13 ];
- S[ 13 ] = SB;
-
- /* unrolled loop: main loop */
- SB = S[ 12 ];
- S[ 12 ] = SA;
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 2 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 3 ] );
- SA = S[ 11 ];
- S[ 11 ] = SB;
-
- SB = S[ 10 ];
- S[ 10 ] = SA;
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 4 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 5 ] );
- SA = S[ 9 ];
- S[ 9 ] = SB;
-
- SB = S[ 8 ];
- S[ 8 ] = SA;
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 6 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 7 ] );
- SA = S[ 7 ];
- S[ 7 ] = SB;
-
- SB = S[ 6 ];
- S[ 6 ] = SA;
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 8 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 9 ] );
- SA = S[ 5 ];
- S[ 5 ] = SB;
-
- SB = S[ 4 ];
- S[ 4 ] = SA;
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 10 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 11 ] );
- SA = S[ 3 ];
- S[ 3 ] = SB;
-
- SB = S[ 2 ];
- S[ 2 ] = SA;
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 12 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 13 ] );
- SA = S[ 1 ];
- S[ 1 ] = SB;
-
- /* unrolled loop: epilog */
- SB = S[ 0 ];
- S[ 0 ] = SA;
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 14 ] );
- out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 15 ] );
-
- /* unrolled loop: end */
- /* apply gain to excitation signal and add to prediction */
- out32_Q10 = SKP_ADD_SAT32( out32_Q10, SKP_SMULWB( Gain_Q26, in[ k ] ) );
-
- /* scale to Q0 */
- out32 = SKP_RSHIFT_ROUND( out32_Q10, 10 );
-
- /* saturate output */
- out[ k ] = ( SKP_int16 )SKP_SAT16( out32 );
-
- /* move result into delay line */
- S[ 15 ] = SKP_LSHIFT_SAT32( out32_Q10, 4 );
- }
-}
-
-
--- a/silk/SKP_Silk_LP_variable_cutoff.c
+++ /dev/null
@@ -1,132 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/*
-
- Elliptic/Cauer filters designed with 0.1 dB passband ripple,
- 80 dB minimum stopband attenuation, and
- [0.95 : 0.15 : 0.35] normalized cut off frequencies.
-
-*/
-#include "SKP_Silk_main.h"
-
-/* Helper function, interpolates the filter taps */
-SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
- SKP_int32 B_Q28[ TRANSITION_NB ],
- SKP_int32 A_Q28[ TRANSITION_NA ],
- const SKP_int ind,
- const SKP_int32 fac_Q16
-)
-{
- SKP_int nb, na;
-
- if( ind < TRANSITION_INT_NUM - 1 ) {
- if( fac_Q16 > 0 ) {
- if( fac_Q16 < 32768 ) { /* fac_Q16 is in range of a 16-bit int */
- /* Piece-wise linear interpolation of B and A */
- for( nb = 0; nb < TRANSITION_NB; nb++ ) {
- B_Q28[ nb ] = SKP_SMLAWB(
- SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ],
- SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] -
- SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ],
- fac_Q16 );
- }
- for( na = 0; na < TRANSITION_NA; na++ ) {
- A_Q28[ na ] = SKP_SMLAWB(
- SKP_Silk_Transition_LP_A_Q28[ ind ][ na ],
- SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ] -
- SKP_Silk_Transition_LP_A_Q28[ ind ][ na ],
- fac_Q16 );
- }
- } else { /* ( fac_Q16 - ( 1 << 16 ) ) is in range of a 16-bit int */
- SKP_assert( fac_Q16 - ( 1 << 16 ) == SKP_SAT16( fac_Q16 - ( 1 << 16 ) ) );
- /* Piece-wise linear interpolation of B and A */
- for( nb = 0; nb < TRANSITION_NB; nb++ ) {
- B_Q28[ nb ] = SKP_SMLAWB(
- SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ],
- SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] -
- SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ],
- fac_Q16 - ( 1 << 16 ) );
- }
- for( na = 0; na < TRANSITION_NA; na++ ) {
- A_Q28[ na ] = SKP_SMLAWB(
- SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ],
- SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ] -
- SKP_Silk_Transition_LP_A_Q28[ ind ][ na ],
- fac_Q16 - ( 1 << 16 ) );
- }
- }
- } else {
- SKP_memcpy( B_Q28, SKP_Silk_Transition_LP_B_Q28[ ind ], TRANSITION_NB * sizeof( SKP_int32 ) );
- SKP_memcpy( A_Q28, SKP_Silk_Transition_LP_A_Q28[ ind ], TRANSITION_NA * sizeof( SKP_int32 ) );
- }
- } else {
- SKP_memcpy( B_Q28, SKP_Silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NB * sizeof( SKP_int32 ) );
- SKP_memcpy( A_Q28, SKP_Silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NA * sizeof( SKP_int32 ) );
- }
-}
-
-/* Low-pass filter with variable cutoff frequency based on */
-/* piece-wise linear interpolation between elliptic filters */
-/* Start by setting psEncC->mode <> 0; */
-/* Deactivate by setting psEncC->mode = 0; */
-void SKP_Silk_LP_variable_cutoff(
- SKP_Silk_LP_state *psLP, /* I/O LP filter state */
- SKP_int16 *signal, /* I/O Low-pass filtered output signal */
- const SKP_int frame_length /* I Frame length */
-)
-{
- SKP_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;
- SKP_int ind = 0;
-
- SKP_assert( psLP->transition_frame_no >= 0 && psLP->transition_frame_no <= TRANSITION_FRAMES );
-
- /* Run filter if needed */
- if( psLP->mode != 0 ) {
- /* Calculate index and interpolation factor for interpolation */
-#if( TRANSITION_INT_STEPS == 64 )
- fac_Q16 = SKP_LSHIFT( TRANSITION_FRAMES - psLP->transition_frame_no, 16 - 6 );
-#else
- fac_Q16 = SKP_DIV32_16( SKP_LSHIFT( TRANSITION_FRAMES - psLP->transition_frame_no, 16 ), TRANSITION_FRAMES );
-#endif
- ind = SKP_RSHIFT( fac_Q16, 16 );
- fac_Q16 -= SKP_LSHIFT( ind, 16 );
-
- SKP_assert( ind >= 0 );
- SKP_assert( ind < TRANSITION_INT_NUM );
-
- /* Interpolate filter coefficients */
- SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 );
-
- /* Update transition frame number for next frame */
- psLP->transition_frame_no = SKP_LIMIT( psLP->transition_frame_no + psLP->mode, 0, TRANSITION_FRAMES );
-
- /* ARMA low-pass filtering */
- SKP_assert( TRANSITION_NB == 3 && TRANSITION_NA == 2 );
- SKP_Silk_biquad_alt( signal, B_Q28, A_Q28, psLP->In_LP_State, signal, frame_length );
- }
-}
--- a/silk/SKP_Silk_LSF_cos_table.c
+++ /dev/null
@@ -1,65 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-// Q12 values (even)
-const SKP_int SKP_Silk_LSFCosTab_FIX_Q12[LSF_COS_TAB_SZ_FIX + 1] = {
- 8192, 8190, 8182, 8170,
- 8152, 8130, 8104, 8072,
- 8034, 7994, 7946, 7896,
- 7840, 7778, 7714, 7644,
- 7568, 7490, 7406, 7318,
- 7226, 7128, 7026, 6922,
- 6812, 6698, 6580, 6458,
- 6332, 6204, 6070, 5934,
- 5792, 5648, 5502, 5352,
- 5198, 5040, 4880, 4718,
- 4552, 4382, 4212, 4038,
- 3862, 3684, 3502, 3320,
- 3136, 2948, 2760, 2570,
- 2378, 2186, 1990, 1794,
- 1598, 1400, 1202, 1002,
- 802, 602, 402, 202,
- 0, -202, -402, -602,
- -802, -1002, -1202, -1400,
- -1598, -1794, -1990, -2186,
- -2378, -2570, -2760, -2948,
- -3136, -3320, -3502, -3684,
- -3862, -4038, -4212, -4382,
- -4552, -4718, -4880, -5040,
- -5198, -5352, -5502, -5648,
- -5792, -5934, -6070, -6204,
- -6332, -6458, -6580, -6698,
- -6812, -6922, -7026, -7128,
- -7226, -7318, -7406, -7490,
- -7568, -7644, -7714, -7778,
- -7840, -7896, -7946, -7994,
- -8034, -8072, -8104, -8130,
- -8152, -8170, -8182, -8190,
- -8192
-};
--- a/silk/SKP_Silk_MacroCount.h
+++ /dev/null
@@ -1,719 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef _SIGPROCFIX_API_MACROCOUNT_H_
-#define _SIGPROCFIX_API_MACROCOUNT_H_
-#include <stdio.h>
-
-#ifdef SKP_MACRO_COUNT
-#define varDefine SKP_int64 ops_count = 0;
-
-extern SKP_int64 ops_count;
-
-SKP_INLINE SKP_int64 SKP_SaveCount(){
- return(ops_count);
-}
-
-SKP_INLINE SKP_int64 SKP_SaveResetCount(){
- SKP_int64 ret;
-
- ret = ops_count;
- ops_count = 0;
- return(ret);
-}
-
-SKP_INLINE SKP_PrintCount(){
- printf("ops_count = %d \n ", (SKP_int32)ops_count);
-}
-
-#undef SKP_MUL
-SKP_INLINE SKP_int32 SKP_MUL(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- ops_count += 4;
- ret = a32 * b32;
- return ret;
-}
-
-#undef SKP_MUL_uint
-SKP_INLINE SKP_uint32 SKP_MUL_uint(SKP_uint32 a32, SKP_uint32 b32){
- SKP_uint32 ret;
- ops_count += 4;
- ret = a32 * b32;
- return ret;
-}
-#undef SKP_MLA
-SKP_INLINE SKP_int32 SKP_MLA(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ops_count += 4;
- ret = a32 + b32 * c32;
- return ret;
-}
-
-#undef SKP_MLA_uint
-SKP_INLINE SKP_int32 SKP_MLA_uint(SKP_uint32 a32, SKP_uint32 b32, SKP_uint32 c32){
- SKP_uint32 ret;
- ops_count += 4;
- ret = a32 + b32 * c32;
- return ret;
-}
-
-#undef SKP_SMULWB
-SKP_INLINE SKP_int32 SKP_SMULWB(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- ops_count += 5;
- ret = (a32 >> 16) * (SKP_int32)((SKP_int16)b32) + (((a32 & 0x0000FFFF) * (SKP_int32)((SKP_int16)b32)) >> 16);
- return ret;
-}
-#undef SKP_SMLAWB
-SKP_INLINE SKP_int32 SKP_SMLAWB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ops_count += 5;
- ret = ((a32) + ((((b32) >> 16) * (SKP_int32)((SKP_int16)(c32))) + ((((b32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(c32))) >> 16)));
- return ret;
-}
-
-#undef SKP_SMULWT
-SKP_INLINE SKP_int32 SKP_SMULWT(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- ops_count += 4;
- ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16);
- return ret;
-}
-#undef SKP_SMLAWT
-SKP_INLINE SKP_int32 SKP_SMLAWT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ops_count += 4;
- ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16));
- return ret;
-}
-
-#undef SKP_SMULBB
-SKP_INLINE SKP_int32 SKP_SMULBB(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- ops_count += 1;
- ret = (SKP_int32)((SKP_int16)a32) * (SKP_int32)((SKP_int16)b32);
- return ret;
-}
-#undef SKP_SMLABB
-SKP_INLINE SKP_int32 SKP_SMLABB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ops_count += 1;
- ret = a32 + (SKP_int32)((SKP_int16)b32) * (SKP_int32)((SKP_int16)c32);
- return ret;
-}
-
-#undef SKP_SMULBT
-SKP_INLINE SKP_int32 SKP_SMULBT(SKP_int32 a32, SKP_int32 b32 ){
- SKP_int32 ret;
- ops_count += 4;
- ret = ((SKP_int32)((SKP_int16)a32)) * (b32 >> 16);
- return ret;
-}
-
-#undef SKP_SMLABT
-SKP_INLINE SKP_int32 SKP_SMLABT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ops_count += 1;
- ret = a32 + ((SKP_int32)((SKP_int16)b32)) * (c32 >> 16);
- return ret;
-}
-
-#undef SKP_SMULTT
-SKP_INLINE SKP_int32 SKP_SMULTT(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- ops_count += 1;
- ret = (a32 >> 16) * (b32 >> 16);
- return ret;
-}
-
-#undef SKP_SMLATT
-SKP_INLINE SKP_int32 SKP_SMLATT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ops_count += 1;
- ret = a32 + (b32 >> 16) * (c32 >> 16);
- return ret;
-}
-
-
-// multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)
-#undef SKP_MLA_ovflw
-#define SKP_MLA_ovflw SKP_MLA
-
-#undef SKP_SMLABB_ovflw
-#define SKP_SMLABB_ovflw SKP_SMLABB
-
-#undef SKP_SMLABT_ovflw
-#define SKP_SMLABT_ovflw SKP_SMLABT
-
-#undef SKP_SMLATT_ovflw
-#define SKP_SMLATT_ovflw SKP_SMLATT
-
-#undef SKP_SMLAWB_ovflw
-#define SKP_SMLAWB_ovflw SKP_SMLAWB
-
-#undef SKP_SMLAWT_ovflw
-#define SKP_SMLAWT_ovflw SKP_SMLAWT
-
-#undef SKP_SMULL
-SKP_INLINE SKP_int64 SKP_SMULL(SKP_int32 a32, SKP_int32 b32){
- SKP_int64 ret;
- ops_count += 8;
- ret = ((SKP_int64)(a32) * /*(SKP_int64)*/(b32));
- return ret;
-}
-
-#undef SKP_SMLAL
-SKP_INLINE SKP_int64 SKP_SMLAL(SKP_int64 a64, SKP_int32 b32, SKP_int32 c32){
- SKP_int64 ret;
- ops_count += 8;
- ret = a64 + ((SKP_int64)(b32) * /*(SKP_int64)*/(c32));
- return ret;
-}
-#undef SKP_SMLALBB
-SKP_INLINE SKP_int64 SKP_SMLALBB(SKP_int64 a64, SKP_int16 b16, SKP_int16 c16){
- SKP_int64 ret;
- ops_count += 4;
- ret = a64 + ((SKP_int64)(b16) * /*(SKP_int64)*/(c16));
- return ret;
-}
-
-#undef SigProcFIX_CLZ16
-SKP_INLINE SKP_int32 SigProcFIX_CLZ16(SKP_int16 in16)
-{
- SKP_int32 out32 = 0;
- ops_count += 10;
- if( in16 == 0 ) {
- return 16;
- }
- /* test nibbles */
- if( in16 & 0xFF00 ) {
- if( in16 & 0xF000 ) {
- in16 >>= 12;
- } else {
- out32 += 4;
- in16 >>= 8;
- }
- } else {
- if( in16 & 0xFFF0 ) {
- out32 += 8;
- in16 >>= 4;
- } else {
- out32 += 12;
- }
- }
- /* test bits and return */
- if( in16 & 0xC ) {
- if( in16 & 0x8 )
- return out32 + 0;
- else
- return out32 + 1;
- } else {
- if( in16 & 0xE )
- return out32 + 2;
- else
- return out32 + 3;
- }
-}
-
-#undef SigProcFIX_CLZ32
-SKP_INLINE SKP_int32 SigProcFIX_CLZ32(SKP_int32 in32)
-{
- /* test highest 16 bits and convert to SKP_int16 */
- ops_count += 2;
- if( in32 & 0xFFFF0000 ) {
- return SigProcFIX_CLZ16((SKP_int16)(in32 >> 16));
- } else {
- return SigProcFIX_CLZ16((SKP_int16)in32) + 16;
- }
-}
-
-#undef SKP_DIV32
-SKP_INLINE SKP_int32 SKP_DIV32(SKP_int32 a32, SKP_int32 b32){
- ops_count += 64;
- return a32 / b32;
-}
-
-#undef SKP_DIV32_16
-SKP_INLINE SKP_int32 SKP_DIV32_16(SKP_int32 a32, SKP_int32 b32){
- ops_count += 32;
- return a32 / b32;
-}
-
-#undef SKP_SAT8
-SKP_INLINE SKP_int8 SKP_SAT8(SKP_int64 a){
- SKP_int8 tmp;
- ops_count += 1;
- tmp = (SKP_int8)((a) > SKP_int8_MAX ? SKP_int8_MAX : \
- ((a) < SKP_int8_MIN ? SKP_int8_MIN : (a)));
- return(tmp);
-}
-
-#undef SKP_SAT16
-SKP_INLINE SKP_int16 SKP_SAT16(SKP_int64 a){
- SKP_int16 tmp;
- ops_count += 1;
- tmp = (SKP_int16)((a) > SKP_int16_MAX ? SKP_int16_MAX : \
- ((a) < SKP_int16_MIN ? SKP_int16_MIN : (a)));
- return(tmp);
-}
-#undef SKP_SAT32
-SKP_INLINE SKP_int32 SKP_SAT32(SKP_int64 a){
- SKP_int32 tmp;
- ops_count += 1;
- tmp = (SKP_int32)((a) > SKP_int32_MAX ? SKP_int32_MAX : \
- ((a) < SKP_int32_MIN ? SKP_int32_MIN : (a)));
- return(tmp);
-}
-#undef SKP_POS_SAT32
-SKP_INLINE SKP_int32 SKP_POS_SAT32(SKP_int64 a){
- SKP_int32 tmp;
- ops_count += 1;
- tmp = (SKP_int32)((a) > SKP_int32_MAX ? SKP_int32_MAX : (a));
- return(tmp);
-}
-
-#undef SKP_ADD_POS_SAT8
-SKP_INLINE SKP_int8 SKP_ADD_POS_SAT8(SKP_int64 a, SKP_int64 b){
- SKP_int8 tmp;
- ops_count += 1;
- tmp = (SKP_int8)((((a)+(b)) & 0x80) ? SKP_int8_MAX : ((a)+(b)));
- return(tmp);
-}
-#undef SKP_ADD_POS_SAT16
-SKP_INLINE SKP_int16 SKP_ADD_POS_SAT16(SKP_int64 a, SKP_int64 b){
- SKP_int16 tmp;
- ops_count += 1;
- tmp = (SKP_int16)((((a)+(b)) & 0x8000) ? SKP_int16_MAX : ((a)+(b)));
- return(tmp);
-}
-
-#undef SKP_ADD_POS_SAT32
-SKP_INLINE SKP_int32 SKP_ADD_POS_SAT32(SKP_int64 a, SKP_int64 b){
- SKP_int32 tmp;
- ops_count += 1;
- tmp = (SKP_int32)((((a)+(b)) & 0x80000000) ? SKP_int32_MAX : ((a)+(b)));
- return(tmp);
-}
-
-#undef SKP_ADD_POS_SAT64
-SKP_INLINE SKP_int64 SKP_ADD_POS_SAT64(SKP_int64 a, SKP_int64 b){
- SKP_int64 tmp;
- ops_count += 1;
- tmp = ((((a)+(b)) & 0x8000000000000000LL) ? SKP_int64_MAX : ((a)+(b)));
- return(tmp);
-}
-
-#undef SKP_LSHIFT8
-SKP_INLINE SKP_int8 SKP_LSHIFT8(SKP_int8 a, SKP_int32 shift){
- SKP_int8 ret;
- ops_count += 1;
- ret = a << shift;
- return ret;
-}
-#undef SKP_LSHIFT16
-SKP_INLINE SKP_int16 SKP_LSHIFT16(SKP_int16 a, SKP_int32 shift){
- SKP_int16 ret;
- ops_count += 1;
- ret = a << shift;
- return ret;
-}
-#undef SKP_LSHIFT32
-SKP_INLINE SKP_int32 SKP_LSHIFT32(SKP_int32 a, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 1;
- ret = a << shift;
- return ret;
-}
-#undef SKP_LSHIFT64
-SKP_INLINE SKP_int64 SKP_LSHIFT64(SKP_int64 a, SKP_int shift){
- ops_count += 1;
- return a << shift;
-}
-
-#undef SKP_LSHIFT_ovflw
-SKP_INLINE SKP_int32 SKP_LSHIFT_ovflw(SKP_int32 a, SKP_int32 shift){
- ops_count += 1;
- return a << shift;
-}
-
-#undef SKP_LSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_LSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
- SKP_uint32 ret;
- ops_count += 1;
- ret = a << shift;
- return ret;
-}
-
-#undef SKP_RSHIFT8
-SKP_INLINE SKP_int8 SKP_RSHIFT8(SKP_int8 a, SKP_int32 shift){
- ops_count += 1;
- return a >> shift;
-}
-#undef SKP_RSHIFT16
-SKP_INLINE SKP_int16 SKP_RSHIFT16(SKP_int16 a, SKP_int32 shift){
- ops_count += 1;
- return a >> shift;
-}
-#undef SKP_RSHIFT32
-SKP_INLINE SKP_int32 SKP_RSHIFT32(SKP_int32 a, SKP_int32 shift){
- ops_count += 1;
- return a >> shift;
-}
-#undef SKP_RSHIFT64
-SKP_INLINE SKP_int64 SKP_RSHIFT64(SKP_int64 a, SKP_int64 shift){
- ops_count += 1;
- return a >> shift;
-}
-
-#undef SKP_RSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_RSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
- ops_count += 1;
- return a >> shift;
-}
-
-#undef SKP_ADD_LSHIFT
-SKP_INLINE SKP_int32 SKP_ADD_LSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 1;
- ret = a + (b << shift);
- return ret; // shift >= 0
-}
-#undef SKP_ADD_LSHIFT32
-SKP_INLINE SKP_int32 SKP_ADD_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 1;
- ret = a + (b << shift);
- return ret; // shift >= 0
-}
-#undef SKP_ADD_LSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_ADD_LSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
- SKP_uint32 ret;
- ops_count += 1;
- ret = a + (b << shift);
- return ret; // shift >= 0
-}
-#undef SKP_ADD_RSHIFT
-SKP_INLINE SKP_int32 SKP_ADD_RSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 1;
- ret = a + (b >> shift);
- return ret; // shift > 0
-}
-#undef SKP_ADD_RSHIFT32
-SKP_INLINE SKP_int32 SKP_ADD_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 1;
- ret = a + (b >> shift);
- return ret; // shift > 0
-}
-#undef SKP_ADD_RSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_ADD_RSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
- SKP_uint32 ret;
- ops_count += 1;
- ret = a + (b >> shift);
- return ret; // shift > 0
-}
-#undef SKP_SUB_LSHIFT32
-SKP_INLINE SKP_int32 SKP_SUB_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 1;
- ret = a - (b << shift);
- return ret; // shift >= 0
-}
-#undef SKP_SUB_RSHIFT32
-SKP_INLINE SKP_int32 SKP_SUB_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 1;
- ret = a - (b >> shift);
- return ret; // shift > 0
-}
-
-#undef SKP_RSHIFT_ROUND
-SKP_INLINE SKP_int32 SKP_RSHIFT_ROUND(SKP_int32 a, SKP_int32 shift){
- SKP_int32 ret;
- ops_count += 3;
- ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
- return ret;
-}
-
-#undef SKP_RSHIFT_ROUND64
-SKP_INLINE SKP_int64 SKP_RSHIFT_ROUND64(SKP_int64 a, SKP_int32 shift){
- SKP_int64 ret;
- ops_count += 6;
- ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
- return ret;
-}
-
-#undef SKP_abs_int64
-SKP_INLINE SKP_int64 SKP_abs_int64(SKP_int64 a){
- ops_count += 1;
- return (((a) > 0) ? (a) : -(a)); // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN
-}
-
-#undef SKP_abs_int32
-SKP_INLINE SKP_int32 SKP_abs_int32(SKP_int32 a){
- ops_count += 1;
- return abs(a);
-}
-
-
-#undef SKP_min
-static SKP_min(a, b){
- ops_count += 1;
- return (((a) < (b)) ? (a) : (b));
-}
-#undef SKP_max
-static SKP_max(a, b){
- ops_count += 1;
- return (((a) > (b)) ? (a) : (b));
-}
-#undef SKP_sign
-static SKP_sign(a){
- ops_count += 1;
- return ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ));
-}
-
-#undef SKP_ADD16
-SKP_INLINE SKP_int16 SKP_ADD16(SKP_int16 a, SKP_int16 b){
- SKP_int16 ret;
- ops_count += 1;
- ret = a + b;
- return ret;
-}
-
-#undef SKP_ADD32
-SKP_INLINE SKP_int32 SKP_ADD32(SKP_int32 a, SKP_int32 b){
- SKP_int32 ret;
- ops_count += 1;
- ret = a + b;
- return ret;
-}
-
-#undef SKP_ADD64
-SKP_INLINE SKP_int64 SKP_ADD64(SKP_int64 a, SKP_int64 b){
- SKP_int64 ret;
- ops_count += 2;
- ret = a + b;
- return ret;
-}
-
-#undef SKP_SUB16
-SKP_INLINE SKP_int16 SKP_SUB16(SKP_int16 a, SKP_int16 b){
- SKP_int16 ret;
- ops_count += 1;
- ret = a - b;
- return ret;
-}
-
-#undef SKP_SUB32
-SKP_INLINE SKP_int32 SKP_SUB32(SKP_int32 a, SKP_int32 b){
- SKP_int32 ret;
- ops_count += 1;
- ret = a - b;
- return ret;
-}
-
-#undef SKP_SUB64
-SKP_INLINE SKP_int64 SKP_SUB64(SKP_int64 a, SKP_int64 b){
- SKP_int64 ret;
- ops_count += 2;
- ret = a - b;
- return ret;
-}
-
-#undef SKP_ADD_SAT16
-SKP_INLINE SKP_int16 SKP_ADD_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
- SKP_int16 res;
- // Nb will be counted in AKP_add32 and SKP_SAT16
- res = (SKP_int16)SKP_SAT16( SKP_ADD32( (SKP_int32)(a16), (b16) ) );
- return res;
-}
-
-#undef SKP_ADD_SAT32
-SKP_INLINE SKP_int32 SKP_ADD_SAT32(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 res;
- ops_count += 1;
- res = ((((a32) + (b32)) & 0x80000000) == 0 ? \
- ((((a32) & (b32)) & 0x80000000) != 0 ? SKP_int32_MIN : (a32)+(b32)) : \
- ((((a32) | (b32)) & 0x80000000) == 0 ? SKP_int32_MAX : (a32)+(b32)) );
- return res;
-}
-
-#undef SKP_ADD_SAT64
-SKP_INLINE SKP_int64 SKP_ADD_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
- SKP_int64 res;
- ops_count += 1;
- res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \
- ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? SKP_int64_MIN : (a64)+(b64)) : \
- ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? SKP_int64_MAX : (a64)+(b64)) );
- return res;
-}
-
-#undef SKP_SUB_SAT16
-SKP_INLINE SKP_int16 SKP_SUB_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
- SKP_int16 res;
- SKP_assert(0);
- // Nb will be counted in sub-macros
- res = (SKP_int16)SKP_SAT16( SKP_SUB32( (SKP_int32)(a16), (b16) ) );
- return res;
-}
-
-#undef SKP_SUB_SAT32
-SKP_INLINE SKP_int32 SKP_SUB_SAT32( SKP_int32 a32, SKP_int32 b32 ) {
- SKP_int32 res;
- ops_count += 1;
- res = ((((a32)-(b32)) & 0x80000000) == 0 ? \
- (( (a32) & ((b32)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a32)-(b32)) : \
- ((((a32)^0x80000000) & (b32) & 0x80000000) ? SKP_int32_MAX : (a32)-(b32)) );
- return res;
-}
-
-#undef SKP_SUB_SAT64
-SKP_INLINE SKP_int64 SKP_SUB_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
- SKP_int64 res;
- ops_count += 1;
- res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \
- (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? SKP_int64_MIN : (a64)-(b64)) : \
- ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? SKP_int64_MAX : (a64)-(b64)) );
-
- return res;
-}
-
-#undef SKP_SMULWW
-SKP_INLINE SKP_int32 SKP_SMULWW(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- // Nb will be counted in sub-macros
- ret = SKP_MLA(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16));
- return ret;
-}
-
-#undef SKP_SMLAWW
-SKP_INLINE SKP_int32 SKP_SMLAWW(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- // Nb will be counted in sub-macros
- ret = SKP_MLA(SKP_SMLAWB((a32), (b32), (c32)), (b32), SKP_RSHIFT_ROUND((c32), 16));
- return ret;
-}
-
-#undef SKP_min_int
-SKP_INLINE SKP_int SKP_min_int(SKP_int a, SKP_int b)
-{
- ops_count += 1;
- return (((a) < (b)) ? (a) : (b));
-}
-
-#undef SKP_min_16
-SKP_INLINE SKP_int16 SKP_min_16(SKP_int16 a, SKP_int16 b)
-{
- ops_count += 1;
- return (((a) < (b)) ? (a) : (b));
-}
-#undef SKP_min_32
-SKP_INLINE SKP_int32 SKP_min_32(SKP_int32 a, SKP_int32 b)
-{
- ops_count += 1;
- return (((a) < (b)) ? (a) : (b));
-}
-#undef SKP_min_64
-SKP_INLINE SKP_int64 SKP_min_64(SKP_int64 a, SKP_int64 b)
-{
- ops_count += 1;
- return (((a) < (b)) ? (a) : (b));
-}
-
-/* SKP_min() versions with typecast in the function call */
-#undef SKP_max_int
-SKP_INLINE SKP_int SKP_max_int(SKP_int a, SKP_int b)
-{
- ops_count += 1;
- return (((a) > (b)) ? (a) : (b));
-}
-#undef SKP_max_16
-SKP_INLINE SKP_int16 SKP_max_16(SKP_int16 a, SKP_int16 b)
-{
- ops_count += 1;
- return (((a) > (b)) ? (a) : (b));
-}
-#undef SKP_max_32
-SKP_INLINE SKP_int32 SKP_max_32(SKP_int32 a, SKP_int32 b)
-{
- ops_count += 1;
- return (((a) > (b)) ? (a) : (b));
-}
-
-#undef SKP_max_64
-SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)
-{
- ops_count += 1;
- return (((a) > (b)) ? (a) : (b));
-}
-
-
-#undef SKP_LIMIT_int
-SKP_INLINE SKP_int SKP_LIMIT_int(SKP_int a, SKP_int limit1, SKP_int limit2)
-{
- SKP_int ret;
- ops_count += 6;
-
- ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
- : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))));
-
- return(ret);
-}
-
-#undef SKP_LIMIT_16
-SKP_INLINE SKP_int16 SKP_LIMIT_16(SKP_int16 a, SKP_int16 limit1, SKP_int16 limit2)
-{
- SKP_int16 ret;
- ops_count += 6;
-
- ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
- : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))));
-
-return(ret);
-}
-
-
-#undef SKP_LIMIT_32
-SKP_INLINE SKP_int SKP_LIMIT_32(SKP_int32 a, SKP_int32 limit1, SKP_int32 limit2)
-{
- SKP_int32 ret;
- ops_count += 6;
-
- ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
- : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))));
- return(ret);
-}
-
-#else
-#define exVarDefine
-#define varDefine
-#define SKP_SaveCount()
-
-#endif
-#endif
-
--- a/silk/SKP_Silk_MacroDebug.h
+++ /dev/null
@@ -1,559 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef _SIGPROCFIX_API_DEBUG_H_
-#define _SIGPROCFIX_API_DEBUG_H_
-
-// Redefine macro functions with extensive assertion in Win32_DEBUG mode.
-// As function can't be undefined, this file can't work with SigProcFIX_MacroCount.h
-
-#if 0 && defined (_WIN32) && defined (_DEBUG) && !defined (SKP_MACRO_COUNT)
-
-#undef SKP_ADD16
-SKP_INLINE SKP_int16 SKP_ADD16(SKP_int16 a, SKP_int16 b){
- SKP_int16 ret;
-
- ret = a + b;
- SKP_assert( ret == SKP_ADD_SAT16( a, b ));
- return ret;
-}
-
-#undef SKP_ADD32
-SKP_INLINE SKP_int32 SKP_ADD32(SKP_int32 a, SKP_int32 b){
- SKP_int32 ret;
-
- ret = a + b;
- SKP_assert( ret == SKP_ADD_SAT32( a, b ));
- return ret;
-}
-
-#undef SKP_ADD64
-SKP_INLINE SKP_int64 SKP_ADD64(SKP_int64 a, SKP_int64 b){
- SKP_int64 ret;
-
- ret = a + b;
- SKP_assert( ret == SKP_ADD_SAT64( a, b ));
- return ret;
-}
-
-#undef SKP_SUB16
-SKP_INLINE SKP_int16 SKP_SUB16(SKP_int16 a, SKP_int16 b){
- SKP_int16 ret;
-
- ret = a - b;
- SKP_assert( ret == SKP_SUB_SAT16( a, b ));
- return ret;
-}
-
-#undef SKP_SUB32
-SKP_INLINE SKP_int32 SKP_SUB32(SKP_int32 a, SKP_int32 b){
- SKP_int32 ret;
-
- ret = a - b;
- SKP_assert( ret == SKP_SUB_SAT32( a, b ));
- return ret;
-}
-
-#undef SKP_SUB64
-SKP_INLINE SKP_int64 SKP_SUB64(SKP_int64 a, SKP_int64 b){
- SKP_int64 ret;
-
- ret = a - b;
- SKP_assert( ret == SKP_SUB_SAT64( a, b ));
- return ret;
-}
-
-#undef SKP_ADD_SAT16
-SKP_INLINE SKP_int16 SKP_ADD_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
- SKP_int16 res;
- res = (SKP_int16)SKP_SAT16( SKP_ADD32( (SKP_int32)(a16), (b16) ) );
- SKP_assert( res == SKP_SAT16( ( SKP_int32 )a16 + ( SKP_int32 )b16 ) );
- return res;
-}
-
-#undef SKP_ADD_SAT32
-SKP_INLINE SKP_int32 SKP_ADD_SAT32(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 res;
- res = ((((a32) + (b32)) & 0x80000000) == 0 ? \
- ((((a32) & (b32)) & 0x80000000) != 0 ? SKP_int32_MIN : (a32)+(b32)) : \
- ((((a32) | (b32)) & 0x80000000) == 0 ? SKP_int32_MAX : (a32)+(b32)) );
- SKP_assert( res == SKP_SAT32( ( SKP_int64 )a32 + ( SKP_int64 )b32 ) );
- return res;
-}
-
-#undef SKP_ADD_SAT64
-SKP_INLINE SKP_int64 SKP_ADD_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
- SKP_int64 res;
- res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \
- ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? SKP_int64_MIN : (a64)+(b64)) : \
- ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? SKP_int64_MAX : (a64)+(b64)) );
- if( res != a64 + b64 ) {
- // Check that we saturated to the correct extreme value
- SKP_assert( ( res == SKP_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( SKP_int64_MAX >> 3 ) ) ) ||
- ( res == SKP_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( SKP_int64_MIN >> 3 ) ) ) );
- } else {
- // Saturation not necessary
- SKP_assert( res == a64 + b64 );
- }
- return res;
-}
-
-#undef SKP_SUB_SAT16
-SKP_INLINE SKP_int16 SKP_SUB_SAT16( SKP_int16 a16, SKP_int16 b16 ) {
- SKP_int16 res;
- res = (SKP_int16)SKP_SAT16( SKP_SUB32( (SKP_int32)(a16), (b16) ) );
- SKP_assert( res == SKP_SAT16( ( SKP_int32 )a16 - ( SKP_int32 )b16 ) );
- return res;
-}
-
-#undef SKP_SUB_SAT32
-SKP_INLINE SKP_int32 SKP_SUB_SAT32( SKP_int32 a32, SKP_int32 b32 ) {
- SKP_int32 res;
- res = ((((a32)-(b32)) & 0x80000000) == 0 ? \
- (( (a32) & ((b32)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a32)-(b32)) : \
- ((((a32)^0x80000000) & (b32) & 0x80000000) ? SKP_int32_MAX : (a32)-(b32)) );
- SKP_assert( res == SKP_SAT32( ( SKP_int64 )a32 - ( SKP_int64 )b32 ) );
- return res;
-}
-
-#undef SKP_SUB_SAT64
-SKP_INLINE SKP_int64 SKP_SUB_SAT64( SKP_int64 a64, SKP_int64 b64 ) {
- SKP_int64 res;
- res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \
- (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? SKP_int64_MIN : (a64)-(b64)) : \
- ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? SKP_int64_MAX : (a64)-(b64)) );
-
- if( res != a64 - b64 ) {
- // Check that we saturated to the correct extreme value
- SKP_assert( ( res == SKP_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( SKP_int64_MAX >> 3 ) ) ) ||
- ( res == SKP_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( SKP_int64_MIN >> 3 ) ) ) );
- } else {
- // Saturation not necessary
- SKP_assert( res == a64 - b64 );
- }
- return res;
-}
-
-#undef SKP_MUL
-SKP_INLINE SKP_int32 SKP_MUL(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- SKP_int64 ret64; // Will easily show how many bits that are needed
- ret = a32 * b32;
- ret64 = (SKP_int64)a32 * (SKP_int64)b32;
- SKP_assert((SKP_int64)ret == ret64 ); //Check output overflow
- return ret;
-}
-
-#undef SKP_MUL_uint
-SKP_INLINE SKP_uint32 SKP_MUL_uint(SKP_uint32 a32, SKP_uint32 b32){
- SKP_uint32 ret;
- ret = a32 * b32;
- SKP_assert((SKP_uint64)ret == (SKP_uint64)a32 * (SKP_uint64)b32); //Check output overflow
- return ret;
-}
-#undef SKP_MLA
-SKP_INLINE SKP_int32 SKP_MLA(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ret = a32 + b32 * c32;
- SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (SKP_int64)c32); //Check output overflow
- return ret;
-}
-
-#undef SKP_MLA_uint
-SKP_INLINE SKP_int32 SKP_MLA_uint(SKP_uint32 a32, SKP_uint32 b32, SKP_uint32 c32){
- SKP_uint32 ret;
- ret = a32 + b32 * c32;
- SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (SKP_int64)c32); //Check output overflow
- return ret;
-}
-
-#undef SKP_SMULWB
-SKP_INLINE SKP_int32 SKP_SMULWB(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- ret = (a32 >> 16) * (SKP_int32)((SKP_int16)b32) + (((a32 & 0x0000FFFF) * (SKP_int32)((SKP_int16)b32)) >> 16);
- SKP_assert((SKP_int64)ret == ((SKP_int64)a32 * (SKP_int16)b32) >> 16);
- return ret;
-}
-#undef SKP_SMLAWB
-SKP_INLINE SKP_int32 SKP_SMLAWB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ret = SKP_ADD32( a32, SKP_SMULWB( b32, c32 ) );
- SKP_assert(SKP_ADD32( a32, SKP_SMULWB( b32, c32 ) ) == SKP_ADD_SAT32( a32, SKP_SMULWB( b32, c32 ) ));
- return ret;
-}
-
-#undef SKP_SMULWT
-SKP_INLINE SKP_int32 SKP_SMULWT(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret;
- ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16);
- SKP_assert((SKP_int64)ret == ((SKP_int64)a32 * (b32 >> 16)) >> 16);
- return ret;
-}
-#undef SKP_SMLAWT
-SKP_INLINE SKP_int32 SKP_SMLAWT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16));
- SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (((SKP_int64)b32 * (c32 >> 16)) >> 16));
- return ret;
-}
-
-#undef SKP_SMULL
-SKP_INLINE SKP_int64 SKP_SMULL(SKP_int64 a64, SKP_int64 b64){
- SKP_int64 ret64;
- ret64 = a64 * b64;
- if( b64 != 0 ) {
- SKP_assert( a64 == (ret64 / b64) );
- } else if( a64 != 0 ) {
- SKP_assert( b64 == (ret64 / a64) );
- }
- return ret64;
-}
-
-// no checking needed for SKP_SMULBB
-#undef SKP_SMLABB
-SKP_INLINE SKP_int32 SKP_SMLABB(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ret = a32 + (SKP_int32)((SKP_int16)b32) * (SKP_int32)((SKP_int16)c32);
- SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (SKP_int16)c32);
- return ret;
-}
-
-// no checking needed for SKP_SMULBT
-#undef SKP_SMLABT
-SKP_INLINE SKP_int32 SKP_SMLABT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ret = a32 + ((SKP_int32)((SKP_int16)b32)) * (c32 >> 16);
- SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (SKP_int64)b32 * (c32 >> 16));
- return ret;
-}
-
-// no checking needed for SKP_SMULTT
-#undef SKP_SMLATT
-SKP_INLINE SKP_int32 SKP_SMLATT(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret;
- ret = a32 + (b32 >> 16) * (c32 >> 16);
- SKP_assert((SKP_int64)ret == (SKP_int64)a32 + (b32 >> 16) * (c32 >> 16));
- return ret;
-}
-
-#undef SKP_SMULWW
-SKP_INLINE SKP_int32 SKP_SMULWW(SKP_int32 a32, SKP_int32 b32){
- SKP_int32 ret, tmp1, tmp2;
- SKP_int64 ret64;
-
- ret = SKP_SMULWB( a32, b32 );
- tmp1 = SKP_RSHIFT_ROUND( b32, 16 );
- tmp2 = SKP_MUL( a32, tmp1 );
-
- SKP_assert( (SKP_int64)tmp2 == (SKP_int64) a32 * (SKP_int64) tmp1 );
-
- tmp1 = ret;
- ret = SKP_ADD32( tmp1, tmp2 );
- SKP_assert( SKP_ADD32( tmp1, tmp2 ) == SKP_ADD_SAT32( tmp1, tmp2 ) );
-
- ret64 = SKP_RSHIFT64( SKP_SMULL( a32, b32 ), 16 );
- SKP_assert( (SKP_int64)ret == ret64 );
-
- return ret;
-}
-
-#undef SKP_SMLAWW
-SKP_INLINE SKP_int32 SKP_SMLAWW(SKP_int32 a32, SKP_int32 b32, SKP_int32 c32){
- SKP_int32 ret, tmp;
-
- tmp = SKP_SMULWW( b32, c32 );
- ret = SKP_ADD32( a32, tmp );
- SKP_assert( ret == SKP_ADD_SAT32( a32, tmp ) );
- return ret;
-}
-
-// multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)
-#undef SKP_MLA_ovflw
-#define SKP_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32)))
-#undef SKP_SMLABB_ovflw
-#define SKP_SMLABB_ovflw(a32, b32, c32) ((a32) + ((SKP_int32)((SKP_int16)(b32))) * (SKP_int32)((SKP_int16)(c32)))
-#undef SKP_SMLABT_ovflw
-#define SKP_SMLABT_ovflw(a32, b32, c32) ((a32) + ((SKP_int32)((SKP_int16)(b32))) * ((c32) >> 16))
-#undef SKP_SMLATT_ovflw
-#define SKP_SMLATT_ovflw(a32, b32, c32) ((a32) + ((b32) >> 16) * ((c32) >> 16))
-#undef SKP_SMLAWB_ovflw
-#define SKP_SMLAWB_ovflw(a32, b32, c32) ((a32) + ((((b32) >> 16) * (SKP_int32)((SKP_int16)(c32))) + ((((b32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(c32))) >> 16)))
-#undef SKP_SMLAWT_ovflw
-#define SKP_SMLAWT_ovflw(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16))
-
-// no checking needed for SKP_SMULL
-// no checking needed for SKP_SMLAL
-// no checking needed for SKP_SMLALBB
-// no checking needed for SigProcFIX_CLZ16
-// no checking needed for SigProcFIX_CLZ32
-
-#undef SKP_DIV32
-SKP_INLINE SKP_int32 SKP_DIV32(SKP_int32 a32, SKP_int32 b32){
- SKP_assert( b32 != 0 );
- return a32 / b32;
-}
-
-#undef SKP_DIV32_16
-SKP_INLINE SKP_int32 SKP_DIV32_16(SKP_int32 a32, SKP_int32 b32){
- SKP_assert( b32 != 0 );
- SKP_assert( b32 <= SKP_int16_MAX );
- SKP_assert( b32 >= SKP_int16_MIN );
- return a32 / b32;
-}
-
-// no checking needed for SKP_SAT8
-// no checking needed for SKP_SAT16
-// no checking needed for SKP_SAT32
-// no checking needed for SKP_POS_SAT32
-// no checking needed for SKP_ADD_POS_SAT8
-// no checking needed for SKP_ADD_POS_SAT16
-// no checking needed for SKP_ADD_POS_SAT32
-// no checking needed for SKP_ADD_POS_SAT64
-#undef SKP_LSHIFT8
-SKP_INLINE SKP_int8 SKP_LSHIFT8(SKP_int8 a, SKP_int32 shift){
- SKP_int8 ret;
- ret = a << shift;
- SKP_assert(shift >= 0);
- SKP_assert(shift < 8);
- SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
- return ret;
-}
-#undef SKP_LSHIFT16
-SKP_INLINE SKP_int16 SKP_LSHIFT16(SKP_int16 a, SKP_int32 shift){
- SKP_int16 ret;
- ret = a << shift;
- SKP_assert(shift >= 0);
- SKP_assert(shift < 16);
- SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
- return ret;
-}
-#undef SKP_LSHIFT32
-SKP_INLINE SKP_int32 SKP_LSHIFT32(SKP_int32 a, SKP_int32 shift){
- SKP_int32 ret;
- ret = a << shift;
- SKP_assert(shift >= 0);
- SKP_assert(shift < 32);
- SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
- return ret;
-}
-#undef SKP_LSHIFT64
-SKP_INLINE SKP_int64 SKP_LSHIFT64(SKP_int64 a, SKP_int shift){
- SKP_assert(shift >= 0);
- SKP_assert(shift < 64);
- return a << shift;
-}
-
-#undef SKP_LSHIFT_ovflw
-SKP_INLINE SKP_int32 SKP_LSHIFT_ovflw(SKP_int32 a, SKP_int32 shift){
- SKP_assert(shift >= 0); /* no check for overflow */
- return a << shift;
-}
-
-#undef SKP_LSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_LSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
- SKP_uint32 ret;
- ret = a << shift;
- SKP_assert(shift >= 0);
- SKP_assert((SKP_int64)ret == ((SKP_int64)a) << shift);
- return ret;
-}
-
-#undef SKP_RSHIFT8
-SKP_INLINE SKP_int8 SKP_RSHIFT8(SKP_int8 a, SKP_int32 shift){
- SKP_assert(shift >= 0);
- SKP_assert(shift < 8);
- return a >> shift;
-}
-#undef SKP_RSHIFT16
-SKP_INLINE SKP_int16 SKP_RSHIFT16(SKP_int16 a, SKP_int32 shift){
- SKP_assert(shift >= 0);
- SKP_assert(shift < 16);
- return a >> shift;
-}
-#undef SKP_RSHIFT32
-SKP_INLINE SKP_int32 SKP_RSHIFT32(SKP_int32 a, SKP_int32 shift){
- SKP_assert(shift >= 0);
- SKP_assert(shift < 32);
- return a >> shift;
-}
-#undef SKP_RSHIFT64
-SKP_INLINE SKP_int64 SKP_RSHIFT64(SKP_int64 a, SKP_int64 shift){
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 63);
- return a >> shift;
-}
-
-#undef SKP_RSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_RSHIFT_uint(SKP_uint32 a, SKP_int32 shift){
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 32);
- return a >> shift;
-}
-
-#undef SKP_ADD_LSHIFT
-SKP_INLINE SKP_int32 SKP_ADD_LSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 31);
- ret = a + (b << shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) << shift));
- return ret; // shift >= 0
-}
-#undef SKP_ADD_LSHIFT32
-SKP_INLINE SKP_int32 SKP_ADD_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 31);
- ret = a + (b << shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) << shift));
- return ret; // shift >= 0
-}
-#undef SKP_ADD_LSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_ADD_LSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
- SKP_uint32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 32);
- ret = a + (b << shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) << shift));
- return ret; // shift >= 0
-}
-#undef SKP_ADD_RSHIFT
-SKP_INLINE SKP_int32 SKP_ADD_RSHIFT(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 31);
- ret = a + (b >> shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) >> shift));
- return ret; // shift > 0
-}
-#undef SKP_ADD_RSHIFT32
-SKP_INLINE SKP_int32 SKP_ADD_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 31);
- ret = a + (b >> shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) >> shift));
- return ret; // shift > 0
-}
-#undef SKP_ADD_RSHIFT_uint
-SKP_INLINE SKP_uint32 SKP_ADD_RSHIFT_uint(SKP_uint32 a, SKP_uint32 b, SKP_int32 shift){
- SKP_uint32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 32);
- ret = a + (b >> shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a + (((SKP_int64)b) >> shift));
- return ret; // shift > 0
-}
-#undef SKP_SUB_LSHIFT32
-SKP_INLINE SKP_int32 SKP_SUB_LSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 31);
- ret = a - (b << shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a - (((SKP_int64)b) << shift));
- return ret; // shift >= 0
-}
-#undef SKP_SUB_RSHIFT32
-SKP_INLINE SKP_int32 SKP_SUB_RSHIFT32(SKP_int32 a, SKP_int32 b, SKP_int32 shift){
- SKP_int32 ret;
- SKP_assert(shift >= 0);
- SKP_assert(shift <= 31);
- ret = a - (b >> shift);
- SKP_assert((SKP_int64)ret == (SKP_int64)a - (((SKP_int64)b) >> shift));
- return ret; // shift > 0
-}
-
-#undef SKP_RSHIFT_ROUND
-SKP_INLINE SKP_int32 SKP_RSHIFT_ROUND(SKP_int32 a, SKP_int32 shift){
- SKP_int32 ret;
- SKP_assert(shift > 0); /* the marco definition can't handle a shift of zero */
- SKP_assert(shift < 32);
- ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
- SKP_assert((SKP_int64)ret == ((SKP_int64)a + ((SKP_int64)1 << (shift - 1))) >> shift);
- return ret;
-}
-
-#undef SKP_RSHIFT_ROUND64
-SKP_INLINE SKP_int64 SKP_RSHIFT_ROUND64(SKP_int64 a, SKP_int32 shift){
- SKP_int64 ret;
- SKP_assert(shift > 0); /* the marco definition can't handle a shift of zero */
- SKP_assert(shift < 64);
- ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
- return ret;
-}
-
-// SKP_abs is used on floats also, so doesn't work...
-//#undef SKP_abs
-//SKP_INLINE SKP_int32 SKP_abs(SKP_int32 a){
-// SKP_assert(a != 0x80000000);
-// return (((a) > 0) ? (a) : -(a)); // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN
-//}
-
-#undef SKP_abs_int64
-SKP_INLINE SKP_int64 SKP_abs_int64(SKP_int64 a){
- SKP_assert(a != 0x8000000000000000);
- return (((a) > 0) ? (a) : -(a)); // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN
-}
-
-#undef SKP_abs_int32
-SKP_INLINE SKP_int32 SKP_abs_int32(SKP_int32 a){
- SKP_assert(a != 0x80000000);
- return abs(a);
-}
-
-#undef SKP_CHECK_FIT8
-SKP_INLINE SKP_int8 SKP_CHECK_FIT8( SKP_int64 a ){
- SKP_int8 ret;
- ret = (SKP_int8)a;
- SKP_assert( (SKP_int64)ret == a );
- return( ret );
-}
-
-#undef SKP_CHECK_FIT16
-SKP_INLINE SKP_int16 SKP_CHECK_FIT16( SKP_int64 a ){
- SKP_int16 ret;
- ret = (SKP_int16)a;
- SKP_assert( (SKP_int64)ret == a );
- return( ret );
-}
-
-#undef SKP_CHECK_FIT32
-SKP_INLINE SKP_int32 SKP_CHECK_FIT32( SKP_int64 a ){
- SKP_int32 ret;
- ret = (SKP_int32)a;
- SKP_assert( (SKP_int64)ret == a );
- return( ret );
-}
-
-// no checking for SKP_NSHIFT_MUL_32_32
-// no checking for SKP_NSHIFT_MUL_16_16
-// no checking needed for SKP_min
-// no checking needed for SKP_max
-// no checking needed for SKP_sign
-
-#endif
-#endif
--- a/silk/SKP_Silk_NLSF2A.c
+++ /dev/null
@@ -1,151 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* conversion between prediction filter coefficients and LSFs */
-/* order should be even */
-/* a piecewise linear approximation maps LSF <-> cos(LSF) */
-/* therefore the result is not accurate LSFs, but the two */
-/* function are accurate inverses of each other */
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* helper function for NLSF2A(..) */
-SKP_INLINE void SKP_Silk_NLSF2A_find_poly(
- SKP_int32 *out, /* o intermediate polynomial, Q20 */
- const SKP_int32 *cLSF, /* i vector of interleaved 2*cos(LSFs), Q20 */
- SKP_int dd /* i polynomial order (= 1/2 * filter order) */
-)
-{
- SKP_int k, n;
- SKP_int32 ftmp;
-
- out[0] = SKP_LSHIFT( 1, 20 );
- out[1] = -cLSF[0];
- for( k = 1; k < dd; k++ ) {
- ftmp = cLSF[2*k]; // Q20
- out[k+1] = SKP_LSHIFT( out[k-1], 1 ) - (SKP_int32)SKP_RSHIFT_ROUND64( SKP_SMULL( ftmp, out[k] ), 20 );
- for( n = k; n > 1; n-- ) {
- out[n] += out[n-2] - (SKP_int32)SKP_RSHIFT_ROUND64( SKP_SMULL( ftmp, out[n-1] ), 20 );
- }
- out[1] -= ftmp;
- }
-}
-
-/* compute whitening filter coefficients from normalized line spectral frequencies */
-void SKP_Silk_NLSF2A(
- SKP_int16 *a, /* o monic whitening filter coefficients in Q12, [d] */
- const SKP_int16 *NLSF, /* i normalized line spectral frequencies in Q15, [d] */
- const SKP_int d /* i filter order (should be even) */
-)
-{
- SKP_int k, i, dd;
- SKP_int32 cos_LSF_Q20[SKP_Silk_MAX_ORDER_LPC];
- SKP_int32 P[SKP_Silk_MAX_ORDER_LPC/2+1], Q[SKP_Silk_MAX_ORDER_LPC/2+1];
- SKP_int32 Ptmp, Qtmp;
- SKP_int32 f_int;
- SKP_int32 f_frac;
- SKP_int32 cos_val, delta;
- SKP_int32 a_int32[SKP_Silk_MAX_ORDER_LPC];
- SKP_int32 maxabs, absval, idx=0, sc_Q16;
-
- SKP_assert( LSF_COS_TAB_SZ_FIX == 128 );
-
- /* convert LSFs to 2*cos(LSF(i)), using piecewise linear curve from table */
- for( k = 0; k < d; k++ ) {
- SKP_assert(NLSF[k] >= 0 );
- SKP_assert(NLSF[k] <= 32767 );
-
- /* f_int on a scale 0-127 (rounded down) */
- f_int = SKP_RSHIFT( NLSF[k], 15 - 7 );
-
- /* f_frac, range: 0..255 */
- f_frac = NLSF[k] - SKP_LSHIFT( f_int, 15 - 7 );
-
- SKP_assert(f_int >= 0);
- SKP_assert(f_int < LSF_COS_TAB_SZ_FIX );
-
- /* Read start and end value from table */
- cos_val = SKP_Silk_LSFCosTab_FIX_Q12[ f_int ]; /* Q12 */
- delta = SKP_Silk_LSFCosTab_FIX_Q12[ f_int + 1 ] - cos_val; /* Q12, with a range of 0..200 */
-
- /* Linear interpolation */
- cos_LSF_Q20[k] = SKP_LSHIFT( cos_val, 8 ) + SKP_MUL( delta, f_frac ); /* Q20 */
- }
-
- dd = SKP_RSHIFT( d, 1 );
-
- /* generate even and odd polynomials using convolution */
- SKP_Silk_NLSF2A_find_poly( P, &cos_LSF_Q20[0], dd );
- SKP_Silk_NLSF2A_find_poly( Q, &cos_LSF_Q20[1], dd );
-
- /* convert even and odd polynomials to SKP_int32 Q12 filter coefs */
- for( k = 0; k < dd; k++ ) {
- Ptmp = P[k+1] + P[k];
- Qtmp = Q[k+1] - Q[k];
-
- /* the Ptmp and Qtmp values at this stage need to fit in int32 */
-
- a_int32[k] = -SKP_RSHIFT_ROUND( Ptmp + Qtmp, 9 ); /* Q20 -> Q12 */
- a_int32[d-k-1] = SKP_RSHIFT_ROUND( Qtmp - Ptmp, 9 ); /* Q20 -> Q12 */
- }
-
- /* Limit the maximum absolute value of the prediction coefficients */
- for( i = 0; i < 10; i++ ) {
- /* Find maximum absolute value and its index */
- maxabs = 0;
- for( k = 0; k < d; k++ ) {
- absval = SKP_abs( a_int32[k] );
- if( absval > maxabs ) {
- maxabs = absval;
- idx = k;
- }
- }
-
- if( maxabs > SKP_int16_MAX ) {
- /* Reduce magnitude of prediction coefficients */
- maxabs = SKP_min( maxabs, 98369 ); // ( SKP_int32_MAX / ( 65470 >> 2 ) ) + SKP_int16_MAX = 98369
- sc_Q16 = 65470 - SKP_DIV32( SKP_MUL( 65470 >> 2, maxabs - SKP_int16_MAX ),
- SKP_RSHIFT32( SKP_MUL( maxabs, idx + 1), 2 ) );
- SKP_Silk_bwexpander_32( a_int32, d, sc_Q16 );
- } else {
- break;
- }
- }
-
- /* Reached the last iteration */
- if( i == 10 ) {
- SKP_assert(0);
- for( k = 0; k < d; k++ ) {
- a_int32[k] = SKP_SAT16( a_int32[k] );
- }
- }
-
- /* Return as SKP_int16 Q12 coefficients */
- for( k = 0; k < d; k++ ) {
- a[k] = (SKP_int16)a_int32[k];
- }
-}
--- a/silk/SKP_Silk_NLSF2A_stable.c
+++ /dev/null
@@ -1,57 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Convert NLSF parameters to stable AR prediction filter coefficients */
-void SKP_Silk_NLSF2A_stable(
- SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */
- const SKP_int16 pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */
- const SKP_int LPC_order /* I LPC/LSF order */
-)
-{
- SKP_int i;
- SKP_int32 invGain_Q30;
-
- SKP_Silk_NLSF2A( pAR_Q12, pNLSF, LPC_order );
-
- /* Ensure stable LPCs */
- for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) {
- if( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) {
- SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) ); /* 10_Q16 = 0.00015 */
- } else {
- break;
- }
- }
-
- /* Reached the last iteration */
- if( i == MAX_LPC_STABILIZE_ITERATIONS ) {
- for( i = 0; i < LPC_order; i++ ) {
- pAR_Q12[ i ] = 0;
- }
- }
-}
--- a/silk/SKP_Silk_NLSF_VQ.c
+++ /dev/null
@@ -1,64 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
-void SKP_Silk_NLSF_VQ(
- SKP_int32 err_Q26[], /* O Quantization errors [K] */
- const SKP_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
- const SKP_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
- const SKP_int K, /* I Number of codebook vectors */
- const SKP_int LPC_order /* I Number of LPCs */
-)
-{
- SKP_int i, m;
- SKP_int32 diff_Q15, sum_error_Q30, sum_error_Q26;
-
- SKP_assert( LPC_order <= 16 );
- SKP_assert( ( LPC_order & 1 ) == 0 );
-
- /* Loop over codebook */
- for( i = 0; i < K; i++ ) {
- sum_error_Q26 = 0;
- for( m = 0; m < LPC_order; m += 2 ) {
- /* Compute weighted squared quantization error for index m */
- diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[ m ], ( SKP_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
- sum_error_Q30 = SKP_SMULBB( diff_Q15, diff_Q15 );
-
- /* Compute weighted squared quantization error for index m + 1 */
- diff_Q15 = SKP_SUB_LSHIFT32( in_Q15[m + 1], ( SKP_int32 )*pCB_Q8++, 7 ); // range: [ -32767 : 32767 ]
- sum_error_Q30 = SKP_SMLABB( sum_error_Q30, diff_Q15, diff_Q15 );
-
- sum_error_Q26 = SKP_ADD_RSHIFT32( sum_error_Q26, sum_error_Q30, 4 );
-
- SKP_assert( sum_error_Q26 >= 0 );
- SKP_assert( sum_error_Q30 >= 0 );
- }
- err_Q26[ i ] = sum_error_Q26;
- }
-}
--- a/silk/SKP_Silk_NLSF_VQ_weights_laroia.c
+++ /dev/null
@@ -1,77 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/*
-R. Laroia, N. Phamdo and N. Farvardin, "Robust and Efficient Quantization of Speech LSP
-Parameters Using Structured Vector Quantization", Proc. IEEE Int. Conf. Acoust., Speech,
-Signal Processing, pp. 641-644, 1991.
-*/
-
-#define Q_OUT 5
-
-/* Laroia low complexity NLSF weights */
-void SKP_Silk_NLSF_VQ_weights_laroia(
- SKP_int16 *pNLSFW_Q5, /* O: Pointer to input vector weights [D x 1] */
- const SKP_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
- const SKP_int D /* I: Input vector dimension (even) */
-)
-{
- SKP_int k;
- SKP_int32 tmp1_int, tmp2_int;
-
- SKP_assert( D > 0 );
- SKP_assert( ( D & 1 ) == 0 );
-
- /* First value */
- tmp1_int = SKP_max_int( pNLSF_Q15[ 0 ], 1 );
- tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );
- tmp2_int = SKP_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], 1 );
- tmp2_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp2_int );
- pNLSFW_Q5[ 0 ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
- SKP_assert( pNLSFW_Q5[ 0 ] > 0 );
-
- /* Main loop */
- for( k = 1; k < D - 1; k += 2 ) {
- tmp1_int = SKP_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], 1 );
- tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );
- pNLSFW_Q5[ k ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
- SKP_assert( pNLSFW_Q5[ k ] > 0 );
-
- tmp2_int = SKP_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], 1 );
- tmp2_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp2_int );
- pNLSFW_Q5[ k + 1 ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
- SKP_assert( pNLSFW_Q5[ k + 1 ] > 0 );
- }
-
- /* Last value */
- tmp1_int = SKP_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], 1 );
- tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );
- pNLSFW_Q5[ D - 1 ] = (SKP_int16)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );
- SKP_assert( pNLSFW_Q5[ D - 1 ] > 0 );
-}
--- a/silk/SKP_Silk_NLSF_decode.c
+++ /dev/null
@@ -1,96 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Predictive dequantizer for NLSF residuals */
-void SKP_Silk_NLSF_residual_dequant( /* O Returns RD value in Q30 */
- SKP_int16 x_Q10[], /* O Output [ order ] */
- const SKP_int8 indices[], /* I Quantization indices [ order ] */
- const SKP_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */
- const SKP_int quant_step_size_Q16, /* I Quantization step size */
- const SKP_int16 order /* I Number of input values */
-)
-{
- SKP_int i, out_Q10, pred_Q10;
-
- out_Q10 = 0;
- for( i = order-1; i >= 0; i-- ) {
- pred_Q10 = SKP_RSHIFT( SKP_SMULBB( out_Q10, (SKP_int16)pred_coef_Q8[ i ] ), 8 );
- out_Q10 = SKP_LSHIFT( indices[ i ], 10 );
- if( out_Q10 > 0 ) {
- out_Q10 = SKP_SUB16( out_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- } else if( out_Q10 < 0 ) {
- out_Q10 = SKP_ADD16( out_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- }
- out_Q10 = SKP_SMLAWB( pred_Q10, out_Q10, quant_step_size_Q16 );
- x_Q10[ i ] = out_Q10;
- }
-}
-
-
-/***********************/
-/* NLSF vector decoder */
-/***********************/
-void SKP_Silk_NLSF_decode(
- SKP_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */
- SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
- const SKP_Silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */
-)
-{
- SKP_int i;
- SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
- SKP_int16 ec_ix[ MAX_LPC_ORDER ];
- SKP_int16 res_Q10[ MAX_LPC_ORDER ];
- SKP_int16 W_tmp_Q5[ MAX_LPC_ORDER ];
- SKP_int32 W_tmp_Q9;
- const SKP_uint8 *pCB_element;
-
- /* Decode first stage */
- pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ NLSFIndices[ 0 ] * psNLSF_CB->order ];
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- pNLSF_Q15[ i ] = SKP_LSHIFT( ( SKP_int16 )pCB_element[ i ], 7 );
- }
-
- /* Unpack entropy table indices and predictor for current CB1 index */
- SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, NLSFIndices[ 0 ] );
-
- /* Trellis dequantizer */
- SKP_Silk_NLSF_residual_dequant( res_Q10, &NLSFIndices[ 1 ], pred_Q8, psNLSF_CB->quantStepSize_Q16, psNLSF_CB->order );
-
- /* Weights from codebook vector */
- SKP_Silk_NLSF_VQ_weights_laroia( W_tmp_Q5, pNLSF_Q15, psNLSF_CB->order );
-
- /* Apply inverse square-rooted weights and add to output */
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- W_tmp_Q9 = SKP_Silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) );
- pNLSF_Q15[ i ] = SKP_ADD16( pNLSF_Q15[ i ], (SKP_int16)SKP_DIV32_16( SKP_LSHIFT( ( SKP_int32 )res_Q10[ i ], 14 ), W_tmp_Q9 ) );
- }
-
- /* NLSF stabilization */
- SKP_Silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order );
-}
--- a/silk/SKP_Silk_NLSF_del_dec_quant.c
+++ /dev/null
@@ -1,201 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Delayed-decision quantizer for NLSF residuals */
-SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */
- SKP_int8 indices[], /* O Quantization indices [ order ] */
- const SKP_int16 x_Q10[], /* I Input [ order ] */
- const SKP_int16 w_Q5[], /* I Weights [ order ] */
- const SKP_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */
- const SKP_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */
- const SKP_uint8 ec_rates_Q5[], /* I Rates [] */
- const SKP_int quant_step_size_Q16, /* I Quantization step size */
- const SKP_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */
- const SKP_int32 mu_Q20, /* I R/D tradeoff */
- const SKP_int16 order /* I Number of input values */
-)
-{
- SKP_int i, j, nStates, ind_tmp, ind_min_max, ind_max_min, in_Q10, res_Q10;
- SKP_int pred_Q10, diff_Q10, out0_Q10, out1_Q10, rate0_Q5, rate1_Q5;
- SKP_int32 RD_tmp_Q25, min_Q25, min_max_Q25, max_min_Q25, pred_coef_Q16;
- SKP_int ind_sort[ NLSF_QUANT_DEL_DEC_STATES ];
- SKP_int8 ind[ NLSF_QUANT_DEL_DEC_STATES ][ MAX_LPC_ORDER ];
- SKP_int16 prev_out_Q10[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
- SKP_int32 RD_Q25[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
- SKP_int32 RD_min_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
- SKP_int32 RD_max_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
- const SKP_uint8 *rates_Q5;
-
- SKP_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) == 0 ); /* must be power of two */
-
- nStates = 1;
- RD_Q25[ 0 ] = 0;
- prev_out_Q10[ 0 ] = 0;
- for( i = order - 1; ; i-- ) {
- rates_Q5 = &ec_rates_Q5[ ec_ix[ i ] ];
- pred_coef_Q16 = SKP_LSHIFT( (SKP_int32)pred_coef_Q8[ i ], 8 );
- in_Q10 = x_Q10[ i ];
- for( j = 0; j < nStates; j++ ) {
- pred_Q10 = SKP_SMULWB( pred_coef_Q16, prev_out_Q10[ j ] );
- res_Q10 = SKP_SUB16( in_Q10, pred_Q10 );
- ind_tmp = SKP_SMULWB( inv_quant_step_size_Q6, res_Q10 );
- ind_tmp = SKP_LIMIT( ind_tmp, -NLSF_QUANT_MAX_AMPLITUDE_EXT, NLSF_QUANT_MAX_AMPLITUDE_EXT-1 );
- ind[ j ][ i ] = (SKP_int8)ind_tmp;
-
- /* compute outputs for ind_tmp and ind_tmp + 1 */
- out0_Q10 = SKP_LSHIFT( ind_tmp, 10 );
- out1_Q10 = SKP_ADD16( out0_Q10, 1024 );
- if( ind_tmp > 0 ) {
- out0_Q10 = SKP_SUB16( out0_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- out1_Q10 = SKP_SUB16( out1_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- } else if( ind_tmp == 0 ) {
- out1_Q10 = SKP_SUB16( out1_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- } else if( ind_tmp == -1 ) {
- out0_Q10 = SKP_ADD16( out0_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- } else {
- out0_Q10 = SKP_ADD16( out0_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- out1_Q10 = SKP_ADD16( out1_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
- }
- out0_Q10 = SKP_SMULWB( out0_Q10, quant_step_size_Q16 );
- out1_Q10 = SKP_SMULWB( out1_Q10, quant_step_size_Q16 );
- out0_Q10 = SKP_ADD16( out0_Q10, pred_Q10 );
- out1_Q10 = SKP_ADD16( out1_Q10, pred_Q10 );
- prev_out_Q10[ j ] = out0_Q10;
- prev_out_Q10[ j + nStates ] = out1_Q10;
-
- /* compute RD for ind_tmp and ind_tmp + 1 */
- if( ind_tmp + 1 >= NLSF_QUANT_MAX_AMPLITUDE ) {
- if( ind_tmp + 1 == NLSF_QUANT_MAX_AMPLITUDE ) {
- rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ];
- rate1_Q5 = 280;
- } else {
- rate0_Q5 = SKP_SMLABB( 280 - 43 * NLSF_QUANT_MAX_AMPLITUDE, 43, ind_tmp );
- rate1_Q5 = SKP_ADD16( rate0_Q5, 43 );
- }
- } else if( ind_tmp <= -NLSF_QUANT_MAX_AMPLITUDE ) {
- if( ind_tmp == -NLSF_QUANT_MAX_AMPLITUDE ) {
- rate0_Q5 = 280;
- rate1_Q5 = rates_Q5[ ind_tmp + 1 + NLSF_QUANT_MAX_AMPLITUDE ];
- } else {
- rate0_Q5 = SKP_SMLABB( 280 - 43 * NLSF_QUANT_MAX_AMPLITUDE, -43, ind_tmp );
- rate1_Q5 = SKP_SUB16( rate0_Q5, 43 );
- }
- } else {
- rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ];
- rate1_Q5 = rates_Q5[ ind_tmp + 1 + NLSF_QUANT_MAX_AMPLITUDE ];
- }
- RD_tmp_Q25 = RD_Q25[ j ];
- diff_Q10 = SKP_SUB16( in_Q10, out0_Q10 );
- RD_Q25[ j ] = SKP_SMLABB( SKP_MLA( RD_tmp_Q25, SKP_SMULBB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate0_Q5 );
- diff_Q10 = SKP_SUB16( in_Q10, out1_Q10 );
- RD_Q25[ j + nStates ] = SKP_SMLABB( SKP_MLA( RD_tmp_Q25, SKP_SMULBB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate1_Q5 );
- }
-
- if( nStates < NLSF_QUANT_DEL_DEC_STATES ) {
- /* double number of states and copy */
- for( j = 0; j < nStates; j++ ) {
- ind[ j + nStates ][ i ] = ind[ j ][ i ] + 1;
- }
- nStates = SKP_LSHIFT( nStates, 1 );
- for( j = nStates; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) {
- ind[ j ][ i ] = ind[ j - nStates ][ i ];
- }
- } else if( i > 0 ) {
- /* sort lower and upper half of RD_Q25, pairwise */
- for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) {
- if( RD_Q25[ j ] > RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] ) {
- RD_max_Q25[ j ] = RD_Q25[ j ];
- RD_min_Q25[ j ] = RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ];
- RD_Q25[ j ] = RD_min_Q25[ j ];
- RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] = RD_max_Q25[ j ];
- /* swap prev_out values */
- out0_Q10 = prev_out_Q10[ j ];
- prev_out_Q10[ j ] = prev_out_Q10[ j + NLSF_QUANT_DEL_DEC_STATES ];
- prev_out_Q10[ j + NLSF_QUANT_DEL_DEC_STATES ] = out0_Q10;
- ind_sort[ j ] = j + NLSF_QUANT_DEL_DEC_STATES;
- } else {
- RD_min_Q25[ j ] = RD_Q25[ j ];
- RD_max_Q25[ j ] = RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ];
- ind_sort[ j ] = j;
- }
- }
- /* compare the highest RD values of the winning half with the lowest one in the losing half, and copy if necessary */
- /* afterwards ind_sort[] will contain the indices of the NLSF_QUANT_DEL_DEC_STATES winning RD values */
- while( 1 ) {
- min_max_Q25 = SKP_int32_MAX;
- max_min_Q25 = 0;
- ind_min_max = 0;
- ind_max_min = 0;
- for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) {
- if( min_max_Q25 > RD_max_Q25[ j ] ) {
- min_max_Q25 = RD_max_Q25[ j ];
- ind_min_max = j;
- }
- if( max_min_Q25 < RD_min_Q25[ j ] ) {
- max_min_Q25 = RD_min_Q25[ j ];
- ind_max_min = j;
- }
- }
- if( min_max_Q25 >= max_min_Q25 ) {
- break;
- }
- /* copy ind_min_max to ind_max_min */
- ind_sort[ ind_max_min ] = ind_sort[ ind_min_max ] ^ NLSF_QUANT_DEL_DEC_STATES;
- RD_Q25[ ind_max_min ] = RD_Q25[ ind_min_max + NLSF_QUANT_DEL_DEC_STATES ];
- prev_out_Q10[ ind_max_min ] = prev_out_Q10[ ind_min_max + NLSF_QUANT_DEL_DEC_STATES ];
- RD_min_Q25[ ind_max_min ] = 0;
- RD_max_Q25[ ind_min_max ] = SKP_int32_MAX;
- SKP_memcpy( ind[ ind_max_min ], ind[ ind_min_max ], MAX_LPC_ORDER * sizeof( SKP_int8 ) );
- }
- /* increment index if it comes from the upper half */
- for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) {
- ind[ j ][ i ] += SKP_RSHIFT( ind_sort[ j ], NLSF_QUANT_DEL_DEC_STATES_LOG2 );
- }
- } else { /* i == 0 */
- /* last sample: find winner, copy indices and return RD value */
- ind_tmp = 0;
- min_Q25 = SKP_int32_MAX;
- for( j = 0; j < 2 * NLSF_QUANT_DEL_DEC_STATES; j++ ) {
- if( min_Q25 > RD_Q25[ j ] ) {
- min_Q25 = RD_Q25[ j ];
- ind_tmp = j;
- }
- }
- for( j = 0; j < order; j++ ) {
- indices[ j ] = ind[ ind_tmp & ( NLSF_QUANT_DEL_DEC_STATES - 1 ) ][ j ];
- SKP_assert( indices[ j ] >= -NLSF_QUANT_MAX_AMPLITUDE_EXT );
- SKP_assert( indices[ j ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT );
- }
- indices[ 0 ] += SKP_RSHIFT( ind_tmp, NLSF_QUANT_DEL_DEC_STATES_LOG2 );
- SKP_assert( indices[ 0 ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT );
- SKP_assert( min_Q25 >= 0 );
- return min_Q25;
- }
- }
-}
--- a/silk/SKP_Silk_NLSF_encode.c
+++ /dev/null
@@ -1,183 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-#define STORE_LSF_DATA_FOR_TRAINING 0
-
-/***********************/
-/* NLSF vector encoder */
-/***********************/
-SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD value in Q25 */
- SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
- SKP_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */
- const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
- const SKP_int16 *pW_Q5, /* I NLSF weight vector [ LPC_ORDER ] */
- const SKP_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */
- const SKP_int nSurvivors, /* I Max survivors after first stage */
- const SKP_int signalType /* I Signal type: 0/1/2 */
-)
-{
- SKP_int i, s, ind1, bestIndex, prob_Q8, bits_q7;
- SKP_int32 W_tmp_Q9;
- SKP_int32 err_Q26[ NLSF_VQ_MAX_VECTORS ];
- SKP_int32 RD_Q25[ NLSF_VQ_MAX_SURVIVORS ];
- SKP_int tempIndices1[ NLSF_VQ_MAX_SURVIVORS ];
- SKP_int8 tempIndices2[ NLSF_VQ_MAX_SURVIVORS * MAX_LPC_ORDER ];
- SKP_int16 res_Q15[ MAX_LPC_ORDER ];
- SKP_int16 res_Q10[ MAX_LPC_ORDER ];
- SKP_int16 NLSF_tmp_Q15[ MAX_LPC_ORDER ];
- SKP_int16 W_tmp_Q5[ MAX_LPC_ORDER ];
- SKP_int16 W_adj_Q5[ MAX_LPC_ORDER ];
- SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
- SKP_int16 ec_ix[ MAX_LPC_ORDER ];
- const SKP_uint8 *pCB_element, *iCDF_ptr;
-
-#if STORE_LSF_DATA_FOR_TRAINING
- SKP_int16 pNLSF_Q15_orig[MAX_LPC_ORDER ];
- DEBUG_STORE_DATA( NLSF.dat, pNLSF_Q15, psNLSF_CB->order * sizeof( SKP_int16 ) );
- DEBUG_STORE_DATA( WNLSF.dat, pW_Q5, psNLSF_CB->order * sizeof( SKP_int16 ) );
- DEBUG_STORE_DATA( NLSF_mu.dat, &NLSF_mu_Q20, sizeof( SKP_int ) );
- DEBUG_STORE_DATA( sigType.dat, &signalType, sizeof( SKP_int ) );
- SKP_memcpy(pNLSF_Q15_orig, pNLSF_Q15, sizeof( pNLSF_Q15_orig ));
-#endif
-
- SKP_assert( nSurvivors <= NLSF_VQ_MAX_SURVIVORS );
- SKP_assert( signalType >= 0 && signalType <= 2 );
- SKP_assert( NLSF_mu_Q20 <= 32767 && NLSF_mu_Q20 >= 0 );
-
- /* NLSF stabilization */
- SKP_Silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order );
-
- /* First stage: VQ */
- SKP_Silk_NLSF_VQ( err_Q26, pNLSF_Q15, psNLSF_CB->CB1_NLSF_Q8, psNLSF_CB->nVectors, psNLSF_CB->order );
-
- /* Sort the quantization errors */
- SKP_Silk_insertion_sort_increasing( err_Q26, tempIndices1, psNLSF_CB->nVectors, nSurvivors );
-
- /* Loop over survivors */
- for( s = 0; s < nSurvivors; s++ ) {
- ind1 = tempIndices1[ s ];
-
- /* Residual after first stage */
- pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ ind1 * psNLSF_CB->order ];
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- NLSF_tmp_Q15[ i ] = SKP_LSHIFT16( ( SKP_int16 )pCB_element[ i ], 7 );
- res_Q15[ i ] = pNLSF_Q15[ i ] - NLSF_tmp_Q15[ i ];
- }
-
- /* Weights from codebook vector */
- SKP_Silk_NLSF_VQ_weights_laroia( W_tmp_Q5, NLSF_tmp_Q15, psNLSF_CB->order );
-
- /* Apply square-rooted weights */
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- W_tmp_Q9 = SKP_Silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) );
- res_Q10[ i ] = ( SKP_int16 )SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
- }
-
- /* Modify input weights accordingly */
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- W_adj_Q5[ i ] = SKP_DIV32_16( SKP_LSHIFT( ( SKP_int32 )pW_Q5[ i ], 5 ), W_tmp_Q5[ i ] );
- }
-
- /* Unpack entropy table indices and predictor for current CB1 index */
- SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 );
-
- /* Trellis quantizer */
- RD_Q25[ s ] = SKP_Silk_NLSF_del_dec_quant( &tempIndices2[ s * MAX_LPC_ORDER ], res_Q10, W_adj_Q5, pred_Q8, ec_ix,
- psNLSF_CB->ec_Rates_Q5, psNLSF_CB->quantStepSize_Q16, psNLSF_CB->invQuantStepSize_Q6, NLSF_mu_Q20, psNLSF_CB->order );
-
- /* Add rate for first stage */
- iCDF_ptr = &psNLSF_CB->CB1_iCDF[ ( signalType >> 1 ) * psNLSF_CB->nVectors ];
- if( ind1 == 0 ) {
- prob_Q8 = 256 - iCDF_ptr[ ind1 ];
- } else {
- prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ];
- }
- bits_q7 = ( 8 << 7 ) - SKP_Silk_lin2log( prob_Q8 );
- RD_Q25[ s ] = SKP_SMLABB( RD_Q25[ s ], bits_q7, SKP_RSHIFT( NLSF_mu_Q20, 2 ) );
- }
-
- /* Find the lowest rate-distortion error */
- SKP_Silk_insertion_sort_increasing( RD_Q25, &bestIndex, nSurvivors, 1 );
-
- NLSFIndices[ 0 ] = ( SKP_int8 )tempIndices1[ bestIndex ];
- SKP_memcpy( &NLSFIndices[ 1 ], &tempIndices2[ bestIndex * MAX_LPC_ORDER ], psNLSF_CB->order * sizeof( SKP_int8 ) );
-
- /* Decode */
- SKP_Silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB );
-
-#if STORE_LSF_DATA_FOR_TRAINING
- {
- /* code for training the codebooks */
- SKP_int32 RD_dec_Q22, Dist_Q22_dec, Rate_Q7, diff_Q15;
- ind1 = NLSFIndices[ 0 ];
- SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 );
-
- pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ ind1 * psNLSF_CB->order ];
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- NLSF_tmp_Q15[ i ] = SKP_LSHIFT16( ( SKP_int16 )pCB_element[ i ], 7 );
- }
- SKP_Silk_NLSF_VQ_weights_laroia( W_tmp_Q5, NLSF_tmp_Q15, psNLSF_CB->order );
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- W_tmp_Q9 = SKP_Silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) );
- res_Q15[ i ] = pNLSF_Q15_orig[ i ] - NLSF_tmp_Q15[ i ];
- res_Q10[ i ] = (SKP_int16)SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
- DEBUG_STORE_DATA( NLSF_res_q10.dat, &res_Q10[ i ], sizeof( SKP_int16 ) );
- res_Q15[ i ] = pNLSF_Q15[ i ] - NLSF_tmp_Q15[ i ];
- res_Q10[ i ] = (SKP_int16)SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 );
- DEBUG_STORE_DATA( NLSF_resq_q10.dat, &res_Q10[ i ], sizeof( SKP_int16 ) );
- }
-
- Dist_Q22_dec = 0;
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- diff_Q15 = pNLSF_Q15_orig[ i ] - pNLSF_Q15[ i ];
- Dist_Q22_dec += ( ( (diff_Q15 >> 5) * (diff_Q15 >> 5) ) * pW_Q5[ i ] ) >> 3;
- }
- iCDF_ptr = &psNLSF_CB->CB1_iCDF[ ( signalType >> 1 ) * psNLSF_CB->nVectors ];
- if( ind1 == 0 ) {
- prob_Q8 = 256 - iCDF_ptr[ ind1 ];
- } else {
- prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ];
- }
- Rate_Q7 = ( 8 << 7 ) - SKP_Silk_lin2log( prob_Q8 );
- for( i = 0; i < psNLSF_CB->order; i++ ) {
- Rate_Q7 += ((int)psNLSF_CB->ec_Rates_Q5[ ec_ix[ i ] + SKP_LIMIT( NLSFIndices[ i + 1 ] + NLSF_QUANT_MAX_AMPLITUDE, 0, 2 * NLSF_QUANT_MAX_AMPLITUDE ) ] ) << 2;
- if( SKP_abs( NLSFIndices[ i + 1 ] ) >= NLSF_QUANT_MAX_AMPLITUDE ) {
- Rate_Q7 += 128 << ( SKP_abs( NLSFIndices[ i + 1 ] ) - NLSF_QUANT_MAX_AMPLITUDE );
- }
- }
- RD_dec_Q22 = Dist_Q22_dec + Rate_Q7 * NLSF_mu_Q20 >> 5;
- DEBUG_STORE_DATA( dec_dist_q22.dat, &Dist_Q22_dec, sizeof( SKP_int32 ) );
- DEBUG_STORE_DATA( dec_rate_q7.dat, &Rate_Q7, sizeof( SKP_int32 ) );
- DEBUG_STORE_DATA( dec_rd_q22.dat, &RD_dec_Q22, sizeof( SKP_int32 ) );
- }
- DEBUG_STORE_DATA( NLSF_ind.dat, NLSFIndices, (psNLSF_CB->order+1) * sizeof( SKP_int8 ) );
-#endif
-
- return RD_Q25[ 0 ];
-}
--- a/silk/SKP_Silk_NLSF_stabilize.c
+++ /dev/null
@@ -1,138 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* NLSF stabilizer: */
-/* */
-/* - Moves NLSFs futher apart if they are too close */
-/* - Moves NLSFs away from borders if they are too close */
-/* - High effort to achieve a modification with minimum */
-/* Euclidean distance to input vector */
-/* - Output are sorted NLSF coefficients */
-/* */
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Constant Definitions */
-#define MAX_LOOPS 20
-
-/* NLSF stabilizer, for a single input data vector */
-void SKP_Silk_NLSF_stabilize(
- SKP_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
- const SKP_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */
- const SKP_int L /* I: Number of NLSF parameters in the input vector */
-)
-{
- SKP_int16 center_freq_Q15, diff_Q15, min_center_Q15, max_center_Q15;
- SKP_int32 min_diff_Q15;
- SKP_int loops;
- SKP_int i, I=0, k;
-
- /* This is necessary to ensure an output within range of a SKP_int16 */
- SKP_assert( NDeltaMin_Q15[L] >= 1 );
-
- for( loops = 0; loops < MAX_LOOPS; loops++ ) {
- /**************************/
- /* Find smallest distance */
- /**************************/
- /* First element */
- min_diff_Q15 = NLSF_Q15[0] - NDeltaMin_Q15[0];
- I = 0;
- /* Middle elements */
- for( i = 1; i <= L-1; i++ ) {
- diff_Q15 = NLSF_Q15[i] - ( NLSF_Q15[i-1] + NDeltaMin_Q15[i] );
- if( diff_Q15 < min_diff_Q15 ) {
- min_diff_Q15 = diff_Q15;
- I = i;
- }
- }
- /* Last element */
- diff_Q15 = (1<<15) - ( NLSF_Q15[L-1] + NDeltaMin_Q15[L] );
- if( diff_Q15 < min_diff_Q15 ) {
- min_diff_Q15 = diff_Q15;
- I = L;
- }
-
- /***************************************************/
- /* Now check if the smallest distance non-negative */
- /***************************************************/
- if (min_diff_Q15 >= 0) {
- return;
- }
-
- if( I == 0 ) {
- /* Move away from lower limit */
- NLSF_Q15[0] = NDeltaMin_Q15[0];
-
- } else if( I == L) {
- /* Move away from higher limit */
- NLSF_Q15[L-1] = (1<<15) - NDeltaMin_Q15[L];
-
- } else {
- /* Find the lower extreme for the location of the current center frequency */
- min_center_Q15 = 0;
- for( k = 0; k < I; k++ ) {
- min_center_Q15 += NDeltaMin_Q15[k];
- }
- min_center_Q15 += SKP_RSHIFT( NDeltaMin_Q15[I], 1 );
-
- /* Find the upper extreme for the location of the current center frequency */
- max_center_Q15 = (1<<15);
- for( k = L; k > I; k-- ) {
- max_center_Q15 -= NDeltaMin_Q15[k];
- }
- max_center_Q15 -= ( NDeltaMin_Q15[I] - SKP_RSHIFT( NDeltaMin_Q15[I], 1 ) );
-
- /* Move apart, sorted by value, keeping the same center frequency */
- center_freq_Q15 = (SKP_int16)SKP_LIMIT_32( SKP_RSHIFT_ROUND( (SKP_int32)NLSF_Q15[I-1] + (SKP_int32)NLSF_Q15[I], 1 ),
- min_center_Q15, max_center_Q15 );
- NLSF_Q15[I-1] = center_freq_Q15 - SKP_RSHIFT( NDeltaMin_Q15[I], 1 );
- NLSF_Q15[I] = NLSF_Q15[I-1] + NDeltaMin_Q15[I];
- }
- }
-
- /* Safe and simple fall back method, which is less ideal than the above */
- if( loops == MAX_LOOPS )
- {
- /* Insertion sort (fast for already almost sorted arrays): */
- /* Best case: O(n) for an already sorted array */
- /* Worst case: O(n^2) for an inversely sorted array */
- SKP_Silk_insertion_sort_increasing_all_values_int16( &NLSF_Q15[0], L );
-
- /* First NLSF should be no less than NDeltaMin[0] */
- NLSF_Q15[0] = SKP_max_int( NLSF_Q15[0], NDeltaMin_Q15[0] );
-
- /* Keep delta_min distance between the NLSFs */
- for( i = 1; i < L; i++ )
- NLSF_Q15[i] = SKP_max_int( NLSF_Q15[i], NLSF_Q15[i-1] + NDeltaMin_Q15[i] );
-
- /* Last NLSF should be no higher than 1 - NDeltaMin[L] */
- NLSF_Q15[L-1] = SKP_min_int( NLSF_Q15[L-1], (1<<15) - NDeltaMin_Q15[L] );
-
- /* Keep NDeltaMin distance between the NLSFs */
- for( i = L-2; i >= 0; i-- )
- NLSF_Q15[i] = SKP_min_int( NLSF_Q15[i], NLSF_Q15[i+1] - NDeltaMin_Q15[i+1] );
- }
-}
--- a/silk/SKP_Silk_NLSF_unpack.c
+++ /dev/null
@@ -1,51 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Unpack predictor values and indices for entropy coding tables */
-void SKP_Silk_NLSF_unpack(
- SKP_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */
- SKP_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */
- const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
- const SKP_int CB1_index /* I Index of vector in first LSF codebook */
-)
-{
- SKP_int i;
- SKP_uint8 entry;
- const SKP_uint8 *ec_sel_ptr;
-
- ec_sel_ptr = &psNLSF_CB->ec_sel[ CB1_index * psNLSF_CB->order / 2 ];
- for( i = 0; i < psNLSF_CB->order; i += 2 ) {
- entry = *ec_sel_ptr++;
- ec_ix [ i ] = SKP_SMULBB( SKP_RSHIFT( entry, 1 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 );
- pred_Q8[ i ] = psNLSF_CB->pred_Q8[ i + ( entry & 1 ) * ( psNLSF_CB->order - 1 ) ];
- ec_ix [ i + 1 ] = SKP_SMULBB( SKP_RSHIFT( entry, 5 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 );
- pred_Q8[ i + 1 ] = psNLSF_CB->pred_Q8[ i + ( SKP_RSHIFT( entry, 4 ) & 1 ) * ( psNLSF_CB->order - 1 ) + 1 ];
- }
-}
-
--- a/silk/SKP_Silk_NSQ.c
+++ /dev/null
@@ -1,427 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-SKP_INLINE void SKP_Silk_nsq_scale_states(
- const SKP_Silk_encoder_state *psEncC, /* I Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- const SKP_int16 x[], /* I input in Q0 */
- SKP_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
- const SKP_int16 sLTP[], /* I re-whitened LTP state in Q0 */
- SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
- SKP_int subfr, /* I subframe number */
- const SKP_int LTP_scale_Q14, /* I */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ] /* I */
-);
-
-SKP_INLINE void SKP_Silk_noise_shape_quantizer(
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- SKP_int signalType, /* I Signal type */
- const SKP_int32 x_sc_Q10[], /* I */
- SKP_int8 pulses[], /* O */
- SKP_int16 xq[], /* O */
- SKP_int32 sLTP_Q16[], /* I/O LTP state */
- const SKP_int16 a_Q12[], /* I Short term prediction coefs */
- const SKP_int16 b_Q14[], /* I Long term prediction coefs */
- const SKP_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
- SKP_int lag, /* I Pitch lag */
- SKP_int32 HarmShapeFIRPacked_Q14, /* I */
- SKP_int Tilt_Q14, /* I Spectral tilt */
- SKP_int32 LF_shp_Q14, /* I */
- SKP_int32 Gain_Q16, /* I */
- SKP_int Lambda_Q10, /* I */
- SKP_int offset_Q10, /* I */
- SKP_int length, /* I Input length */
- SKP_int shapingLPCOrder, /* I Noise shaping AR filter order */
- SKP_int predictLPCOrder /* I Prediction filter order */
-);
-
-void SKP_Silk_NSQ(
- const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- SideInfoIndices *psIndices, /* I/O Quantization Indices */
- const SKP_int16 x[], /* I prefiltered input signal */
- SKP_int8 pulses[], /* O quantized qulse signal */
- const SKP_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefficients */
- const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefficients */
- const SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
- const SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
- const SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ], /* I */
- const SKP_int Lambda_Q10, /* I */
- const SKP_int LTP_scale_Q14 /* I LTP state scaling */
-)
-{
- SKP_int k, lag, start_idx, LSF_interpolation_flag;
- const SKP_int16 *A_Q12, *B_Q14, *AR_shp_Q13;
- SKP_int16 *pxq;
- SKP_int32 sLTP_Q16[ 2 * MAX_FRAME_LENGTH ];
- SKP_int16 sLTP[ 2 * MAX_FRAME_LENGTH ];
- SKP_int32 HarmShapeFIRPacked_Q14;
- SKP_int offset_Q10;
- SKP_int32 x_sc_Q10[ MAX_FRAME_LENGTH / MAX_NB_SUBFR ];
-
- NSQ->rand_seed = psIndices->Seed;
-
- /* Set unvoiced lag to the previous one, overwrite later for voiced */
- lag = NSQ->lagPrev;
-
- SKP_assert( NSQ->prev_inv_gain_Q16 != 0 );
-
- offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ];
-
- if( psIndices->NLSFInterpCoef_Q2 == 4 ) {
- LSF_interpolation_flag = 0;
- } else {
- LSF_interpolation_flag = 1;
- }
-
- /* Setup pointers to start of sub frame */
- NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length;
- NSQ->sLTP_buf_idx = psEncC->ltp_mem_length;
- pxq = &NSQ->xq[ psEncC->ltp_mem_length ];
- for( k = 0; k < psEncC->nb_subfr; k++ ) {
- A_Q12 = &PredCoef_Q12[ (( k >> 1 ) | ( 1 - LSF_interpolation_flag )) * MAX_LPC_ORDER ];
- B_Q14 = <PCoef_Q14[ k * LTP_ORDER ];
- AR_shp_Q13 = &AR2_Q13[ k * MAX_SHAPE_LPC_ORDER ];
-
- /* Noise shape parameters */
- SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );
- HarmShapeFIRPacked_Q14 = SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );
- HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );
-
- NSQ->rewhite_flag = 0;
- if( psIndices->signalType == TYPE_VOICED ) {
- /* Voiced */
- lag = pitchL[ k ];
-
- /* Re-whitening */
- if( ( k & ( 3 - SKP_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) {
- /* Rewhiten with new A coefs */
- start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2;
- SKP_assert( start_idx > 0 );
-
- SKP_Silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ],
- A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder );
-
- NSQ->rewhite_flag = 1;
- NSQ->sLTP_buf_idx = psEncC->ltp_mem_length;
- }
- }
-
- SKP_Silk_nsq_scale_states( psEncC, NSQ, x, x_sc_Q10, sLTP, sLTP_Q16, k, LTP_scale_Q14, Gains_Q16, pitchL );
-
- SKP_Silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q16, A_Q12, B_Q14,
- AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10,
- offset_Q10, psEncC->subfr_length, psEncC->shapingLPCOrder, psEncC->predictLPCOrder );
-
- x += psEncC->subfr_length;
- pulses += psEncC->subfr_length;
- pxq += psEncC->subfr_length;
- }
-
- /* Update lagPrev for next frame */
- NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ];
-
- /* Save quantized speech and noise shaping signals */
- SKP_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int16 ) );
- SKP_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int32 ) );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int16 ) );
- DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int8 ) );
- DEBUG_STORE_DATA( sLTP_Q16.dat, &sLTP_Q16[ psEncC->ltp_mem_length ], psEncC->frame_length * sizeof( SKP_int32 ) );
-#endif
-}
-
-/***********************************/
-/* SKP_Silk_noise_shape_quantizer */
-/***********************************/
-SKP_INLINE void SKP_Silk_noise_shape_quantizer(
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- SKP_int signalType, /* I Signal type */
- const SKP_int32 x_sc_Q10[], /* I */
- SKP_int8 pulses[], /* O */
- SKP_int16 xq[], /* O */
- SKP_int32 sLTP_Q16[], /* I/O LTP state */
- const SKP_int16 a_Q12[], /* I Short term prediction coefs */
- const SKP_int16 b_Q14[], /* I Long term prediction coefs */
- const SKP_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */
- SKP_int lag, /* I Pitch lag */
- SKP_int32 HarmShapeFIRPacked_Q14, /* I */
- SKP_int Tilt_Q14, /* I Spectral tilt */
- SKP_int32 LF_shp_Q14, /* I */
- SKP_int32 Gain_Q16, /* I */
- SKP_int Lambda_Q10, /* I */
- SKP_int offset_Q10, /* I */
- SKP_int length, /* I Input length */
- SKP_int shapingLPCOrder, /* I Noise shaping AR filter order */
- SKP_int predictLPCOrder /* I Prediction filter order */
-)
-{
- SKP_int i, j;
- SKP_int32 LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14;
- SKP_int32 n_LF_Q10, r_Q10, rr_Q10, q1_Q10, q2_Q10, rd1_Q10, rd2_Q10;
- SKP_int32 dither, exc_Q10, LPC_exc_Q10, xq_Q10;
- SKP_int32 tmp1, tmp2, sLF_AR_shp_Q10;
- SKP_int32 *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr;
-
- shp_lag_ptr = &NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ];
- pred_lag_ptr = &sLTP_Q16[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ];
-
- /* Setup short term AR state */
- psLPC_Q14 = &NSQ->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 ];
-
- for( i = 0; i < length; i++ ) {
- /* Generate dither */
- NSQ->rand_seed = SKP_RAND( NSQ->rand_seed );
-
- /* dither = rand_seed < 0 ? 0xFFFFFFFF : 0; */
- dither = SKP_RSHIFT( NSQ->rand_seed, 31 );
-
- /* Short-term prediction */
- SKP_assert( ( predictLPCOrder & 1 ) == 0 ); /* check that order is even */
- SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */
- SKP_assert( predictLPCOrder >= 10 ); /* check that unrolling works */
-
- /* Partially unrolled */
- LPC_pred_Q10 = SKP_SMULWB( psLPC_Q14[ 0 ], a_Q12[ 0 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -1 ], a_Q12[ 1 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -2 ], a_Q12[ 2 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -3 ], a_Q12[ 3 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -4 ], a_Q12[ 4 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -5 ], a_Q12[ 5 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -6 ], a_Q12[ 6 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -7 ], a_Q12[ 7 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -8 ], a_Q12[ 8 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -9 ], a_Q12[ 9 ] );
- for( j = 10; j < predictLPCOrder; j ++ ) {
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -j ], a_Q12[ j ] );
- }
-
- /* Long-term prediction */
- if( signalType == TYPE_VOICED ) {
- /* Unrolled loop */
- LTP_pred_Q14 = SKP_SMULWB( pred_lag_ptr[ 0 ], b_Q14[ 0 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], b_Q14[ 1 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -2 ], b_Q14[ 2 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -3 ], b_Q14[ 3 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], b_Q14[ 4 ] );
- pred_lag_ptr++;
- } else {
- LTP_pred_Q14 = 0;
- }
-
- /* Noise shape feedback */
- SKP_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */
- tmp2 = psLPC_Q14[ 0 ];
- tmp1 = NSQ->sAR2_Q14[ 0 ];
- NSQ->sAR2_Q14[ 0 ] = tmp2;
- n_AR_Q10 = SKP_SMULWB( tmp2, AR_shp_Q13[ 0 ] );
- for( j = 2; j < shapingLPCOrder; j += 2 ) {
- tmp2 = NSQ->sAR2_Q14[ j - 1 ];
- NSQ->sAR2_Q14[ j - 1 ] = tmp1;
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ j - 1 ] );
- tmp1 = NSQ->sAR2_Q14[ j + 0 ];
- NSQ->sAR2_Q14[ j + 0 ] = tmp2;
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp2, AR_shp_Q13[ j ] );
- }
- NSQ->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1;
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] );
-
- n_AR_Q10 = SKP_RSHIFT( n_AR_Q10, 1 ); /* Q11 -> Q10 */
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, NSQ->sLF_AR_shp_Q12, Tilt_Q14 );
-
- n_LF_Q10 = SKP_LSHIFT( SKP_SMULWB( NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - 1 ], LF_shp_Q14 ), 2 );
- n_LF_Q10 = SKP_SMLAWT( n_LF_Q10, NSQ->sLF_AR_shp_Q12, LF_shp_Q14 );
-
- SKP_assert( lag > 0 || signalType != TYPE_VOICED );
-
- /* Long-term shaping */
- if( lag > 0 ) {
- /* Symmetric, packed FIR coefficients */
- n_LTP_Q14 = SKP_SMULWB( SKP_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );
- n_LTP_Q14 = SKP_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 );
- n_LTP_Q14 = SKP_LSHIFT( n_LTP_Q14, 6 );
- shp_lag_ptr++;
-
- tmp1 = SKP_SUB32( LTP_pred_Q14, n_LTP_Q14 ); /* Add Q14 stuff */
- tmp1 = SKP_RSHIFT( tmp1, 4 ); /* convert to Q10 */
- tmp1 = SKP_ADD32( tmp1, LPC_pred_Q10 ); /* add Q10 stuff */
- tmp1 = SKP_SUB32( tmp1, n_AR_Q10 ); /* subtract Q10 stuff */
- } else {
- tmp1 = SKP_SUB32( LPC_pred_Q10, n_AR_Q10 ); /* subtract Q10 stuff */
- }
-
- /* Input minus prediction plus noise feedback */
- //r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP;
- tmp1 = SKP_SUB32( tmp1, n_LF_Q10 ); /* subtract Q10 stuff */
- r_Q10 = SKP_SUB32( x_sc_Q10[ i ], tmp1 );
-
- /* Flip sign depending on dither */
- r_Q10 = r_Q10 ^ dither;
- r_Q10 = SKP_LIMIT_32( r_Q10, -31 << 10, 30 << 10 );
-
- /* Find two quantization level candidates and measure their rate-distortion */
- q1_Q10 = SKP_SUB32( r_Q10, offset_Q10 );
- q1_Q10 = SKP_RSHIFT( q1_Q10, 10 );
- if( q1_Q10 > 0 ) {
- q1_Q10 = SKP_SUB32( SKP_LSHIFT( q1_Q10, 10 ), QUANT_LEVEL_ADJUST_Q10 );
- q1_Q10 = SKP_ADD32( q1_Q10, offset_Q10 );
- q2_Q10 = SKP_ADD32( q1_Q10, 1024 );
- rd1_Q10 = SKP_SMULBB( q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( q2_Q10, Lambda_Q10 );
- } else if( q1_Q10 == 0 ) {
- q1_Q10 = offset_Q10;
- q2_Q10 = SKP_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 );
- rd1_Q10 = SKP_SMULBB( q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( q2_Q10, Lambda_Q10 );
- } else if( q1_Q10 == -1 ) {
- q2_Q10 = offset_Q10;
- q1_Q10 = SKP_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 );
- rd1_Q10 = SKP_SMULBB( -q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( q2_Q10, Lambda_Q10 );
- } else { /* Q1_Q10 < -1 */
- q1_Q10 = SKP_ADD32( SKP_LSHIFT( q1_Q10, 10 ), QUANT_LEVEL_ADJUST_Q10 );
- q1_Q10 = SKP_ADD32( q1_Q10, offset_Q10 );
- q2_Q10 = SKP_ADD32( q1_Q10, 1024 );
- rd1_Q10 = SKP_SMULBB( -q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( -q2_Q10, Lambda_Q10 );
- }
- rr_Q10 = SKP_SUB32( r_Q10, q1_Q10 );
- rd1_Q10 = SKP_RSHIFT( SKP_SMLABB( rd1_Q10, rr_Q10, rr_Q10 ), 10 );
- rr_Q10 = SKP_SUB32( r_Q10, q2_Q10 );
- rd2_Q10 = SKP_RSHIFT( SKP_SMLABB( rd2_Q10, rr_Q10, rr_Q10 ), 10 );
-
- if( rd2_Q10 < rd1_Q10 ) {
- q1_Q10 = q2_Q10;
- }
-
- pulses[ i ] = ( SKP_int8 )SKP_RSHIFT_ROUND( q1_Q10, 10 );
-
- /* Excitation */
- exc_Q10 = q1_Q10 ^ dither;
-
- /* Add predictions */
- LPC_exc_Q10 = SKP_ADD32( exc_Q10, SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) );
- xq_Q10 = SKP_ADD32( LPC_exc_Q10, LPC_pred_Q10 );
-
- /* Scale XQ back to normal level before saving */
- xq[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( xq_Q10, Gain_Q16 ), 10 ) );
-
- /* Update states */
- psLPC_Q14++;
- *psLPC_Q14 = SKP_LSHIFT( xq_Q10, 4 );
- sLF_AR_shp_Q10 = SKP_SUB32( xq_Q10, n_AR_Q10 );
- NSQ->sLF_AR_shp_Q12 = SKP_LSHIFT( sLF_AR_shp_Q10, 2 );
-
- NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx ] = SKP_SUB32( sLF_AR_shp_Q10, n_LF_Q10 );
- sLTP_Q16[ NSQ->sLTP_buf_idx ] = SKP_LSHIFT( LPC_exc_Q10, 6 );
- NSQ->sLTP_shp_buf_idx++;
- NSQ->sLTP_buf_idx++;
-
- /* Make dither dependent on quantized signal */
- NSQ->rand_seed += pulses[ i ];
- }
-
- /* Update LPC synth buffer */
- SKP_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
-}
-
-SKP_INLINE void SKP_Silk_nsq_scale_states(
- const SKP_Silk_encoder_state *psEncC, /* I Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- const SKP_int16 x[], /* I input in Q0 */
- SKP_int32 x_sc_Q10[], /* O input scaled with 1/Gain */
- const SKP_int16 sLTP[], /* I re-whitened LTP state in Q0 */
- SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
- SKP_int subfr, /* I subframe number */
- const SKP_int LTP_scale_Q14, /* I */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ] /* I */
-)
-{
- SKP_int i, lag;
- SKP_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;
-
- inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );
- inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );
- lag = pitchL[ subfr ];
-
- /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */
- if( NSQ->rewhite_flag ) {
- inv_gain_Q32 = SKP_LSHIFT( inv_gain_Q16, 16 );
- if( subfr == 0 ) {
- /* Do LTP downscaling */
- inv_gain_Q32 = SKP_LSHIFT( SKP_SMULWB( inv_gain_Q32, LTP_scale_Q14 ), 2 );
- }
- for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {
- SKP_assert( i < MAX_FRAME_LENGTH );
- sLTP_Q16[ i ] = SKP_SMULWB( inv_gain_Q32, sLTP[ i ] );
- }
- }
-
- /* Adjust for changing gain */
- if( inv_gain_Q16 != NSQ->prev_inv_gain_Q16 ) {
- gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 );
-
- /* Scale long-term shaping state */
- for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx; i++ ) {
- NSQ->sLTP_shp_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q10[ i ] );
- }
-
- /* Scale long-term prediction state */
- if( NSQ->rewhite_flag == 0 ) {
- for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {
- sLTP_Q16[ i ] = SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] );
- }
- }
-
- NSQ->sLF_AR_shp_Q12 = SKP_SMULWW( gain_adj_Q16, NSQ->sLF_AR_shp_Q12 );
-
- /* Scale short-term prediction and shaping states */
- for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) {
- NSQ->sLPC_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLPC_Q14[ i ] );
- }
- for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) {
- NSQ->sAR2_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] );
- }
- }
-
- /* Scale input */
- for( i = 0; i < psEncC->subfr_length; i++ ) {
- x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( SKP_int16 )inv_gain_Q16 ), 6 );
- }
-
- /* save inv_gain */
- SKP_assert( inv_gain_Q16 != 0 );
- NSQ->prev_inv_gain_Q16 = inv_gain_Q16;
-}
--- a/silk/SKP_Silk_NSQ_del_dec.c
+++ /dev/null
@@ -1,680 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-typedef struct {
- SKP_int32 sLPC_Q14[ MAX_FRAME_LENGTH / MAX_NB_SUBFR + NSQ_LPC_BUF_LENGTH ];
- SKP_int32 RandState[ DECISION_DELAY ];
- SKP_int32 Q_Q10[ DECISION_DELAY ];
- SKP_int32 Xq_Q10[ DECISION_DELAY ];
- SKP_int32 Pred_Q16[ DECISION_DELAY ];
- SKP_int32 Shape_Q10[ DECISION_DELAY ];
- SKP_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ];
- SKP_int32 LF_AR_Q12;
- SKP_int32 Seed;
- SKP_int32 SeedInit;
- SKP_int32 RD_Q10;
-} NSQ_del_dec_struct;
-
-typedef struct {
- SKP_int32 Q_Q10;
- SKP_int32 RD_Q10;
- SKP_int32 xq_Q14;
- SKP_int32 LF_AR_Q12;
- SKP_int32 sLTP_shp_Q10;
- SKP_int32 LPC_exc_Q16;
-} NSQ_sample_struct;
-
-SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
- const SKP_Silk_encoder_state *psEncC, /* I Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
- const SKP_int16 x[], /* I Input in Q0 */
- SKP_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
- const SKP_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
- SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
- SKP_int subfr, /* I Subframe number */
- SKP_int nStatesDelayedDecision, /* I Number of del dec states */
- SKP_int smpl_buf_idx, /* I Index to newest samples in buffers */
- const SKP_int LTP_scale_Q14, /* I LTP state scaling */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ] /* I Pitch lag */
-);
-
-/******************************************/
-/* Noise shape quantizer for one subframe */
-/******************************************/
-SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
- SKP_int signalType, /* I Signal type */
- const SKP_int32 x_Q10[], /* I */
- SKP_int8 pulses[], /* O */
- SKP_int16 xq[], /* O */
- SKP_int32 sLTP_Q16[], /* I/O LTP filter state */
- SKP_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
- const SKP_int16 a_Q12[], /* I Short term prediction coefs */
- const SKP_int16 b_Q14[], /* I Long term prediction coefs */
- const SKP_int16 AR_shp_Q13[], /* I Noise shaping coefs */
- SKP_int lag, /* I Pitch lag */
- SKP_int32 HarmShapeFIRPacked_Q14, /* I */
- SKP_int Tilt_Q14, /* I Spectral tilt */
- SKP_int32 LF_shp_Q14, /* I */
- SKP_int32 Gain_Q16, /* I */
- SKP_int Lambda_Q10, /* I */
- SKP_int offset_Q10, /* I */
- SKP_int length, /* I Input length */
- SKP_int subfr, /* I Subframe number */
- SKP_int shapingLPCOrder, /* I Shaping LPC filter order */
- SKP_int predictLPCOrder, /* I Prediction filter order */
- SKP_int warping_Q16, /* I */
- SKP_int nStatesDelayedDecision, /* I Number of states in decision tree */
- SKP_int *smpl_buf_idx, /* I Index to newest samples in buffers */
- SKP_int decisionDelay /* I */
-);
-
-void SKP_Silk_NSQ_del_dec(
- const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- SideInfoIndices *psIndices, /* I/O Quantization Indices */
- const SKP_int16 x[], /* I Prefiltered input signal */
- SKP_int8 pulses[], /* O Quantized pulse signal */
- const SKP_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Prediction coefs */
- const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I LT prediction coefs */
- const SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
- const SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
- const SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ], /* I */
- const SKP_int Lambda_Q10, /* I */
- const SKP_int LTP_scale_Q14 /* I LTP state scaling */
-)
-{
- SKP_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
- SKP_int last_smple_idx, smpl_buf_idx, decisionDelay;
- const SKP_int16 *A_Q12, *B_Q14, *AR_shp_Q13;
- SKP_int16 *pxq;
- SKP_int32 sLTP_Q16[ 2 * MAX_FRAME_LENGTH ];
- SKP_int16 sLTP[ 2 * MAX_FRAME_LENGTH ];
- SKP_int32 HarmShapeFIRPacked_Q14;
- SKP_int offset_Q10;
- SKP_int32 RDmin_Q10;
- SKP_int32 x_sc_Q10[ MAX_SUB_FRAME_LENGTH ];
- SKP_int32 delayedGain_Q16[ DECISION_DELAY ];
- NSQ_del_dec_struct psDelDec[ MAX_DEL_DEC_STATES ];
- NSQ_del_dec_struct *psDD;
-
- /* Set unvoiced lag to the previous one, overwrite later for voiced */
- lag = NSQ->lagPrev;
-
- SKP_assert( NSQ->prev_inv_gain_Q16 != 0 );
-
- /* Initialize delayed decision states */
- SKP_memset( psDelDec, 0, psEncC->nStatesDelayedDecision * sizeof( NSQ_del_dec_struct ) );
- for( k = 0; k < psEncC->nStatesDelayedDecision; k++ ) {
- psDD = &psDelDec[ k ];
- psDD->Seed = ( k + psIndices->Seed ) & 3;
- psDD->SeedInit = psDD->Seed;
- psDD->RD_Q10 = 0;
- psDD->LF_AR_Q12 = NSQ->sLF_AR_shp_Q12;
- psDD->Shape_Q10[ 0 ] = NSQ->sLTP_shp_Q10[ psEncC->ltp_mem_length - 1 ];
- SKP_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
- SKP_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) );
- }
-
- offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ];
- smpl_buf_idx = 0; /* index of oldest samples */
-
- decisionDelay = SKP_min_int( DECISION_DELAY, psEncC->subfr_length );
-
- /* For voiced frames limit the decision delay to lower than the pitch lag */
- if( psIndices->signalType == TYPE_VOICED ) {
- for( k = 0; k < psEncC->nb_subfr; k++ ) {
- decisionDelay = SKP_min_int( decisionDelay, pitchL[ k ] - LTP_ORDER / 2 - 1 );
- }
- } else {
- if( lag > 0 ) {
- decisionDelay = SKP_min_int( decisionDelay, lag - LTP_ORDER / 2 - 1 );
- }
- }
-
- if( psIndices->NLSFInterpCoef_Q2 == 4 ) {
- LSF_interpolation_flag = 0;
- } else {
- LSF_interpolation_flag = 1;
- }
-
- /* Setup pointers to start of sub frame */
- pxq = &NSQ->xq[ psEncC->ltp_mem_length ];
- NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length;
- NSQ->sLTP_buf_idx = psEncC->ltp_mem_length;
- subfr = 0;
- for( k = 0; k < psEncC->nb_subfr; k++ ) {
- A_Q12 = &PredCoef_Q12[ ( ( k >> 1 ) | ( 1 - LSF_interpolation_flag ) ) * MAX_LPC_ORDER ];
- B_Q14 = <PCoef_Q14[ k * LTP_ORDER ];
- AR_shp_Q13 = &AR2_Q13[ k * MAX_SHAPE_LPC_ORDER ];
-
- /* Noise shape parameters */
- SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );
- HarmShapeFIRPacked_Q14 = SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );
- HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );
-
- NSQ->rewhite_flag = 0;
- if( psIndices->signalType == TYPE_VOICED ) {
- /* Voiced */
- lag = pitchL[ k ];
-
- /* Re-whitening */
- if( ( k & ( 3 - SKP_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) {
- if( k == 2 ) {
- /* RESET DELAYED DECISIONS */
- /* Find winner */
- RDmin_Q10 = psDelDec[ 0 ].RD_Q10;
- Winner_ind = 0;
- for( i = 1; i < psEncC->nStatesDelayedDecision; i++ ) {
- if( psDelDec[ i ].RD_Q10 < RDmin_Q10 ) {
- RDmin_Q10 = psDelDec[ i ].RD_Q10;
- Winner_ind = i;
- }
- }
- for( i = 0; i < psEncC->nStatesDelayedDecision; i++ ) {
- if( i != Winner_ind ) {
- psDelDec[ i ].RD_Q10 += ( SKP_int32_MAX >> 4 );
- SKP_assert( psDelDec[ i ].RD_Q10 >= 0 );
- }
- }
-
- /* Copy final part of signals from winner state to output and long-term filter states */
- psDD = &psDelDec[ Winner_ind ];
- last_smple_idx = smpl_buf_idx + decisionDelay;
- for( i = 0; i < decisionDelay; i++ ) {
- last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;
- pulses[ i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
- pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
- SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], Gains_Q16[ 1 ] ), 10 ) );
- NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q10[ last_smple_idx ];
- }
-
- subfr = 0;
- }
-
- /* Rewhiten with new A coefs */
- start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2;
- SKP_assert( start_idx > 0 );
-
- SKP_Silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ],
- A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder );
-
- NSQ->sLTP_buf_idx = psEncC->ltp_mem_length;
- NSQ->rewhite_flag = 1;
- }
- }
-
- SKP_Silk_nsq_del_dec_scale_states( psEncC, NSQ, psDelDec, x, x_sc_Q10, sLTP, sLTP_Q16, k,
- psEncC->nStatesDelayedDecision, smpl_buf_idx, LTP_scale_Q14, Gains_Q16, pitchL );
-
- SKP_Silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q16,
- delayedGain_Q16, A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ],
- Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder,
- psEncC->predictLPCOrder, psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay );
-
- x += psEncC->subfr_length;
- pulses += psEncC->subfr_length;
- pxq += psEncC->subfr_length;
- }
-
- /* Find winner */
- RDmin_Q10 = psDelDec[ 0 ].RD_Q10;
- Winner_ind = 0;
- for( k = 1; k < psEncC->nStatesDelayedDecision; k++ ) {
- if( psDelDec[ k ].RD_Q10 < RDmin_Q10 ) {
- RDmin_Q10 = psDelDec[ k ].RD_Q10;
- Winner_ind = k;
- }
- }
-
- /* Copy final part of signals from winner state to output and long-term filter states */
- psDD = &psDelDec[ Winner_ind ];
- psIndices->Seed = psDD->SeedInit;
- last_smple_idx = smpl_buf_idx + decisionDelay;
- for( i = 0; i < decisionDelay; i++ ) {
- last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;
- pulses[ i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
- pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
- SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], Gains_Q16[ psEncC->nb_subfr - 1 ] ), 10 ) );
- NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q10[ last_smple_idx ];
- sLTP_Q16[ NSQ->sLTP_buf_idx - decisionDelay + i ] = psDD->Pred_Q16[ last_smple_idx ];
- }
- SKP_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
- SKP_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) );
-
- /* Update states */
- NSQ->sLF_AR_shp_Q12 = psDD->LF_AR_Q12;
- NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ];
-
- /* Save quantized speech and noise shaping signals */
- SKP_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int16 ) );
- SKP_memmove( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( SKP_int32 ) );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( xq.dat, &pxq[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int16 ) );
- DEBUG_STORE_DATA( q.dat, &pulses[ -psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int8 ) );
- DEBUG_STORE_DATA( sLTP_Q16.dat, &sLTP_Q16[ psEncC->ltp_mem_length ], psEncC->frame_length * sizeof( SKP_int32 ) );
-#endif
-}
-
-/******************************************/
-/* Noise shape quantizer for one subframe */
-/******************************************/
-SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
- SKP_int signalType, /* I Signal type */
- const SKP_int32 x_Q10[], /* I */
- SKP_int8 pulses[], /* O */
- SKP_int16 xq[], /* O */
- SKP_int32 sLTP_Q16[], /* I/O LTP filter state */
- SKP_int32 delayedGain_Q16[], /* I/O Gain delay buffer */
- const SKP_int16 a_Q12[], /* I Short term prediction coefs */
- const SKP_int16 b_Q14[], /* I Long term prediction coefs */
- const SKP_int16 AR_shp_Q13[], /* I Noise shaping coefs */
- SKP_int lag, /* I Pitch lag */
- SKP_int32 HarmShapeFIRPacked_Q14, /* I */
- SKP_int Tilt_Q14, /* I Spectral tilt */
- SKP_int32 LF_shp_Q14, /* I */
- SKP_int32 Gain_Q16, /* I */
- SKP_int Lambda_Q10, /* I */
- SKP_int offset_Q10, /* I */
- SKP_int length, /* I Input length */
- SKP_int subfr, /* I Subframe number */
- SKP_int shapingLPCOrder, /* I Shaping LPC filter order */
- SKP_int predictLPCOrder, /* I Prediction filter order */
- SKP_int warping_Q16, /* I */
- SKP_int nStatesDelayedDecision, /* I Number of states in decision tree */
- SKP_int *smpl_buf_idx, /* I Index to newest samples in buffers */
- SKP_int decisionDelay /* I */
-)
-{
- SKP_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;
- SKP_int32 Winner_rand_state;
- SKP_int32 LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14, LTP_Q10;
- SKP_int32 n_LF_Q10, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10;
- SKP_int32 q1_Q10, q2_Q10, dither, exc_Q10, LPC_exc_Q10, xq_Q10;
- SKP_int32 tmp1, tmp2, sLF_AR_shp_Q10;
- SKP_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14;
- NSQ_sample_struct psSampleState[ MAX_DEL_DEC_STATES ][ 2 ];
- NSQ_del_dec_struct *psDD;
- NSQ_sample_struct *psSS;
-
- shp_lag_ptr = &NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ];
- pred_lag_ptr = &sLTP_Q16[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ];
-
- for( i = 0; i < length; i++ ) {
- /* Perform common calculations used in all states */
-
- /* Long-term prediction */
- if( signalType == TYPE_VOICED ) {
- /* Unrolled loop */
- LTP_pred_Q14 = SKP_SMULWB( pred_lag_ptr[ 0 ], b_Q14[ 0 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], b_Q14[ 1 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -2 ], b_Q14[ 2 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -3 ], b_Q14[ 3 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], b_Q14[ 4 ] );
- pred_lag_ptr++;
- } else {
- LTP_pred_Q14 = 0;
- }
-
- /* Long-term shaping */
- if( lag > 0 ) {
- /* Symmetric, packed FIR coefficients */
- n_LTP_Q14 = SKP_SMULWB( SKP_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );
- n_LTP_Q14 = SKP_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 );
- n_LTP_Q14 = SKP_LSHIFT( n_LTP_Q14, 6 );
- shp_lag_ptr++;
-
- LTP_Q10 = SKP_RSHIFT( SKP_SUB32( LTP_pred_Q14, n_LTP_Q14 ), 4 );
- } else {
- LTP_Q10 = 0;
- }
-
- for( k = 0; k < nStatesDelayedDecision; k++ ) {
- /* Delayed decision state */
- psDD = &psDelDec[ k ];
-
- /* Sample state */
- psSS = psSampleState[ k ];
-
- /* Generate dither */
- psDD->Seed = SKP_RAND( psDD->Seed );
-
- /* dither = rand_seed < 0 ? 0xFFFFFFFF : 0; */
- dither = SKP_RSHIFT( psDD->Seed, 31 );
-
- /* Pointer used in short term prediction and shaping */
- psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ];
- /* Short-term prediction */
- SKP_assert( predictLPCOrder >= 10 ); /* check that unrolling works */
- SKP_assert( ( predictLPCOrder & 1 ) == 0 ); /* check that order is even */
- SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 ); /* check that array starts at 4-byte aligned address */
- /* Partially unrolled */
- LPC_pred_Q10 = SKP_SMULWB( psLPC_Q14[ 0 ], a_Q12[ 0 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -1 ], a_Q12[ 1 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -2 ], a_Q12[ 2 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -3 ], a_Q12[ 3 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -4 ], a_Q12[ 4 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -5 ], a_Q12[ 5 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -6 ], a_Q12[ 6 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -7 ], a_Q12[ 7 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -8 ], a_Q12[ 8 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -9 ], a_Q12[ 9 ] );
- for( j = 10; j < predictLPCOrder; j ++ ) {
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -j ], a_Q12[ j ] );
- }
-
- /* Noise shape feedback */
- SKP_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */
- /* Output of lowpass section */
- tmp2 = SKP_SMLAWB( psLPC_Q14[ 0 ], psDD->sAR2_Q14[ 0 ], warping_Q16 );
- /* Output of allpass section */
- tmp1 = SKP_SMLAWB( psDD->sAR2_Q14[ 0 ], psDD->sAR2_Q14[ 1 ] - tmp2, warping_Q16 );
- psDD->sAR2_Q14[ 0 ] = tmp2;
- n_AR_Q10 = SKP_SMULWB( tmp2, AR_shp_Q13[ 0 ] );
- /* Loop over allpass sections */
- for( j = 2; j < shapingLPCOrder; j += 2 ) {
- /* Output of allpass section */
- tmp2 = SKP_SMLAWB( psDD->sAR2_Q14[ j - 1 ], psDD->sAR2_Q14[ j + 0 ] - tmp1, warping_Q16 );
- psDD->sAR2_Q14[ j - 1 ] = tmp1;
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ j - 1 ] );
- /* Output of allpass section */
- tmp1 = SKP_SMLAWB( psDD->sAR2_Q14[ j + 0 ], psDD->sAR2_Q14[ j + 1 ] - tmp2, warping_Q16 );
- psDD->sAR2_Q14[ j + 0 ] = tmp2;
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp2, AR_shp_Q13[ j ] );
- }
- psDD->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1;
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] );
-
- n_AR_Q10 = SKP_RSHIFT( n_AR_Q10, 1 ); /* Q11 -> Q10 */
- n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psDD->LF_AR_Q12, Tilt_Q14 );
-
- n_LF_Q10 = SKP_LSHIFT( SKP_SMULWB( psDD->Shape_Q10[ *smpl_buf_idx ], LF_shp_Q14 ), 2 );
- n_LF_Q10 = SKP_SMLAWT( n_LF_Q10, psDD->LF_AR_Q12, LF_shp_Q14 );
-
- /* Input minus prediction plus noise feedback */
- /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */
- tmp1 = SKP_ADD32( LTP_Q10, LPC_pred_Q10 ); /* add Q10 stuff */
- tmp1 = SKP_SUB32( tmp1, n_AR_Q10 ); /* subtract Q10 stuff */
- tmp1 = SKP_SUB32( tmp1, n_LF_Q10 ); /* subtract Q10 stuff */
- r_Q10 = SKP_SUB32( x_Q10[ i ], tmp1 ); /* residual error Q10 */
-
- /* Flip sign depending on dither */
- r_Q10 = r_Q10 ^ dither;
- r_Q10 = SKP_LIMIT_32( r_Q10, -31 << 10, 30 << 10 );
-
- /* Find two quantization level candidates and measure their rate-distortion */
- q1_Q10 = SKP_SUB32( r_Q10, offset_Q10 );
- q1_Q10 = SKP_RSHIFT( q1_Q10, 10 );
- if( q1_Q10 > 0 ) {
- q1_Q10 = SKP_SUB32( SKP_LSHIFT( q1_Q10, 10 ), QUANT_LEVEL_ADJUST_Q10 );
- q1_Q10 = SKP_ADD32( q1_Q10, offset_Q10 );
- q2_Q10 = SKP_ADD32( q1_Q10, 1024 );
- rd1_Q10 = SKP_SMULBB( q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( q2_Q10, Lambda_Q10 );
- } else if( q1_Q10 == 0 ) {
- q1_Q10 = offset_Q10;
- q2_Q10 = SKP_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 );
- rd1_Q10 = SKP_SMULBB( q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( q2_Q10, Lambda_Q10 );
- } else if( q1_Q10 == -1 ) {
- q2_Q10 = offset_Q10;
- q1_Q10 = SKP_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 );
- rd1_Q10 = SKP_SMULBB( -q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( q2_Q10, Lambda_Q10 );
- } else { /* Q1_Q10 < -1 */
- q1_Q10 = SKP_ADD32( SKP_LSHIFT( q1_Q10, 10 ), QUANT_LEVEL_ADJUST_Q10 );
- q1_Q10 = SKP_ADD32( q1_Q10, offset_Q10 );
- q2_Q10 = SKP_ADD32( q1_Q10, 1024 );
- rd1_Q10 = SKP_SMULBB( -q1_Q10, Lambda_Q10 );
- rd2_Q10 = SKP_SMULBB( -q2_Q10, Lambda_Q10 );
- }
- rr_Q10 = SKP_SUB32( r_Q10, q1_Q10 );
- rd1_Q10 = SKP_RSHIFT( SKP_SMLABB( rd1_Q10, rr_Q10, rr_Q10 ), 10 );
- rr_Q10 = SKP_SUB32( r_Q10, q2_Q10 );
- rd2_Q10 = SKP_RSHIFT( SKP_SMLABB( rd2_Q10, rr_Q10, rr_Q10 ), 10 );
-
- if( rd1_Q10 < rd2_Q10 ) {
- psSS[ 0 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd1_Q10 );
- psSS[ 1 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd2_Q10 );
- psSS[ 0 ].Q_Q10 = q1_Q10;
- psSS[ 1 ].Q_Q10 = q2_Q10;
- } else {
- psSS[ 0 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd2_Q10 );
- psSS[ 1 ].RD_Q10 = SKP_ADD32( psDD->RD_Q10, rd1_Q10 );
- psSS[ 0 ].Q_Q10 = q2_Q10;
- psSS[ 1 ].Q_Q10 = q1_Q10;
- }
-
- /* Update states for best quantization */
-
- /* Quantized excitation */
- exc_Q10 = psSS[ 0 ].Q_Q10 ^ dither;
-
- /* Add predictions */
- LPC_exc_Q10 = exc_Q10 + SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 );
- xq_Q10 = SKP_ADD32( LPC_exc_Q10, LPC_pred_Q10 );
-
- /* Update states */
- sLF_AR_shp_Q10 = SKP_SUB32( xq_Q10, n_AR_Q10 );
- psSS[ 0 ].sLTP_shp_Q10 = SKP_SUB32( sLF_AR_shp_Q10, n_LF_Q10 );
- psSS[ 0 ].LF_AR_Q12 = SKP_LSHIFT( sLF_AR_shp_Q10, 2 );
- psSS[ 0 ].xq_Q14 = SKP_LSHIFT( xq_Q10, 4 );
- psSS[ 0 ].LPC_exc_Q16 = SKP_LSHIFT( LPC_exc_Q10, 6 );
-
- /* Update states for second best quantization */
-
- /* Quantized excitation */
- exc_Q10 = psSS[ 1 ].Q_Q10 ^ dither;
-
- /* Add predictions */
- LPC_exc_Q10 = exc_Q10 + SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 );
- xq_Q10 = SKP_ADD32( LPC_exc_Q10, LPC_pred_Q10 );
-
- /* Update states */
- sLF_AR_shp_Q10 = SKP_SUB32( xq_Q10, n_AR_Q10 );
- psSS[ 1 ].sLTP_shp_Q10 = SKP_SUB32( sLF_AR_shp_Q10, n_LF_Q10 );
- psSS[ 1 ].LF_AR_Q12 = SKP_LSHIFT( sLF_AR_shp_Q10, 2 );
- psSS[ 1 ].xq_Q14 = SKP_LSHIFT( xq_Q10, 4 );
- psSS[ 1 ].LPC_exc_Q16 = SKP_LSHIFT( LPC_exc_Q10, 6 );
- }
-
- *smpl_buf_idx = ( *smpl_buf_idx - 1 ) & DECISION_DELAY_MASK; /* Index to newest samples */
- last_smple_idx = ( *smpl_buf_idx + decisionDelay ) & DECISION_DELAY_MASK; /* Index to decisionDelay old samples */
-
- /* Find winner */
- RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10;
- Winner_ind = 0;
- for( k = 1; k < nStatesDelayedDecision; k++ ) {
- if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) {
- RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10;
- Winner_ind = k;
- }
- }
-
- /* Increase RD values of expired states */
- Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ];
- for( k = 0; k < nStatesDelayedDecision; k++ ) {
- if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) {
- psSampleState[ k ][ 0 ].RD_Q10 = SKP_ADD32( psSampleState[ k ][ 0 ].RD_Q10, ( SKP_int32_MAX >> 4 ) );
- psSampleState[ k ][ 1 ].RD_Q10 = SKP_ADD32( psSampleState[ k ][ 1 ].RD_Q10, ( SKP_int32_MAX >> 4 ) );
- SKP_assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 );
- }
- }
-
- /* Find worst in first set and best in second set */
- RDmax_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10;
- RDmin_Q10 = psSampleState[ 0 ][ 1 ].RD_Q10;
- RDmax_ind = 0;
- RDmin_ind = 0;
- for( k = 1; k < nStatesDelayedDecision; k++ ) {
- /* find worst in first set */
- if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) {
- RDmax_Q10 = psSampleState[ k ][ 0 ].RD_Q10;
- RDmax_ind = k;
- }
- /* find best in second set */
- if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) {
- RDmin_Q10 = psSampleState[ k ][ 1 ].RD_Q10;
- RDmin_ind = k;
- }
- }
-
- /* Replace a state if best from second set outperforms worst in first set */
- if( RDmin_Q10 < RDmax_Q10 ) {
- SKP_memcpy( ((SKP_int32 *)&psDelDec[ RDmax_ind ]) + i,
- ((SKP_int32 *)&psDelDec[ RDmin_ind ]) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( SKP_int32) );
- SKP_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) );
- }
-
- /* Write samples from winner to output and long-term filter states */
- psDD = &psDelDec[ Winner_ind ];
- if( subfr > 0 || i >= decisionDelay ) {
- pulses[ i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 );
- xq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND(
- SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], delayedGain_Q16[ last_smple_idx ] ), 10 ) );
- NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q10[ last_smple_idx ];
- sLTP_Q16[ NSQ->sLTP_buf_idx - decisionDelay ] = psDD->Pred_Q16[ last_smple_idx ];
- }
- NSQ->sLTP_shp_buf_idx++;
- NSQ->sLTP_buf_idx++;
-
- /* Update states */
- for( k = 0; k < nStatesDelayedDecision; k++ ) {
- psDD = &psDelDec[ k ];
- psSS = &psSampleState[ k ][ 0 ];
- psDD->LF_AR_Q12 = psSS->LF_AR_Q12;
- psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ] = psSS->xq_Q14;
- psDD->Xq_Q10[ *smpl_buf_idx ] = SKP_RSHIFT( psSS->xq_Q14, 4 );
- psDD->Q_Q10[ *smpl_buf_idx ] = psSS->Q_Q10;
- psDD->Pred_Q16[ *smpl_buf_idx ] = psSS->LPC_exc_Q16;
- psDD->Shape_Q10[ *smpl_buf_idx ] = psSS->sLTP_shp_Q10;
- psDD->Seed = SKP_ADD32( psDD->Seed, SKP_RSHIFT_ROUND( psSS->Q_Q10, 10 ) );
- psDD->RandState[ *smpl_buf_idx ] = psDD->Seed;
- psDD->RD_Q10 = psSS->RD_Q10;
- }
- delayedGain_Q16[ *smpl_buf_idx ] = Gain_Q16;
- }
- /* Update LPC states */
- for( k = 0; k < nStatesDelayedDecision; k++ ) {
- psDD = &psDelDec[ k ];
- SKP_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );
- }
-}
-
-SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
- const SKP_Silk_encoder_state *psEncC, /* I Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */
- const SKP_int16 x[], /* I Input in Q0 */
- SKP_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */
- const SKP_int16 sLTP[], /* I Re-whitened LTP state in Q0 */
- SKP_int32 sLTP_Q16[], /* O LTP state matching scaled input */
- SKP_int subfr, /* I Subframe number */
- SKP_int nStatesDelayedDecision, /* I Number of del dec states */
- SKP_int smpl_buf_idx, /* I Index to newest samples in buffers */
- const SKP_int LTP_scale_Q14, /* I LTP state scaling */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ] /* I Pitch lag */
-)
-{
- SKP_int i, k, lag;
- SKP_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;
- NSQ_del_dec_struct *psDD;
-
- inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );
- inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );
- lag = pitchL[ subfr ];
-
- /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */
- if( NSQ->rewhite_flag ) {
- inv_gain_Q32 = SKP_LSHIFT( inv_gain_Q16, 16 );
- if( subfr == 0 ) {
- /* Do LTP downscaling */
- inv_gain_Q32 = SKP_LSHIFT( SKP_SMULWB( inv_gain_Q32, LTP_scale_Q14 ), 2 );
- }
- for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {
- SKP_assert( i < MAX_FRAME_LENGTH );
- sLTP_Q16[ i ] = SKP_SMULWB( inv_gain_Q32, sLTP[ i ] );
- }
- }
-
- /* Adjust for changing gain */
- if( inv_gain_Q16 != NSQ->prev_inv_gain_Q16 ) {
- gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 );
-
- /* Scale long-term shaping state */
- for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx; i++ ) {
- NSQ->sLTP_shp_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q10[ i ] );
- }
-
- /* Scale long-term prediction state */
- if( NSQ->rewhite_flag == 0 ) {
- for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {
- sLTP_Q16[ i ] = SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] );
- }
- }
-
- for( k = 0; k < nStatesDelayedDecision; k++ ) {
- psDD = &psDelDec[ k ];
-
- /* Scale scalar states */
- psDD->LF_AR_Q12 = SKP_SMULWW( gain_adj_Q16, psDD->LF_AR_Q12 );
-
- /* Scale short-term prediction and shaping states */
- for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) {
- psDD->sLPC_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->sLPC_Q14[ i ] );
- }
- for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) {
- psDD->sAR2_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->sAR2_Q14[ i ] );
- }
- for( i = 0; i < DECISION_DELAY; i++ ) {
- psDD->Pred_Q16[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->Pred_Q16[ i ] );
- psDD->Shape_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->Shape_Q10[ i ] );
- }
- }
- }
-
- /* Scale input */
- for( i = 0; i < psEncC->subfr_length; i++ ) {
- x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( SKP_int16 )inv_gain_Q16 ), 6 );
- }
-
- /* save inv_gain */
- SKP_assert( inv_gain_Q16 != 0 );
- NSQ->prev_inv_gain_Q16 = inv_gain_Q16;
-}
--- a/silk/SKP_Silk_PLC.c
+++ /dev/null
@@ -1,388 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-#include "SKP_Silk_PLC.h"
-
-#define NB_ATT 2
-static const SKP_int16 HARM_ATT_Q15[NB_ATT] = { 32440, 31130 }; /* 0.99, 0.95 */
-static const SKP_int16 PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = { 31130, 26214 }; /* 0.95, 0.8 */
-static const SKP_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */
-
-void SKP_Silk_PLC_Reset(
- SKP_Silk_decoder_state *psDec /* I/O Decoder state */
-)
-{
- psDec->sPLC.pitchL_Q8 = SKP_RSHIFT( psDec->frame_length, 1 );
-}
-
-void SKP_Silk_PLC(
- SKP_Silk_decoder_state *psDec, /* I Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I Decoder control */
- SKP_int16 signal[], /* O Concealed signal */
- SKP_int length, /* I length of residual */
- SKP_int lost /* I Loss flag */
-)
-{
- /* PLC control function */
- if( psDec->fs_kHz != psDec->sPLC.fs_kHz ) {
- SKP_Silk_PLC_Reset( psDec );
- psDec->sPLC.fs_kHz = psDec->fs_kHz;
- }
-
- if( lost ) {
- /****************************/
- /* Generate Signal */
- /****************************/
- SKP_Silk_PLC_conceal( psDec, psDecCtrl, signal, length );
-
- psDec->lossCnt++;
- } else {
- /****************************/
- /* Update state */
- /****************************/
- SKP_Silk_PLC_update( psDec, psDecCtrl, signal, length );
- }
-}
-
-/**************************************************/
-/* Update state of PLC */
-/**************************************************/
-void SKP_Silk_PLC_update(
- SKP_Silk_decoder_state *psDec, /* (I/O) Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* (I/O) Decoder control */
- SKP_int16 signal[],
- SKP_int length
-)
-{
- SKP_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14;
- SKP_int i, j;
- SKP_Silk_PLC_struct *psPLC;
-
- psPLC = &psDec->sPLC;
-
- /* Update parameters used in case of packet loss */
- psDec->prevSignalType = psDec->indices.signalType;
- LTP_Gain_Q14 = 0;
- if( psDec->indices.signalType == TYPE_VOICED ) {
- /* Find the parameters for the last subframe which contains a pitch pulse */
- for( j = 0; j * psDec->subfr_length < psDecCtrl->pitchL[ psDec->nb_subfr - 1 ]; j++ ) {
- if( j == psDec->nb_subfr ){
- break;
- }
- temp_LTP_Gain_Q14 = 0;
- for( i = 0; i < LTP_ORDER; i++ ) {
- temp_LTP_Gain_Q14 += psDecCtrl->LTPCoef_Q14[ ( psDec->nb_subfr - 1 - j ) * LTP_ORDER + i ];
- }
- if( temp_LTP_Gain_Q14 > LTP_Gain_Q14 ) {
- LTP_Gain_Q14 = temp_LTP_Gain_Q14;
- SKP_memcpy( psPLC->LTPCoef_Q14,
- &psDecCtrl->LTPCoef_Q14[ SKP_SMULBB( psDec->nb_subfr - 1 - j, LTP_ORDER ) ],
- LTP_ORDER * sizeof( SKP_int16 ) );
-
- psPLC->pitchL_Q8 = SKP_LSHIFT( psDecCtrl->pitchL[ psDec->nb_subfr - 1 - j ], 8 );
- }
- }
-
-#if USE_SINGLE_TAP
- SKP_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ) );
- psPLC->LTPCoef_Q14[ LTP_ORDER / 2 ] = LTP_Gain_Q14;
-#endif
-
- /* Limit LT coefs */
- if( LTP_Gain_Q14 < V_PITCH_GAIN_START_MIN_Q14 ) {
- SKP_int scale_Q10;
- SKP_int32 tmp;
-
- tmp = SKP_LSHIFT( V_PITCH_GAIN_START_MIN_Q14, 10 );
- scale_Q10 = SKP_DIV32( tmp, SKP_max( LTP_Gain_Q14, 1 ) );
- for( i = 0; i < LTP_ORDER; i++ ) {
- psPLC->LTPCoef_Q14[ i ] = SKP_RSHIFT( SKP_SMULBB( psPLC->LTPCoef_Q14[ i ], scale_Q10 ), 10 );
- }
- } else if( LTP_Gain_Q14 > V_PITCH_GAIN_START_MAX_Q14 ) {
- SKP_int scale_Q14;
- SKP_int32 tmp;
-
- tmp = SKP_LSHIFT( V_PITCH_GAIN_START_MAX_Q14, 14 );
- scale_Q14 = SKP_DIV32( tmp, SKP_max( LTP_Gain_Q14, 1 ) );
- for( i = 0; i < LTP_ORDER; i++ ) {
- psPLC->LTPCoef_Q14[ i ] = SKP_RSHIFT( SKP_SMULBB( psPLC->LTPCoef_Q14[ i ], scale_Q14 ), 14 );
- }
- }
- } else {
- psPLC->pitchL_Q8 = SKP_LSHIFT( SKP_SMULBB( psDec->fs_kHz, 18 ), 8 );
- SKP_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ));
- }
-
- /* Save LPC coeficients */
- SKP_memcpy( psPLC->prevLPC_Q12, psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order * sizeof( SKP_int16 ) );
- psPLC->prevLTP_scale_Q14 = psDecCtrl->LTP_scale_Q14;
-
- /* Save Gains */
- SKP_memcpy( psPLC->prevGain_Q16, psDecCtrl->Gains_Q16, psDec->nb_subfr * sizeof( SKP_int32 ) );
-}
-
-void SKP_Silk_PLC_conceal(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[], /* O concealed signal */
- SKP_int length /* I length of residual */
-)
-{
- SKP_int i, j, k;
- SKP_int16 *B_Q14, exc_buf[ MAX_FRAME_LENGTH ], *exc_buf_ptr;
- SKP_int16 rand_scale_Q14, A_Q12_tmp[ MAX_LPC_ORDER ];
- SKP_int32 rand_seed, harm_Gain_Q15, rand_Gain_Q15;
- SKP_int lag, idx, sLTP_buf_idx, shift1, shift2;
- SKP_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr;
- SKP_int32 sig_Q10[ MAX_FRAME_LENGTH ], *sig_Q10_ptr, LPC_exc_Q10, LPC_pred_Q10, LTP_pred_Q14;
- SKP_Silk_PLC_struct *psPLC;
- psPLC = &psDec->sPLC;
-
- /* Update LTP buffer */
- SKP_memmove( psDec->sLTP_Q16, &psDec->sLTP_Q16[ psDec->frame_length ], psDec->ltp_mem_length * sizeof( SKP_int32 ) );
-
- /* LPC concealment. Apply BWE to previous LPC */
- SKP_Silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SKP_FIX_CONST( BWE_COEF, 16 ) );
-
- /* Find random noise component */
- /* Scale previous excitation signal */
- exc_buf_ptr = exc_buf;
- for( k = ( psDec->nb_subfr >> 1 ); k < psDec->nb_subfr; k++ ) {
- for( i = 0; i < psDec->subfr_length; i++ ) {
- exc_buf_ptr[ i ] = ( SKP_int16 )SKP_RSHIFT(
- SKP_SMULWW( psDec->exc_Q10[ i + k * psDec->subfr_length ], psPLC->prevGain_Q16[ k ] ), 10 );
- }
- exc_buf_ptr += psDec->subfr_length;
- }
- /* Find the subframe with lowest energy of the last two and use that as random noise generator */
- SKP_Silk_sum_sqr_shift( &energy1, &shift1, exc_buf, psDec->subfr_length );
- SKP_Silk_sum_sqr_shift( &energy2, &shift2, &exc_buf[ psDec->subfr_length ], psDec->subfr_length );
-
- if( SKP_RSHIFT( energy1, shift2 ) < SKP_RSHIFT( energy2, shift1 ) ) {
- /* First sub-frame has lowest energy */
- rand_ptr = &psDec->exc_Q10[ SKP_max_int( 0, 3 * psDec->subfr_length - RAND_BUF_SIZE ) ];
- } else {
- /* Second sub-frame has lowest energy */
- rand_ptr = &psDec->exc_Q10[ SKP_max_int( 0, psDec->frame_length - RAND_BUF_SIZE ) ];
- }
-
- /* Setup Gain to random noise component */
- B_Q14 = psPLC->LTPCoef_Q14;
- rand_scale_Q14 = psPLC->randScale_Q14;
-
- /* Setup attenuation gains */
- harm_Gain_Q15 = HARM_ATT_Q15[ SKP_min_int( NB_ATT - 1, psDec->lossCnt ) ];
- if( psDec->prevSignalType == TYPE_VOICED ) {
- rand_Gain_Q15 = PLC_RAND_ATTENUATE_V_Q15[ SKP_min_int( NB_ATT - 1, psDec->lossCnt ) ];
- } else {
- rand_Gain_Q15 = PLC_RAND_ATTENUATE_UV_Q15[ SKP_min_int( NB_ATT - 1, psDec->lossCnt ) ];
- }
-
- /* First Lost frame */
- if( psDec->lossCnt == 0 ) {
- rand_scale_Q14 = 1 << 14;
-
- /* Reduce random noise Gain for voiced frames */
- if( psDec->prevSignalType == TYPE_VOICED ) {
- for( i = 0; i < LTP_ORDER; i++ ) {
- rand_scale_Q14 -= B_Q14[ i ];
- }
- rand_scale_Q14 = SKP_max_16( 3277, rand_scale_Q14 ); /* 0.2 */
- rand_scale_Q14 = ( SKP_int16 )SKP_RSHIFT( SKP_SMULBB( rand_scale_Q14, psPLC->prevLTP_scale_Q14 ), 14 );
- } else {
- /* Reduce random noise for unvoiced frames with high LPC gain */
- SKP_int32 invGain_Q30, down_scale_Q30;
-
- SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, psPLC->prevLPC_Q12, psDec->LPC_order );
-
- down_scale_Q30 = SKP_min_32( SKP_RSHIFT( 1 << 30, LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 );
- down_scale_Q30 = SKP_max_32( SKP_RSHIFT( 1 << 30, LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 );
- down_scale_Q30 = SKP_LSHIFT( down_scale_Q30, LOG2_INV_LPC_GAIN_HIGH_THRES );
-
- rand_Gain_Q15 = SKP_RSHIFT( SKP_SMULWB( down_scale_Q30, rand_Gain_Q15 ), 14 );
- }
- }
-
- rand_seed = psPLC->rand_seed;
- lag = SKP_RSHIFT_ROUND( psPLC->pitchL_Q8, 8 );
- sLTP_buf_idx = psDec->ltp_mem_length;
-
- /***************************/
- /* LTP synthesis filtering */
- /***************************/
- sig_Q10_ptr = sig_Q10;
- for( k = 0; k < psDec->nb_subfr; k++ ) {
- /* Setup pointer */
- pred_lag_ptr = &psDec->sLTP_Q16[ sLTP_buf_idx - lag + LTP_ORDER / 2 ];
- for( i = 0; i < psDec->subfr_length; i++ ) {
- rand_seed = SKP_RAND( rand_seed );
- idx = SKP_RSHIFT( rand_seed, 25 ) & RAND_BUF_MASK;
-
- /* Unrolled loop */
- LTP_pred_Q14 = SKP_SMULWB( pred_lag_ptr[ 0 ], B_Q14[ 0 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], B_Q14[ 1 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -2 ], B_Q14[ 2 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -3 ], B_Q14[ 3 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], B_Q14[ 4 ] );
- pred_lag_ptr++;
-
- /* Generate LPC residual */
- LPC_exc_Q10 = SKP_LSHIFT( SKP_SMULWB( rand_ptr[ idx ], rand_scale_Q14 ), 2 ); /* Random noise part */
- LPC_exc_Q10 = SKP_ADD32( LPC_exc_Q10, SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) ); /* Harmonic part */
-
- /* Update states */
- psDec->sLTP_Q16[ sLTP_buf_idx ] = SKP_LSHIFT( LPC_exc_Q10, 6 );
- sLTP_buf_idx++;
-
- /* Save LPC residual */
- sig_Q10_ptr[ i ] = LPC_exc_Q10;
- }
- sig_Q10_ptr += psDec->subfr_length;
- /* Gradually reduce LTP gain */
- for( j = 0; j < LTP_ORDER; j++ ) {
- B_Q14[ j ] = SKP_RSHIFT( SKP_SMULBB( harm_Gain_Q15, B_Q14[ j ] ), 15 );
- }
- /* Gradually reduce excitation gain */
- rand_scale_Q14 = SKP_RSHIFT( SKP_SMULBB( rand_scale_Q14, rand_Gain_Q15 ), 15 );
-
- /* Slowly increase pitch lag */
- psPLC->pitchL_Q8 += SKP_SMULWB( psPLC->pitchL_Q8, PITCH_DRIFT_FAC_Q16 );
- psPLC->pitchL_Q8 = SKP_min_32( psPLC->pitchL_Q8, SKP_LSHIFT( SKP_SMULBB( MAX_PITCH_LAG_MS, psDec->fs_kHz ), 8 ) );
- lag = SKP_RSHIFT_ROUND( psPLC->pitchL_Q8, 8 );
- }
-
- /***************************/
- /* LPC synthesis filtering */
- /***************************/
- sig_Q10_ptr = sig_Q10;
- /* Preload LPC coeficients to array on stack. Gives small performance gain */
- SKP_memcpy( A_Q12_tmp, psPLC->prevLPC_Q12, psDec->LPC_order * sizeof( SKP_int16 ) );
- SKP_assert( psDec->LPC_order >= 10 ); /* check that unrolling works */
- for( k = 0; k < psDec->nb_subfr; k++ ) {
- for( i = 0; i < psDec->subfr_length; i++ ){
- /* partly unrolled */
- LPC_pred_Q10 = SKP_SMULWB( psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 2 ], A_Q12_tmp[ 1 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 3 ], A_Q12_tmp[ 2 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 4 ], A_Q12_tmp[ 3 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 5 ], A_Q12_tmp[ 4 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 6 ], A_Q12_tmp[ 5 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 7 ], A_Q12_tmp[ 6 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 8 ], A_Q12_tmp[ 7 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 9 ], A_Q12_tmp[ 8 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], A_Q12_tmp[ 9 ] );
-
- for( j = 10; j < psDec->LPC_order; j++ ) {
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - j - 1 ], A_Q12_tmp[ j ] );
- }
-
- /* Add prediction to LPC residual */
- sig_Q10_ptr[ i ] = SKP_ADD32( sig_Q10_ptr[ i ], LPC_pred_Q10 );
-
- /* Update states */
- psDec->sLPC_Q14[ MAX_LPC_ORDER + i ] = SKP_LSHIFT( sig_Q10_ptr[ i ], 4 );
- }
- sig_Q10_ptr += psDec->subfr_length;
- /* Update LPC filter state */
- SKP_memcpy( psDec->sLPC_Q14, &psDec->sLPC_Q14[ psDec->subfr_length ], MAX_LPC_ORDER * sizeof( SKP_int32 ) );
- }
-
- /* Scale with Gain */
- for( i = 0; i < psDec->frame_length; i++ ) {
- signal[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( sig_Q10[ i ], psPLC->prevGain_Q16[ psDec->nb_subfr - 1 ] ), 10 ) );
- }
-
- /**************************************/
- /* Update states */
- /**************************************/
- psPLC->rand_seed = rand_seed;
- psPLC->randScale_Q14 = rand_scale_Q14;
- for( i = 0; i < MAX_NB_SUBFR; i++ ) {
- psDecCtrl->pitchL[ i ] = lag;
- }
-}
-
-/* Glues concealed frames with new good recieved frames */
-void SKP_Silk_PLC_glue_frames(
- SKP_Silk_decoder_state *psDec, /* I/O decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[], /* I/O signal */
- SKP_int length /* I length of residual */
-)
-{
- SKP_int i, energy_shift;
- SKP_int32 energy;
- SKP_Silk_PLC_struct *psPLC;
- psPLC = &psDec->sPLC;
-
- if( psDec->lossCnt ) {
- /* Calculate energy in concealed residual */
- SKP_Silk_sum_sqr_shift( &psPLC->conc_energy, &psPLC->conc_energy_shift, signal, length );
-
- psPLC->last_frame_lost = 1;
- } else {
- if( psDec->sPLC.last_frame_lost ) {
- /* Calculate residual in decoded signal if last frame was lost */
- SKP_Silk_sum_sqr_shift( &energy, &energy_shift, signal, length );
-
- /* Normalize energies */
- if( energy_shift > psPLC->conc_energy_shift ) {
- psPLC->conc_energy = SKP_RSHIFT( psPLC->conc_energy, energy_shift - psPLC->conc_energy_shift );
- } else if( energy_shift < psPLC->conc_energy_shift ) {
- energy = SKP_RSHIFT( energy, psPLC->conc_energy_shift - energy_shift );
- }
-
- /* Fade in the energy difference */
- if( energy > psPLC->conc_energy ) {
- SKP_int32 frac_Q24, LZ;
- SKP_int32 gain_Q16, slope_Q16;
-
- LZ = SKP_Silk_CLZ32( psPLC->conc_energy );
- LZ = LZ - 1;
- psPLC->conc_energy = SKP_LSHIFT( psPLC->conc_energy, LZ );
- energy = SKP_RSHIFT( energy, SKP_max_32( 24 - LZ, 0 ) );
-
- frac_Q24 = SKP_DIV32( psPLC->conc_energy, SKP_max( energy, 1 ) );
-
- gain_Q16 = SKP_LSHIFT( SKP_Silk_SQRT_APPROX( frac_Q24 ), 4 );
- slope_Q16 = SKP_DIV32_16( ( 1 << 16 ) - gain_Q16, length );
- /* Make slope 4x steeper to avoid missing onsets after DTX */
- slope_Q16 = SKP_LSHIFT( slope_Q16, 2 );
-
- for( i = 0; i < length; i++ ) {
- signal[ i ] = SKP_SMULWB( gain_Q16, signal[ i ] );
- gain_Q16 += slope_Q16;
- if( gain_Q16 > 1 << 16 ) {
- break;
- }
- }
- }
- }
- psPLC->last_frame_lost = 0;
- }
-}
--- a/silk/SKP_Silk_PLC.h
+++ /dev/null
@@ -1,79 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef SKP_SILK_PLC_FIX_H
-#define SKP_SILK_PLC_FIX_H
-
-#include "SKP_Silk_main.h"
-
-#define BWE_COEF 0.99
-#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */
-#define V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */
-#define MAX_PITCH_LAG_MS 18
-#define SA_THRES_Q8 50
-#define USE_SINGLE_TAP 1
-#define RAND_BUF_SIZE 128
-#define RAND_BUF_MASK (RAND_BUF_SIZE - 1)
-#define LOG2_INV_LPC_GAIN_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */
-#define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */
-#define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */
-
-void SKP_Silk_PLC_Reset(
- SKP_Silk_decoder_state *psDec /* I/O Decoder state */
-);
-
-void SKP_Silk_PLC(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[], /* I/O signal */
- SKP_int length, /* I length of residual */
- SKP_int lost /* I Loss flag */
-);
-
-void SKP_Silk_PLC_update(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[],
- SKP_int length
-);
-
-void SKP_Silk_PLC_conceal(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[], /* O LPC residual signal */
- SKP_int length /* I length of signal */
-);
-
-void SKP_Silk_PLC_glue_frames(
- SKP_Silk_decoder_state *psDec, /* I/O decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[], /* I/O signal */
- SKP_int length /* I length of signal */
-);
-
-#endif
-
--- a/silk/SKP_Silk_SDK_API.h
+++ /dev/null
@@ -1,149 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef SKP_SILK_SDK_API_H
-#define SKP_SILK_SDK_API_H
-
-#include "SKP_Silk_control.h"
-#include "SKP_Silk_typedef.h"
-#include "SKP_Silk_errors.h"
-#include "entenc.h"
-#include "entdec.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define SILK_MAX_FRAMES_PER_PACKET 3
-
-/* Struct for TOC (Table of Contents) */
-typedef struct {
- SKP_int VADFlag; /* Voice activity for packet */
- SKP_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */
- SKP_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */
-} SKP_Silk_TOC_struct;
-
-/****************************************/
-/* Encoder functions */
-/****************************************/
-
-/***********************************************/
-/* Get size in bytes of the Silk encoder state */
-/***********************************************/
-SKP_int SKP_Silk_SDK_Get_Encoder_Size( /* O: Returns error code */
- SKP_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */
-);
-
-/*************************/
-/* Init or reset encoder */
-/*************************/
-SKP_int SKP_Silk_SDK_InitEncoder( /* O: Returns error code */
- void *encState, /* I/O: State */
- SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
-);
-
-/***************************************/
-/* Read control structure from encoder */
-/***************************************/
-SKP_int SKP_Silk_SDK_QueryEncoder( /* O: Returns error code */
- const void *encState, /* I: State */
- SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
-);
-
-/**************************/
-/* Encode frame with Silk */
-/**************************/
-/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
-/* encControl->payloadSize_ms is set to */
-SKP_int SKP_Silk_SDK_Encode( /* O: Returns error code */
- void *encState, /* I/O: State */
- SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control status */
- const SKP_int16 *samplesIn, /* I: Speech sample input vector */
- SKP_int nSamplesIn, /* I: Number of samples in input vector */
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- SKP_int32 *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
- const SKP_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */
-);
-
-/****************************************/
-/* Decoder functions */
-/****************************************/
-
-/***********************************************/
-/* Get size in bytes of the Silk decoder state */
-/***********************************************/
-SKP_int SKP_Silk_SDK_Get_Decoder_Size( /* O: Returns error code */
- SKP_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */
-);
-
-/*************************/
-/* Init or Reset decoder */
-/*************************/
-SKP_int SKP_Silk_SDK_InitDecoder( /* O: Returns error code */
- void *decState /* I/O: State */
-);
-
-/******************/
-/* Decode a frame */
-/******************/
-SKP_int SKP_Silk_SDK_Decode( /* O: Returns error code */
- void* decState, /* I/O: State */
- SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */
- SKP_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode fec */
- SKP_int newPacketFlag, /* I: Indicates first decoder call for this packet */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int16 *samplesOut, /* O: Decoded output speech vector */
- SKP_int32 *nSamplesOut /* O: Number of samples decoded */
-);
-
-/***************************************************************/
-/* Find Low Bit Rate Redundancy (LBRR) information in a packet */
-/***************************************************************/
-void SKP_Silk_SDK_search_for_LBRR(
- const SKP_uint8 *inData, /* I: Encoded input vector */
- const SKP_int16 nBytesIn, /* I: Number of input bytes */
- SKP_int lost_offset, /* I: Offset from lost packet */
- SKP_uint8 *LBRRData, /* O: LBRR payload */
- SKP_int32 *nLBRRBytes /* O: Number of LBRR Bytes */
-);
-
-/**************************************/
-/* Get table of contents for a packet */
-/**************************************/
-SKP_int SKP_Silk_SDK_get_TOC(
- const SKP_uint8 *payload, /* I Payload data */
- const SKP_int nBytesIn, /* I: Number of input bytes */
- const SKP_int nFramesPerPayload, /* I: Number of SILK frames per payload */
- SKP_Silk_TOC_struct *Silk_TOC /* O: Type of content */
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/silk/SKP_Silk_SigProc_FIX.h
+++ /dev/null
@@ -1,671 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-
-#ifndef _SKP_SILK_SIGPROC_FIX_H_
-#define _SKP_SILK_SIGPROC_FIX_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-//#define SKP_MACRO_COUNT /* Used to enable WMOPS counting */
-
-#define SKP_Silk_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */
-#define SKP_Silk_MAX_CORRELATION_LENGTH 640 /* max input length to the correlation */
-#include "SKP_Silk_typedef.h"
-#include <string.h>
-#include <stdlib.h> /* for abs() */
-#include "SKP_Silk_resampler_structs.h"
-
-# include "SKP_Silk_macros.h"
-
-
-
-/********************************************************************/
-/* SIGNAL PROCESSING FUNCTIONS */
-/********************************************************************/
-
-/*!
- * Initialize/reset the resampler state for a given pair of input/output sampling rates
-*/
-SKP_int SKP_Silk_resampler_init(
- SKP_Silk_resampler_state_struct *S, /* I/O: Resampler state */
- SKP_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */
- SKP_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */
-);
-
-
-/*!
- * Clear the states of all resampling filters, without resetting sampling rate ratio
- */
-SKP_int SKP_Silk_resampler_clear(
- SKP_Silk_resampler_state_struct *S /* I/O: Resampler state */
-);
-
-/*!
- * Resampler: convert from one sampling rate to another
- */
-SKP_int SKP_Silk_resampler(
- SKP_Silk_resampler_state_struct *S, /* I/O: Resampler state */
- SKP_int16 out[], /* O: Output signal */
- const SKP_int16 in[], /* I: Input signal */
- SKP_int32 inLen /* I: Number of input samples */
-);
-
-/*!
- Upsample 2x, low quality
- */
-void SKP_Silk_resampler_up2(
- SKP_int32 *S, /* I/O: State vector [ 2 ] */
- SKP_int16 *out, /* O: Output signal [ 2 * len ] */
- const SKP_int16 *in, /* I: Input signal [ len ] */
- SKP_int32 len /* I: Number of input samples */
-);
-
-/*!
-* Downsample 2x, mediocre quality
-*/
-void SKP_Silk_resampler_down2(
- SKP_int32 *S, /* I/O: State vector [ 2 ] */
- SKP_int16 *out, /* O: Output signal [ len ] */
- const SKP_int16 *in, /* I: Input signal [ floor(len/2) ] */
- SKP_int32 inLen /* I: Number of input samples */
-);
-
-
-/*!
- * Downsample by a factor 2/3, low quality
-*/
-void SKP_Silk_resampler_down2_3(
- SKP_int32 *S, /* I/O: State vector [ 6 ] */
- SKP_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */
- const SKP_int16 *in, /* I: Input signal [ inLen ] */
- SKP_int32 inLen /* I: Number of input samples */
-);
-
-/*!
- * Downsample by a factor 3, low quality
-*/
-void SKP_Silk_resampler_down3(
- SKP_int32 *S, /* I/O: State vector [ 8 ] */
- SKP_int16 *out, /* O: Output signal [ floor(inLen/3) ] */
- const SKP_int16 *in, /* I: Input signal [ inLen ] */
- SKP_int32 inLen /* I: Number of input samples */
-);
-
-/*!
- * second order ARMA filter;
- * slower than biquad() but uses more precise coefficients
- * can handle (slowly) varying coefficients
- */
-void SKP_Silk_biquad_alt(
- const SKP_int16 *in, /* I: input signal */
- const SKP_int32 *B_Q28, /* I: MA coefficients [3] */
- const SKP_int32 *A_Q28, /* I: AR coefficients [2] */
- SKP_int32 *S, /* I/O: state vector [2] */
- SKP_int16 *out, /* O: output signal */
- const SKP_int32 len /* I: signal length (must be even) */
-);
-
-/*!
- * variable order MA filter. Prediction error filter implementation. Coeficients negated and starting with coef to x[n - 1]
- */
-void SKP_Silk_MA_Prediction(
- const SKP_int16 *in, /* I: Input signal */
- const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
- SKP_int32 *S, /* I/O: State vector [order] */
- SKP_int16 *out, /* O: Output signal */
- const SKP_int32 len, /* I: Signal length */
- const SKP_int32 order /* I: Filter order */
-);
-
-/*!
- * 16th order AR filter for LPC synthesis, coefficients are in Q12
- */
-void SKP_Silk_LPC_synthesis_order16(
- const SKP_int16 *in, /* I: excitation signal */
- const SKP_int16 *A_Q12, /* I: AR coefficients [16], between -8_Q0 and 8_Q0 */
- const SKP_int32 Gain_Q26, /* I: gain */
- SKP_int32 *S, /* I/O: state vector [16] */
- SKP_int16 *out, /* O: output signal */
- const SKP_int32 len /* I: signal length, must be multiple of 16 */
-);
-
-/* variable order MA prediction error filter. */
-/* Inverse filter of SKP_Silk_LPC_synthesis_filter */
-void SKP_Silk_LPC_analysis_filter(
- SKP_int16 *out, /* O: Output signal */
- const SKP_int16 *in, /* I: Input signal */
- const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */
- const SKP_int32 len, /* I: Signal length */
- const SKP_int32 Order /* I: Filter order */
-);
-
-/* even order AR filter */
-void SKP_Silk_LPC_synthesis_filter(
- const SKP_int16 *in, /* I: excitation signal */
- const SKP_int16 *A_Q12, /* I: AR coefficients [Order], between -8_Q0 and 8_Q0 */
- const SKP_int32 Gain_Q26, /* I: gain */
- SKP_int32 *S, /* I/O: state vector [Order] */
- SKP_int16 *out, /* O: output signal */
- const SKP_int32 len, /* I: signal length */
- const SKP_int Order /* I: filter order, must be even */
-);
-
-/* Chirp (bandwidth expand) LP AR filter */
-void SKP_Silk_bwexpander(
- SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
- const SKP_int d, /* I Length of ar */
- SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
-);
-
-/* Chirp (bandwidth expand) LP AR filter */
-void SKP_Silk_bwexpander_32(
- SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
- const SKP_int d, /* I Length of ar */
- SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */
-);
-
-/* Compute inverse of LPC prediction gain, and */
-/* test if LPC coefficients are stable (all poles within unit circle) */
-SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
- SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
- const SKP_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */
- const SKP_int order /* I: Prediction order */
-);
-
-SKP_int SKP_Silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
- SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */
- const SKP_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */
- const SKP_int order /* I: Prediction order */
-);
-
-/* split signal in two decimated bands using first-order allpass filters */
-void SKP_Silk_ana_filt_bank_1(
- const SKP_int16 *in, /* I: Input signal [N] */
- SKP_int32 *S, /* I/O: State vector [2] */
- SKP_int16 *outL, /* O: Low band [N/2] */
- SKP_int16 *outH, /* O: High band [N/2] */
- const SKP_int32 N /* I: Number of input samples */
-);
-
-/********************************************************************/
-/* SCALAR FUNCTIONS */
-/********************************************************************/
-
-/* approximation of 128 * log2() (exact inverse of approx 2^() below) */
-/* convert input to a log scale */
-SKP_int32 SKP_Silk_lin2log(const SKP_int32 inLin); /* I: input in linear scale */
-
-/* Approximation of a sigmoid function */
-SKP_int SKP_Silk_sigm_Q15(SKP_int in_Q5);
-
-/* approximation of 2^() (exact inverse of approx log2() above) */
-/* convert input to a linear scale */
-SKP_int32 SKP_Silk_log2lin(const SKP_int32 inLog_Q7); /* I: input on log scale */
-
-/* Function that returns the maximum absolut value of the input vector */
-SKP_int16 SKP_Silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
- const SKP_int16 *vec, /* I Input vector [len] */
- const SKP_int32 len /* I Length of input vector */
-);
-
-/* Compute number of bits to right shift the sum of squares of a vector */
-/* of int16s to make it fit in an int32 */
-void SKP_Silk_sum_sqr_shift(
- SKP_int32 *energy, /* O Energy of x, after shifting to the right */
- SKP_int *shift, /* O Number of bits right shift applied to energy */
- const SKP_int16 *x, /* I Input vector */
- SKP_int len /* I Length of input vector */
-);
-
-/* Calculates the reflection coefficients from the correlation sequence */
-/* Faster than schur64(), but much less accurate. */
-/* uses SMLAWB(), requiring armv5E and higher. */
-SKP_int32 SKP_Silk_schur( /* O: Returns residual energy */
- SKP_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */
- const SKP_int32 *c, /* I: correlations [order+1] */
- const SKP_int32 order /* I: prediction order */
-);;
-
-/* Calculates the reflection coefficients from the correlation sequence */
-/* Slower than schur(), but more accurate. */
-/* Uses SMULL(), available on armv4 */
-SKP_int32 SKP_Silk_schur64( /* O: returns residual energy */
- SKP_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */
- const SKP_int32 c[], /* I: Correlations [order+1] */
- SKP_int32 order /* I: Prediction order */
-);
-
-/* Step up function, converts reflection coefficients to prediction coefficients */
-void SKP_Silk_k2a(
- SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
- const SKP_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */
- const SKP_int32 order /* I: Prediction order */
-);
-
-/* Step up function, converts reflection coefficients to prediction coefficients */
-void SKP_Silk_k2a_Q16(
- SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
- const SKP_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */
- const SKP_int32 order /* I: Prediction order */
-);
-
-/* Apply sine window to signal vector. */
-/* Window types: */
-/* 1 -> sine window from 0 to pi/2 */
-/* 2 -> sine window from pi/2 to pi */
-/* every other sample of window is linearly interpolated, for speed */
-void SKP_Silk_apply_sine_window(
- SKP_int16 px_win[], /* O Pointer to windowed signal */
- const SKP_int16 px[], /* I Pointer to input signal */
- const SKP_int win_type, /* I Selects a window type */
- const SKP_int length /* I Window length, multiple of 4 */
-);
-
-/* Compute autocorrelation */
-void SKP_Silk_autocorr(
- SKP_int32 *results, /* O Result (length correlationCount) */
- SKP_int *scale, /* O Scaling of the correlation vector */
- const SKP_int16 *inputData, /* I Input data to correlate */
- const SKP_int inputDataSize, /* I Length of input */
- const SKP_int correlationCount /* I Number of correlation taps to compute */
-);
-
-/* Pitch estimator */
-#define SKP_Silk_PE_MIN_COMPLEX 0
-#define SKP_Silk_PE_MID_COMPLEX 1
-#define SKP_Silk_PE_MAX_COMPLEX 2
-
-void SKP_Silk_decode_pitch(
- SKP_int16 lagIndex, /* I */
- SKP_int8 contourIndex, /* O */
- SKP_int pitch_lags[], /* O 4 pitch values */
- const SKP_int Fs_kHz, /* I sampling frequency (kHz) */
- const SKP_int nb_subfr /* I number of sub frames */
-);
-
-SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */
- const SKP_int16 *signal, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */
- SKP_int *pitch_out, /* O 4 pitch lag values */
- SKP_int16 *lagIndex, /* O Lag Index */
- SKP_int8 *contourIndex, /* O Pitch contour Index */
- SKP_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */
- SKP_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */
- const SKP_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */
- const SKP_int search_thres2_Q15, /* I Final threshold for lag candidates 0 - 1 */
- const SKP_int Fs_kHz, /* I Sample frequency (kHz) */
- const SKP_int complexity, /* I Complexity setting, 0-2, where 2 is highest */
- const SKP_int nb_subfr /* I number of 5 ms subframes */
-);
-
-/* parameter defining the size and accuracy of the piecewise linear */
-/* cosine approximatin table. */
-
-#define LSF_COS_TAB_SZ_FIX 128
-/* rom table with cosine values */
-extern const SKP_int SKP_Silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ];
-
-void SKP_Silk_LPC_fit(
- SKP_int16 *a_QQ, /* O stabilized LPC vector, Q(24-rshift) [L] */
- SKP_int32 *a_Q24, /* I LPC vector [L] */
- const SKP_int QQ, /* I Q domain of output LPC vector */
- const SKP_int L /* I Number of LPC parameters in the input vector */
-);
-
-/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */
-/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */
-void SKP_Silk_A2NLSF(
- SKP_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */
- SKP_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */
- const SKP_int d /* I Filter order (must be even) */
-);
-
-/* compute whitening filter coefficients from normalized line spectral frequencies */
-void SKP_Silk_NLSF2A(
- SKP_int16 *a, /* o monic whitening filter coefficients in Q12, [d] */
- const SKP_int16 *NLSF, /* i normalized line spectral frequencies in Q15, [d] */
- const SKP_int d /* i filter order (should be even) */
-);
-
-void SKP_Silk_insertion_sort_increasing(
- SKP_int32 *a, /* I/O Unsorted / Sorted vector */
- SKP_int *index, /* O: Index vector for the sorted elements */
- const SKP_int L, /* I: Vector length */
- const SKP_int K /* I: Number of correctly sorted positions */
-);
-
-void SKP_Silk_insertion_sort_decreasing_int16(
- SKP_int16 *a, /* I/O: Unsorted / Sorted vector */
- SKP_int *index, /* O: Index vector for the sorted elements */
- const SKP_int L, /* I: Vector length */
- const SKP_int K /* I: Number of correctly sorted positions */
-);
-
-void SKP_Silk_insertion_sort_increasing_all_values_int16(
- SKP_int16 *a, /* I/O: Unsorted / Sorted vector */
- const SKP_int L /* I: Vector length */
-);
-
-/* NLSF stabilizer, for a single input data vector */
-void SKP_Silk_NLSF_stabilize(
- SKP_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */
- const SKP_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */
- const SKP_int L /* I: Number of NLSF parameters in the input vector */
-);
-
-/* Laroia low complexity NLSF weights */
-void SKP_Silk_NLSF_VQ_weights_laroia(
- SKP_int16 *pNLSFW_Q5, /* O: Pointer to input vector weights [D x 1] */
- const SKP_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */
- const SKP_int D /* I: Input vector dimension (even) */
-);
-
-/* Compute reflection coefficients from input signal */
-void SKP_Silk_burg_modified(
- SKP_int32 *res_nrg, /* O residual energy */
- SKP_int *res_nrgQ, /* O residual energy Q value */
- SKP_int32 A_Q16[], /* O prediction coefficients (length order) */
- const SKP_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
- const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
- const SKP_int nb_subfr, /* I number of subframes stacked in x */
- const SKP_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
- const SKP_int D /* I order */
-);
-
-/* Copy and multiply a vector by a constant */
-void SKP_Silk_scale_copy_vector16(
- SKP_int16 *data_out,
- const SKP_int16 *data_in,
- SKP_int32 gain_Q16, /* I: gain in Q16 */
- const SKP_int dataSize /* I: length */
-);
-
-/* Some for the LTP related function requires Q26 to work.*/
-void SKP_Silk_scale_vector32_Q26_lshift_18(
- SKP_int32 *data1, /* I/O: Q0/Q18 */
- SKP_int32 gain_Q26, /* I: Q26 */
- SKP_int dataSize /* I: length */
-);
-
-/********************************************************************/
-/* INLINE ARM MATH */
-/********************************************************************/
-
-/* return sum(inVec1[i]*inVec2[i]) */
-SKP_int32 SKP_Silk_inner_prod_aligned(
- const SKP_int16 *const inVec1, /* I input vector 1 */
- const SKP_int16 *const inVec2, /* I input vector 2 */
- const SKP_int len /* I vector lengths */
-);
-
-SKP_int32 SKP_Silk_inner_prod_aligned_scale(
- const SKP_int16 *const inVec1, /* I input vector 1 */
- const SKP_int16 *const inVec2, /* I input vector 2 */
- const SKP_int scale, /* I number of bits to shift */
- const SKP_int len /* I vector lengths */
-);
-
-SKP_int64 SKP_Silk_inner_prod16_aligned_64(
- const SKP_int16 *inVec1, /* I input vector 1 */
- const SKP_int16 *inVec2, /* I input vector 2 */
- const SKP_int len /* I vector lengths */
-);
-
-/********************************************************************/
-/* MACROS */
-/********************************************************************/
-
-/* Rotate a32 right by 'rot' bits. Negative rot values result in rotating
- left. Output is 32bit int.
- Note: contemporary compilers recognize the C expression below and
- compile it into a 'ror' instruction if available. No need for inline ASM! */
-SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot )
-{
- SKP_uint32 x = (SKP_uint32) a32;
- SKP_uint32 r = (SKP_uint32) rot;
- SKP_uint32 m = (SKP_uint32) -rot;
- if(rot <= 0)
- return (SKP_int32) ((x << m) | (x >> (32 - m)));
- else
- return (SKP_int32) ((x << (32 - r)) | (x >> r));
-}
-
-/* Allocate SKP_int16 alligned to 4-byte memory address */
-#if EMBEDDED_ARM
-#define SKP_DWORD_ALIGN __attribute__((aligned(4)))
-#else
-#define SKP_DWORD_ALIGN
-#endif
-
-/* Useful Macros that can be adjusted to other platforms */
-#define SKP_memcpy(a, b, c) memcpy((a), (b), (c)) /* Dest, Src, ByteCount */
-#define SKP_memset(a, b, c) memset((a), (b), (c)) /* Dest, value, ByteCount */
-#define SKP_memmove(a, b, c) memmove((a), (b), (c)) /* Dest, Src, ByteCount */
-/* fixed point macros */
-
-// (a32 * b32) output have to be 32bit int
-#define SKP_MUL(a32, b32) ((a32) * (b32))
-
-// (a32 * b32) output have to be 32bit uint
-#define SKP_MUL_uint(a32, b32) SKP_MUL(a32, b32)
-
-// a32 + (b32 * c32) output have to be 32bit int
-#define SKP_MLA(a32, b32, c32) SKP_ADD32((a32),((b32) * (c32)))
-
-// a32 + (b32 * c32) output have to be 32bit uint
-#define SKP_MLA_uint(a32, b32, c32) SKP_MLA(a32, b32, c32)
-
-// ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int
-#define SKP_SMULTT(a32, b32) (((a32) >> 16) * ((b32) >> 16))
-
-// a32 + ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int
-#define SKP_SMLATT(a32, b32, c32) SKP_ADD32((a32),((b32) >> 16) * ((c32) >> 16))
-
-#define SKP_SMLALBB(a64, b16, c16) SKP_ADD64((a64),(SKP_int64)((SKP_int32)(b16) * (SKP_int32)(c16)))
-
-// (a32 * b32)
-#define SKP_SMULL(a32, b32) ((SKP_int64)(a32) * /*(SKP_int64)*/(b32))
-
-// multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)
-#define SKP_MLA_ovflw(a32, b32, c32) SKP_MLA(a32, b32, c32)
-#ifndef SKP_SMLABB_ovflw
-# define SKP_SMLABB_ovflw(a32, b32, c32) SKP_SMLABB(a32, b32, c32)
-#endif
-#define SKP_SMLABT_ovflw(a32, b32, c32) SKP_SMLABT(a32, b32, c32)
-#define SKP_SMLATT_ovflw(a32, b32, c32) SKP_SMLATT(a32, b32, c32)
-#define SKP_SMLAWB_ovflw(a32, b32, c32) SKP_SMLAWB(a32, b32, c32)
-#define SKP_SMLAWT_ovflw(a32, b32, c32) SKP_SMLAWT(a32, b32, c32)
-
-#define SKP_DIV32_16(a32, b16) ((SKP_int32)((a32) / (b16)))
-#define SKP_DIV32(a32, b32) ((SKP_int32)((a32) / (b32)))
-
-// These macros enables checking for overflow in SKP_Silk_API_Debug.h
-#define SKP_ADD16(a, b) ((a) + (b))
-#define SKP_ADD32(a, b) ((a) + (b))
-#define SKP_ADD64(a, b) ((a) + (b))
-
-#define SKP_SUB16(a, b) ((a) - (b))
-#define SKP_SUB32(a, b) ((a) - (b))
-#define SKP_SUB64(a, b) ((a) - (b))
-
-#define SKP_SAT8(a) ((a) > SKP_int8_MAX ? SKP_int8_MAX : \
- ((a) < SKP_int8_MIN ? SKP_int8_MIN : (a)))
-#define SKP_SAT16(a) ((a) > SKP_int16_MAX ? SKP_int16_MAX : \
- ((a) < SKP_int16_MIN ? SKP_int16_MIN : (a)))
-#define SKP_SAT32(a) ((a) > SKP_int32_MAX ? SKP_int32_MAX : \
- ((a) < SKP_int32_MIN ? SKP_int32_MIN : (a)))
-
-#define SKP_CHECK_FIT8(a) (a)
-#define SKP_CHECK_FIT16(a) (a)
-#define SKP_CHECK_FIT32(a) (a)
-
-#define SKP_ADD_SAT16(a, b) (SKP_int16)SKP_SAT16( SKP_ADD32( (SKP_int32)(a), (b) ) )
-#define SKP_ADD_SAT64(a, b) ((((a) + (b)) & 0x8000000000000000LL) == 0 ? \
- ((((a) & (b)) & 0x8000000000000000LL) != 0 ? SKP_int64_MIN : (a)+(b)) : \
- ((((a) | (b)) & 0x8000000000000000LL) == 0 ? SKP_int64_MAX : (a)+(b)) )
-
-#define SKP_SUB_SAT16(a, b) (SKP_int16)SKP_SAT16( SKP_SUB32( (SKP_int32)(a), (b) ) )
-#define SKP_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \
- (( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? SKP_int64_MIN : (a)-(b)) : \
- ((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? SKP_int64_MAX : (a)-(b)) )
-
-/* Saturation for positive input values */
-#define SKP_POS_SAT32(a) ((a) > SKP_int32_MAX ? SKP_int32_MAX : (a))
-
-/* Add with saturation for positive input values */
-#define SKP_ADD_POS_SAT8(a, b) ((((a)+(b)) & 0x80) ? SKP_int8_MAX : ((a)+(b)))
-#define SKP_ADD_POS_SAT16(a, b) ((((a)+(b)) & 0x8000) ? SKP_int16_MAX : ((a)+(b)))
-#define SKP_ADD_POS_SAT32(a, b) ((((a)+(b)) & 0x80000000) ? SKP_int32_MAX : ((a)+(b)))
-#define SKP_ADD_POS_SAT64(a, b) ((((a)+(b)) & 0x8000000000000000LL) ? SKP_int64_MAX : ((a)+(b)))
-
-#define SKP_LSHIFT8(a, shift) ((a)<<(shift)) // shift >= 0, shift < 8
-#define SKP_LSHIFT16(a, shift) ((a)<<(shift)) // shift >= 0, shift < 16
-#define SKP_LSHIFT32(a, shift) ((a)<<(shift)) // shift >= 0, shift < 32
-#define SKP_LSHIFT64(a, shift) ((a)<<(shift)) // shift >= 0, shift < 64
-#define SKP_LSHIFT(a, shift) SKP_LSHIFT32(a, shift) // shift >= 0, shift < 32
-
-#define SKP_RSHIFT8(a, shift) ((a)>>(shift)) // shift >= 0, shift < 8
-#define SKP_RSHIFT16(a, shift) ((a)>>(shift)) // shift >= 0, shift < 16
-#define SKP_RSHIFT32(a, shift) ((a)>>(shift)) // shift >= 0, shift < 32
-#define SKP_RSHIFT64(a, shift) ((a)>>(shift)) // shift >= 0, shift < 64
-#define SKP_RSHIFT(a, shift) SKP_RSHIFT32(a, shift) // shift >= 0, shift < 32
-
-/* saturates before shifting */
-#define SKP_LSHIFT_SAT16(a, shift) (SKP_LSHIFT16( SKP_LIMIT( (a), SKP_RSHIFT16( SKP_int16_MIN, (shift) ), \
- SKP_RSHIFT16( SKP_int16_MAX, (shift) ) ), (shift) ))
-#define SKP_LSHIFT_SAT32(a, shift) (SKP_LSHIFT32( SKP_LIMIT( (a), SKP_RSHIFT32( SKP_int32_MIN, (shift) ), \
- SKP_RSHIFT32( SKP_int32_MAX, (shift) ) ), (shift) ))
-
-#define SKP_LSHIFT_ovflw(a, shift) ((a)<<(shift)) // shift >= 0, allowed to overflow
-#define SKP_LSHIFT_uint(a, shift) ((a)<<(shift)) // shift >= 0
-#define SKP_RSHIFT_uint(a, shift) ((a)>>(shift)) // shift >= 0
-
-#define SKP_ADD_LSHIFT(a, b, shift) ((a) + SKP_LSHIFT((b), (shift))) // shift >= 0
-#define SKP_ADD_LSHIFT32(a, b, shift) SKP_ADD32((a), SKP_LSHIFT32((b), (shift))) // shift >= 0
-#define SKP_ADD_LSHIFT_uint(a, b, shift) ((a) + SKP_LSHIFT_uint((b), (shift))) // shift >= 0
-#define SKP_ADD_RSHIFT(a, b, shift) ((a) + SKP_RSHIFT((b), (shift))) // shift >= 0
-#define SKP_ADD_RSHIFT32(a, b, shift) SKP_ADD32((a), SKP_RSHIFT32((b), (shift))) // shift >= 0
-#define SKP_ADD_RSHIFT_uint(a, b, shift) ((a) + SKP_RSHIFT_uint((b), (shift))) // shift >= 0
-#define SKP_SUB_LSHIFT32(a, b, shift) SKP_SUB32((a), SKP_LSHIFT32((b), (shift))) // shift >= 0
-#define SKP_SUB_RSHIFT32(a, b, shift) SKP_SUB32((a), SKP_RSHIFT32((b), (shift))) // shift >= 0
-
-/* Requires that shift > 0 */
-#define SKP_RSHIFT_ROUND(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
-#define SKP_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1)
-
-/* Number of rightshift required to fit the multiplication */
-#define SKP_NSHIFT_MUL_32_32(a, b) ( -(31- (32-SKP_Silk_CLZ32(SKP_abs(a)) + (32-SKP_Silk_CLZ32(SKP_abs(b))))) )
-#define SKP_NSHIFT_MUL_16_16(a, b) ( -(15- (16-SKP_Silk_CLZ16(SKP_abs(a)) + (16-SKP_Silk_CLZ16(SKP_abs(b))))) )
-
-
-#define SKP_min(a, b) (((a) < (b)) ? (a) : (b))
-#define SKP_max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* Macro to convert floating-point constants to fixed-point */
-#define SKP_FIX_CONST( C, Q ) ((SKP_int32)((C) * ((SKP_int64)1 << (Q)) + 0.5))
-
-/* SKP_min() versions with typecast in the function call */
-SKP_INLINE SKP_int SKP_min_int(SKP_int a, SKP_int b)
-{
- return (((a) < (b)) ? (a) : (b));
-}
-SKP_INLINE SKP_int16 SKP_min_16(SKP_int16 a, SKP_int16 b)
-{
- return (((a) < (b)) ? (a) : (b));
-}
-SKP_INLINE SKP_int32 SKP_min_32(SKP_int32 a, SKP_int32 b)
-{
- return (((a) < (b)) ? (a) : (b));
-}
-SKP_INLINE SKP_int64 SKP_min_64(SKP_int64 a, SKP_int64 b)
-{
- return (((a) < (b)) ? (a) : (b));
-}
-
-/* SKP_min() versions with typecast in the function call */
-SKP_INLINE SKP_int SKP_max_int(SKP_int a, SKP_int b)
-{
- return (((a) > (b)) ? (a) : (b));
-}
-SKP_INLINE SKP_int16 SKP_max_16(SKP_int16 a, SKP_int16 b)
-{
- return (((a) > (b)) ? (a) : (b));
-}
-SKP_INLINE SKP_int32 SKP_max_32(SKP_int32 a, SKP_int32 b)
-{
- return (((a) > (b)) ? (a) : (b));
-}
-SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)
-{
- return (((a) > (b)) ? (a) : (b));
-}
-
-#define SKP_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \
- : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))
-
-#define SKP_LIMIT_int SKP_LIMIT
-#define SKP_LIMIT_16 SKP_LIMIT
-#define SKP_LIMIT_32 SKP_LIMIT
-
-//#define SKP_non_neg(a) ((a) & ((-(a)) >> (8 * sizeof(a) - 1))) /* doesn't seem faster than SKP_max(0, a);
-
-#define SKP_abs(a) (((a) > 0) ? (a) : -(a)) // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN
-#define SKP_abs_int(a) (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1)))
-#define SKP_abs_int32(a) (((a) ^ ((a) >> 31)) - ((a) >> 31))
-#define SKP_abs_int64(a) (((a) > 0) ? (a) : -(a))
-
-#define SKP_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ))
-
-#define SKP_sqrt(a) (sqrt(a))
-
-/* PSEUDO-RANDOM GENERATOR */
-/* Make sure to store the result as the seed for the next call (also in between */
-/* frames), otherwise result won't be random at all. When only using some of the */
-/* bits, take the most significant bits by right-shifting. */
-#define SKP_RAND(seed) (SKP_MLA_ovflw(907633515, (seed), 196314165))
-
-// Add some multiplication functions that can be easily mapped to ARM.
-
-// SKP_SMMUL: Signed top word multiply.
-// ARMv6 2 instruction cycles.
-// ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)
-//#define SKP_SMMUL(a32, b32) (SKP_int32)SKP_RSHIFT(SKP_SMLAL(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16)), 16)
-// the following seems faster on x86
-#define SKP_SMMUL(a32, b32) (SKP_int32)SKP_RSHIFT64(SKP_SMULL((a32), (b32)), 32)
-
-#include "SKP_Silk_Inlines.h"
-#include "SKP_Silk_MacroCount.h"
-#include "SKP_Silk_MacroDebug.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/silk/SKP_Silk_VAD.c
+++ /dev/null
@@ -1,321 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include <stdlib.h>
-#include "SKP_Silk_main.h"
-
-/**********************************/
-/* Initialization of the Silk VAD */
-/**********************************/
-SKP_int SKP_Silk_VAD_Init( /* O Return value, 0 if success */
- SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
-)
-{
- SKP_int b, ret = 0;
-
- /* reset state memory */
- SKP_memset( psSilk_VAD, 0, sizeof( SKP_Silk_VAD_state ) );
-
- /* init noise levels */
- /* Initialize array with approx pink noise levels (psd proportional to inverse of frequency) */
- for( b = 0; b < VAD_N_BANDS; b++ ) {
- psSilk_VAD->NoiseLevelBias[ b ] = SKP_max_32( SKP_DIV32_16( VAD_NOISE_LEVELS_BIAS, b + 1 ), 1 );
- }
-
- /* Initialize state */
- for( b = 0; b < VAD_N_BANDS; b++ ) {
- psSilk_VAD->NL[ b ] = SKP_MUL( 100, psSilk_VAD->NoiseLevelBias[ b ] );
- psSilk_VAD->inv_NL[ b ] = SKP_DIV32( SKP_int32_MAX, psSilk_VAD->NL[ b ] );
- }
- psSilk_VAD->counter = 15;
-
- /* init smoothed energy-to-noise ratio*/
- for( b = 0; b < VAD_N_BANDS; b++ ) {
- psSilk_VAD->NrgRatioSmth_Q8[ b ] = 100 * 256; /* 100 * 256 --> 20 dB SNR */
- }
-
- return( ret );
-}
-
-/* Weighting factors for tilt measure */
-const static SKP_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 };
-
-/***************************************/
-/* Get the speech activity level in Q8 */
-/***************************************/
-SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
- SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
- const SKP_int16 pIn[] /* I PCM input */
-)
-{
- SKP_int SA_Q15, pSNR_dB_Q7, input_tilt;
- SKP_int decimated_framelength, dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s;
- SKP_int32 sumSquared, smooth_coef_Q16;
- SKP_int16 HPstateTmp;
- SKP_int16 X[ VAD_N_BANDS ][ MAX_FRAME_LENGTH / 2 ];
- SKP_int32 Xnrg[ VAD_N_BANDS ];
- SKP_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ];
- SKP_int32 speech_nrg, x_tmp;
- SKP_int ret = 0;
- SKP_Silk_VAD_state *psSilk_VAD = &psEncC->sVAD;
-
- /* Safety checks */
- SKP_assert( VAD_N_BANDS == 4 );
- SKP_assert( MAX_FRAME_LENGTH >= psEncC->frame_length );
- SKP_assert( psEncC->frame_length <= 512 );
- SKP_assert( psEncC->frame_length == 8 * SKP_RSHIFT( psEncC->frame_length, 3 ) );
-
- /***********************/
- /* Filter and Decimate */
- /***********************/
- /* 0-8 kHz to 0-4 kHz and 4-8 kHz */
- SKP_Silk_ana_filt_bank_1( pIn, &psSilk_VAD->AnaState[ 0 ], &X[ 0 ][ 0 ], &X[ 3 ][ 0 ], psEncC->frame_length );
-
- /* 0-4 kHz to 0-2 kHz and 2-4 kHz */
- SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState1[ 0 ], &X[ 0 ][ 0 ], &X[ 2 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 1 ) );
-
- /* 0-2 kHz to 0-1 kHz and 1-2 kHz */
- SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState2[ 0 ], &X[ 0 ][ 0 ], &X[ 1 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 2 ) );
-
- /*********************************************/
- /* HP filter on lowest band (differentiator) */
- /*********************************************/
- decimated_framelength = SKP_RSHIFT( psEncC->frame_length, 3 );
- X[ 0 ][ decimated_framelength - 1 ] = SKP_RSHIFT( X[ 0 ][ decimated_framelength - 1 ], 1 );
- HPstateTmp = X[ 0 ][ decimated_framelength - 1 ];
- for( i = decimated_framelength - 1; i > 0; i-- ) {
- X[ 0 ][ i - 1 ] = SKP_RSHIFT( X[ 0 ][ i - 1 ], 1 );
- X[ 0 ][ i ] -= X[ 0 ][ i - 1 ];
- }
- X[ 0 ][ 0 ] -= psSilk_VAD->HPstate;
- psSilk_VAD->HPstate = HPstateTmp;
-
- /*************************************/
- /* Calculate the energy in each band */
- /*************************************/
- for( b = 0; b < VAD_N_BANDS; b++ ) {
- /* Find the decimated framelength in the non-uniformly divided bands */
- decimated_framelength = SKP_RSHIFT( psEncC->frame_length, SKP_min_int( VAD_N_BANDS - b, VAD_N_BANDS - 1 ) );
-
- /* Split length into subframe lengths */
- dec_subframe_length = SKP_RSHIFT( decimated_framelength, VAD_INTERNAL_SUBFRAMES_LOG2 );
- dec_subframe_offset = 0;
-
- /* Compute energy per sub-frame */
- /* initialize with summed energy of last subframe */
- Xnrg[ b ] = psSilk_VAD->XnrgSubfr[ b ];
- for( s = 0; s < VAD_INTERNAL_SUBFRAMES; s++ ) {
- sumSquared = 0;
- for( i = 0; i < dec_subframe_length; i++ ) {
- /* The energy will be less than dec_subframe_length * ( SKP_int16_MIN / 8 ) ^ 2. */
- /* Therefore we can accumulate with no risk of overflow (unless dec_subframe_length > 128) */
- x_tmp = SKP_RSHIFT( X[ b ][ i + dec_subframe_offset ], 3 );
- sumSquared = SKP_SMLABB( sumSquared, x_tmp, x_tmp );
-
- /* Safety check */
- SKP_assert( sumSquared >= 0 );
- }
-
- /* Add/saturate summed energy of current subframe */
- if( s < VAD_INTERNAL_SUBFRAMES - 1 ) {
- Xnrg[ b ] = SKP_ADD_POS_SAT32( Xnrg[ b ], sumSquared );
- } else {
- /* Look-ahead subframe */
- Xnrg[ b ] = SKP_ADD_POS_SAT32( Xnrg[ b ], SKP_RSHIFT( sumSquared, 1 ) );
- }
-
- dec_subframe_offset += dec_subframe_length;
- }
- psSilk_VAD->XnrgSubfr[ b ] = sumSquared;
- }
-
- /********************/
- /* Noise estimation */
- /********************/
- SKP_Silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD );
-
- /***********************************************/
- /* Signal-plus-noise to noise ratio estimation */
- /***********************************************/
- sumSquared = 0;
- input_tilt = 0;
- for( b = 0; b < VAD_N_BANDS; b++ ) {
- speech_nrg = Xnrg[ b ] - psSilk_VAD->NL[ b ];
- if( speech_nrg > 0 ) {
- /* Divide, with sufficient resolution */
- if( ( Xnrg[ b ] & 0xFF800000 ) == 0 ) {
- NrgToNoiseRatio_Q8[ b ] = SKP_DIV32( SKP_LSHIFT( Xnrg[ b ], 8 ), psSilk_VAD->NL[ b ] + 1 );
- } else {
- NrgToNoiseRatio_Q8[ b ] = SKP_DIV32( Xnrg[ b ], SKP_RSHIFT( psSilk_VAD->NL[ b ], 8 ) + 1 );
- }
-
- /* Convert to log domain */
- SNR_Q7 = SKP_Silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128;
-
- /* Sum-of-squares */
- sumSquared = SKP_SMLABB( sumSquared, SNR_Q7, SNR_Q7 ); /* Q14 */
-
- /* Tilt measure */
- if( speech_nrg < ( 1 << 20 ) ) {
- /* Scale down SNR value for small subband speech energies */
- SNR_Q7 = SKP_SMULWB( SKP_LSHIFT( SKP_Silk_SQRT_APPROX( speech_nrg ), 6 ), SNR_Q7 );
- }
- input_tilt = SKP_SMLAWB( input_tilt, tiltWeights[ b ], SNR_Q7 );
- } else {
- NrgToNoiseRatio_Q8[ b ] = 256;
- }
- }
-
- /* Mean-of-squares */
- sumSquared = SKP_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */
-
- /* Root-mean-square approximation, scale to dBs, and write to output pointer */
- pSNR_dB_Q7 = ( SKP_int16 )( 3 * SKP_Silk_SQRT_APPROX( sumSquared ) ); /* Q7 */
-
- /*********************************/
- /* Speech Probability Estimation */
- /*********************************/
- SA_Q15 = SKP_Silk_sigm_Q15( SKP_SMULWB( VAD_SNR_FACTOR_Q16, pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 );
-
- /**************************/
- /* Frequency Tilt Measure */
- /**************************/
- psEncC->input_tilt_Q15 = SKP_LSHIFT( SKP_Silk_sigm_Q15( input_tilt ) - 16384, 1 );
-
- /**************************************************/
- /* Scale the sigmoid output based on power levels */
- /**************************************************/
- speech_nrg = 0;
- for( b = 0; b < VAD_N_BANDS; b++ ) {
- /* Accumulate signal-without-noise energies, higher frequency bands have more weight */
- speech_nrg += ( b + 1 ) * SKP_RSHIFT( Xnrg[ b ] - psSilk_VAD->NL[ b ], 4 );
- }
-
- /* Power scaling */
- if( speech_nrg <= 0 ) {
- SA_Q15 = SKP_RSHIFT( SA_Q15, 1 );
- } else if( speech_nrg < 32768 ) {
- if( psEncC->frame_length == 10 * psEncC->fs_kHz ) {
- speech_nrg = SKP_LSHIFT_SAT32( speech_nrg, 16 );
- } else {
- speech_nrg = SKP_LSHIFT_SAT32( speech_nrg, 15 );
- }
-
- /* square-root */
- speech_nrg = SKP_Silk_SQRT_APPROX( speech_nrg );
- SA_Q15 = SKP_SMULWB( 32768 + speech_nrg, SA_Q15 );
- }
-
- /* Copy the resulting speech activity in Q8 */
- psEncC->speech_activity_Q8 = SKP_min_int( SKP_RSHIFT( SA_Q15, 7 ), SKP_uint8_MAX );
-
- /***********************************/
- /* Energy Level and SNR estimation */
- /***********************************/
- /* Smoothing coefficient */
- smooth_coef_Q16 = SKP_SMULWB( VAD_SNR_SMOOTH_COEF_Q18, SKP_SMULWB( SA_Q15, SA_Q15 ) );
-
- if( psEncC->frame_length == 10 * psEncC->fs_kHz ) {
- smooth_coef_Q16 >>= 1;
- }
-
- for( b = 0; b < VAD_N_BANDS; b++ ) {
- /* compute smoothed energy-to-noise ratio per band */
- psSilk_VAD->NrgRatioSmth_Q8[ b ] = SKP_SMLAWB( psSilk_VAD->NrgRatioSmth_Q8[ b ],
- NrgToNoiseRatio_Q8[ b ] - psSilk_VAD->NrgRatioSmth_Q8[ b ], smooth_coef_Q16 );
-
- /* signal to noise ratio in dB per band */
- SNR_Q7 = 3 * ( SKP_Silk_lin2log( psSilk_VAD->NrgRatioSmth_Q8[b] ) - 8 * 128 );
- /* quality = sigmoid( 0.25 * ( SNR_dB - 16 ) ); */
- psEncC->input_quality_bands_Q15[ b ] = SKP_Silk_sigm_Q15( SKP_RSHIFT( SNR_Q7 - 16 * 128, 4 ) );
- }
-
- return( ret );
-}
-
-/**************************/
-/* Noise level estimation */
-/**************************/
-void SKP_Silk_VAD_GetNoiseLevels(
- const SKP_int32 pX[ VAD_N_BANDS ], /* I subband energies */
- SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
-)
-{
- SKP_int k;
- SKP_int32 nl, nrg, inv_nrg;
- SKP_int coef, min_coef;
-
- /* Initially faster smoothing */
- if( psSilk_VAD->counter < 1000 ) { /* 1000 = 20 sec */
- min_coef = SKP_DIV32_16( SKP_int16_MAX, SKP_RSHIFT( psSilk_VAD->counter, 4 ) + 1 );
- } else {
- min_coef = 0;
- }
-
- for( k = 0; k < VAD_N_BANDS; k++ ) {
- /* Get old noise level estimate for current band */
- nl = psSilk_VAD->NL[ k ];
- SKP_assert( nl >= 0 );
-
- /* Add bias */
- nrg = SKP_ADD_POS_SAT32( pX[ k ], psSilk_VAD->NoiseLevelBias[ k ] );
- SKP_assert( nrg > 0 );
-
- /* Invert energies */
- inv_nrg = SKP_DIV32( SKP_int32_MAX, nrg );
- SKP_assert( inv_nrg >= 0 );
-
- /* Less update when subband energy is high */
- if( nrg > SKP_LSHIFT( nl, 3 ) ) {
- coef = VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 >> 3;
- } else if( nrg < nl ) {
- coef = VAD_NOISE_LEVEL_SMOOTH_COEF_Q16;
- } else {
- coef = SKP_SMULWB( SKP_SMULWW( inv_nrg, nl ), VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 << 1 );
- }
-
- /* Initially faster smoothing */
- coef = SKP_max_int( coef, min_coef );
-
- /* Smooth inverse energies */
- psSilk_VAD->inv_NL[ k ] = SKP_SMLAWB( psSilk_VAD->inv_NL[ k ], inv_nrg - psSilk_VAD->inv_NL[ k ], coef );
- SKP_assert( psSilk_VAD->inv_NL[ k ] >= 0 );
-
- /* Compute noise level by inverting again */
- nl = SKP_DIV32( SKP_int32_MAX, psSilk_VAD->inv_NL[ k ] );
- SKP_assert( nl >= 0 );
-
- /* Limit noise levels (guarantee 7 bits of head room) */
- nl = SKP_min( nl, 0x00FFFFFF );
-
- /* Store as part of state */
- psSilk_VAD->NL[ k ] = nl;
- }
-
- /* Increment frame counter */
- psSilk_VAD->counter++;
-}
--- a/silk/SKP_Silk_VQ_WMat_EC.c
+++ /dev/null
@@ -1,107 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */
-void SKP_Silk_VQ_WMat_EC(
- SKP_int8 *ind, /* O index of best codebook vector */
- SKP_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/
- const SKP_int16 *in_Q14, /* I input vector to be quantized */
- const SKP_int32 *W_Q18, /* I weighting matrix */
- const SKP_int8 *cb_Q7, /* I codebook */
- const SKP_uint8 *cl_Q5, /* I code length for each codebook vector */
- const SKP_int mu_Q9, /* I tradeoff between weighted error and rate */
- SKP_int L /* I number of vectors in codebook */
-)
-{
- SKP_int k;
- const SKP_int8 *cb_row_Q7;
- SKP_int16 diff_Q14[ 5 ];
- SKP_int32 sum1_Q14, sum2_Q16;
-
- /* Loop over codebook */
- *rate_dist_Q14 = SKP_int32_MAX;
- cb_row_Q7 = cb_Q7;
- for( k = 0; k < L; k++ ) {
- diff_Q14[ 0 ] = in_Q14[ 0 ] - SKP_LSHIFT( cb_row_Q7[ 0 ], 7 );
- diff_Q14[ 1 ] = in_Q14[ 1 ] - SKP_LSHIFT( cb_row_Q7[ 1 ], 7 );
- diff_Q14[ 2 ] = in_Q14[ 2 ] - SKP_LSHIFT( cb_row_Q7[ 2 ], 7 );
- diff_Q14[ 3 ] = in_Q14[ 3 ] - SKP_LSHIFT( cb_row_Q7[ 3 ], 7 );
- diff_Q14[ 4 ] = in_Q14[ 4 ] - SKP_LSHIFT( cb_row_Q7[ 4 ], 7 );
-
- /* Weighted rate */
- sum1_Q14 = SKP_SMULBB( mu_Q9, cl_Q5[ k ] );
-
- SKP_assert( sum1_Q14 >= 0 );
-
- /* first row of W_Q18 */
- sum2_Q16 = SKP_SMULWB( W_Q18[ 1 ], diff_Q14[ 1 ] );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 2 ], diff_Q14[ 2 ] );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 3 ], diff_Q14[ 3 ] );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 4 ], diff_Q14[ 4 ] );
- sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 0 ], diff_Q14[ 0 ] );
- sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 0 ] );
-
- /* second row of W_Q18 */
- sum2_Q16 = SKP_SMULWB( W_Q18[ 7 ], diff_Q14[ 2 ] );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 8 ], diff_Q14[ 3 ] );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 9 ], diff_Q14[ 4 ] );
- sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 6 ], diff_Q14[ 1 ] );
- sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 1 ] );
-
- /* third row of W_Q18 */
- sum2_Q16 = SKP_SMULWB( W_Q18[ 13 ], diff_Q14[ 3 ] );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 14 ], diff_Q14[ 4 ] );
- sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 12 ], diff_Q14[ 2 ] );
- sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 2 ] );
-
- /* fourth row of W_Q18 */
- sum2_Q16 = SKP_SMULWB( W_Q18[ 19 ], diff_Q14[ 4 ] );
- sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );
- sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 18 ], diff_Q14[ 3 ] );
- sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 3 ] );
-
- /* last row of W_Q18 */
- sum2_Q16 = SKP_SMULWB( W_Q18[ 24 ], diff_Q14[ 4 ] );
- sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16, diff_Q14[ 4 ] );
-
- SKP_assert( sum1_Q14 >= 0 );
-
- /* find best */
- if( sum1_Q14 < *rate_dist_Q14 ) {
- *rate_dist_Q14 = sum1_Q14;
- *ind = (SKP_int8)k;
- }
-
- /* Go to next cbk vector */
- cb_row_Q7 += LTP_ORDER;
- }
-}
--- a/silk/SKP_Silk_ana_filt_bank_1.c
+++ /dev/null
@@ -1,79 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_ana_filt_bank_1.c *
- * *
- * Split signal into two decimated bands using first-order allpass filters *
- * *
- * Copyright 2006 (c), Skype Limited *
- * Date: 060221 *
- * */
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Coefficients for 2-band filter bank based on first-order allpass filters */
-// old
-static SKP_int16 A_fb1_20[ 1 ] = { 5394 << 1 };
-static SKP_int16 A_fb1_21[ 1 ] = { 20623 << 1 }; /* wrap-around to negative number is intentional */
-
-/* Split signal into two decimated bands using first-order allpass filters */
-void SKP_Silk_ana_filt_bank_1(
- const SKP_int16 *in, /* I: Input signal [N] */
- SKP_int32 *S, /* I/O: State vector [2] */
- SKP_int16 *outL, /* O: Low band [N/2] */
- SKP_int16 *outH, /* O: High band [N/2] */
- const SKP_int32 N /* I: Number of input samples */
-)
-{
- SKP_int k, N2 = SKP_RSHIFT( N, 1 );
- SKP_int32 in32, X, Y, out_1, out_2;
-
- /* Internal variables and state are in Q10 format */
- for( k = 0; k < N2; k++ ) {
- /* Convert to Q10 */
- in32 = SKP_LSHIFT( (SKP_int32)in[ 2 * k ], 10 );
-
- /* All-pass section for even input sample */
- Y = SKP_SUB32( in32, S[ 0 ] );
- X = SKP_SMLAWB( Y, Y, A_fb1_21[ 0 ] );
- out_1 = SKP_ADD32( S[ 0 ], X );
- S[ 0 ] = SKP_ADD32( in32, X );
-
- /* Convert to Q10 */
- in32 = SKP_LSHIFT( (SKP_int32)in[ 2 * k + 1 ], 10 );
-
- /* All-pass section for odd input sample, and add to output of previous section */
- Y = SKP_SUB32( in32, S[ 1 ] );
- X = SKP_SMULWB( Y, A_fb1_20[ 0 ] );
- out_2 = SKP_ADD32( S[ 1 ], X );
- S[ 1 ] = SKP_ADD32( in32, X );
-
- /* Add/subtract, convert back to int16 and store to output */
- outL[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_ADD32( out_2, out_1 ), 11 ) );
- outH[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SUB32( out_2, out_1 ), 11 ) );
- }
-}
--- a/silk/SKP_Silk_apply_sine_window.c
+++ /dev/null
@@ -1,97 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Apply sine window to signal vector. */
-/* Window types: */
-/* 1 -> sine window from 0 to pi/2 */
-/* 2 -> sine window from pi/2 to pi */
-/* Every other sample is linearly interpolated, for speed. */
-/* Window length must be between 16 and 120 (incl) and a multiple of 4. */
-
-/* Matlab code for table:
- for k=16:9*4:16+2*9*4, fprintf(' %7.d,', -round(65536*pi ./ (k:4:k+8*4))); fprintf('\n'); end
-*/
-static SKP_int16 freq_table_Q16[ 27 ] = {
- 12111, 9804, 8235, 7100, 6239, 5565, 5022, 4575, 4202,
- 3885, 3612, 3375, 3167, 2984, 2820, 2674, 2542, 2422,
- 2313, 2214, 2123, 2038, 1961, 1889, 1822, 1760, 1702,
-};
-
-void SKP_Silk_apply_sine_window(
- SKP_int16 px_win[], /* O Pointer to windowed signal */
- const SKP_int16 px[], /* I Pointer to input signal */
- const SKP_int win_type, /* I Selects a window type */
- const SKP_int length /* I Window length, multiple of 4 */
-)
-{
- SKP_int k, f_Q16, c_Q16;
- SKP_int32 S0_Q16, S1_Q16;
-
- SKP_assert( win_type == 1 || win_type == 2 );
-
- /* Length must be in a range from 16 to 120 and a multiple of 4 */
- SKP_assert( length >= 16 && length <= 120 );
- SKP_assert( ( length & 3 ) == 0 );
-
- /* Frequency */
- k = ( length >> 2 ) - 4;
- SKP_assert( k >= 0 && k <= 26 );
- f_Q16 = (SKP_int)freq_table_Q16[ k ];
-
- /* Factor used for cosine approximation */
- c_Q16 = SKP_SMULWB( f_Q16, -f_Q16 );
- SKP_assert( c_Q16 >= -32768 );
-
- /* initialize state */
- if( win_type == 1 ) {
- /* start from 0 */
- S0_Q16 = 0;
- /* approximation of sin(f) */
- S1_Q16 = f_Q16 + SKP_RSHIFT( length, 3 );
- } else {
- /* start from 1 */
- S0_Q16 = ( 1 << 16 );
- /* approximation of cos(f) */
- S1_Q16 = ( 1 << 16 ) + SKP_RSHIFT( c_Q16, 1 ) + SKP_RSHIFT( length, 4 );
- }
-
- /* Uses the recursive equation: sin(n*f) = 2 * cos(f) * sin((n-1)*f) - sin((n-2)*f) */
- /* 4 samples at a time */
- for( k = 0; k < length; k += 4 ) {
- px_win[ k ] = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k ] );
- px_win[ k + 1 ] = (SKP_int16)SKP_SMULWB( S1_Q16, px[ k + 1] );
- S0_Q16 = SKP_SMULWB( S1_Q16, c_Q16 ) + SKP_LSHIFT( S1_Q16, 1 ) - S0_Q16 + 1;
- S0_Q16 = SKP_min( S0_Q16, ( 1 << 16 ) );
-
- px_win[ k + 2 ] = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k + 2] );
- px_win[ k + 3 ] = (SKP_int16)SKP_SMULWB( S0_Q16, px[ k + 3 ] );
- S1_Q16 = SKP_SMULWB( S0_Q16, c_Q16 ) + SKP_LSHIFT( S0_Q16, 1 ) - S1_Q16;
- S1_Q16 = SKP_min( S1_Q16, ( 1 << 16 ) );
- }
-}
--- a/silk/SKP_Silk_array_maxabs.c
+++ /dev/null
@@ -1,69 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_Silk_int16_array_maxabs.c *
- * *
- * Function that returns the maximum absolut value of *
- * the input vector *
- * *
- * Copyright 2006 (c), Skype Limited *
- * Date: 060221 *
- * */
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Function that returns the maximum absolut value of the input vector */
-SKP_int16 SKP_Silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */
- const SKP_int16 *vec, /* I Input vector [len] */
- const SKP_int32 len /* I Length of input vector */
-)
-{
- SKP_int32 max = 0, i, lvl = 0, ind;
- if( len == 0 ) return 0;
-
- ind = len - 1;
- max = SKP_SMULBB( vec[ ind ], vec[ ind ] );
- for( i = len - 2; i >= 0; i-- ) {
- lvl = SKP_SMULBB( vec[ i ], vec[ i ] );
- if( lvl > max ) {
- max = lvl;
- ind = i;
- }
- }
-
- /* Do not return 32768, as it will not fit in an int16 so may lead to problems later on */
- if( max >= 1073676289 ) { // (2^15-1)^2 = 1073676289
- return( SKP_int16_MAX );
- } else {
- if( vec[ ind ] < 0 ) {
- return( -vec[ ind ] );
- } else {
- return( vec[ ind ] );
- }
- }
-}
-
--- a/silk/SKP_Silk_autocorr.c
+++ /dev/null
@@ -1,72 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Compute autocorrelation */
-void SKP_Silk_autocorr(
- SKP_int32 *results, /* O Result (length correlationCount) */
- SKP_int *scale, /* O Scaling of the correlation vector */
- const SKP_int16 *inputData, /* I Input data to correlate */
- const SKP_int inputDataSize, /* I Length of input */
- const SKP_int correlationCount /* I Number of correlation taps to compute */
-)
-{
- SKP_int i, lz, nRightShifts, corrCount;
- SKP_int64 corr64;
-
- corrCount = SKP_min_int( inputDataSize, correlationCount );
-
- /* compute energy (zero-lag correlation) */
- corr64 = SKP_Silk_inner_prod16_aligned_64( inputData, inputData, inputDataSize );
-
- /* deal with all-zero input data */
- corr64 += 1;
-
- /* number of leading zeros */
- lz = SKP_Silk_CLZ64( corr64 );
-
- /* scaling: number of right shifts applied to correlations */
- nRightShifts = 35 - lz;
- *scale = nRightShifts;
-
- if( nRightShifts <= 0 ) {
- results[ 0 ] = SKP_LSHIFT( (SKP_int32)SKP_CHECK_FIT32( corr64 ), -nRightShifts );
-
- /* compute remaining correlations based on int32 inner product */
- for( i = 1; i < corrCount; i++ ) {
- results[ i ] = SKP_LSHIFT( SKP_Silk_inner_prod_aligned( inputData, inputData + i, inputDataSize - i ), -nRightShifts );
- }
- } else {
- results[ 0 ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( corr64, nRightShifts ) );
-
- /* compute remaining correlations based on int64 inner product */
- for( i = 1; i < corrCount; i++ ) {
- results[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( SKP_Silk_inner_prod16_aligned_64( inputData, inputData + i, inputDataSize - i ), nRightShifts ) );
- }
- }
-}
--- a/silk/SKP_Silk_biquad_alt.c
+++ /dev/null
@@ -1,73 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_Silk_biquad_alt.c *
- * *
- * Second order ARMA filter *
- * Can handle slowly varying filter coefficients *
- * */
-#include "SKP_Silk_SigProc_FIX.h"
-
-
-/* Second order ARMA filter, alternative implementation */
-void SKP_Silk_biquad_alt(
- const SKP_int16 *in, /* I: Input signal */
- const SKP_int32 *B_Q28, /* I: MA coefficients [3] */
- const SKP_int32 *A_Q28, /* I: AR coefficients [2] */
- SKP_int32 *S, /* I/O: State vector [2] */
- SKP_int16 *out, /* O: Output signal */
- const SKP_int32 len /* I: Signal length (must be even) */
-)
-{
- /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */
- SKP_int k;
- SKP_int32 inval, A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14;
-
- /* Negate A_Q28 values and split in two parts */
- A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */
- A0_U_Q28 = SKP_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */
- A1_L_Q28 = ( -A_Q28[ 1 ] ) & 0x00003FFF; /* lower part */
- A1_U_Q28 = SKP_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */
-
- for( k = 0; k < len; k++ ) {
- /* S[ 0 ], S[ 1 ]: Q12 */
- inval = in[ k ];
- out32_Q14 = SKP_LSHIFT( SKP_SMLAWB( S[ 0 ], B_Q28[ 0 ], inval ), 2 );
-
- S[ 0 ] = S[1] + SKP_RSHIFT_ROUND( SKP_SMULWB( out32_Q14, A0_L_Q28 ), 14 );
- S[ 0 ] = SKP_SMLAWB( S[ 0 ], out32_Q14, A0_U_Q28 );
- S[ 0 ] = SKP_SMLAWB( S[ 0 ], B_Q28[ 1 ], inval);
-
- S[ 1 ] = SKP_RSHIFT_ROUND( SKP_SMULWB( out32_Q14, A1_L_Q28 ), 14 );
- S[ 1 ] = SKP_SMLAWB( S[ 1 ], out32_Q14, A1_U_Q28 );
- S[ 1 ] = SKP_SMLAWB( S[ 1 ], B_Q28[ 2 ], inval );
-
- /* Scale back to Q0 and saturate */
- out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT( out32_Q14 + (1<<14) - 1, 14 ) );
- }
-}
--- a/silk/SKP_Silk_burg_modified.c
+++ /dev/null
@@ -1,228 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_Silk_burg_modified.c *
- * *
- * Calculates the reflection coefficients from the input vector *
- * Input vector contains nb_subfr sub vectors of length L_sub + D *
- * *
- * Copyright 2009 (c), Skype Limited *
- * Date: 100105 *
- */
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-#define MAX_FRAME_SIZE 384 // subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384
-#define MAX_NB_SUBFR 4
-
-#define QA 25
-#define N_BITS_HEAD_ROOM 2
-#define MIN_RSHIFTS -16
-#define MAX_RSHIFTS (32 - QA)
-
-/* Compute reflection coefficients from input signal */
-void SKP_Silk_burg_modified(
- SKP_int32 *res_nrg, /* O residual energy */
- SKP_int *res_nrg_Q, /* O residual energy Q value */
- SKP_int32 A_Q16[], /* O prediction coefficients (length order) */
- const SKP_int16 x[], /* I input signal, length: nb_subfr * ( D + subfr_length ) */
- const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
- const SKP_int nb_subfr, /* I number of subframes stacked in x */
- const SKP_int32 WhiteNoiseFrac_Q32, /* I fraction added to zero-lag autocorrelation */
- const SKP_int D /* I order */
-)
-{
- SKP_int k, n, s, lz, rshifts, rshifts_extra;
- SKP_int32 C0, num, nrg, rc_Q31, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2;
- const SKP_int16 *x_ptr;
-
- SKP_int32 C_first_row[ SKP_Silk_MAX_ORDER_LPC ];
- SKP_int32 C_last_row[ SKP_Silk_MAX_ORDER_LPC ];
- SKP_int32 Af_QA[ SKP_Silk_MAX_ORDER_LPC ];
-
- SKP_int32 CAf[ SKP_Silk_MAX_ORDER_LPC + 1 ];
- SKP_int32 CAb[ SKP_Silk_MAX_ORDER_LPC + 1 ];
-
- SKP_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE );
- SKP_assert( nb_subfr <= MAX_NB_SUBFR );
-
-
- /* Compute autocorrelations, added over subframes */
- SKP_Silk_sum_sqr_shift( &C0, &rshifts, x, nb_subfr * subfr_length );
- if( rshifts > MAX_RSHIFTS ) {
- C0 = SKP_LSHIFT32( C0, rshifts - MAX_RSHIFTS );
- SKP_assert( C0 > 0 );
- rshifts = MAX_RSHIFTS;
- } else {
- lz = SKP_Silk_CLZ32( C0 ) - 1;
- rshifts_extra = N_BITS_HEAD_ROOM - lz;
- if( rshifts_extra > 0 ) {
- rshifts_extra = SKP_min( rshifts_extra, MAX_RSHIFTS - rshifts );
- C0 = SKP_RSHIFT32( C0, rshifts_extra );
- } else {
- rshifts_extra = SKP_max( rshifts_extra, MIN_RSHIFTS - rshifts );
- C0 = SKP_LSHIFT32( C0, -rshifts_extra );
- }
- rshifts += rshifts_extra;
- }
- SKP_memset( C_first_row, 0, SKP_Silk_MAX_ORDER_LPC * sizeof( SKP_int32 ) );
- if( rshifts > 0 ) {
- for( s = 0; s < nb_subfr; s++ ) {
- x_ptr = x + s * subfr_length;
- for( n = 1; n < D + 1; n++ ) {
- C_first_row[ n - 1 ] += (SKP_int32)SKP_RSHIFT64(
- SKP_Silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n ), rshifts );
- }
- }
- } else {
- for( s = 0; s < nb_subfr; s++ ) {
- x_ptr = x + s * subfr_length;
- for( n = 1; n < D + 1; n++ ) {
- C_first_row[ n - 1 ] += SKP_LSHIFT32(
- SKP_Silk_inner_prod_aligned( x_ptr, x_ptr + n, subfr_length - n ), -rshifts );
- }
- }
- }
- SKP_memcpy( C_last_row, C_first_row, SKP_Silk_MAX_ORDER_LPC * sizeof( SKP_int32 ) );
-
- /* Initialize */
- CAb[ 0 ] = CAf[ 0 ] = C0 + SKP_SMMUL( WhiteNoiseFrac_Q32, C0 ) + 1; // Q(-rshifts)
-
- for( n = 0; n < D; n++ ) {
- /* Update first row of correlation matrix (without first element) */
- /* Update last row of correlation matrix (without last element, stored in reversed order) */
- /* Update C * Af */
- /* Update C * flipud(Af) (stored in reversed order) */
- if( rshifts > -2 ) {
- for( s = 0; s < nb_subfr; s++ ) {
- x_ptr = x + s * subfr_length;
- x1 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], 16 - rshifts ); // Q(16-rshifts)
- x2 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); // Q(16-rshifts)
- tmp1 = SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], QA - 16 ); // Q(QA-16)
- tmp2 = SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); // Q(QA-16)
- for( k = 0; k < n; k++ ) {
- C_first_row[ k ] = SKP_SMLAWB( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); // Q( -rshifts )
- C_last_row[ k ] = SKP_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); // Q( -rshifts )
- Atmp_QA = Af_QA[ k ];
- tmp1 = SKP_SMLAWB( tmp1, Atmp_QA, x_ptr[ n - k - 1 ] ); // Q(QA-16)
- tmp2 = SKP_SMLAWB( tmp2, Atmp_QA, x_ptr[ subfr_length - n + k ] ); // Q(QA-16)
- }
- tmp1 = SKP_LSHIFT32( -tmp1, 32 - QA - rshifts ); // Q(16-rshifts)
- tmp2 = SKP_LSHIFT32( -tmp2, 32 - QA - rshifts ); // Q(16-rshifts)
- for( k = 0; k <= n; k++ ) {
- CAf[ k ] = SKP_SMLAWB( CAf[ k ], tmp1, x_ptr[ n - k ] ); // Q( -rshift )
- CAb[ k ] = SKP_SMLAWB( CAb[ k ], tmp2, x_ptr[ subfr_length - n + k - 1 ] ); // Q( -rshift )
- }
- }
- } else {
- for( s = 0; s < nb_subfr; s++ ) {
- x_ptr = x + s * subfr_length;
- x1 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], -rshifts ); // Q( -rshifts )
- x2 = -SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); // Q( -rshifts )
- tmp1 = SKP_LSHIFT32( (SKP_int32)x_ptr[ n ], 17 ); // Q17
- tmp2 = SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n - 1 ], 17 ); // Q17
- for( k = 0; k < n; k++ ) {
- C_first_row[ k ] = SKP_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); // Q( -rshifts )
- C_last_row[ k ] = SKP_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); // Q( -rshifts )
- Atmp1 = SKP_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); // Q17
- tmp1 = SKP_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); // Q17
- tmp2 = SKP_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); // Q17
- }
- tmp1 = -tmp1; // Q17
- tmp2 = -tmp2; // Q17
- for( k = 0; k <= n; k++ ) {
- CAf[ k ] = SKP_SMLAWW( CAf[ k ], tmp1,
- SKP_LSHIFT32( (SKP_int32)x_ptr[ n - k ], -rshifts - 1 ) ); // Q( -rshift )
- CAb[ k ] = SKP_SMLAWW( CAb[ k ], tmp2,
- SKP_LSHIFT32( (SKP_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) );// Q( -rshift )
- }
- }
- }
-
- /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */
- tmp1 = C_first_row[ n ]; // Q( -rshifts )
- tmp2 = C_last_row[ n ]; // Q( -rshifts )
- num = 0; // Q( -rshifts )
- nrg = SKP_ADD32( CAb[ 0 ], CAf[ 0 ] ); // Q( 1-rshifts )
- for( k = 0; k < n; k++ ) {
- Atmp_QA = Af_QA[ k ];
- lz = SKP_Silk_CLZ32( SKP_abs( Atmp_QA ) ) - 1;
- lz = SKP_min( 32 - QA, lz );
- Atmp1 = SKP_LSHIFT32( Atmp_QA, lz ); // Q( QA + lz )
-
- tmp1 = SKP_ADD_LSHIFT32( tmp1, SKP_SMMUL( C_last_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); // Q( -rshifts )
- tmp2 = SKP_ADD_LSHIFT32( tmp2, SKP_SMMUL( C_first_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); // Q( -rshifts )
- num = SKP_ADD_LSHIFT32( num, SKP_SMMUL( CAb[ n - k ], Atmp1 ), 32 - QA - lz ); // Q( -rshifts )
- nrg = SKP_ADD_LSHIFT32( nrg, SKP_SMMUL( SKP_ADD32( CAb[ k + 1 ], CAf[ k + 1 ] ),
- Atmp1 ), 32 - QA - lz ); // Q( 1-rshifts )
- }
- CAf[ n + 1 ] = tmp1; // Q( -rshifts )
- CAb[ n + 1 ] = tmp2; // Q( -rshifts )
- num = SKP_ADD32( num, tmp2 ); // Q( -rshifts )
- num = SKP_LSHIFT32( -num, 1 ); // Q( 1-rshifts )
-
- /* Calculate the next order reflection (parcor) coefficient */
- if( SKP_abs( num ) < nrg ) {
- rc_Q31 = SKP_DIV32_varQ( num, nrg, 31 );
- } else {
- /* Negative energy or ratio too high; set remaining coefficients to zero and exit loop */
- SKP_memset( &Af_QA[ n ], 0, ( D - n ) * sizeof( SKP_int32 ) );
- SKP_assert( 0 );
- break;
- }
-
- /* Update the AR coefficients */
- for( k = 0; k < (n + 1) >> 1; k++ ) {
- tmp1 = Af_QA[ k ]; // QA
- tmp2 = Af_QA[ n - k - 1 ]; // QA
- Af_QA[ k ] = SKP_ADD_LSHIFT32( tmp1, SKP_SMMUL( tmp2, rc_Q31 ), 1 ); // QA
- Af_QA[ n - k - 1 ] = SKP_ADD_LSHIFT32( tmp2, SKP_SMMUL( tmp1, rc_Q31 ), 1 ); // QA
- }
- Af_QA[ n ] = SKP_RSHIFT32( rc_Q31, 31 - QA ); // QA
-
- /* Update C * Af and C * Ab */
- for( k = 0; k <= n + 1; k++ ) {
- tmp1 = CAf[ k ]; // Q( -rshifts )
- tmp2 = CAb[ n - k + 1 ]; // Q( -rshifts )
- CAf[ k ] = SKP_ADD_LSHIFT32( tmp1, SKP_SMMUL( tmp2, rc_Q31 ), 1 ); // Q( -rshifts )
- CAb[ n - k + 1 ] = SKP_ADD_LSHIFT32( tmp2, SKP_SMMUL( tmp1, rc_Q31 ), 1 ); // Q( -rshifts )
- }
- }
-
- /* Return residual energy */
- nrg = CAf[ 0 ]; // Q( -rshifts )
- tmp1 = 1 << 16; // Q16
- for( k = 0; k < D; k++ ) {
- Atmp1 = SKP_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); // Q16
- nrg = SKP_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); // Q( -rshifts )
- tmp1 = SKP_SMLAWW( tmp1, Atmp1, Atmp1 ); // Q16
- A_Q16[ k ] = -Atmp1;
- }
- *res_nrg = SKP_SMLAWW( nrg, SKP_SMMUL( WhiteNoiseFrac_Q32, C0 ), -tmp1 ); // Q( -rshifts )
- *res_nrg_Q = -rshifts;
-}
--- a/silk/SKP_Silk_bwexpander.c
+++ /dev/null
@@ -1,49 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Chirp (bandwidth expand) LP AR filter */
-void SKP_Silk_bwexpander(
- SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
- const SKP_int d, /* I Length of ar */
- SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
-)
-{
- SKP_int i;
- SKP_int32 chirp_minus_one_Q16;
-
- chirp_minus_one_Q16 = chirp_Q16 - 65536;
-
- /* NB: Dont use SKP_SMULWB, instead of SKP_RSHIFT_ROUND( SKP_MUL() , 16 ), below. */
- /* Bias in SKP_SMULWB can lead to unstable filters */
- for( i = 0; i < d - 1; i++ ) {
- ar[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ i ] ), 16 );
- chirp_Q16 += SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 );
- }
- ar[ d - 1 ] = (SKP_int16)SKP_RSHIFT_ROUND( SKP_MUL( chirp_Q16, ar[ d - 1 ] ), 16 );
-}
--- a/silk/SKP_Silk_bwexpander_32.c
+++ /dev/null
@@ -1,46 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Chirp (bandwidth expand) LP AR filter */
-void SKP_Silk_bwexpander_32(
- SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
- const SKP_int d, /* I Length of ar */
- SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */
-)
-{
- SKP_int i;
- SKP_int32 tmp_chirp_Q16;
-
- tmp_chirp_Q16 = chirp_Q16;
- for( i = 0; i < d - 1; i++ ) {
- ar[ i ] = SKP_SMULWW( ar[ i ], tmp_chirp_Q16 );
- tmp_chirp_Q16 = SKP_SMULWW( chirp_Q16, tmp_chirp_Q16 );
- }
- ar[ d - 1 ] = SKP_SMULWW( ar[ d - 1 ], tmp_chirp_Q16 );
-}
--- a/silk/SKP_Silk_check_control_input.c
+++ /dev/null
@@ -1,94 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-#include "SKP_Silk_control.h"
-#include "SKP_Silk_errors.h"
-
-/* Check encoder control struct */
-SKP_int check_control_input(
- SKP_SILK_SDK_EncControlStruct *encControl /* I: Control structure */
-)
-{
- SKP_assert( encControl != NULL );
-
- if( ( ( encControl->API_sampleRate != 8000 ) &&
- ( encControl->API_sampleRate != 12000 ) &&
- ( encControl->API_sampleRate != 16000 ) &&
- ( encControl->API_sampleRate != 24000 ) &&
- ( encControl->API_sampleRate != 32000 ) &&
- ( encControl->API_sampleRate != 44100 ) &&
- ( encControl->API_sampleRate != 48000 ) ) ||
- ( ( encControl->desiredInternalSampleRate != 8000 ) &&
- ( encControl->desiredInternalSampleRate != 12000 ) &&
- ( encControl->desiredInternalSampleRate != 16000 ) ) ||
- ( ( encControl->maxInternalSampleRate != 8000 ) &&
- ( encControl->maxInternalSampleRate != 12000 ) &&
- ( encControl->maxInternalSampleRate != 16000 ) ) ||
- ( ( encControl->minInternalSampleRate != 8000 ) &&
- ( encControl->minInternalSampleRate != 12000 ) &&
- ( encControl->minInternalSampleRate != 16000 ) ) ||
- ( encControl->minInternalSampleRate > encControl->desiredInternalSampleRate ) ||
- ( encControl->maxInternalSampleRate < encControl->desiredInternalSampleRate ) ||
- ( encControl->minInternalSampleRate > encControl->maxInternalSampleRate ) ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_FS_NOT_SUPPORTED;
- }
- if( encControl->payloadSize_ms != 10 &&
- encControl->payloadSize_ms != 20 &&
- encControl->payloadSize_ms != 40 &&
- encControl->payloadSize_ms != 60 ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;
- }
- if( encControl->packetLossPercentage < 0 || encControl->packetLossPercentage > 100 ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_INVALID_LOSS_RATE;
- }
- if( encControl->useDTX < 0 || encControl->useDTX > 1 ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_INVALID_DTX_SETTING;
- }
- if( encControl->useCBR < 0 || encControl->useCBR > 1 ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_INVALID_CBR_SETTING;
- }
- if( encControl->useInBandFEC < 0 || encControl->useInBandFEC > 1 ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING;
- }
- if( encControl->nChannels < 1 || encControl->nChannels > ENCODER_NUM_CHANNELS ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR;
- }
- if( encControl->complexity < 0 || encControl->complexity > 10 ) {
- SKP_assert( 0 );
- return SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING;
- }
-
- return SKP_SILK_NO_ERROR;
-}
--- a/silk/SKP_Silk_code_signs.c
+++ /dev/null
@@ -1,111 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-//#define SKP_enc_map(a) ((a) > 0 ? 1 : 0)
-//#define SKP_dec_map(a) ((a) > 0 ? 1 : -1)
-/* shifting avoids if-statement */
-#define SKP_enc_map(a) ( SKP_RSHIFT( (a), 15 ) + 1 )
-#define SKP_dec_map(a) ( SKP_LSHIFT( (a), 1 ) - 1 )
-
-/* Encodes signs of excitation */
-void SKP_Silk_encode_signs(
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- const SKP_int8 pulses[], /* I pulse signal */
- SKP_int length, /* I length of input */
- const SKP_int signalType, /* I Signal type */
- const SKP_int quantOffsetType, /* I Quantization offset type */
- const SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
-)
-{
- SKP_int i, j, p;
- SKP_uint8 icdf[ 2 ];
- const SKP_int8 *q_ptr;
- const SKP_uint8 *icdf_ptr;
-
- icdf[ 1 ] = 0;
- q_ptr = pulses;
- i = SKP_SMULBB( 6, SKP_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );
- icdf_ptr = &SKP_Silk_sign_iCDF[ i ];
- length = SKP_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH );
- for( i = 0; i < length; i++ ) {
- p = sum_pulses[ i ];
- if( p > 0 ) {
- icdf[ 0 ] = icdf_ptr[ SKP_min( p - 1, 5 ) ];
- for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) {
- if( q_ptr[ j ] != 0 ) {
- ec_enc_icdf( psRangeEnc, SKP_enc_map( q_ptr[ j ]), icdf, 8 );
- }
- }
- }
- q_ptr += SHELL_CODEC_FRAME_LENGTH;
- }
-}
-
-/* Decodes signs of excitation */
-void SKP_Silk_decode_signs(
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int pulses[], /* I/O pulse signal */
- SKP_int length, /* I length of input */
- const SKP_int signalType, /* I Signal type */
- const SKP_int quantOffsetType, /* I Quantization offset type */
- const SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
-)
-{
- SKP_int i, j, p;
- SKP_uint8 icdf[ 2 ];
- SKP_int *q_ptr;
- const SKP_uint8 *icdf_ptr;
-
- icdf[ 1 ] = 0;
- q_ptr = pulses;
- i = SKP_SMULBB( 6, SKP_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );
- icdf_ptr = &SKP_Silk_sign_iCDF[ i ];
- length = SKP_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH );
- for( i = 0; i < length; i++ ) {
- p = sum_pulses[ i ];
- if( p > 0 ) {
- icdf[ 0 ] = icdf_ptr[ SKP_min( p - 1, 5 ) ];
- for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) {
- if( q_ptr[ j ] > 0 ) {
- /* attach sign */
-#if 0
- /* conditional implementation */
- if( ec_dec_icdf( psRangeDec, icdf, 8 ) == 0 ) {
- q_ptr[ j ] = -q_ptr[ j ];
- }
-#else
- /* implementation with shift, subtraction, multiplication */
- q_ptr[ j ] *= SKP_dec_map( ec_dec_icdf( psRangeDec, icdf, 8 ) );
-#endif
- }
- }
- }
- q_ptr += SHELL_CODEC_FRAME_LENGTH;
- }
-}
--- a/silk/SKP_Silk_control.h
+++ /dev/null
@@ -1,120 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef SKP_SILK_CONTROL_H
-#define SKP_SILK_CONTROL_H
-
-#include "SKP_Silk_typedef.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Decoder API flags */
-#define FLAG_DECODE_NORMAL 0
-#define FLAG_PACKET_LOST 1
-#define FLAG_DECODE_LBRR 2
-
-/***********************************************/
-/* Structure for controlling encoder operation */
-/***********************************************/
-typedef struct {
- /* I: Number of channels; 1/2 */
- SKP_int32 nChannels;
-
- /* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
- SKP_int32 API_sampleRate;
-
- /* I: Maximum internal sampling rate in Hertz; 8000/12000/16000 */
- SKP_int32 maxInternalSampleRate;
-
- /* I: Minimum internal sampling rate in Hertz; 8000/12000/16000 */
- SKP_int32 minInternalSampleRate;
-
- /* I: Soft request for internal sampling rate in Hertz; 8000/12000/16000 */
- SKP_int32 desiredInternalSampleRate;
-
- /* I: Number of samples per packet in milliseconds; 10/20/40/60 */
- SKP_int payloadSize_ms;
-
- /* I: Bitrate during active speech in bits/second; internally limited */
- SKP_int32 bitRate;
-
- /* I: Uplink packet loss in percent (0-100) */
- SKP_int packetLossPercentage;
-
- /* I: Complexity mode; 0 is lowest, 10 is highest complexity */
- SKP_int complexity;
-
- /* I: Flag to enable in-band Forward Error Correction (FEC); 0/1 */
- SKP_int useInBandFEC;
-
- /* I: Flag to enable discontinuous transmission (DTX); 0/1 */
- SKP_int useDTX;
-
- /* I: Flag to use constant bitrate */
- SKP_int useCBR;
-
- /* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */
- SKP_int32 internalSampleRate;
-
- /* O: Flag that bandwidth switching is allowed (because low voice activity) */
- SKP_int allowBandwidthSwitch;
-
- /* O: Flag that SILK runs in WB mode without variable LP filter (use for switching between WB/SWB/FB) */
- SKP_int inWBmodeWithoutVariableLP;
-} SKP_SILK_SDK_EncControlStruct;
-
-/**************************************************************************/
-/* Structure for controlling decoder operation and reading decoder status */
-/**************************************************************************/
-typedef struct {
- /* I: Number of channels; 1/2 */
- SKP_int32 nChannels;
-
- /* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
- SKP_int32 API_sampleRate;
-
- /* I: Number of samples per packet in milliseconds; 10/20/40/60 */
- SKP_int payloadSize_ms;
-
- /* I: Internal sampling rate used, in Hertz; 8000/12000/16000 */
- SKP_int32 internalSampleRate;
-
- /* O: Number of samples per frame */
- SKP_int frameSize;
-
- /* O: Frames per payload 1, 2, 3 */
- SKP_int framesPerPayload;
-} SKP_SILK_SDK_DecControlStruct;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/silk/SKP_Silk_control_SNR.c
+++ /dev/null
@@ -1,74 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-#include "SKP_Silk_tuning_parameters.h"
-
-/* Control SNR of redidual quantizer */
-SKP_int SKP_Silk_control_SNR(
- SKP_Silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
- SKP_int32 TargetRate_bps /* I Target max bitrate (bps) */
-)
-{
- SKP_int k, ret = SKP_SILK_NO_ERROR;
- SKP_int32 frac_Q6;
- const SKP_int32 *rateTable;
-
- /* Set bitrate/coding quality */
- TargetRate_bps = SKP_LIMIT( TargetRate_bps, MIN_TARGET_RATE_BPS, MAX_TARGET_RATE_BPS );
- if( TargetRate_bps != psEncC->TargetRate_bps ) {
- psEncC->TargetRate_bps = TargetRate_bps;
-
- /* If new TargetRate_bps, translate to SNR_dB value */
- if( psEncC->fs_kHz == 8 ) {
- rateTable = TargetRate_table_NB;
- } else if( psEncC->fs_kHz == 12 ) {
- rateTable = TargetRate_table_MB;
- } else if( psEncC->fs_kHz == 16 ) {
- rateTable = TargetRate_table_WB;
- } else {
- SKP_assert( 0 );
- }
-
- /* Reduce bitrate for 10 ms modes in these calculations */
- if( psEncC->nb_subfr == 2 ) {
- TargetRate_bps -= REDUCE_BITRATE_10_MS_BPS;
- }
-
- /* Find bitrate interval in table and interpolate */
- for( k = 1; k < TARGET_RATE_TAB_SZ; k++ ) {
- if( TargetRate_bps <= rateTable[ k ] ) {
- frac_Q6 = SKP_DIV32( SKP_LSHIFT( TargetRate_bps - rateTable[ k - 1 ], 6 ),
- rateTable[ k ] - rateTable[ k - 1 ] );
- psEncC->SNR_dB_Q7 = SKP_LSHIFT( SNR_table_Q1[ k - 1 ], 6 ) + SKP_MUL( frac_Q6, SNR_table_Q1[ k ] - SNR_table_Q1[ k - 1 ] );
- break;
- }
- }
- }
-
- return ret;
-}
--- a/silk/SKP_Silk_control_audio_bandwidth.c
+++ /dev/null
@@ -1,106 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-#include "SKP_Silk_tuning_parameters.h"
-
-/* Control internal sampling rate */
-SKP_int SKP_Silk_control_audio_bandwidth(
- SKP_Silk_encoder_state *psEncC /* I/O Pointer to Silk encoder state */
-)
-{
- SKP_int fs_kHz;
- SKP_int32 fs_Hz;
-
- fs_kHz = psEncC->fs_kHz;
- fs_Hz = SKP_SMULBB( fs_kHz, 1000 );
- if( fs_Hz == 0 ) {
- /* Encoder has just been initialized */
- fs_Hz = SKP_min( psEncC->desiredInternal_fs_Hz, psEncC->API_fs_Hz );
- fs_kHz = SKP_DIV32_16( fs_Hz, 1000 );
- } else if( fs_Hz > psEncC->API_fs_Hz || fs_Hz > psEncC->maxInternal_fs_Hz || fs_Hz < psEncC->minInternal_fs_Hz ) {
- /* Make sure internal rate is not higher than external rate or maximum allowed, or lower than minimum allowed */
- fs_Hz = psEncC->API_fs_Hz;
- fs_Hz = SKP_min( fs_Hz, psEncC->maxInternal_fs_Hz );
- fs_Hz = SKP_max( fs_Hz, psEncC->minInternal_fs_Hz );
- fs_kHz = SKP_DIV32_16( fs_Hz, 1000 );
- } else {
- /* State machine for the internal sampling rate switching */
- if( psEncC->sLP.transition_frame_no >= TRANSITION_FRAMES ) {
- /* Stop transition phase */
- psEncC->sLP.mode = 0;
- }
- if( psEncC->allow_bandwidth_switch ) {
- /* Check if we should switch down */
- if( SKP_SMULBB( psEncC->fs_kHz, 1000 ) > psEncC->desiredInternal_fs_Hz )
- {
- /* Switch down */
- if( psEncC->sLP.mode == 0 ) {
- /* New transition */
- psEncC->sLP.transition_frame_no = TRANSITION_FRAMES;
-
- /* Reset transition filter state */
- SKP_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) );
- }
- if( psEncC->sLP.transition_frame_no <= 0 ) {
- /* Stop transition phase */
- psEncC->sLP.mode = 0;
-
- /* Switch to a lower sample frequency */
- fs_kHz = psEncC->fs_kHz == 16 ? 12 : 8;
- } else {
- /* Direction: down (at double speed) */
- psEncC->sLP.mode = -2;
- }
- }
- else
- /* Check if we should switch up */
- if( SKP_SMULBB( psEncC->fs_kHz, 1000 ) < psEncC->desiredInternal_fs_Hz )
- {
- /* Switch up */
- if( psEncC->sLP.mode == 0 ) {
- /* Switch to a higher sample frequency */
- fs_kHz = psEncC->fs_kHz == 8 ? 12 : 16;
-
- /* New transition */
- psEncC->sLP.transition_frame_no = 0;
-
- /* Reset transition filter state */
- SKP_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) );
- }
- /* Direction: up */
- psEncC->sLP.mode = 1;
- }
- }
- }
-
-#ifdef FORCE_INTERNAL_FS_KHZ
- fs_kHz = FORCE_INTERNAL_FS_KHZ;
-#endif
-
- return fs_kHz;
-}
--- a/silk/SKP_Silk_control_codec.c
+++ /dev/null
@@ -1,420 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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 "SKP_Silk_tuning_parameters.h"
-#ifdef FIXED_POINT
-#include "SKP_Silk_main_FIX.h"
-#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX
-#else
-#include "SKP_Silk_main_FLP.h"
-#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FLP
-#endif
-
-SKP_int SKP_Silk_setup_resamplers(
- SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */
- SKP_int fs_kHz /* I */
-);
-
-SKP_int SKP_Silk_setup_fs(
- SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */
- SKP_int fs_kHz, /* I */
- SKP_int PacketSize_ms /* I */
-);
-
-SKP_int SKP_Silk_setup_complexity(
- SKP_Silk_encoder_state *psEncC, /* I/O */
- SKP_int Complexity /* I */
-);
-
-SKP_INLINE SKP_int SKP_Silk_setup_LBRR(
- SKP_Silk_encoder_state *psEncC, /* I/O */
- const SKP_int32 TargetRate_bps /* I */
-);
-
-
-/* Control encoder */
-SKP_int SKP_Silk_control_encoder(
- SKP_Silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
- SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */
- const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */
- const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
- const SKP_int channelNb /* I Channel number */
-)
-{
- SKP_int fs_kHz, ret = 0;
-
- psEnc->sCmn.useDTX = encControl->useDTX;
- psEnc->sCmn.useCBR = encControl->useCBR;
- psEnc->sCmn.API_fs_Hz = encControl->API_sampleRate;
- psEnc->sCmn.maxInternal_fs_Hz = encControl->maxInternalSampleRate;
- psEnc->sCmn.minInternal_fs_Hz = encControl->minInternalSampleRate;
- psEnc->sCmn.desiredInternal_fs_Hz = encControl->desiredInternalSampleRate;
- psEnc->sCmn.useInBandFEC = encControl->useInBandFEC;
- psEnc->sCmn.nChannels = encControl->nChannels;
- psEnc->sCmn.allow_bandwidth_switch = allow_bw_switch;
- psEnc->sCmn.channelNb = channelNb;
-
- if( psEnc->sCmn.controlled_since_last_payload != 0 && psEnc->sCmn.prefillFlag == 0 ) {
- if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) {
- /* Change in API sampling rate in the middle of encoding a packet */
- ret += SKP_Silk_setup_resamplers( psEnc, psEnc->sCmn.fs_kHz );
- }
- return ret;
- }
-
- /* Beyond this point we know that there are no previously coded frames in the payload buffer */
-
- /********************************************/
- /* Determine internal sampling rate */
- /********************************************/
- fs_kHz = SKP_Silk_control_audio_bandwidth( &psEnc->sCmn );
-
- /********************************************/
- /* Prepare resampler and buffered data */
- /********************************************/
- ret += SKP_Silk_setup_resamplers( psEnc, fs_kHz );
-
- /********************************************/
- /* Set internal sampling frequency */
- /********************************************/
- ret += SKP_Silk_setup_fs( psEnc, fs_kHz, encControl->payloadSize_ms );
-
- /********************************************/
- /* Set encoding complexity */
- /********************************************/
- ret += SKP_Silk_setup_complexity( &psEnc->sCmn, encControl->complexity );
-
- /********************************************/
- /* Set packet loss rate measured by farend */
- /********************************************/
- psEnc->sCmn.PacketLoss_perc = encControl->packetLossPercentage;
-
- /********************************************/
- /* Set LBRR usage */
- /********************************************/
- ret += SKP_Silk_setup_LBRR( &psEnc->sCmn, TargetRate_bps );
-
- psEnc->sCmn.controlled_since_last_payload = 1;
-
- return ret;
-}
-
-SKP_int SKP_Silk_setup_resamplers(
- SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */
- SKP_int fs_kHz /* I */
-)
-{
- SKP_int ret = SKP_SILK_NO_ERROR;
- SKP_int32 nSamples_temp;
-
- if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz )
- {
- if( psEnc->sCmn.fs_kHz == 0 ) {
- /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
- ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 );
- } else {
- /* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */
- SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * ( MAX_API_FS_KHZ / 8 ) ];
-#ifdef FIXED_POINT
- SKP_int16 *x_bufFIX = psEnc->x_buf;
-#else
- SKP_int16 x_bufFIX[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];
-#endif
-
- nSamples_temp = SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + LA_SHAPE_MS * psEnc->sCmn.fs_kHz;
-
-#ifndef FIXED_POINT
- SKP_float2short_array( x_bufFIX, psEnc->x_buf, nSamples_temp );
-#endif
-
- if( SKP_SMULBB( fs_kHz, 1000 ) < psEnc->sCmn.API_fs_Hz && psEnc->sCmn.fs_kHz != 0 ) {
- /* Resample buffered data in x_buf to API_fs_Hz */
-
- SKP_Silk_resampler_state_struct temp_resampler_state;
-
- /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */
- ret += SKP_Silk_resampler_init( &temp_resampler_state, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz );
-
- /* Temporary resampling of x_buf data to API_fs_Hz */
- ret += SKP_Silk_resampler( &temp_resampler_state, x_buf_API_fs_Hz, x_bufFIX, nSamples_temp );
-
- /* Calculate number of samples that has been temporarily upsampled */
- nSamples_temp = SKP_DIV32_16( nSamples_temp * psEnc->sCmn.API_fs_Hz, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ) );
-
- /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
- ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, SKP_SMULBB( fs_kHz, 1000 ) );
-
- } else {
- /* Copy data */
- SKP_memcpy( x_buf_API_fs_Hz, x_bufFIX, nSamples_temp * sizeof( SKP_int16 ) );
- }
-
- if( 1000 * fs_kHz != psEnc->sCmn.API_fs_Hz ) {
- /* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */
- ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, nSamples_temp );
- }
-#ifndef FIXED_POINT
- SKP_short2float_array( psEnc->x_buf, x_bufFIX, ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * fs_kHz );
-#endif
- }
- }
-
- psEnc->sCmn.prev_API_fs_Hz = psEnc->sCmn.API_fs_Hz;
-
- return ret;
-}
-
-SKP_int SKP_Silk_setup_fs(
- SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */
- SKP_int fs_kHz, /* I */
- SKP_int PacketSize_ms /* I */
-)
-{
- SKP_int ret = SKP_SILK_NO_ERROR;
-
- /* Set packet size */
- if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) {
- if( ( PacketSize_ms != 10 ) &&
- ( PacketSize_ms != 20 ) &&
- ( PacketSize_ms != 40 ) &&
- ( PacketSize_ms != 60 ) ) {
- ret = SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;
- }
- if( PacketSize_ms <= 10 ) {
- psEnc->sCmn.nFramesPerPacket = 1;
- psEnc->sCmn.nb_subfr = PacketSize_ms == 10 ? 2 : 1;
- psEnc->sCmn.frame_length = SKP_SMULBB( PacketSize_ms, fs_kHz );
- psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
- if( psEnc->sCmn.fs_kHz == 8 ) {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
- } else {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
- }
- } else {
- psEnc->sCmn.nFramesPerPacket = SKP_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS );
- psEnc->sCmn.nb_subfr = MAX_NB_SUBFR;
- psEnc->sCmn.frame_length = SKP_SMULBB( 20, fs_kHz );
- psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
- if( psEnc->sCmn.fs_kHz == 8 ) {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;
- } else {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF;
- }
- }
- psEnc->sCmn.PacketSize_ms = PacketSize_ms;
- psEnc->sCmn.TargetRate_bps = 0; /* trigger new SNR computation */
- }
-
- /* Set internal sampling frequency */
- SKP_assert( fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16 );
- SKP_assert( psEnc->sCmn.nb_subfr == 2 || psEnc->sCmn.nb_subfr == 4 );
- if( psEnc->sCmn.fs_kHz != fs_kHz ) {
- /* reset part of the state */
-#ifdef FIXED_POINT
- SKP_memset( &psEnc->sShape, 0, sizeof( SKP_Silk_shape_state_FIX ) );
- SKP_memset( &psEnc->sPrefilt, 0, sizeof( SKP_Silk_prefilter_state_FIX ) );
-#else
- SKP_memset( &psEnc->sShape, 0, sizeof( SKP_Silk_shape_state_FLP ) );
- SKP_memset( &psEnc->sPrefilt, 0, sizeof( SKP_Silk_prefilter_state_FLP ) );
-#endif
- SKP_memset( &psEnc->sCmn.sNSQ, 0, sizeof( SKP_Silk_nsq_state ) );
- SKP_memset( psEnc->sCmn.prev_NLSFq_Q15, 0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );
- SKP_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );
- psEnc->sCmn.inputBufIx = 0;
- psEnc->sCmn.nFramesAnalyzed = 0;
- psEnc->sCmn.TargetRate_bps = 0; /* trigger new SNR computation */
-
- /* Initialize non-zero parameters */
- psEnc->sCmn.prevLag = 100;
- psEnc->sCmn.first_frame_after_reset = 1;
- psEnc->sPrefilt.lagPrev = 100;
- psEnc->sShape.LastGainIndex = 10;
- psEnc->sCmn.sNSQ.lagPrev = 100;
- psEnc->sCmn.sNSQ.prev_inv_gain_Q16 = 65536;
-
- psEnc->sCmn.fs_kHz = fs_kHz;
- if( psEnc->sCmn.fs_kHz == 8 ) {
- if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;
- } else {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
- }
- } else {
- if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF;
- } else {
- psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
- }
- }
- if( psEnc->sCmn.fs_kHz == 8 || psEnc->sCmn.fs_kHz == 12 ) {
- psEnc->sCmn.predictLPCOrder = MIN_LPC_ORDER;
- psEnc->sCmn.psNLSF_CB = &SKP_Silk_NLSF_CB_NB_MB;
- } else {
- psEnc->sCmn.predictLPCOrder = MAX_LPC_ORDER;
- psEnc->sCmn.psNLSF_CB = &SKP_Silk_NLSF_CB_WB;
- }
- psEnc->sCmn.subfr_length = SUB_FRAME_LENGTH_MS * fs_kHz;
- psEnc->sCmn.frame_length = SKP_SMULBB( psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr );
- psEnc->sCmn.ltp_mem_length = SKP_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz );
- psEnc->sCmn.la_pitch = SKP_SMULBB( LA_PITCH_MS, fs_kHz );
- psEnc->sCmn.max_pitch_lag = SKP_SMULBB( 18, fs_kHz );
- if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
- psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
- } else {
- psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
- }
- if( psEnc->sCmn.fs_kHz == 16 ) {
- psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );
- psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
- } else if( psEnc->sCmn.fs_kHz == 12 ) {
- psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 9 );
- psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;
- } else {
- psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 9 );
- psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;
- }
- }
-
- /* Check that settings are valid */
- SKP_assert( ( psEnc->sCmn.subfr_length * psEnc->sCmn.nb_subfr ) == psEnc->sCmn.frame_length );
-
- return ret;
-}
-
-SKP_int SKP_Silk_setup_complexity(
- SKP_Silk_encoder_state *psEncC, /* I/O */
- SKP_int Complexity /* I */
-)
-{
- SKP_int ret = 0;
-
- /* Set encoding complexity */
- SKP_assert( Complexity >= 0 && Complexity <= 10 );
- if( Complexity < 2 ) {
- psEncC->pitchEstimationComplexity = SKP_Silk_PE_MIN_COMPLEX;
- psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.8, 16 );
- psEncC->pitchEstimationLPCOrder = 6;
- psEncC->shapingLPCOrder = 8;
- psEncC->la_shape = 3 * psEncC->fs_kHz;
- psEncC->nStatesDelayedDecision = 1;
- psEncC->useInterpolatedNLSFs = 0;
- psEncC->LTPQuantLowComplexity = 1;
- psEncC->NLSF_MSVQ_Survivors = 2;
- psEncC->warping_Q16 = 0;
- } else if( Complexity < 4 ) {
- psEncC->pitchEstimationComplexity = SKP_Silk_PE_MID_COMPLEX;
- psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.76, 16 );
- psEncC->pitchEstimationLPCOrder = 8;
- psEncC->shapingLPCOrder = 10;
- psEncC->la_shape = 5 * psEncC->fs_kHz;
- psEncC->nStatesDelayedDecision = 1;
- psEncC->useInterpolatedNLSFs = 1;
- psEncC->LTPQuantLowComplexity = 0;
- psEncC->NLSF_MSVQ_Survivors = 4;
- psEncC->warping_Q16 = 0;
- } else if( Complexity < 6 ) {
- psEncC->pitchEstimationComplexity = SKP_Silk_PE_MID_COMPLEX;
- psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.74, 16 );
- psEncC->pitchEstimationLPCOrder = 10;
- psEncC->shapingLPCOrder = 12;
- psEncC->la_shape = 5 * psEncC->fs_kHz;
- psEncC->nStatesDelayedDecision = 2;
- psEncC->useInterpolatedNLSFs = 0;
- psEncC->LTPQuantLowComplexity = 0;
- psEncC->NLSF_MSVQ_Survivors = 6;
- psEncC->warping_Q16 = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
- } else if( Complexity < 8 ) {
- psEncC->pitchEstimationComplexity = SKP_Silk_PE_MID_COMPLEX;
- psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.72, 16 );
- psEncC->pitchEstimationLPCOrder = 12;
- psEncC->shapingLPCOrder = 14;
- psEncC->la_shape = 5 * psEncC->fs_kHz;
- psEncC->nStatesDelayedDecision = 3;
- psEncC->useInterpolatedNLSFs = 0;
- psEncC->LTPQuantLowComplexity = 0;
- psEncC->NLSF_MSVQ_Survivors = 8;
- psEncC->warping_Q16 = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
- } else {
- psEncC->pitchEstimationComplexity = SKP_Silk_PE_MAX_COMPLEX;
- psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.7, 16 );
- psEncC->pitchEstimationLPCOrder = 16;
- psEncC->shapingLPCOrder = 16;
- psEncC->la_shape = 5 * psEncC->fs_kHz;
- psEncC->nStatesDelayedDecision = MAX_DEL_DEC_STATES;
- psEncC->useInterpolatedNLSFs = 1;
- psEncC->LTPQuantLowComplexity = 0;
- psEncC->NLSF_MSVQ_Survivors = 16;
- psEncC->warping_Q16 = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
- }
-
- /* Do not allow higher pitch estimation LPC order than predict LPC order */
- psEncC->pitchEstimationLPCOrder = SKP_min_int( psEncC->pitchEstimationLPCOrder, psEncC->predictLPCOrder );
- psEncC->shapeWinLength = SUB_FRAME_LENGTH_MS * psEncC->fs_kHz + 2 * psEncC->la_shape;
-
- SKP_assert( psEncC->pitchEstimationLPCOrder <= MAX_FIND_PITCH_LPC_ORDER );
- SKP_assert( psEncC->shapingLPCOrder <= MAX_SHAPE_LPC_ORDER );
- SKP_assert( psEncC->nStatesDelayedDecision <= MAX_DEL_DEC_STATES );
- SKP_assert( psEncC->warping_Q16 <= 32767 );
- SKP_assert( psEncC->la_shape <= LA_SHAPE_MAX );
- SKP_assert( psEncC->shapeWinLength <= SHAPE_LPC_WIN_MAX );
- SKP_assert( psEncC->NLSF_MSVQ_Survivors <= NLSF_VQ_MAX_SURVIVORS );
-
- return ret;
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_LBRR(
- SKP_Silk_encoder_state *psEncC, /* I/O */
- const SKP_int32 TargetRate_bps /* I */
-)
-{
- SKP_int ret = SKP_SILK_NO_ERROR;
- SKP_int32 LBRRRate_thres_bps;
-
- SKP_assert( psEncC->fs_kHz == 8 || psEncC->fs_kHz == 12 || psEncC->fs_kHz == 16 );
- if( psEncC->fs_kHz == 8 ) {
- LBRRRate_thres_bps = LBRR_NB_MIN_RATE_BPS;
- } else if( psEncC->fs_kHz == 12 ) {
- LBRRRate_thres_bps = LBRR_MB_MIN_RATE_BPS;
- } else {
- LBRRRate_thres_bps = LBRR_WB_MIN_RATE_BPS;
- }
-
- LBRRRate_thres_bps = SKP_RSHIFT( SKP_SMULBB( LBRRRate_thres_bps, 7 - psEncC->PacketLoss_perc ), 2 );
- if( psEncC->useInBandFEC && TargetRate_bps >= LBRRRate_thres_bps && psEncC->PacketLoss_perc > 0 ) {
- /* Set gain increase / rate reduction for LBRR usage */
- psEncC->LBRR_GainIncreases = SKP_max_int( 7 - SKP_SMULWB( psEncC->PacketLoss_perc, SKP_FIX_CONST( 0.4, 16 ) ), 2 );
- psEncC->LBRR_enabled = 1;
- } else {
- psEncC->LBRR_enabled = 0;
- }
-
- return ret;
-}
--- a/silk/SKP_Silk_create_init_destroy.c
+++ /dev/null
@@ -1,53 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-
-/************************/
-/* Init Decoder State */
-/************************/
-SKP_int SKP_Silk_init_decoder(
- SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */
-)
-{
- /* Clear the entire encoder state, except anything copied */
- SKP_memset( psDec, 0, sizeof( SKP_Silk_decoder_state ) );
-
- /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */
- psDec->first_frame_after_reset = 1;
- psDec->prev_inv_gain_Q16 = 65536;
-
- /* Reset CNG state */
- SKP_Silk_CNG_Reset( psDec );
-
- /* Reset PLC state */
- SKP_Silk_PLC_Reset( psDec );
-
- return(0);
-}
-
--- a/silk/SKP_Silk_debug.c
+++ /dev/null
@@ -1,175 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/* *
- * SKP_debug.c *
- * *
- * This contains code to help debugging *
- * *
- * Copyright 2009 (c), Skype Limited *
- * Date: 090629 *
- * */
-
-#include "SKP_debug.h"
-#include "SKP_Silk_SigProc_FIX.h"
-
-#if SKP_TIC_TOC
-
-#ifdef _WIN32
-
-#if (defined(_WIN32) || defined(_WINCE))
-#include <windows.h> /* timer */
-#else // Linux or Mac
-#include <sys/time.h>
-#endif
-
-unsigned long GetHighResolutionTime(void) /* O: time in usec*/
-{
- /* Returns a time counter in microsec */
- /* the resolution is platform dependent */
- /* but is typically 1.62 us resolution */
- LARGE_INTEGER lpPerformanceCount;
- LARGE_INTEGER lpFrequency;
- QueryPerformanceCounter(&lpPerformanceCount);
- QueryPerformanceFrequency(&lpFrequency);
- return (unsigned long)((1000000*(lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart);
-}
-#else // Linux or Mac
-unsigned long GetHighResolutionTime(void) /* O: time in usec*/
-{
- struct timeval tv;
- gettimeofday(&tv, 0);
- return((tv.tv_sec*1000000)+(tv.tv_usec));
-}
-#endif
-
-int SKP_Timer_nTimers = 0;
-int SKP_Timer_depth_ctr = 0;
-char SKP_Timer_tags[SKP_NUM_TIMERS_MAX][SKP_NUM_TIMERS_MAX_TAG_LEN];
-#ifdef WIN32
-LARGE_INTEGER SKP_Timer_start[SKP_NUM_TIMERS_MAX];
-#else
-unsigned long SKP_Timer_start[SKP_NUM_TIMERS_MAX];
-#endif
-unsigned int SKP_Timer_cnt[SKP_NUM_TIMERS_MAX];
-SKP_int64 SKP_Timer_min[SKP_NUM_TIMERS_MAX];
-SKP_int64 SKP_Timer_sum[SKP_NUM_TIMERS_MAX];
-SKP_int64 SKP_Timer_max[SKP_NUM_TIMERS_MAX];
-SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX];
-
-#ifdef WIN32
-void SKP_TimerSave(char *file_name)
-{
- if( SKP_Timer_nTimers > 0 )
- {
- int k;
- FILE *fp;
- LARGE_INTEGER lpFrequency;
- LARGE_INTEGER lpPerformanceCount1, lpPerformanceCount2;
- int del = 0x7FFFFFFF;
- double avg, sum_avg;
- /* estimate overhead of calling performance counters */
- for( k = 0; k < 1000; k++ ) {
- QueryPerformanceCounter(&lpPerformanceCount1);
- QueryPerformanceCounter(&lpPerformanceCount2);
- lpPerformanceCount2.QuadPart -= lpPerformanceCount1.QuadPart;
- if( (int)lpPerformanceCount2.LowPart < del )
- del = lpPerformanceCount2.LowPart;
- }
- QueryPerformanceFrequency(&lpFrequency);
- /* print results to file */
- sum_avg = 0.0f;
- for( k = 0; k < SKP_Timer_nTimers; k++ ) {
- if (SKP_Timer_depth[k] == 0) {
- sum_avg += (1e6 * SKP_Timer_sum[k] / SKP_Timer_cnt[k] - del) / lpFrequency.QuadPart * SKP_Timer_cnt[k];
- }
- }
- fp = fopen(file_name, "w");
- fprintf(fp, " min avg %% max count\n");
- for( k = 0; k < SKP_Timer_nTimers; k++ ) {
- if (SKP_Timer_depth[k] == 0) {
- fprintf(fp, "%-28s", SKP_Timer_tags[k]);
- } else if (SKP_Timer_depth[k] == 1) {
- fprintf(fp, " %-27s", SKP_Timer_tags[k]);
- } else if (SKP_Timer_depth[k] == 2) {
- fprintf(fp, " %-26s", SKP_Timer_tags[k]);
- } else if (SKP_Timer_depth[k] == 3) {
- fprintf(fp, " %-25s", SKP_Timer_tags[k]);
- } else {
- fprintf(fp, " %-24s", SKP_Timer_tags[k]);
- }
- avg = (1e6 * SKP_Timer_sum[k] / SKP_Timer_cnt[k] - del) / lpFrequency.QuadPart;
- fprintf(fp, "%8.2f", (1e6 * (SKP_max_64(SKP_Timer_min[k] - del, 0))) / lpFrequency.QuadPart);
- fprintf(fp, "%12.2f %6.2f", avg, 100.0 * avg / sum_avg * SKP_Timer_cnt[k]);
- fprintf(fp, "%12.2f", (1e6 * (SKP_max_64(SKP_Timer_max[k] - del, 0))) / lpFrequency.QuadPart);
- fprintf(fp, "%10d\n", SKP_Timer_cnt[k]);
- }
- fprintf(fp, " microseconds\n");
- fclose(fp);
- }
-}
-#else
-void SKP_TimerSave(char *file_name)
-{
- if( SKP_Timer_nTimers > 0 )
- {
- int k;
- FILE *fp;
- /* print results to file */
- fp = fopen(file_name, "w");
- fprintf(fp, " min avg max count\n");
- for( k = 0; k < SKP_Timer_nTimers; k++ )
- {
- if (SKP_Timer_depth[k] == 0) {
- fprintf(fp, "%-28s", SKP_Timer_tags[k]);
- } else if (SKP_Timer_depth[k] == 1) {
- fprintf(fp, " %-27s", SKP_Timer_tags[k]);
- } else if (SKP_Timer_depth[k] == 2) {
- fprintf(fp, " %-26s", SKP_Timer_tags[k]);
- } else if (SKP_Timer_depth[k] == 3) {
- fprintf(fp, " %-25s", SKP_Timer_tags[k]);
- } else {
- fprintf(fp, " %-24s", SKP_Timer_tags[k]);
- }
- fprintf(fp, "%d ", SKP_Timer_min[k]);
- fprintf(fp, "%f ", (double)SKP_Timer_sum[k] / (double)SKP_Timer_cnt[k]);
- fprintf(fp, "%d ", SKP_Timer_max[k]);
- fprintf(fp, "%10d\n", SKP_Timer_cnt[k]);
- }
- fprintf(fp, " microseconds\n");
- fclose(fp);
- }
-}
-#endif
-
-#endif /* SKP_TIC_TOC */
-
-#if SKP_DEBUG
-FILE *SKP_debug_store_fp[ SKP_NUM_STORES_MAX ];
-int SKP_debug_store_count = 0;
-#endif /* SKP_DEBUG */
-
--- a/silk/SKP_Silk_dec_API.c
+++ /dev/null
@@ -1,286 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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 "SKP_Silk_SDK_API.h"
-#include "SKP_Silk_main.h"
-
-/************************/
-/* Decoder Super Struct */
-/************************/
-typedef struct {
- SKP_Silk_decoder_state channel_state[ DECODER_NUM_CHANNELS ];
- stereo_state sStereo;
- SKP_int nChannels;
-} SKP_Silk_decoder;
-
-/*********************/
-/* Decoder functions */
-/*********************/
-
-SKP_int SKP_Silk_SDK_Get_Decoder_Size( SKP_int32 *decSizeBytes )
-{
- SKP_int ret = SKP_SILK_NO_ERROR;
-
- *decSizeBytes = sizeof( SKP_Silk_decoder );
-
- return ret;
-}
-
-/* Reset decoder state */
-SKP_int SKP_Silk_SDK_InitDecoder(
- void* decState /* I/O: State */
-)
-{
- SKP_int n, ret = SKP_SILK_NO_ERROR;
- SKP_Silk_decoder_state *channel_state = ((SKP_Silk_decoder *)decState)->channel_state;
-
- for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
- ret = SKP_Silk_init_decoder( &channel_state[ n ] );
- }
-
- return ret;
-}
-
-/* Decode a frame */
-SKP_int SKP_Silk_SDK_Decode(
- void* decState, /* I/O: State */
- SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */
- SKP_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode FEC */
- SKP_int newPacketFlag, /* I: Indicates first decoder call for this packet */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int16 *samplesOut, /* O: Decoded output speech vector */
- SKP_int32 *nSamplesOut /* O: Number of samples decoded */
-)
-{
- SKP_int i, n, prev_fs_kHz, doResample, flags, nFlags, ret = SKP_SILK_NO_ERROR;
- SKP_int32 nSamplesOutDec, LBRR_symbol;
- SKP_int16 samplesOut1_tmp[ 2 * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ];
- SKP_int16 samplesOut2_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ];
- SKP_int MS_pred_Q14[ 2 ] = { 0 };
- SKP_int16 *dec_out_ptr, *resample_out_ptr;
- SKP_Silk_decoder *psDec = ( SKP_Silk_decoder * )decState;
- SKP_Silk_decoder_state *channel_state = psDec->channel_state;
-
- /**********************************/
- /* Test if first frame in payload */
- /**********************************/
- if( newPacketFlag ) {
- for( n = 0; n < decControl->nChannels; n++ ) {
- channel_state[ n ].nFramesDecoded = 0; /* Used to count frames in packet */
- }
- }
-
- /* Save previous sample frequency */
- prev_fs_kHz = channel_state[ 0 ].fs_kHz;
-
- if( decControl->nChannels > psDec->nChannels ) {
- /* Mono -> Stereo transition: init state of second channel and stereo state */
- SKP_memset( &psDec->sStereo, 0, sizeof( psDec->sStereo ) );
- ret += SKP_Silk_init_decoder( &channel_state[ 1 ] );
- }
- psDec->nChannels = decControl->nChannels;
-
- for( n = 0; n < decControl->nChannels; n++ ) {
- if( channel_state[ n ].nFramesDecoded == 0 ) {
- SKP_int fs_kHz_dec;
- if( decControl->payloadSize_ms == 10 ) {
- channel_state[ n ].nFramesPerPacket = 1;
- channel_state[ n ].nb_subfr = 2;
- } else if( decControl->payloadSize_ms == 20 ) {
- channel_state[ n ].nFramesPerPacket = 1;
- channel_state[ n ].nb_subfr = 4;
- } else if( decControl->payloadSize_ms == 40 ) {
- channel_state[ n ].nFramesPerPacket = 2;
- channel_state[ n ].nb_subfr = 4;
- } else if( decControl->payloadSize_ms == 60 ) {
- channel_state[ n ].nFramesPerPacket = 3;
- channel_state[ n ].nb_subfr = 4;
- } else {
- SKP_assert( 0 );
- return SKP_SILK_DEC_INVALID_FRAME_SIZE;
- }
- fs_kHz_dec = ( decControl->internalSampleRate >> 10 ) + 1;
- if( fs_kHz_dec != 8 && fs_kHz_dec != 12 && fs_kHz_dec != 16 ) {
- SKP_assert( 0 );
- return SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY;
- }
- SKP_Silk_decoder_set_fs( &channel_state[ n ], fs_kHz_dec );
- }
- }
-
- if( decControl->API_sampleRate > MAX_API_FS_KHZ * 1000 || decControl->API_sampleRate < 8000 ) {
- ret = SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY;
- return( ret );
- }
-
- doResample = SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) != decControl->API_sampleRate;
-
- /* Set up pointers to temp buffers */
- if( doResample || decControl->nChannels == 2 ) {
- dec_out_ptr = samplesOut1_tmp;
- } else {
- dec_out_ptr = samplesOut;
- }
- if( decControl->nChannels == 2 ) {
- resample_out_ptr = samplesOut2_tmp;
- } else {
- resample_out_ptr = samplesOut;
- }
-
- if( lostFlag != FLAG_PACKET_LOST && channel_state[ 0 ].nFramesDecoded == 0 ) {
- /* First decoder call for this payload */
- nFlags = SKP_SMULBB( decControl->nChannels, channel_state[ 0 ].nFramesPerPacket + 1 );
- flags = SKP_RSHIFT( psRangeDec->buf[ 0 ], 8 - nFlags ) & ( SKP_LSHIFT( 1, nFlags ) - 1 );
- for( i = 0; i < nFlags; i++ ) {
- ec_dec_icdf( psRangeDec, SKP_Silk_uniform2_iCDF, 8 );
- }
- /* Decode VAD flags and LBRR flag */
- for( n = decControl->nChannels - 1; n >= 0; n-- ) {
- channel_state[ n ].LBRR_flag = flags & 1;
- flags = SKP_RSHIFT( flags, 1 );
- for( i = channel_state[ n ].nFramesPerPacket - 1; i >= 0 ; i-- ) {
- channel_state[ n ].VAD_flags[ i ] = flags & 1;
- flags = SKP_RSHIFT( flags, 1 );
- }
- }
- /* Decode LBRR flags */
- for( n = 0; n < decControl->nChannels; n++ ) {
- SKP_memset( channel_state[ n ].LBRR_flags, 0, sizeof( channel_state[ n ].LBRR_flags ) );
- if( channel_state[ n ].LBRR_flag ) {
- if( channel_state[ n ].nFramesPerPacket == 1 ) {
- channel_state[ n ].LBRR_flags[ 0 ] = 1;
- } else {
- LBRR_symbol = ec_dec_icdf( psRangeDec, SKP_Silk_LBRR_flags_iCDF_ptr[ channel_state[ n ].nFramesPerPacket - 2 ], 8 ) + 1;
- for( i = 0; i < channel_state[ n ].nFramesPerPacket; i++ ) {
- channel_state[ n ].LBRR_flags[ i ] = SKP_RSHIFT( LBRR_symbol, i ) & 1;
- }
- }
- }
- }
-
- if( lostFlag == FLAG_DECODE_NORMAL ) {
- /* Regular decoding: skip all LBRR data */
- for( i = 0; i < channel_state[ 0 ].nFramesPerPacket; i++ ) {
- for( n = 0; n < decControl->nChannels; n++ ) {
- if( channel_state[ n ].LBRR_flags[ i ] ) {
- SKP_int pulses[ MAX_FRAME_LENGTH ];
- SKP_Silk_decode_indices( &channel_state[ n ], psRangeDec, i, 1 );
- SKP_Silk_decode_pulses( psRangeDec, pulses, channel_state[ n ].indices.signalType,
- channel_state[ n ].indices.quantOffsetType, channel_state[ n ].frame_length );
- }
- }
- }
- }
- }
-
- /* Get MS predictor index */
- if( decControl->nChannels == 2 ) {
- SKP_Silk_stereo_decode_pred( psRangeDec, MS_pred_Q14 );
- }
-
- /* Call decoder for one frame */
- for( n = 0; n < decControl->nChannels; n++ ) {
- ret += SKP_Silk_decode_frame( &channel_state[ n ], psRangeDec, &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], &nSamplesOutDec, lostFlag );
- }
-
- /* Convert Mid/Side to Left/Right */
- if( decControl->nChannels == 2 ) {
- SKP_Silk_stereo_MS_to_LR( &psDec->sStereo, dec_out_ptr, &dec_out_ptr[ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], MS_pred_Q14, channel_state[ 0 ].fs_kHz, nSamplesOutDec );
- }
-
- /* Number of output samples */
- if( doResample ) {
- *nSamplesOut = SKP_DIV32( nSamplesOutDec * decControl->API_sampleRate, SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) );
- } else {
- *nSamplesOut = nSamplesOutDec;
- }
-
- for( n = 0; n < decControl->nChannels; n++ ) {
- /* Resample if needed */
- if( doResample ) {
- /* Initialize resampler when switching internal or external sampling frequency */
- if( prev_fs_kHz != channel_state[ n ].fs_kHz || channel_state[ n ].prev_API_sampleRate != decControl->API_sampleRate ) {
- ret = SKP_Silk_resampler_init( &channel_state[ n ].resampler_state, SKP_SMULBB( channel_state[ n ].fs_kHz, 1000 ), decControl->API_sampleRate );
- }
-
- /* Resample the output to API_sampleRate */
- ret += SKP_Silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], nSamplesOutDec );
- } else {
- resample_out_ptr = &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ];
- }
-
- /* Interleave if needed */
- if( decControl->nChannels == 2 ) {
- for( i = 0; i < *nSamplesOut; i++ ) {
- samplesOut[ n + 2 * i ] = resample_out_ptr[ i ];
- }
- }
-
- channel_state[ n ].prev_API_sampleRate = decControl->API_sampleRate;
- }
-
- /* Copy parameters to control stucture */
- decControl->frameSize = ( SKP_int )*nSamplesOut;
- decControl->framesPerPayload = ( SKP_int )channel_state[ n ].nFramesPerPacket;
-
- return ret;
-}
-
-/* Getting table of contents for a packet */
-SKP_int SKP_Silk_SDK_get_TOC(
- const SKP_uint8 *payload, /* I Payload data */
- const SKP_int nBytesIn, /* I: Number of input bytes */
- const SKP_int nFramesPerPayload, /* I: Number of SILK frames per payload */
- SKP_Silk_TOC_struct *Silk_TOC /* O: Type of content */
-)
-{
- SKP_int i, flags, ret = SKP_SILK_NO_ERROR;
-
- if( nBytesIn < 1 ) {
- return -1;
- }
- if( nFramesPerPayload < 0 || nFramesPerPayload > 3 ) {
- return -1;
- }
-
- SKP_memset( Silk_TOC, 0, sizeof( Silk_TOC ) );
-
- /* For stereo, extract the flags for the mid channel */
- flags = SKP_RSHIFT( payload[ 0 ], 7 - nFramesPerPayload ) & ( SKP_LSHIFT( 1, nFramesPerPayload + 1 ) - 1 );
-
- Silk_TOC->inbandFECFlag = flags & 1;
- for( i = nFramesPerPayload - 1; i >= 0 ; i-- ) {
- flags = SKP_RSHIFT( flags, 1 );
- Silk_TOC->VADFlags[ i ] = flags & 1;
- Silk_TOC->VADFlag |= flags & 1;
- }
-
- return ret;
-}
--- a/silk/SKP_Silk_decode_core.c
+++ /dev/null
@@ -1,224 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/**********************************************************/
-/* Core decoder. Performs inverse NSQ operation LTP + LPC */
-/**********************************************************/
-void SKP_Silk_decode_core(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I Decoder control */
- SKP_int16 xq[], /* O Decoded speech */
- const SKP_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */
-)
-{
- SKP_int i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType;
- SKP_int16 *A_Q12, *B_Q14, *pxq, A_Q12_tmp[ MAX_LPC_ORDER ];
- SKP_int16 sLTP[ MAX_FRAME_LENGTH ];
- SKP_int32 LTP_pred_Q14, LPC_pred_Q10, Gain_Q16, inv_gain_Q16, inv_gain_Q32, gain_adj_Q16, rand_seed, offset_Q10;
- SKP_int32 *pred_lag_ptr, *pexc_Q10, *pres_Q10;
- SKP_int32 res_Q10[ MAX_SUB_FRAME_LENGTH ];
- SKP_int32 vec_Q10[ MAX_SUB_FRAME_LENGTH ];
-
- SKP_assert( psDec->prev_inv_gain_Q16 != 0 );
-
- offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psDec->indices.signalType >> 1 ][ psDec->indices.quantOffsetType ];
-
- if( psDec->indices.NLSFInterpCoef_Q2 < 1 << 2 ) {
- NLSF_interpolation_flag = 1;
- } else {
- NLSF_interpolation_flag = 0;
- }
-
- /* Decode excitation */
- rand_seed = psDec->indices.Seed;
- for( i = 0; i < psDec->frame_length; i++ ) {
- rand_seed = SKP_RAND( rand_seed );
- psDec->exc_Q10[ i ] = SKP_LSHIFT( ( SKP_int32 )pulses[ i ], 10 );
- if( psDec->exc_Q10[ i ] > 0 ) {
- psDec->exc_Q10[ i ] -= QUANT_LEVEL_ADJUST_Q10;
- } else
- if( psDec->exc_Q10[ i ] < 0 ) {
- psDec->exc_Q10[ i ] += QUANT_LEVEL_ADJUST_Q10;
- }
- psDec->exc_Q10[ i ] += offset_Q10;
- psDec->exc_Q10[ i ] ^= SKP_RSHIFT( rand_seed, 31 );
-
- rand_seed += pulses[ i ];
- }
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( dec_q.dat, pulses, psDec->frame_length * sizeof( SKP_int ) );
-#endif
-
- pexc_Q10 = psDec->exc_Q10;
- pxq = &psDec->outBuf[ psDec->ltp_mem_length ];
- sLTP_buf_idx = psDec->ltp_mem_length;
- /* Loop over subframes */
- for( k = 0; k < psDec->nb_subfr; k++ ) {
- pres_Q10 = res_Q10;
- A_Q12 = psDecCtrl->PredCoef_Q12[ k >> 1 ];
-
- /* Preload LPC coeficients to array on stack. Gives small performance gain */
- SKP_memcpy( A_Q12_tmp, A_Q12, psDec->LPC_order * sizeof( SKP_int16 ) );
- B_Q14 = &psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER ];
- Gain_Q16 = psDecCtrl->Gains_Q16[ k ];
- signalType = psDec->indices.signalType;
-
- inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gain_Q16, 1 ), 32 );
- inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );
-
- /* Calculate Gain adjustment factor */
- gain_adj_Q16 = 1 << 16;
- if( inv_gain_Q16 != psDec->prev_inv_gain_Q16 ) {
- gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, psDec->prev_inv_gain_Q16, 16 );
-
- /* Scale short term state */
- for( i = 0; i < MAX_LPC_ORDER; i++ ) {
- psDec->sLPC_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, psDec->sLPC_Q14[ i ] );
- }
- }
-
- /* Save inv_gain */
- SKP_assert( inv_gain_Q16 != 0 );
- psDec->prev_inv_gain_Q16 = inv_gain_Q16;
-
- /* Avoid abrupt transition from voiced PLC to unvoiced normal decoding */
- if( psDec->lossCnt && psDec->prevSignalType == TYPE_VOICED &&
- psDec->indices.signalType != TYPE_VOICED && k < MAX_NB_SUBFR/2 ) {
-
- SKP_memset( B_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ) );
- B_Q14[ LTP_ORDER/2 ] = SKP_FIX_CONST( 0.25, 14 );
-
- signalType = TYPE_VOICED;
- psDecCtrl->pitchL[ k ] = psDec->lagPrev;
- }
-
- if( signalType == TYPE_VOICED ) {
- /* Voiced */
- lag = psDecCtrl->pitchL[ k ];
-
- /* Re-whitening */
- if( ( k & ( 3 - SKP_LSHIFT( NLSF_interpolation_flag, 1 ) ) ) == 0 ) {
- /* Rewhiten with new A coefs */
- start_idx = psDec->ltp_mem_length - lag - psDec->LPC_order - LTP_ORDER / 2;
- SKP_assert( start_idx > 0 );
-
- SKP_Silk_LPC_analysis_filter( &sLTP[ start_idx ], &psDec->outBuf[ start_idx + k * psDec->subfr_length ],
- A_Q12, psDec->ltp_mem_length - start_idx, psDec->LPC_order );
-
- /* After rewhitening the LTP state is unscaled */
- inv_gain_Q32 = SKP_LSHIFT( inv_gain_Q16, 16 );
- if( k == 0 ) {
- /* Do LTP downscaling */
- inv_gain_Q32 = SKP_LSHIFT( SKP_SMULWB( inv_gain_Q32, psDecCtrl->LTP_scale_Q14 ), 2 );
- }
- for( i = 0; i < lag + LTP_ORDER/2; i++ ) {
- psDec->sLTP_Q16[ sLTP_buf_idx - i - 1 ] = SKP_SMULWB( inv_gain_Q32, sLTP[ psDec->ltp_mem_length - i - 1 ] );
- }
- } else {
- /* Update LTP state when Gain changes */
- if( gain_adj_Q16 != 1 << 16 ) {
- for( i = 0; i < lag + LTP_ORDER/2; i++ ) {
- psDec->sLTP_Q16[ sLTP_buf_idx - i - 1 ] = SKP_SMULWW( gain_adj_Q16, psDec->sLTP_Q16[ sLTP_buf_idx - i - 1 ] );
- }
- }
- }
- }
-
- /* Long-term prediction */
- if( signalType == TYPE_VOICED ) {
- /* Setup pointer */
- pred_lag_ptr = &psDec->sLTP_Q16[ sLTP_buf_idx - lag + LTP_ORDER / 2 ];
- for( i = 0; i < psDec->subfr_length; i++ ) {
- /* Unrolled loop */
- LTP_pred_Q14 = SKP_SMULWB( pred_lag_ptr[ 0 ], B_Q14[ 0 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], B_Q14[ 1 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -2 ], B_Q14[ 2 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -3 ], B_Q14[ 3 ] );
- LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], B_Q14[ 4 ] );
- pred_lag_ptr++;
-
- /* Generate LPC excitation */
- pres_Q10[ i ] = SKP_ADD32( pexc_Q10[ i ], SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) );
-
- /* Update states */
- psDec->sLTP_Q16[ sLTP_buf_idx ] = SKP_LSHIFT( pres_Q10[ i ], 6 );
- sLTP_buf_idx++;
- }
- } else {
- pres_Q10 = pexc_Q10;
- }
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( dec_exc_Q10.dat, pexc_Q10, psDec->subfr_length * sizeof( SKP_int32 ) );
- DEBUG_STORE_DATA( dec_res_Q10.dat, pres_Q10, psDec->subfr_length * sizeof( SKP_int32 ) );
-#endif
-
- for( i = 0; i < psDec->subfr_length; i++ ) {
- /* Partially unrolled */
- LPC_pred_Q10 = SKP_SMULWB( psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 2 ], A_Q12_tmp[ 1 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 3 ], A_Q12_tmp[ 2 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 4 ], A_Q12_tmp[ 3 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 5 ], A_Q12_tmp[ 4 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 6 ], A_Q12_tmp[ 5 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 7 ], A_Q12_tmp[ 6 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 8 ], A_Q12_tmp[ 7 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 9 ], A_Q12_tmp[ 8 ] );
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], A_Q12_tmp[ 9 ] );
- for( j = 10; j < psDec->LPC_order; j++ ) {
- LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - j - 1 ], A_Q12_tmp[ j ] );
- }
-
- /* Add prediction to LPC excitation */
- vec_Q10[ i ] = SKP_ADD32( pres_Q10[ i ], LPC_pred_Q10 );
-
- /* Update states */
- psDec->sLPC_Q14[ MAX_LPC_ORDER + i ] = SKP_LSHIFT( vec_Q10[ i ], 4 );
- }
-
- /* Scale with Gain */
- for( i = 0; i < psDec->subfr_length; i++ ) {
- pxq[ i ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SMULWW( vec_Q10[ i ], Gain_Q16 ), 10 ) );
- }
-
- /* Update LPC filter state */
- SKP_memcpy( psDec->sLPC_Q14, &psDec->sLPC_Q14[ psDec->subfr_length ], MAX_LPC_ORDER * sizeof( SKP_int32 ) );
- pexc_Q10 += psDec->subfr_length;
- pxq += psDec->subfr_length;
- }
-
- /* Copy to output */
- SKP_memcpy( xq, &psDec->outBuf[ psDec->ltp_mem_length ], psDec->frame_length * sizeof( SKP_int16 ) );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( dec_sLTP_Q16.dat, &psDec->sLTP_Q16[ psDec->ltp_mem_length ], psDec->frame_length * sizeof( SKP_int32 ));
- DEBUG_STORE_DATA( dec_xq.dat, xq, psDec->frame_length * sizeof( SKP_int16 ) );
-#endif
-}
--- a/silk/SKP_Silk_decode_frame.c
+++ /dev/null
@@ -1,134 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-#include "SKP_Silk_PLC.h"
-
-/****************/
-/* Decode frame */
-/****************/
-SKP_int SKP_Silk_decode_frame(
- SKP_Silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int16 pOut[], /* O Pointer to output speech frame */
- SKP_int32 *pN, /* O Pointer to size of output frame */
- SKP_int lostFlag /* I 0: no loss, 1 loss, 2 decode fec */
-)
-{
- SKP_Silk_decoder_control sDecCtrl;
- SKP_int L, mv_len, ret = 0;
- SKP_int pulses[ MAX_FRAME_LENGTH ];
-
-TIC(DECODE_FRAME)
-
- L = psDec->frame_length;
- sDecCtrl.LTP_scale_Q14 = 0;
-
- /* Safety checks */
- SKP_assert( L > 0 && L <= MAX_FRAME_LENGTH );
-
- if( lostFlag == FLAG_DECODE_NORMAL ||
- ( lostFlag == FLAG_DECODE_LBRR && psDec->LBRR_flags[ psDec->nFramesDecoded ] == 1 ) )
- {
- /*********************************************/
- /* Decode quantization indices of side info */
- /*********************************************/
-TIC(decode_indices)
- SKP_Silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag );
-TOC(decode_indices)
-
- /*********************************************/
- /* Decode quantization indices of excitation */
- /*********************************************/
-TIC(decode_pulses)
- SKP_Silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType,
- psDec->indices.quantOffsetType, psDec->frame_length );
-TOC(decode_pulses)
-
- /********************************************/
- /* Decode parameters and pulse signal */
- /********************************************/
-TIC(decode_params)
- SKP_Silk_decode_parameters( psDec, &sDecCtrl );
-TOC(decode_params)
-
- /* Update length. Sampling frequency may have changed */
- L = psDec->frame_length;
-
- /********************************************************/
- /* Run inverse NSQ */
- /********************************************************/
-TIC(decode_core)
- SKP_Silk_decode_core( psDec, &sDecCtrl, pOut, pulses );
-TOC(decode_core)
-
- /********************************************************/
- /* Update PLC state */
- /********************************************************/
- SKP_Silk_PLC( psDec, &sDecCtrl, pOut, L, 0 );
-
- psDec->lossCnt = 0;
- psDec->prevSignalType = psDec->indices.signalType;
- SKP_assert( psDec->prevSignalType >= 0 && psDec->prevSignalType <= 2 );
-
- /* A frame has been decoded without errors */
- psDec->first_frame_after_reset = 0;
- } else {
- /* Handle packet loss by extrapolation */
- SKP_Silk_PLC( psDec, &sDecCtrl, pOut, L, 1 );
- }
-
- /*************************/
- /* Update output buffer. */
- /*************************/
- SKP_assert( psDec->ltp_mem_length >= psDec->frame_length );
- mv_len = psDec->ltp_mem_length - psDec->frame_length;
- SKP_memmove( psDec->outBuf, &psDec->outBuf[ psDec->frame_length ], mv_len * sizeof(SKP_int16) );
- SKP_memcpy( &psDec->outBuf[ mv_len ], pOut, psDec->frame_length * sizeof( SKP_int16 ) );
-
- /****************************************************************/
- /* Ensure smooth connection of extrapolated and good frames */
- /****************************************************************/
- SKP_Silk_PLC_glue_frames( psDec, &sDecCtrl, pOut, L );
-
- /************************************************/
- /* Comfort noise generation / estimation */
- /************************************************/
- SKP_Silk_CNG( psDec, &sDecCtrl, pOut, L );
-
- /* Update some decoder state variables */
- psDec->lagPrev = sDecCtrl.pitchL[ psDec->nb_subfr - 1 ];
- psDec->nFramesDecoded++;
-
- /* Set output frame length */
- *pN = L;
-
-TOC(DECODE_FRAME)
-
- return ret;
-}
-
\ No newline at end of file
--- a/silk/SKP_Silk_decode_indices.c
+++ /dev/null
@@ -1,153 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Decode side-information parameters from payload */
-void SKP_Silk_decode_indices(
- SKP_Silk_decoder_state *psDec, /* I/O State */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int FrameIndex, /* I Frame number */
- SKP_int decode_LBRR /* I Flag indicating LBRR data is being decoded */
-)
-{
- SKP_int i, k, Ix, condCoding;
- SKP_int decode_absolute_lagIndex, delta_lagIndex;
- SKP_int16 ec_ix[ MAX_LPC_ORDER ];
- SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
-
- /* Use conditional coding if previous frame available */
- if( FrameIndex > 0 && ( decode_LBRR == 0 || psDec->LBRR_flags[ FrameIndex - 1 ] == 1 ) ) {
- condCoding = 1;
- } else {
- condCoding = 0;
- }
-
- /*******************************************/
- /* Decode signal type and quantizer offset */
- /*******************************************/
- if( decode_LBRR || psDec->VAD_flags[ FrameIndex ] ) {
- Ix = ec_dec_icdf( psRangeDec, SKP_Silk_type_offset_VAD_iCDF, 8 ) + 2;
- } else {
- Ix = ec_dec_icdf( psRangeDec, SKP_Silk_type_offset_no_VAD_iCDF, 8 );
- }
- psDec->indices.signalType = (SKP_int8)SKP_RSHIFT( Ix, 1 );
- psDec->indices.quantOffsetType = (SKP_int8)( Ix & 1 );
-
- /****************/
- /* Decode gains */
- /****************/
- /* First subframe */
- if( condCoding ) {
- /* Conditional coding */
- psDec->indices.GainsIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_delta_gain_iCDF, 8 );
- } else {
- /* Independent coding, in two stages: MSB bits followed by 3 LSBs */
- psDec->indices.GainsIndices[ 0 ] = (SKP_int8)SKP_LSHIFT( ec_dec_icdf( psRangeDec, SKP_Silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 );
- psDec->indices.GainsIndices[ 0 ] += (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_uniform8_iCDF, 8 );
- }
-
- /* Remaining subframes */
- for( i = 1; i < psDec->nb_subfr; i++ ) {
- psDec->indices.GainsIndices[ i ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_delta_gain_iCDF, 8 );
- }
-
- /**********************/
- /* Decode LSF Indices */
- /**********************/
- psDec->indices.NLSFIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->CB1_iCDF[ ( psDec->indices.signalType >> 1 ) * psDec->psNLSF_CB->nVectors ], 8 );
- SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psDec->psNLSF_CB, psDec->indices.NLSFIndices[ 0 ] );
- SKP_assert( psDec->psNLSF_CB->order == psDec->LPC_order );
- for( i = 0; i < psDec->psNLSF_CB->order; i++ ) {
- Ix = ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 );
- if( Ix == 0 ) {
- Ix -= ec_dec_icdf( psRangeDec, SKP_Silk_NLSF_EXT_iCDF, 8 );
- } else if( Ix == 2 * NLSF_QUANT_MAX_AMPLITUDE ) {
- Ix += ec_dec_icdf( psRangeDec, SKP_Silk_NLSF_EXT_iCDF, 8 );
- }
- psDec->indices.NLSFIndices[ i+1 ] = (SKP_int8)( Ix - NLSF_QUANT_MAX_AMPLITUDE );
- }
-
- /* Decode LSF interpolation factor */
- if( psDec->nb_subfr == MAX_NB_SUBFR ) {
- psDec->indices.NLSFInterpCoef_Q2 = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_NLSF_interpolation_factor_iCDF, 8 );
- } else {
- psDec->indices.NLSFInterpCoef_Q2 = 4;
- }
-
- if( psDec->indices.signalType == TYPE_VOICED )
- {
- /*********************/
- /* Decode pitch lags */
- /*********************/
- /* Get lag index */
- decode_absolute_lagIndex = 1;
- if( condCoding && psDec->ec_prevSignalType == TYPE_VOICED ) {
- /* Decode Delta index */
- delta_lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, SKP_Silk_pitch_delta_iCDF, 8 );
- if( delta_lagIndex > 0 ) {
- delta_lagIndex = delta_lagIndex - 9;
- psDec->indices.lagIndex = (SKP_int16)( psDec->ec_prevLagIndex + delta_lagIndex );
- decode_absolute_lagIndex = 0;
- }
- }
- if( decode_absolute_lagIndex ) {
- /* Absolute decoding */
- psDec->indices.lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, SKP_Silk_pitch_lag_iCDF, 8 ) * SKP_RSHIFT( psDec->fs_kHz, 1 );
- psDec->indices.lagIndex += (SKP_int16)ec_dec_icdf( psRangeDec, psDec->pitch_lag_low_bits_iCDF, 8 );
- }
- psDec->ec_prevLagIndex = psDec->indices.lagIndex;
-
- /* Get countour index */
- psDec->indices.contourIndex = (SKP_int8)ec_dec_icdf( psRangeDec, psDec->pitch_contour_iCDF, 8 );
-
- /********************/
- /* Decode LTP gains */
- /********************/
- /* Decode PERIndex value */
- psDec->indices.PERIndex = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_LTP_per_index_iCDF, 8 );
-
- for( k = 0; k < psDec->nb_subfr; k++ ) {
- psDec->indices.LTPIndex[ k ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_LTP_gain_iCDF_ptrs[ psDec->indices.PERIndex ], 8 );
- }
-
- /**********************/
- /* Decode LTP scaling */
- /**********************/
- if( !condCoding ) {
- psDec->indices.LTP_scaleIndex = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_LTPscale_iCDF, 8 );
- } else {
- psDec->indices.LTP_scaleIndex = 0;
- }
- }
- psDec->ec_prevSignalType = psDec->indices.signalType;
-
- /***************/
- /* Decode seed */
- /***************/
- psDec->indices.Seed = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_uniform4_iCDF, 8 );
-}
--- a/silk/SKP_Silk_decode_parameters.c
+++ /dev/null
@@ -1,111 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Decode parameters from payload */
-void SKP_Silk_decode_parameters(
- SKP_Silk_decoder_state *psDec, /* I/O State */
- SKP_Silk_decoder_control *psDecCtrl /* I/O Decoder control */
-)
-{
- SKP_int i, k, Ix;
- SKP_int16 pNLSF_Q15[ MAX_LPC_ORDER ], pNLSF0_Q15[ MAX_LPC_ORDER ];
- const SKP_int8 *cbk_ptr_Q7;
-
- /* Dequant Gains */
- SKP_Silk_gains_dequant( psDecCtrl->Gains_Q16, psDec->indices.GainsIndices,
- &psDec->LastGainIndex, psDec->nFramesDecoded, psDec->nb_subfr );
-
- /****************/
- /* Decode NLSFs */
- /****************/
- SKP_Silk_NLSF_decode( pNLSF_Q15, psDec->indices.NLSFIndices, psDec->psNLSF_CB );
-
- /* Convert NLSF parameters to AR prediction filter coefficients */
- SKP_Silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 1 ], pNLSF_Q15, psDec->LPC_order );
-
- /* If just reset, e.g., because internal Fs changed, do not allow interpolation */
- /* improves the case of packet loss in the first frame after a switch */
- if( psDec->first_frame_after_reset == 1 ) {
- psDec->indices.NLSFInterpCoef_Q2 = 4;
- }
-
- if( psDec->indices.NLSFInterpCoef_Q2 < 4 ) {
- /* Calculation of the interpolated NLSF0 vector from the interpolation factor, */
- /* the previous NLSF1, and the current NLSF1 */
- for( i = 0; i < psDec->LPC_order; i++ ) {
- pNLSF0_Q15[ i ] = psDec->prevNLSF_Q15[ i ] + SKP_RSHIFT( SKP_MUL( psDec->indices.NLSFInterpCoef_Q2,
- pNLSF_Q15[ i ] - psDec->prevNLSF_Q15[ i ] ), 2 );
- }
-
- /* Convert NLSF parameters to AR prediction filter coefficients */
- SKP_Silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 0 ], pNLSF0_Q15, psDec->LPC_order );
- } else {
- /* Copy LPC coefficients for first half from second half */
- SKP_memcpy( psDecCtrl->PredCoef_Q12[ 0 ], psDecCtrl->PredCoef_Q12[ 1 ],
- psDec->LPC_order * sizeof( SKP_int16 ) );
- }
-
- SKP_memcpy( psDec->prevNLSF_Q15, pNLSF_Q15, psDec->LPC_order * sizeof( SKP_int16 ) );
-
- /* After a packet loss do BWE of LPC coefs */
- if( psDec->lossCnt ) {
- SKP_Silk_bwexpander( psDecCtrl->PredCoef_Q12[ 0 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 );
- SKP_Silk_bwexpander( psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 );
- }
-
- if( psDec->indices.signalType == TYPE_VOICED ) {
- /*********************/
- /* Decode pitch lags */
- /*********************/
-
- /* Decode pitch values */
- SKP_Silk_decode_pitch( psDec->indices.lagIndex, psDec->indices.contourIndex, psDecCtrl->pitchL, psDec->fs_kHz, psDec->nb_subfr );
-
- /* Decode Codebook Index */
- cbk_ptr_Q7 = SKP_Silk_LTP_vq_ptrs_Q7[ psDec->indices.PERIndex ]; /* set pointer to start of codebook */
-
- for( k = 0; k < psDec->nb_subfr; k++ ) {
- Ix = psDec->indices.LTPIndex[ k ];
- for( i = 0; i < LTP_ORDER; i++ ) {
- psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER + i ] = SKP_LSHIFT( cbk_ptr_Q7[ Ix * LTP_ORDER + i ], 7 );
- }
- }
-
- /**********************/
- /* Decode LTP scaling */
- /**********************/
- Ix = psDec->indices.LTP_scaleIndex;
- psDecCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ Ix ];
- } else {
- SKP_memset( psDecCtrl->pitchL, 0, psDec->nb_subfr * sizeof( SKP_int ) );
- SKP_memset( psDecCtrl->LTPCoef_Q14, 0, LTP_ORDER * psDec->nb_subfr * sizeof( SKP_int16 ) );
- psDec->indices.PERIndex = 0;
- psDecCtrl->LTP_scale_Q14 = 0;
- }
-}
--- a/silk/SKP_Silk_decode_pitch.c
+++ /dev/null
@@ -1,71 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/***********************************************************
-* Pitch analyser function
-********************************************************** */
-#include "SKP_Silk_SigProc_FIX.h"
-#include "SKP_Silk_pitch_est_defines.h"
-
-void SKP_Silk_decode_pitch(
- SKP_int16 lagIndex, /* I */
- SKP_int8 contourIndex, /* O */
- SKP_int pitch_lags[], /* O pitch values */
- const SKP_int Fs_kHz, /* I sampling frequency (kHz) */
- const SKP_int nb_subfr /* I number of sub frames */
-)
-{
- SKP_int lag, k, min_lag, cbk_size;
- const SKP_int8 *Lag_CB_ptr;
-
- if( Fs_kHz == 8 ) {
- if( nb_subfr == PE_MAX_NB_SUBFR ) {
- Lag_CB_ptr = &SKP_Silk_CB_lags_stage2[ 0 ][ 0 ];
- cbk_size = PE_NB_CBKS_STAGE2_EXT;
- } else {
- SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 );
- Lag_CB_ptr = &SKP_Silk_CB_lags_stage2_10_ms[ 0 ][ 0 ];
- cbk_size = PE_NB_CBKS_STAGE2_10MS;
- }
- } else {
- if( nb_subfr == PE_MAX_NB_SUBFR ) {
- Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ];
- cbk_size = PE_NB_CBKS_STAGE3_MAX;
- } else {
- SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 );
- Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
- cbk_size = PE_NB_CBKS_STAGE3_10MS;
- }
- }
-
- min_lag = SKP_SMULBB( PE_MIN_LAG_MS, Fs_kHz );
- lag = min_lag + lagIndex;
-
- for( k = 0; k < nb_subfr; k++ ) {
- pitch_lags[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, contourIndex, cbk_size );
- }
-}
\ No newline at end of file
--- a/silk/SKP_Silk_decode_pulses.c
+++ /dev/null
@@ -1,107 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/*********************************************/
-/* Decode quantization indices of excitation */
-/*********************************************/
-void SKP_Silk_decode_pulses(
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int pulses[], /* O Excitation signal */
- const SKP_int signalType, /* I Sigtype */
- const SKP_int quantOffsetType, /* I quantOffsetType */
- const SKP_int frame_length /* I Frame length */
-)
-{
- SKP_int i, j, k, iter, abs_q, nLS, RateLevelIndex;
- SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ], nLshifts[ MAX_NB_SHELL_BLOCKS ];
- SKP_int *pulses_ptr;
- const SKP_uint8 *cdf_ptr;
-
- /*********************/
- /* Decode rate level */
- /*********************/
- RateLevelIndex = ec_dec_icdf( psRangeDec, SKP_Silk_rate_levels_iCDF[ signalType >> 1 ], 8 );
-
- /* Calculate number of shell blocks */
- SKP_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );
- iter = SKP_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH );
- if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ){
- SKP_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */
- iter++;
- }
-
- /***************************************************/
- /* Sum-Weighted-Pulses Decoding */
- /***************************************************/
- cdf_ptr = SKP_Silk_pulses_per_block_iCDF[ RateLevelIndex ];
- for( i = 0; i < iter; i++ ) {
- nLshifts[ i ] = 0;
- sum_pulses[ i ] = ec_dec_icdf( psRangeDec, cdf_ptr, 8 );
-
- /* LSB indication */
- while( sum_pulses[ i ] == MAX_PULSES + 1 ) {
- nLshifts[ i ]++;
- sum_pulses[ i ] = ec_dec_icdf( psRangeDec, SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 );
- }
- }
-
- /***************************************************/
- /* Shell decoding */
- /***************************************************/
- for( i = 0; i < iter; i++ ) {
- if( sum_pulses[ i ] > 0 ) {
- SKP_Silk_shell_decoder( &pulses[ SKP_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], psRangeDec, sum_pulses[ i ] );
- } else {
- SKP_memset( &pulses[ SKP_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof( SKP_int ) );
- }
- }
-
- /***************************************************/
- /* LSB Decoding */
- /***************************************************/
- for( i = 0; i < iter; i++ ) {
- if( nLshifts[ i ] > 0 ) {
- nLS = nLshifts[ i ];
- pulses_ptr = &pulses[ SKP_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ];
- for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) {
- abs_q = pulses_ptr[ k ];
- for( j = 0; j < nLS; j++ ) {
- abs_q = SKP_LSHIFT( abs_q, 1 );
- abs_q += ec_dec_icdf( psRangeDec, SKP_Silk_lsb_iCDF, 8 );
- }
- pulses_ptr[ k ] = abs_q;
- }
- }
- }
-
- /****************************************/
- /* Decode and add signs to pulse signal */
- /****************************************/
- SKP_Silk_decode_signs( psRangeDec, pulses, frame_length, signalType, quantOffsetType, sum_pulses );
-}
--- a/silk/SKP_Silk_decoder_set_fs.c
+++ /dev/null
@@ -1,93 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Set decoder sampling rate */
-void SKP_Silk_decoder_set_fs(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state pointer */
- SKP_int fs_kHz /* I Sampling frequency (kHz) */
-)
-{
- SKP_int frame_length;
-
- SKP_assert( fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16 );
- SKP_assert( psDec->nb_subfr == MAX_NB_SUBFR || psDec->nb_subfr == MAX_NB_SUBFR/2 );
-
- psDec->subfr_length = SKP_SMULBB( SUB_FRAME_LENGTH_MS, fs_kHz );
- frame_length = SKP_SMULBB( psDec->nb_subfr, psDec->subfr_length );
- if( psDec->fs_kHz != fs_kHz || frame_length != psDec->frame_length ) {
- psDec->fs_kHz = fs_kHz;
- psDec->frame_length = frame_length;
- psDec->ltp_mem_length = SKP_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz );
- if( psDec->fs_kHz == 8 ) {
- if( psDec->nb_subfr == MAX_NB_SUBFR ) {
- psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;
- } else {
- psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
- }
- } else {
- if( psDec->nb_subfr == MAX_NB_SUBFR ) {
- psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF;
- } else {
- psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
- }
- }
- if( psDec->fs_kHz == 8 || psDec->fs_kHz == 12 ) {
- psDec->LPC_order = MIN_LPC_ORDER;
- psDec->psNLSF_CB = &SKP_Silk_NLSF_CB_NB_MB;
- } else {
- psDec->LPC_order = MAX_LPC_ORDER;
- psDec->psNLSF_CB = &SKP_Silk_NLSF_CB_WB;
- }
-
- /* Reset part of the decoder state */
- SKP_memset( psDec->sLPC_Q14, 0, sizeof( psDec->sLPC_Q14 ) );
- SKP_memset( psDec->outBuf, 0, MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );
- SKP_memset( psDec->prevNLSF_Q15, 0, sizeof( psDec->prevNLSF_Q15 ) );
-
- psDec->lagPrev = 100;
- psDec->LastGainIndex = 10;
- psDec->prevSignalType = TYPE_NO_VOICE_ACTIVITY;
- psDec->first_frame_after_reset = 1;
-
- if( fs_kHz == 16 ) {
- psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
- } else if( fs_kHz == 12 ) {
- psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;
- } else if( fs_kHz == 8 ) {
- psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;
- } else {
- /* unsupported sampling rate */
- SKP_assert( 0 );
- }
- }
-
- /* Check that settings are valid */
- SKP_assert( psDec->frame_length > 0 && psDec->frame_length <= MAX_FRAME_LENGTH );
-}
-
--- a/silk/SKP_Silk_define.h
+++ /dev/null
@@ -1,235 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef SKP_SILK_DEFINE_H
-#define SKP_SILK_DEFINE_H
-
-#include "SKP_Silk_errors.h"
-#include "SKP_Silk_typedef.h"
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Max number of encoder channels (1/2) */
-#define ENCODER_NUM_CHANNELS 2
-/* Number of decoder channels (1/2) */
-#define DECODER_NUM_CHANNELS 2
-
-#define MAX_FRAMES_PER_PACKET 3
-
-/* Limits on bitrate */
-#define MIN_TARGET_RATE_BPS 5000
-#define MAX_TARGET_RATE_BPS 80000
-#define TARGET_RATE_TAB_SZ 8
-
-/* Decay time for bitreservoir */
-#define BITRESERVOIR_DECAY_TIME_MS 200
-
-/* LBRR thresholds */
-#define LBRR_NB_MIN_RATE_BPS 9000
-#define LBRR_MB_MIN_RATE_BPS 12000
-#define LBRR_WB_MIN_RATE_BPS 15000
-
-/* DTX settings */
-#define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */
-#define MAX_CONSECUTIVE_DTX 20 /* eq 400 ms */
-
-/* Maximum sampling frequency, should be 16 for embedded */
-#define MAX_FS_KHZ 16
-#define MAX_API_FS_KHZ 48
-
-/* Signal types */
-#define TYPE_NO_VOICE_ACTIVITY 0
-#define TYPE_UNVOICED 1
-#define TYPE_VOICED 2
-
-/* Setting for stereo processing */
-#define STEREO_QUANT_TAB_SIZE 16
-#define STEREO_QUANT_SUB_STEPS 5
-#define STEREO_INTERP_LEN_MS 8 /* must be even */
-
-/* Range of pitch lag estimates */
-#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */
-#define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */
-
-/* Number of subframes */
-#define MAX_NB_SUBFR 4
-
-/* Number of samples per frame */
-#define LTP_MEM_LENGTH_MS 20
-#define SUB_FRAME_LENGTH_MS 5
-#define MAX_SUB_FRAME_LENGTH ( SUB_FRAME_LENGTH_MS * MAX_FS_KHZ )
-#define MAX_FRAME_LENGTH_MS ( SUB_FRAME_LENGTH_MS * MAX_NB_SUBFR )
-#define MAX_FRAME_LENGTH ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ )
-
-/* Milliseconds of lookahead for pitch analysis */
-#define LA_PITCH_MS 2
-#define LA_PITCH_MAX ( LA_PITCH_MS * MAX_FS_KHZ )
-
-/* Order of LPC used in find pitch */
-#define MAX_FIND_PITCH_LPC_ORDER 16
-
-/* Length of LPC window used in find pitch */
-#define FIND_PITCH_LPC_WIN_MS ( 20 + (LA_PITCH_MS << 1) )
-#define FIND_PITCH_LPC_WIN_MS_2_SF ( 10 + (LA_PITCH_MS << 1) )
-#define FIND_PITCH_LPC_WIN_MAX ( FIND_PITCH_LPC_WIN_MS * MAX_FS_KHZ )
-
-/* Milliseconds of lookahead for noise shape analysis */
-#define LA_SHAPE_MS 5
-#define LA_SHAPE_MAX ( LA_SHAPE_MS * MAX_FS_KHZ )
-
-/* Maximum length of LPC window used in noise shape analysis */
-#define SHAPE_LPC_WIN_MAX ( 15 * MAX_FS_KHZ )
-
-/* dB level of lowest gain quantization level */
-#define MIN_QGAIN_DB 2
-/* dB level of highest gain quantization level */
-#define MAX_QGAIN_DB 88
-/* Number of gain quantization levels */
-#define N_LEVELS_QGAIN 64
-/* Max increase in gain quantization index */
-#define MAX_DELTA_GAIN_QUANT 36
-/* Max decrease in gain quantization index */
-#define MIN_DELTA_GAIN_QUANT -4
-
-/* Quantization offsets (multiples of 4) */
-#define OFFSET_VL_Q10 32
-#define OFFSET_VH_Q10 100
-#define OFFSET_UVL_Q10 100
-#define OFFSET_UVH_Q10 240
-
-#define QUANT_LEVEL_ADJUST_Q10 80
-
-/* Maximum numbers of iterations used to stabilize a LPC vector */
-#define MAX_LPC_STABILIZE_ITERATIONS 20
-
-#define MAX_LPC_ORDER 16
-#define MIN_LPC_ORDER 10
-
-/* Find Pred Coef defines */
-#define LTP_ORDER 5
-
-/* LTP quantization settings */
-#define NB_LTP_CBKS 3
-
-/* Flag to use harmonic noise shaping */
-#define USE_HARM_SHAPING 1
-
-/* Max LPC order of noise shaping filters */
-#define MAX_SHAPE_LPC_ORDER 16
-
-#define HARM_SHAPE_FIR_TAPS 3
-
-/* Maximum number of delayed decision states */
-#define MAX_DEL_DEC_STATES 4
-
-#define LTP_BUF_LENGTH 512
-#define LTP_MASK ( LTP_BUF_LENGTH - 1 )
-
-#define DECISION_DELAY 32
-#define DECISION_DELAY_MASK ( DECISION_DELAY - 1 )
-
-/* Number of subframes for excitation entropy coding */
-#define SHELL_CODEC_FRAME_LENGTH 16
-#define LOG2_SHELL_CODEC_FRAME_LENGTH 4
-#define MAX_NB_SHELL_BLOCKS ( MAX_FRAME_LENGTH / SHELL_CODEC_FRAME_LENGTH )
-
-/* Number of rate levels, for entropy coding of excitation */
-#define N_RATE_LEVELS 10
-
-/* Maximum sum of pulses per shell coding frame */
-#define MAX_PULSES 16
-
-#define MAX_MATRIX_SIZE MAX_LPC_ORDER /* Max of LPC Order and LTP order */
-
-#if( MAX_LPC_ORDER > DECISION_DELAY )
-# define NSQ_LPC_BUF_LENGTH MAX_LPC_ORDER
-#else
-# define NSQ_LPC_BUF_LENGTH DECISION_DELAY
-#endif
-
-/***********************/
-/* High pass filtering */
-/***********************/
-#define HIGH_PASS_INPUT 1
-
-/***************************/
-/* Voice activity detector */
-/***************************/
-#define VAD_N_BANDS 4
-
-#define VAD_INTERNAL_SUBFRAMES_LOG2 2
-#define VAD_INTERNAL_SUBFRAMES (1 << VAD_INTERNAL_SUBFRAMES_LOG2)
-
-#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 1024 /* Must be < 4096 */
-#define VAD_NOISE_LEVELS_BIAS 50
-
-/* Sigmoid settings */
-#define VAD_NEGATIVE_OFFSET_Q5 128 /* sigmoid is 0 at -128 */
-#define VAD_SNR_FACTOR_Q16 45000
-
-/* smoothing for SNR measurement */
-#define VAD_SNR_SMOOTH_COEF_Q18 4096
-
-/******************/
-/* NLSF quantizer */
-/******************/
-#define NLSF_VQ_MAX_VECTORS 32
-#define NLSF_VQ_MAX_SURVIVORS 16
-#define NLSF_QUANT_MAX_AMPLITUDE 4
-#define NLSF_QUANT_MAX_AMPLITUDE_EXT 10
-#define NLSF_QUANT_LEVEL_ADJ 0.1
-#define NLSF_QUANT_DEL_DEC_STATES_LOG2 2
-#define NLSF_QUANT_DEL_DEC_STATES ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 )
-
-/* Transition filtering for mode switching */
-# define TRANSITION_TIME_MS 5120 // 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)
-# define TRANSITION_NB 3 /* Hardcoded in tables */
-# define TRANSITION_NA 2 /* Hardcoded in tables */
-# define TRANSITION_INT_NUM 5 /* Hardcoded in tables */
-# define TRANSITION_FRAMES ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS ) // todo: needs to be made flexible for 10 ms frames
-# define TRANSITION_INT_STEPS ( TRANSITION_FRAMES / ( TRANSITION_INT_NUM - 1 ) )
-
-/* BWE factors to apply after packet loss */
-#define BWE_AFTER_LOSS_Q16 63570
-
-/* Defines for CN generation */
-#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */
-#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */
-#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/silk/SKP_Silk_enc_API.c
+++ /dev/null
@@ -1,387 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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 "SKP_Silk_define.h"
-#include "SKP_Silk_SDK_API.h"
-#include "SKP_Silk_control.h"
-#include "SKP_Silk_typedef.h"
-#include "SKP_Silk_structs.h"
-#include "SKP_Silk_tuning_parameters.h"
-#ifdef FIXED_POINT
-#include "SKP_Silk_main_FIX.h"
-#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX
-#define SKP_Silk_encode_frame_Fxx SKP_Silk_encode_frame_FIX
-#else
-#include "SKP_Silk_main_FLP.h"
-#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FLP
-#define SKP_Silk_encode_frame_Fxx SKP_Silk_encode_frame_FLP
-#endif
-
-/* Encoder Super Struct */
-typedef struct {
- SKP_Silk_encoder_state_Fxx state_Fxx[ ENCODER_NUM_CHANNELS ];
- stereo_state sStereo;
- SKP_int32 nBitsExceeded;
- SKP_int nChannels;
- SKP_int timeSinceSwitchAllowed_ms;
- SKP_int allowBandwidthSwitch;
-} SKP_Silk_encoder;
-
-/****************************************/
-/* Encoder functions */
-/****************************************/
-
-SKP_int SKP_Silk_SDK_Get_Encoder_Size( SKP_int32 *encSizeBytes )
-{
- SKP_int ret = SKP_SILK_NO_ERROR;
-
- *encSizeBytes = sizeof( SKP_Silk_encoder );
-
- return ret;
-}
-
-/*************************/
-/* Init or Reset encoder */
-/*************************/
-SKP_int SKP_Silk_SDK_InitEncoder(
- void *encState, /* I/O: State */
- SKP_SILK_SDK_EncControlStruct *encStatus /* O: Control structure */
-)
-{
- SKP_Silk_encoder *psEnc;
- SKP_int n, ret = SKP_SILK_NO_ERROR;
-
- psEnc = (SKP_Silk_encoder *)encState;
-
- /* Reset encoder */
- for( n = 0; n < ENCODER_NUM_CHANNELS; n++ ) {
- if( ret += SKP_Silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) {
- SKP_assert( 0 );
- }
- }
- SKP_memset( &psEnc->sStereo, 0, sizeof( psEnc->sStereo ) );
-
- psEnc->nBitsExceeded = 0;
- psEnc->nChannels = 1;
-
- /* Read control structure */
- if( ret += SKP_Silk_SDK_QueryEncoder( encState, encStatus ) ) {
- SKP_assert( 0 );
- }
-
- return ret;
-}
-
-/***************************************/
-/* Read control structure from encoder */
-/***************************************/
-SKP_int SKP_Silk_SDK_QueryEncoder(
- const void *encState, /* I: State Vector */
- SKP_SILK_SDK_EncControlStruct *encStatus /* O: Control Structure */
-)
-{
- SKP_Silk_encoder_state_Fxx *state_Fxx;
- SKP_int ret = SKP_SILK_NO_ERROR;
-
- state_Fxx = ((SKP_Silk_encoder *)encState)->state_Fxx;
-
- encStatus->API_sampleRate = state_Fxx->sCmn.API_fs_Hz;
- encStatus->maxInternalSampleRate = state_Fxx->sCmn.maxInternal_fs_Hz;
- encStatus->minInternalSampleRate = state_Fxx->sCmn.minInternal_fs_Hz;
- encStatus->desiredInternalSampleRate = state_Fxx->sCmn.desiredInternal_fs_Hz;
- encStatus->payloadSize_ms = state_Fxx->sCmn.PacketSize_ms;
- encStatus->bitRate = state_Fxx->sCmn.TargetRate_bps;
- encStatus->packetLossPercentage = state_Fxx->sCmn.PacketLoss_perc;
- encStatus->complexity = state_Fxx->sCmn.Complexity;
- encStatus->useInBandFEC = state_Fxx->sCmn.useInBandFEC;
- encStatus->useDTX = state_Fxx->sCmn.useDTX;
- encStatus->useCBR = state_Fxx->sCmn.useCBR;
- encStatus->internalSampleRate = SKP_SMULBB( state_Fxx->sCmn.fs_kHz, 1000 );
-
- return ret;
-}
-
-/**************************/
-/* Encode frame with Silk */
-/**************************/
-SKP_int SKP_Silk_SDK_Encode(
- void *encState, /* I/O: State */
- SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */
- const SKP_int16 *samplesIn, /* I: Speech sample input vector */
- SKP_int nSamplesIn, /* I: Number of samples in input vector */
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- SKP_int32 *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
- const SKP_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */
-)
-{
- SKP_int n, i, nBits, flags, tmp_payloadSize_ms, tmp_complexity, ret = 0;
- SKP_int nSamplesToBuffer, nBlocksOf10ms, nSamplesFromInput = 0;
- SKP_int speech_act_thr_for_switch_Q8;
- SKP_int32 TargetRate_bps, channelRate_bps, LBRR_symbol;
- SKP_Silk_encoder *psEnc = ( SKP_Silk_encoder * )encState;
- SKP_int MS_predictorIx[ 2 ] = { 0 };
- SKP_int16 buf[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ];
-
- /* Check values in encoder control structure */
- if( ( ret = check_control_input( encControl ) != 0 ) ) {
- SKP_assert( 0 );
- return ret;
- }
-
- if( encControl->nChannels > psEnc->nChannels ) {
- /* Mono -> Stereo transition: init state of second channel and stereo state */
- SKP_memset( &psEnc->sStereo, 0, sizeof( psEnc->sStereo ) );
- ret += SKP_Silk_init_encoder( &psEnc->state_Fxx[ 1 ] );
- }
- psEnc->nChannels = encControl->nChannels;
-
- nBlocksOf10ms = SKP_DIV32( 100 * nSamplesIn, encControl->API_sampleRate );
- if( prefillFlag ) {
- /* Only accept input length of 10 ms */
- if( nBlocksOf10ms != 1 ) {
- ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
- SKP_assert( 0 );
- return ret;
- }
- /* Reset Encoder */
- for( n = 0; n < encControl->nChannels; n++ ) {
- if( ret = SKP_Silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) {
- SKP_assert( 0 );
- }
- }
- tmp_payloadSize_ms = encControl->payloadSize_ms;
- encControl->payloadSize_ms = 10;
- tmp_complexity = encControl->complexity;
- encControl->complexity = 0;
- for( n = 0; n < encControl->nChannels; n++ ) {
- psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
- psEnc->state_Fxx[ n ].sCmn.prefillFlag = 1;
- }
- } else {
- /* Only accept input lengths that are a multiple of 10 ms */
- if( nBlocksOf10ms * encControl->API_sampleRate != 100 * nSamplesIn || nSamplesIn < 0 ) {
- ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
- SKP_assert( 0 );
- return ret;
- }
- /* Make sure no more than one packet can be produced */
- if( 1000 * (SKP_int32)nSamplesIn > encControl->payloadSize_ms * encControl->API_sampleRate ) {
- ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
- SKP_assert( 0 );
- return ret;
- }
- }
-
- TargetRate_bps = SKP_RSHIFT32( encControl->bitRate, encControl->nChannels - 1 );
- for( n = 0; n < encControl->nChannels; n++ ) {
- if( ( ret = SKP_Silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, TargetRate_bps, psEnc->allowBandwidthSwitch, n ) ) != 0 ) {
- SKP_assert( 0 );
- return ret;
- }
- }
- SKP_assert( encControl->nChannels == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );
-
- /* Input buffering/resampling and encoding */
- while( 1 ) {
- nSamplesToBuffer = psEnc->state_Fxx[ 0 ].sCmn.frame_length - psEnc->state_Fxx[ 0 ].sCmn.inputBufIx;
- nSamplesToBuffer = SKP_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 0 ].sCmn.fs_kHz );
- nSamplesFromInput = SKP_DIV32_16( nSamplesToBuffer * psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 );
- /* Resample and write to buffer */
- if( encControl->nChannels == 2 ) {
- for( n = 0; n < nSamplesFromInput; n++ ) {
- buf[ n ] = samplesIn[ 2 * n ];
- }
- ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state,
- &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], buf, nSamplesFromInput );
- psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
-
- nSamplesToBuffer = psEnc->state_Fxx[ 1 ].sCmn.frame_length - psEnc->state_Fxx[ 1 ].sCmn.inputBufIx;
- nSamplesToBuffer = SKP_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );
- for( n = 0; n < nSamplesFromInput; n++ ) {
- buf[ n ] = samplesIn[ 2 * n + 1 ];
- }
- ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state,
- &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx ], buf, nSamplesFromInput );
- psEnc->state_Fxx[ 1 ].sCmn.inputBufIx += nSamplesToBuffer;
- } else {
- SKP_assert( encControl->nChannels == 1 );
- ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state,
- &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], samplesIn, nSamplesFromInput );
- psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
- }
- samplesIn += nSamplesFromInput * encControl->nChannels;
- nSamplesIn -= nSamplesFromInput;
-
- /* Default */
- psEnc->allowBandwidthSwitch = 0;
-
- /* Silk encoder */
- if( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx >= psEnc->state_Fxx[ 0 ].sCmn.frame_length ) {
- /* Enough data in input buffer, so encode */
- SKP_assert( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx == psEnc->state_Fxx[ 0 ].sCmn.frame_length );
- SKP_assert( encControl->nChannels == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc->state_Fxx[ 1 ].sCmn.frame_length );
-
- /* Deal with LBRR data */
- if( psEnc->state_Fxx[ 0 ].sCmn.nFramesAnalyzed == 0 && !prefillFlag ) {
- /* Create space at start of payload for VAD and FEC flags */
- SKP_uint8 iCDF[ 2 ] = { 0, 0 };
- iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannels );
- ec_enc_icdf( psRangeEnc, 0, iCDF, 8 );
-
- /* Encode any LBRR data from previous packet */
- /* Encode LBRR flags */
- for( n = 0; n < encControl->nChannels; n++ ) {
- LBRR_symbol = 0;
- for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) {
- LBRR_symbol |= SKP_LSHIFT( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ], i );
- }
- psEnc->state_Fxx[ n ].sCmn.LBRR_flag = LBRR_symbol > 0 ? 1 : 0;
- if( LBRR_symbol && psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket > 1 ) {
- ec_enc_icdf( psRangeEnc, LBRR_symbol - 1, SKP_Silk_LBRR_flags_iCDF_ptr[ psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket - 2 ], 8 );
- }
- }
-
- /* Code LBRR indices and excitation signals */
- for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) {
- for( n = 0; n < encControl->nChannels; n++ ) {
- if( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] ) {
- SKP_Silk_encode_indices( &psEnc->state_Fxx[ n ].sCmn, psRangeEnc, i, 1 );
- SKP_Silk_encode_pulses( psRangeEnc, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].signalType, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].quantOffsetType,
- psEnc->state_Fxx[ n ].sCmn.pulses_LBRR[ i ], psEnc->state_Fxx[ n ].sCmn.frame_length );
- }
- }
- }
-
- /* Reset LBRR flags */
- for( n = 0; n < encControl->nChannels; n++ ) {
- SKP_memset( psEnc->state_Fxx[ n ].sCmn.LBRR_flags, 0, sizeof( psEnc->state_Fxx[ n ].sCmn.LBRR_flags ) );
- }
- }
-
- /* Convert Left/Right to Mid/Side */
- if( encControl->nChannels == 2 ) {
- SKP_Silk_stereo_LR_to_MS( psRangeEnc, &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf,
- psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length );
- }
-
-
- /* Total target bits for packet */
- nBits = SKP_DIV32_16( SKP_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
- /* Subtract bits already used */
- nBits -= ec_tell( psRangeEnc );
- /* Divide by number of uncoded frames left in packet */
- nBits = SKP_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesAnalyzed );
- /* Convert to bits/second */
- if( encControl->payloadSize_ms == 10 ) {
- TargetRate_bps = SKP_SMULBB( nBits, 100 );
- } else {
- TargetRate_bps = SKP_SMULBB( nBits, 50 );
- }
- /* Subtract fraction of bits in excess of target in previous packets */
- TargetRate_bps -= SKP_DIV32_16( SKP_MUL( psEnc->nBitsExceeded, 1000 ), BITRESERVOIR_DECAY_TIME_MS );
- /* Don't exceed input bitrate */
- TargetRate_bps = SKP_min( TargetRate_bps, encControl->bitRate );
-
- /* Encode */
- for( n = 0; n < encControl->nChannels; n++ ) {
- /* For stereo coding, allocate 60% of the bitrate to mid and 40% to side */
- if( encControl->nChannels == 1 ) {
- channelRate_bps = TargetRate_bps;
- } else if( n == 0 ) {
- channelRate_bps = SKP_RSHIFT( TargetRate_bps, 1 ) + 2000;
- } else {
- channelRate_bps = SKP_RSHIFT( TargetRate_bps, 1 ) - 2000;
- }
- SKP_Silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, channelRate_bps );
- if( ( ret = SKP_Silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc ) ) != 0 ) {
- SKP_assert( 0 );
- }
- psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
- psEnc->state_Fxx[ n ].sCmn.inputBufIx = 0;
- }
-
- /* Insert VAD and FEC flags at beginning of bitstream */
- if( *nBytesOut > 0 ) {
- flags = 0;
- for( n = 0; n < encControl->nChannels; n++ ) {
- for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) {
- flags = SKP_LSHIFT( flags, 1 );
- flags |= psEnc->state_Fxx[ n ].sCmn.VAD_flags[ i ];
- }
- flags = SKP_LSHIFT( flags, 1 );
- flags |= psEnc->state_Fxx[ n ].sCmn.LBRR_flag;
- }
- ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannels );
-
- /* Return zero bytes if DTXed */
- if( psEnc->state_Fxx[ 0 ].sCmn.inDTX && ( encControl->nChannels == 1 || psEnc->state_Fxx[ 1 ].sCmn.inDTX ) ) {
- *nBytesOut = 0;
- }
-
- psEnc->nBitsExceeded += *nBytesOut * 8;
- psEnc->nBitsExceeded -= SKP_DIV32_16( SKP_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
- psEnc->nBitsExceeded = SKP_LIMIT( psEnc->nBitsExceeded, 0, 10000 );
-
- /* Update flag indicating if bandwidth switching is allowed */
- speech_act_thr_for_switch_Q8 = SKP_SMLAWB( SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ),
- SKP_FIX_CONST( ( 1 - SPEECH_ACTIVITY_DTX_THRES ) / MAX_BANDWIDTH_SWITCH_DELAY_MS, 16 + 8 ), psEnc->timeSinceSwitchAllowed_ms );
- if( psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8 < speech_act_thr_for_switch_Q8 ) {
- psEnc->allowBandwidthSwitch = 1;
- psEnc->timeSinceSwitchAllowed_ms = 0;
- } else {
- psEnc->allowBandwidthSwitch = 0;
- psEnc->timeSinceSwitchAllowed_ms += encControl->payloadSize_ms;
- }
- }
-
- if( nSamplesIn == 0 ) {
- break;
- }
- } else {
- break;
- }
- }
-
- encControl->allowBandwidthSwitch = psEnc->allowBandwidthSwitch;
- encControl->inWBmodeWithoutVariableLP = ( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == 16 ) && ( psEnc->state_Fxx[ 0 ].sCmn.sLP.mode == 0 );
- encControl->internalSampleRate = SKP_SMULBB( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, 1000 );
- if( prefillFlag ) {
- encControl->payloadSize_ms = tmp_payloadSize_ms;
- encControl->complexity = tmp_complexity;
- for( n = 0; n < encControl->nChannels; n++ ) {
- psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
- psEnc->state_Fxx[ n ].sCmn.prefillFlag = 0;
- }
- }
-
- return ret;
-}
-
--- a/silk/SKP_Silk_encode_indices.c
+++ /dev/null
@@ -1,246 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Encode side-information parameters to payload */
-void SKP_Silk_encode_indices(
- SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- SKP_int FrameIndex, /* I Frame number */
- SKP_int encode_LBRR /* I Flag indicating LBRR data is being encoded */
-)
-{
- SKP_int i, k, condCoding, typeOffset;
- SKP_int encode_absolute_lagIndex, delta_lagIndex;
- SKP_int16 ec_ix[ MAX_LPC_ORDER ];
- SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
- const SideInfoIndices *psIndices;
-#if SAVE_ALL_INTERNAL_DATA
- SKP_int nBytes_lagIndex, nBytes_contourIndex, nBytes_LTP;
- SKP_int nBytes_after, nBytes_before;
-#endif
-
- /* Use conditional coding if previous frame available */
- if( FrameIndex > 0 && ( encode_LBRR == 0 || psEncC->LBRR_flags[ FrameIndex - 1 ] == 1 ) ) {
- condCoding = 1;
- } else {
- condCoding = 0;
- }
-
- if( encode_LBRR ) {
- psIndices = &psEncC->indices_LBRR[ FrameIndex ];
- } else {
- psIndices = &psEncC->indices;
- }
-
- /*******************************************/
- /* Encode signal type and quantizer offset */
- /*******************************************/
- typeOffset = 2 * psIndices->signalType + psIndices->quantOffsetType;
- SKP_assert( typeOffset >= 0 && typeOffset < 6 );
- SKP_assert( encode_LBRR == 0 || typeOffset >= 2 );
- if( encode_LBRR || typeOffset >= 2 ) {
- ec_enc_icdf( psRangeEnc, typeOffset - 2, SKP_Silk_type_offset_VAD_iCDF, 8 );
- } else {
- ec_enc_icdf( psRangeEnc, typeOffset, SKP_Silk_type_offset_no_VAD_iCDF, 8 );
- }
-
- /****************/
- /* Encode gains */
- /****************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
- /* first subframe */
- if( condCoding ) {
- /* conditional coding */
- SKP_assert( psIndices->GainsIndices[ 0 ] >= 0 && psIndices->GainsIndices[ 0 ] < MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 );
- ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ], SKP_Silk_delta_gain_iCDF, 8 );
- } else {
- /* independent coding, in two stages: MSB bits followed by 3 LSBs */
- SKP_assert( psIndices->GainsIndices[ 0 ] >= 0 && psIndices->GainsIndices[ 0 ] < N_LEVELS_QGAIN );
- ec_enc_icdf( psRangeEnc, SKP_RSHIFT( psIndices->GainsIndices[ 0 ], 3 ), SKP_Silk_gain_iCDF[ psIndices->signalType ], 8 );
- ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ] & 7, SKP_Silk_uniform8_iCDF, 8 );
- }
-
- /* remaining subframes */
- for( i = 1; i < psEncC->nb_subfr; i++ ) {
- SKP_assert( psIndices->GainsIndices[ i ] >= 0 && psIndices->GainsIndices[ i ] < MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 );
- ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ i ], SKP_Silk_delta_gain_iCDF, 8 );
- }
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_after -= nBytes_before; // bytes just added
- DEBUG_STORE_DATA( nBytes_gains.dat, &nBytes_after, sizeof( SKP_int ) );
-#endif
-
- /****************/
- /* Encode NLSFs */
- /****************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
- ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ 0 ], &psEncC->psNLSF_CB->CB1_iCDF[ ( psIndices->signalType >> 1 ) * psEncC->psNLSF_CB->nVectors ], 8 );
- SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psEncC->psNLSF_CB, psIndices->NLSFIndices[ 0 ] );
- SKP_assert( psEncC->psNLSF_CB->order == psEncC->predictLPCOrder );
- for( i = 0; i < psEncC->psNLSF_CB->order; i++ ) {
- if( psIndices->NLSFIndices[ i+1 ] >= NLSF_QUANT_MAX_AMPLITUDE ) {
- ec_enc_icdf( psRangeEnc, 2 * NLSF_QUANT_MAX_AMPLITUDE, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 );
- ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, SKP_Silk_NLSF_EXT_iCDF, 8 );
- } else if( psIndices->NLSFIndices[ i+1 ] <= -NLSF_QUANT_MAX_AMPLITUDE ) {
- ec_enc_icdf( psRangeEnc, 0, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 );
- ec_enc_icdf( psRangeEnc, -psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, SKP_Silk_NLSF_EXT_iCDF, 8 );
- } else {
- ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ i+1 ] + NLSF_QUANT_MAX_AMPLITUDE, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 );
- }
- }
-
- /* Encode NLSF interpolation factor */
- if( psEncC->nb_subfr == MAX_NB_SUBFR ) {
- SKP_assert( psEncC->useInterpolatedNLSFs == 1 || psIndices->NLSFInterpCoef_Q2 == ( 1 << 2 ) );
- SKP_assert( psIndices->NLSFInterpCoef_Q2 >= 0 && psIndices->NLSFInterpCoef_Q2 < 5 );
- ec_enc_icdf( psRangeEnc, psIndices->NLSFInterpCoef_Q2, SKP_Silk_NLSF_interpolation_factor_iCDF, 8 );
- }
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- DEBUG_STORE_DATA( lsf_interpol.dat, &psIndices->NLSFInterpCoef_Q2, sizeof(int) );
- nBytes_after = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_after -= nBytes_before; // bytes just added
- DEBUG_STORE_DATA( nBytes_LSF.dat, &nBytes_after, sizeof( SKP_int ) );
-#endif
-
- if( psIndices->signalType == TYPE_VOICED )
- {
- /*********************/
- /* Encode pitch lags */
- /*********************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
- /* lag index */
- encode_absolute_lagIndex = 1;
- if( condCoding && psEncC->ec_prevSignalType == TYPE_VOICED ) {
- /* Delta Encoding */
- delta_lagIndex = psIndices->lagIndex - psEncC->ec_prevLagIndex;
- if( delta_lagIndex < -8 || delta_lagIndex > 11 ) {
- delta_lagIndex = 0;
- } else {
- delta_lagIndex = delta_lagIndex + 9;
- encode_absolute_lagIndex = 0; /* Only use delta */
- }
- SKP_assert( delta_lagIndex >= 0 && delta_lagIndex < 21 );
- ec_enc_icdf( psRangeEnc, delta_lagIndex, SKP_Silk_pitch_delta_iCDF, 8 );
- }
- if( encode_absolute_lagIndex ) {
- /* Absolute encoding */
- SKP_int32 pitch_high_bits, pitch_low_bits;
- pitch_high_bits = SKP_DIV32_16( psIndices->lagIndex, SKP_RSHIFT( psEncC->fs_kHz, 1 ) );
- pitch_low_bits = psIndices->lagIndex - SKP_SMULBB( pitch_high_bits, SKP_RSHIFT( psEncC->fs_kHz, 1 ) );
- SKP_assert( pitch_low_bits < psEncC->fs_kHz / 2 );
- SKP_assert( pitch_high_bits < 32 );
- ec_enc_icdf( psRangeEnc, pitch_high_bits, SKP_Silk_pitch_lag_iCDF, 8 );
- ec_enc_icdf( psRangeEnc, pitch_low_bits, psEncC->pitch_lag_low_bits_iCDF, 8 );
- }
- psEncC->ec_prevLagIndex = psIndices->lagIndex;
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_lagIndex = nBytes_after - nBytes_before; // bytes just added
-#endif
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
- /* Countour index */
- SKP_assert( psIndices->contourIndex >= 0 );
- SKP_assert( ( psIndices->contourIndex < 34 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 4 ) ||
- ( psIndices->contourIndex < 11 && psEncC->fs_kHz == 8 && psEncC->nb_subfr == 4 ) ||
- ( psIndices->contourIndex < 12 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 2 ) ||
- ( psIndices->contourIndex < 3 && psEncC->fs_kHz == 8 && psEncC->nb_subfr == 2 ) );
- ec_enc_icdf( psRangeEnc, psIndices->contourIndex, psEncC->pitch_contour_iCDF, 8 );
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_contourIndex = nBytes_after - nBytes_before; // bytes just added
-#endif
-
- /********************/
- /* Encode LTP gains */
- /********************/
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
-
- /* PERIndex value */
- SKP_assert( psIndices->PERIndex >= 0 && psIndices->PERIndex < 3 );
- ec_enc_icdf( psRangeEnc, psIndices->PERIndex, SKP_Silk_LTP_per_index_iCDF, 8 );
-
- /* Codebook Indices */
- for( k = 0; k < psEncC->nb_subfr; k++ ) {
- SKP_assert( psIndices->LTPIndex[ k ] >= 0 && psIndices->LTPIndex[ k ] < ( 8 << psIndices->PERIndex ) );
- ec_enc_icdf( psRangeEnc, psIndices->LTPIndex[ k ], SKP_Silk_LTP_gain_iCDF_ptrs[ psIndices->PERIndex ], 8 );
- }
-
- /**********************/
- /* Encode LTP scaling */
- /**********************/
- if( !condCoding ) {
- SKP_assert( psIndices->LTP_scaleIndex >= 0 && psIndices->LTP_scaleIndex < 3 );
- ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, SKP_Silk_LTPscale_iCDF, 8 );
- }
- SKP_assert( !condCoding || psIndices->LTP_scaleIndex == 0 );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_after = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
- nBytes_LTP = nBytes_after - nBytes_before; // bytes just added
-#endif
- }
-#ifdef SAVE_ALL_INTERNAL_DATA
- else {
- // Unvoiced speech
- nBytes_lagIndex = 0;
- nBytes_contourIndex = 0;
- nBytes_LTP = 0;
- }
- DEBUG_STORE_DATA( nBytes_lagIndex.dat, &nBytes_lagIndex, sizeof( SKP_int ) );
- DEBUG_STORE_DATA( nBytes_contourIndex.dat, &nBytes_contourIndex, sizeof( SKP_int ) );
- DEBUG_STORE_DATA( nBytes_LTP.dat, &nBytes_LTP, sizeof( SKP_int ) );
-#endif
-
- psEncC->ec_prevSignalType = psIndices->signalType;
-
-#ifdef SAVE_ALL_INTERNAL_DATA
- nBytes_before = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
-#endif
-
- /***************/
- /* Encode seed */
- /***************/
- SKP_assert( psIndices->Seed >= 0 && psIndices->Seed < 4 );
- ec_enc_icdf( psRangeEnc, psIndices->Seed, SKP_Silk_uniform4_iCDF, 8 );
-}
--- a/silk/SKP_Silk_encode_pulses.c
+++ /dev/null
@@ -1,197 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/*********************************************/
-/* Encode quantization indices of excitation */
-/*********************************************/
-
-SKP_INLINE SKP_int combine_and_check( /* return ok */
- SKP_int *pulses_comb, /* O */
- const SKP_int *pulses_in, /* I */
- SKP_int max_pulses, /* I max value for sum of pulses */
- SKP_int len /* I number of output values */
-)
-{
- SKP_int k, sum;
-
- for( k = 0; k < len; k++ ) {
- sum = pulses_in[ 2 * k ] + pulses_in[ 2 * k + 1 ];
- if( sum > max_pulses ) {
- return 1;
- }
- pulses_comb[ k ] = sum;
- }
-
- return 0;
-}
-
-/* Encode quantization indices of excitation */
-void SKP_Silk_encode_pulses(
- ec_enc *psRangeEnc, /* I/O compressor data structure */
- const SKP_int signalType, /* I Sigtype */
- const SKP_int quantOffsetType, /* I quantOffsetType */
- SKP_int8 pulses[], /* I quantization indices */
- const SKP_int frame_length /* I Frame length */
-)
-{
- SKP_int i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0;
- SKP_int32 abs_q, minSumBits_Q5, sumBits_Q5;
- SKP_int abs_pulses[ MAX_FRAME_LENGTH ];
- SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ];
- SKP_int nRshifts[ MAX_NB_SHELL_BLOCKS ];
- SKP_int pulses_comb[ 8 ];
- SKP_int *abs_pulses_ptr;
- const SKP_int8 *pulses_ptr;
- const SKP_uint8 *cdf_ptr;
- const SKP_uint8 *nBits_ptr;
-
- SKP_memset( pulses_comb, 0, 8 * sizeof( SKP_int ) ); // Fixing Valgrind reported problem
-
- /****************************/
- /* Prepare for shell coding */
- /****************************/
- /* Calculate number of shell blocks */
- SKP_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );
- iter = SKP_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH );
- if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ){
- SKP_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */
- iter++;
- SKP_memset( &pulses[ frame_length ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof(SKP_int8));
- }
-
- /* Take the absolute value of the pulses */
- for( i = 0; i < iter * SHELL_CODEC_FRAME_LENGTH; i+=4 ) {
- abs_pulses[i+0] = ( SKP_int )SKP_abs( pulses[ i + 0 ] );
- abs_pulses[i+1] = ( SKP_int )SKP_abs( pulses[ i + 1 ] );
- abs_pulses[i+2] = ( SKP_int )SKP_abs( pulses[ i + 2 ] );
- abs_pulses[i+3] = ( SKP_int )SKP_abs( pulses[ i + 3 ] );
- }
-
- /* Calc sum pulses per shell code frame */
- abs_pulses_ptr = abs_pulses;
- for( i = 0; i < iter; i++ ) {
- nRshifts[ i ] = 0;
-
- while( 1 ) {
- /* 1+1 -> 2 */
- scale_down = combine_and_check( pulses_comb, abs_pulses_ptr, SKP_Silk_max_pulses_table[ 0 ], 8 );
- /* 2+2 -> 4 */
- scale_down += combine_and_check( pulses_comb, pulses_comb, SKP_Silk_max_pulses_table[ 1 ], 4 );
- /* 4+4 -> 8 */
- scale_down += combine_and_check( pulses_comb, pulses_comb, SKP_Silk_max_pulses_table[ 2 ], 2 );
- /* 8+8 -> 16 */
- scale_down += combine_and_check( &sum_pulses[ i ], pulses_comb, SKP_Silk_max_pulses_table[ 3 ], 1 );
-
- if( scale_down ) {
- /* We need to downscale the quantization signal */
- nRshifts[ i ]++;
- for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) {
- abs_pulses_ptr[ k ] = SKP_RSHIFT( abs_pulses_ptr[ k ], 1 );
- }
- } else {
- /* Jump out of while(1) loop and go to next shell coding frame */
- break;
- }
- }
- abs_pulses_ptr += SHELL_CODEC_FRAME_LENGTH;
- }
-
- /**************/
- /* Rate level */
- /**************/
- /* find rate level that leads to fewest bits for coding of pulses per block info */
- minSumBits_Q5 = SKP_int32_MAX;
- for( k = 0; k < N_RATE_LEVELS - 1; k++ ) {
- nBits_ptr = SKP_Silk_pulses_per_block_BITS_Q5[ k ];
- sumBits_Q5 = SKP_Silk_rate_levels_BITS_Q5[ signalType >> 1 ][ k ];
- for( i = 0; i < iter; i++ ) {
- if( nRshifts[ i ] > 0 ) {
- sumBits_Q5 += nBits_ptr[ MAX_PULSES + 1 ];
- } else {
- sumBits_Q5 += nBits_ptr[ sum_pulses[ i ] ];
- }
- }
- if( sumBits_Q5 < minSumBits_Q5 ) {
- minSumBits_Q5 = sumBits_Q5;
- RateLevelIndex = k;
- }
- }
- ec_enc_icdf( psRangeEnc, RateLevelIndex, SKP_Silk_rate_levels_iCDF[ signalType >> 1 ], 8 );
-
- /***************************************************/
- /* Sum-Weighted-Pulses Encoding */
- /***************************************************/
- cdf_ptr = SKP_Silk_pulses_per_block_iCDF[ RateLevelIndex ];
- for( i = 0; i < iter; i++ ) {
- if( nRshifts[ i ] == 0 ) {
- ec_enc_icdf( psRangeEnc, sum_pulses[ i ], cdf_ptr, 8 );
- } else {
- ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, cdf_ptr, 8 );
- for( k = 0; k < nRshifts[ i ] - 1; k++ ) {
- ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 );
- }
- ec_enc_icdf( psRangeEnc, sum_pulses[ i ], SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 );
- }
- }
-
- /******************/
- /* Shell Encoding */
- /******************/
- for( i = 0; i < iter; i++ ) {
- if( sum_pulses[ i ] > 0 ) {
- SKP_Silk_shell_encoder( psRangeEnc, &abs_pulses[ i * SHELL_CODEC_FRAME_LENGTH ] );
- }
- }
-
- /****************/
- /* LSB Encoding */
- /****************/
- for( i = 0; i < iter; i++ ) {
- if( nRshifts[ i ] > 0 ) {
- pulses_ptr = &pulses[ i * SHELL_CODEC_FRAME_LENGTH ];
- nLS = nRshifts[ i ] - 1;
- for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) {
- abs_q = (SKP_int8)SKP_abs( pulses_ptr[ k ] );
- for( j = nLS; j > 0; j-- ) {
- bit = SKP_RSHIFT( abs_q, j ) & 1;
- ec_enc_icdf( psRangeEnc, bit, SKP_Silk_lsb_iCDF, 8 );
- }
- bit = abs_q & 1;
- ec_enc_icdf( psRangeEnc, bit, SKP_Silk_lsb_iCDF, 8 );
- }
- }
- }
-
-#if! USE_CELT_PVQ
- /****************/
- /* Encode signs */
- /****************/
- SKP_Silk_encode_signs( psRangeEnc, pulses, frame_length, signalType, quantOffsetType, sum_pulses );
-#endif
-}
--- a/silk/SKP_Silk_errors.h
+++ /dev/null
@@ -1,98 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef SKP_SILK_ERRORS_H
-#define SKP_SILK_ERRORS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/******************/
-/* Error messages */
-/******************/
-#define SKP_SILK_NO_ERROR 0
-
-/**************************/
-/* Encoder error messages */
-/**************************/
-
-/* Input length is not a multiple of 10 ms, or length is longer than the packet length */
-#define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -101
-
-/* Sampling frequency not 8000, 12000 or 16000 Hertz */
-#define SKP_SILK_ENC_FS_NOT_SUPPORTED -102
-
-/* Packet size not 10, 20, 40, or 60 ms */
-#define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -103
-
-/* Allocated payload buffer too short */
-#define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT -104
-
-/* Loss rate not between 0 and 100 percent */
-#define SKP_SILK_ENC_INVALID_LOSS_RATE -105
-
-/* Complexity setting not valid, use 0...10 */
-#define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING -106
-
-/* Inband FEC setting not valid, use 0 or 1 */
-#define SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING -107
-
-/* DTX setting not valid, use 0 or 1 */
-#define SKP_SILK_ENC_INVALID_DTX_SETTING -108
-
-/* CBR setting not valid, use 0 or 1 */
-#define SKP_SILK_ENC_INVALID_CBR_SETTING -109
-
-/* Internal encoder error */
-#define SKP_SILK_ENC_INTERNAL_ERROR -110
-
-/* Internal encoder error */
-#define SKP_SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR -111
-
-/**************************/
-/* Decoder error messages */
-/**************************/
-
-/* Output sampling frequency lower than internal decoded sampling frequency */
-#define SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY -200
-
-/* Payload size exceeded the maximum allowed 1024 bytes */
-#define SKP_SILK_DEC_PAYLOAD_TOO_LARGE -201
-
-/* Payload has bit errors */
-#define SKP_SILK_DEC_PAYLOAD_ERROR -202
-
-/* Payload has bit errors */
-#define SKP_SILK_DEC_INVALID_FRAME_SIZE -203
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/silk/SKP_Silk_gain_quant.c
+++ /dev/null
@@ -1,118 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-#define OFFSET ( ( MIN_QGAIN_DB * 128 ) / 6 + 16 * 128 )
-#define SCALE_Q16 ( ( 65536 * ( N_LEVELS_QGAIN - 1 ) ) / ( ( ( MAX_QGAIN_DB - MIN_QGAIN_DB ) * 128 ) / 6 ) )
-#define INV_SCALE_Q16 ( ( 65536 * ( ( ( MAX_QGAIN_DB - MIN_QGAIN_DB ) * 128 ) / 6 ) ) / ( N_LEVELS_QGAIN - 1 ) )
-
-/* Gain scalar quantization with hysteresis, uniform on log scale */
-void SKP_Silk_gains_quant(
- SKP_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */
- SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */
- SKP_int8 *prev_ind, /* I/O last index in previous frame */
- const SKP_int conditional, /* I first gain is delta coded if 1 */
- const SKP_int nb_subfr /* I number of subframes */
-)
-{
- SKP_int k, double_step_size_threshold;
-
- for( k = 0; k < nb_subfr; k++ ) {
- /* Add half of previous quantization error, convert to log scale, scale, floor() */
- ind[ k ] = SKP_SMULWB( SCALE_Q16, SKP_Silk_lin2log( gain_Q16[ k ] ) - OFFSET );
-
- /* Round towards previous quantized gain (hysteresis) */
- if( ind[ k ] < *prev_ind ) {
- ind[ k ]++;
- }
- ind[ k ] = SKP_max_int( ind[ k ], 0 );
-
- /* Compute delta indices and limit */
- if( k == 0 && conditional == 0 ) {
- /* Full index */
- ind[ k ] = SKP_LIMIT_int( ind[ k ], *prev_ind + MIN_DELTA_GAIN_QUANT, N_LEVELS_QGAIN - 1 );
- *prev_ind = ind[ k ];
- } else {
- /* Delta index */
- ind[ k ] = ind[ k ] - *prev_ind;
-
- /* Double the quantization step size for large gain increases, so that the max gain level can be reached */
- double_step_size_threshold = 2 * MAX_DELTA_GAIN_QUANT - N_LEVELS_QGAIN + *prev_ind;
- if( ind[ k ] > double_step_size_threshold ) {
- ind[ k ] = double_step_size_threshold + SKP_RSHIFT( ind[ k ] - double_step_size_threshold + 1, 1 );
- }
-
- ind[ k ] = SKP_LIMIT_int( ind[ k ], MIN_DELTA_GAIN_QUANT, MAX_DELTA_GAIN_QUANT );
-
- /* Accumulate deltas */
- if( ind[ k ] > double_step_size_threshold ) {
- *prev_ind += SKP_LSHIFT( ind[ k ], 1 ) - double_step_size_threshold;
- } else {
- *prev_ind += ind[ k ];
- }
-
- /* Shift to make non-negative */
- ind[ k ] -= MIN_DELTA_GAIN_QUANT;
- }
-
- /* Convert to linear scale and scale */
- gain_Q16[ k ] = SKP_Silk_log2lin( SKP_min_32( SKP_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */
- }
-}
-
-/* Gains scalar dequantization, uniform on log scale */
-void SKP_Silk_gains_dequant(
- SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */
- const SKP_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */
- SKP_int8 *prev_ind, /* I/O last index in previous frame */
- const SKP_int conditional, /* I first gain is delta coded if 1 */
- const SKP_int nb_subfr /* I number of subframes */
-)
-{
- SKP_int k, ind_tmp, double_step_size_threshold;
-
- for( k = 0; k < nb_subfr; k++ ) {
- if( k == 0 && conditional == 0 ) {
- *prev_ind = ind[ k ];
- } else {
- /* Delta index */
- ind_tmp = ind[ k ] + MIN_DELTA_GAIN_QUANT;
-
- /* Accumulate deltas */
- double_step_size_threshold = 2 * MAX_DELTA_GAIN_QUANT - N_LEVELS_QGAIN + *prev_ind;
- if( ind_tmp > double_step_size_threshold ) {
- *prev_ind += SKP_LSHIFT( ind_tmp, 1 ) - double_step_size_threshold;
- } else {
- *prev_ind += ind_tmp;
- }
- }
-
- /* Convert to linear scale and scale */
- gain_Q16[ k ] = SKP_Silk_log2lin( SKP_min_32( SKP_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */
- }
-}
--- a/silk/SKP_Silk_init_encoder.c
+++ /dev/null
@@ -1,61 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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
-
-#ifdef FIXED_POINT
-#include "SKP_Silk_main_FIX.h"
-#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX
-#else
-#include "SKP_Silk_main_FLP.h"
-#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FLP
-#endif
-
-/*********************************/
-/* Initialize Silk Encoder state */
-/*********************************/
-SKP_int SKP_Silk_init_encoder(
- SKP_Silk_encoder_state_Fxx *psEnc /* I/O Pointer to Silk encoder state */
-) {
- SKP_int ret = 0;
-
- /* Clear the entire encoder state */
- SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_Fxx ) );
-
- psEnc->sCmn.variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
- psEnc->sCmn.variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
-
- /* Used to deactivate LSF interpolation, fluctuation reduction, pitch prediction */
- psEnc->sCmn.first_frame_after_reset = 1;
-
- /* Initialize Silk VAD */
- ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD );
-
- return( ret );
-}
--- a/silk/SKP_Silk_inner_prod_aligned.c
+++ /dev/null
@@ -1,77 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* sum= for(i=0;i<len;i++)inVec1[i]*inVec2[i]; --- inner product */
-/* Note for ARM asm: */
-/* * inVec1 and inVec2 should be at least 2 byte aligned. (Or defined as short/int16) */
-/* * len should be positive 16bit integer. */
-/* * only when len>6, memory access can be reduced by half. */
-
-SKP_int32 SKP_Silk_inner_prod_aligned(
- const SKP_int16 *const inVec1, /* I input vector 1 */
- const SKP_int16 *const inVec2, /* I input vector 2 */
- const SKP_int len /* I vector lengths */
-)
-{
- SKP_int i;
- SKP_int32 sum = 0;
- for( i = 0; i < len; i++ ) {
- sum = SKP_SMLABB( sum, inVec1[ i ], inVec2[ i ] );
- }
- return sum;
-}
-
-SKP_int32 SKP_Silk_inner_prod_aligned_scale(
- const SKP_int16 *const inVec1, /* I input vector 1 */
- const SKP_int16 *const inVec2, /* I input vector 2 */
- const SKP_int scale, /* I number of bits to shift */
- const SKP_int len /* I vector lengths */
-)
-{
- SKP_int i;
- SKP_int32 sum = 0;
- for( i = 0; i < len; i++ ) {
- sum = SKP_ADD_RSHIFT32( sum, SKP_SMULBB( inVec1[ i ], inVec2[ i ] ), scale );
- }
- return sum;
-}
-
-SKP_int64 SKP_Silk_inner_prod16_aligned_64(
- const SKP_int16 *inVec1, /* I input vector 1 */
- const SKP_int16 *inVec2, /* I input vector 2 */
- const SKP_int len /* I vector lengths */
-)
-{
- SKP_int i;
- SKP_int64 sum = 0;
- for( i = 0; i < len; i++ ) {
- sum = SKP_SMLALBB( sum, inVec1[ i ], inVec2[ i ] );
- }
- return sum;
-}
--- a/silk/SKP_Silk_interpolate.c
+++ /dev/null
@@ -1,47 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Interpolate two vectors */
-void SKP_Silk_interpolate(
- SKP_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */
- const SKP_int16 x0[ MAX_LPC_ORDER ], /* I first vector */
- const SKP_int16 x1[ MAX_LPC_ORDER ], /* I second vector */
- const SKP_int ifact_Q2, /* I interp. factor, weight on 2nd vector */
- const SKP_int d /* I number of parameters */
-)
-{
- SKP_int i;
-
- SKP_assert( ifact_Q2 >= 0 );
- SKP_assert( ifact_Q2 <= 4 );
-
- for( i = 0; i < d; i++ ) {
- xi[ i ] = ( SKP_int16 )SKP_ADD_RSHIFT( x0[ i ], SKP_SMULBB( x1[ i ] - x0[ i ], ifact_Q2 ), 2 );
- }
-}
--- a/silk/SKP_Silk_k2a.c
+++ /dev/null
@@ -1,49 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Step up function, converts reflection coefficients to prediction coefficients */
-void SKP_Silk_k2a(
- SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
- const SKP_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */
- const SKP_int32 order /* I: Prediction order */
-)
-{
- SKP_int k, n;
- SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ];
-
- for( k = 0; k < order; k++ ) {
- for( n = 0; n < k; n++ ) {
- Atmp[ n ] = A_Q24[ n ];
- }
- for( n = 0; n < k; n++ ) {
- A_Q24[ n ] = SKP_SMLAWB( A_Q24[ n ], SKP_LSHIFT( Atmp[ k - n - 1 ], 1 ), rc_Q15[ k ] );
- }
- A_Q24[ k ] = -SKP_LSHIFT( (SKP_int32)rc_Q15[ k ], 9 );
- }
-}
--- a/silk/SKP_Silk_k2a_Q16.c
+++ /dev/null
@@ -1,49 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Step up function, converts reflection coefficients to prediction coefficients */
-void SKP_Silk_k2a_Q16(
- SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */
- const SKP_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */
- const SKP_int32 order /* I: Prediction order */
-)
-{
- SKP_int k, n;
- SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ];
-
- for( k = 0; k < order; k++ ) {
- for( n = 0; n < k; n++ ) {
- Atmp[ n ] = A_Q24[ n ];
- }
- for( n = 0; n < k; n++ ) {
- A_Q24[ n ] = SKP_SMLAWW( A_Q24[ n ], Atmp[ k - n - 1 ], rc_Q16[ k ] );
- }
- A_Q24[ k ] = -SKP_LSHIFT( rc_Q16[ k ], 8 );
- }
-}
--- a/silk/SKP_Silk_lin2log.c
+++ /dev/null
@@ -1,40 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-/* Approximation of 128 * log2() (very close inverse of approx 2^() below) */
-/* Convert input to a log scale */
-SKP_int32 SKP_Silk_lin2log( const SKP_int32 inLin ) /* I: Input in linear scale */
-{
- SKP_int32 lz, frac_Q7;
-
- SKP_Silk_CLZ_FRAC( inLin, &lz, &frac_Q7 );
-
- /* Piece-wise parabolic approximation */
- return( SKP_LSHIFT( 31 - lz, 7 ) + SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), 179 ) );
-}
-
--- a/silk/SKP_Silk_log2lin.c
+++ /dev/null
@@ -1,50 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* Approximation of 2^() (very close inverse of SKP_Silk_lin2log()) */
-/* Convert input to a linear scale */
-SKP_int32 SKP_Silk_log2lin( const SKP_int32 inLog_Q7 ) /* I: Input on log scale */
-{
- SKP_int32 out, frac_Q7;
-
- if( inLog_Q7 < 0 ) {
- return 0;
- }
-
- out = SKP_LSHIFT( 1, SKP_RSHIFT( inLog_Q7, 7 ) );
- frac_Q7 = inLog_Q7 & 0x7F;
- if( inLog_Q7 < 2048 ) {
- /* Piece-wise parabolic approximation */
- out = SKP_ADD_RSHIFT( out, SKP_MUL( out, SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) ), 7 );
- } else {
- /* Piece-wise parabolic approximation */
- out = SKP_MLA( out, SKP_RSHIFT( out, 7 ), SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), -174 ) );
- }
- return out;
-}
--- a/silk/SKP_Silk_macros.h
+++ /dev/null
@@ -1,132 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef _SKP_SILK_API_C_H_
-#define _SKP_SILK_API_C_H_
-
-// This is an inline header file for general platform.
-
-// (a32 * (SKP_int32)((SKP_int16)(b32))) >> 16 output have to be 32bit int
-#define SKP_SMULWB(a32, b32) ((((a32) >> 16) * (SKP_int32)((SKP_int16)(b32))) + ((((a32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(b32))) >> 16))
-
-// a32 + (b32 * (SKP_int32)((SKP_int16)(c32))) >> 16 output have to be 32bit int
-#define SKP_SMLAWB(a32, b32, c32) ((a32) + ((((b32) >> 16) * (SKP_int32)((SKP_int16)(c32))) + ((((b32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(c32))) >> 16)))
-
-// (a32 * (b32 >> 16)) >> 16
-#define SKP_SMULWT(a32, b32) (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16))
-
-// a32 + (b32 * (c32 >> 16)) >> 16
-#define SKP_SMLAWT(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16))
-
-// (SKP_int32)((SKP_int16)(a3))) * (SKP_int32)((SKP_int16)(b32)) output have to be 32bit int
-#define SKP_SMULBB(a32, b32) ((SKP_int32)((SKP_int16)(a32)) * (SKP_int32)((SKP_int16)(b32)))
-
-// a32 + (SKP_int32)((SKP_int16)(b32)) * (SKP_int32)((SKP_int16)(c32)) output have to be 32bit int
-#define SKP_SMLABB(a32, b32, c32) ((a32) + ((SKP_int32)((SKP_int16)(b32))) * (SKP_int32)((SKP_int16)(c32)))
-
-// (SKP_int32)((SKP_int16)(a32)) * (b32 >> 16)
-#define SKP_SMULBT(a32, b32) ((SKP_int32)((SKP_int16)(a32)) * ((b32) >> 16))
-
-// a32 + (SKP_int32)((SKP_int16)(b32)) * (c32 >> 16)
-#define SKP_SMLABT(a32, b32, c32) ((a32) + ((SKP_int32)((SKP_int16)(b32))) * ((c32) >> 16))
-
-// a64 + (b32 * c32)
-#define SKP_SMLAL(a64, b32, c32) (SKP_ADD64((a64), ((SKP_int64)(b32) * (SKP_int64)(c32))))
-
-// (a32 * b32) >> 16
-#define SKP_SMULWW(a32, b32) SKP_MLA(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16))
-
-// a32 + ((b32 * c32) >> 16)
-#define SKP_SMLAWW(a32, b32, c32) SKP_MLA(SKP_SMLAWB((a32), (b32), (c32)), (b32), SKP_RSHIFT_ROUND((c32), 16))
-
-/* add/subtract with output saturated */
-#define SKP_ADD_SAT32(a, b) ((((a) + (b)) & 0x80000000) == 0 ? \
- ((((a) & (b)) & 0x80000000) != 0 ? SKP_int32_MIN : (a)+(b)) : \
- ((((a) | (b)) & 0x80000000) == 0 ? SKP_int32_MAX : (a)+(b)) )
-
-#define SKP_SUB_SAT32(a, b) ((((a)-(b)) & 0x80000000) == 0 ? \
- (( (a) & ((b)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a)-(b)) : \
- ((((a)^0x80000000) & (b) & 0x80000000) ? SKP_int32_MAX : (a)-(b)) )
-
-SKP_INLINE SKP_int32 SKP_Silk_CLZ16(SKP_int16 in16)
-{
- SKP_int32 out32 = 0;
- if( in16 == 0 ) {
- return 16;
- }
- /* test nibbles */
- if( in16 & 0xFF00 ) {
- if( in16 & 0xF000 ) {
- in16 >>= 12;
- } else {
- out32 += 4;
- in16 >>= 8;
- }
- } else {
- if( in16 & 0xFFF0 ) {
- out32 += 8;
- in16 >>= 4;
- } else {
- out32 += 12;
- }
- }
- /* test bits and return */
- if( in16 & 0xC ) {
- if( in16 & 0x8 )
- return out32 + 0;
- else
- return out32 + 1;
- } else {
- if( in16 & 0xE )
- return out32 + 2;
- else
- return out32 + 3;
- }
-}
-
-SKP_INLINE SKP_int32 SKP_Silk_CLZ32(SKP_int32 in32)
-{
- /* test highest 16 bits and convert to SKP_int16 */
- if( in32 & 0xFFFF0000 ) {
- return SKP_Silk_CLZ16((SKP_int16)(in32 >> 16));
- } else {
- return SKP_Silk_CLZ16((SKP_int16)in32) + 16;
- }
-}
-
-/* Row based */
-#define matrix_ptr(Matrix_base_adr, row, column, N) *(Matrix_base_adr + ((row)*(N)+(column)))
-#define matrix_adr(Matrix_base_adr, row, column, N) (Matrix_base_adr + ((row)*(N)+(column)))
-
-/* Column based */
-#ifndef matrix_c_ptr
-# define matrix_c_ptr(Matrix_base_adr, row, column, M) *(Matrix_base_adr + ((row)+(M)*(column)))
-#endif
-#define matrix_c_adr(Matrix_base_adr, row, column, M) (Matrix_base_adr + ((row)+(M)*(column)))
-
-#endif //_SKP_SILK_API_C_H_
-
--- a/silk/SKP_Silk_main.h
+++ /dev/null
@@ -1,447 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-#ifndef SKP_SILK_MAIN_H
-#define SKP_SILK_MAIN_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "SKP_Silk_SigProc_FIX.h"
-#include "SKP_Silk_define.h"
-#include "SKP_Silk_structs.h"
-#include "SKP_Silk_tables.h"
-#include "SKP_Silk_PLC.h"
-#include "SKP_Silk_control.h"
-#include "SKP_debug.h"
-#include "entenc.h"
-#include "entdec.h"
-
-
-/* Uncomment the next line to store intermadiate data to files */
-//#define SAVE_ALL_INTERNAL_DATA 1
-/* Uncomment the next line to force a fixed internal sampling rate (independent of what bitrate is used */
-//#define FORCE_INTERNAL_FS_KHZ 16
-
-
-/* Convert Left/Right stereo signal to adaptive Mid/Side representation */
-void SKP_Silk_stereo_LR_to_MS(
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- stereo_state *state, /* I/O State */
- SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */
- SKP_int16 x2[], /* I/O Right input signal, becomes side signal */
- SKP_int fs_kHz, /* I Samples rate (kHz) */
- SKP_int frame_length /* I Number of samples */
-);
-
-/* Convert adaptive Mid/Side representation to Left/Right stereo signal */
-void SKP_Silk_stereo_MS_to_LR(
- stereo_state *state, /* I/O State */
- SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */
- SKP_int16 x2[], /* I/O Right input signal, becomes side signal */
- const SKP_int32 pred_Q13[], /* I Predictors */
- SKP_int fs_kHz, /* I Samples rate (kHz) */
- SKP_int frame_length /* I Number of samples */
-);
-
-/* Find least-squares prediction gain for one signal based on another and quantize it */
-SKP_int32 SKP_Silk_stereo_find_predictor( /* O Returns predictor in Q13 */
- const SKP_int16 x[], /* I Basis signal */
- const SKP_int16 y[], /* I Target signal */
- SKP_int length /* I Number of samples */
-);
-
-/* Quantize mid/side predictors and entropy code the quantization indices */
-void SKP_Silk_stereo_encode_pred(
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- SKP_int32 pred_Q13[] /* I/O Predictors (out: quantized) */
-);
-
-/* Decode mid/side predictors */
-void SKP_Silk_stereo_decode_pred(
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int32 pred_Q13[] /* O Predictors */
-);
-
-/* Encodes signs of excitation */
-void SKP_Silk_encode_signs(
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- const SKP_int8 pulses[], /* I pulse signal */
- SKP_int length, /* I length of input */
- const SKP_int signalType, /* I Signal type */
- const SKP_int quantOffsetType, /* I Quantization offset type */
- const SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
-);
-
-/* Decodes signs of excitation */
-void SKP_Silk_decode_signs(
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int pulses[], /* I/O pulse signal */
- SKP_int length, /* I length of input */
- const SKP_int signalType, /* I Signal type */
- const SKP_int quantOffsetType, /* I Quantization offset type */
- const SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */
-);
-
-/* Check encoder control struct */
-SKP_int check_control_input(
- SKP_SILK_SDK_EncControlStruct *encControl /* I: Control structure */
-);
-
-/* Control internal sampling rate */
-SKP_int SKP_Silk_control_audio_bandwidth(
- SKP_Silk_encoder_state *psEncC /* I/O Pointer to Silk encoder state */
-);
-
-/* Control SNR of redidual quantizer */
-SKP_int SKP_Silk_control_SNR(
- SKP_Silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */
- SKP_int32 TargetRate_bps /* I Target max bitrate (bps) */
-);
-
-/***************/
-/* Shell coder */
-/***************/
-
-/* Encode quantization indices of excitation */
-void SKP_Silk_encode_pulses(
- ec_enc *psRangeEnc, /* I/O compressor data structure */
- const SKP_int signalType, /* I Signal type */
- const SKP_int quantOffsetType, /* I quantOffsetType */
- SKP_int8 pulses[], /* I quantization indices */
- const SKP_int frame_length /* I Frame length */
-);
-
-/* Shell encoder, operates on one shell code frame of 16 pulses */
-void SKP_Silk_shell_encoder(
- ec_enc *psRangeEnc, /* I/O compressor data structure */
- const SKP_int *pulses0 /* I data: nonnegative pulse amplitudes */
-);
-
-/* Shell decoder, operates on one shell code frame of 16 pulses */
-void SKP_Silk_shell_decoder(
- SKP_int *pulses0, /* O data: nonnegative pulse amplitudes */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- const SKP_int pulses4 /* I number of pulses per pulse-subframe */
-);
-
-/* Gain scalar quantization with hysteresis, uniform on log scale */
-void SKP_Silk_gains_quant(
- SKP_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */
- SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */
- SKP_int8 *prev_ind, /* I/O last index in previous frame */
- const SKP_int conditional, /* I first gain is delta coded if 1 */
- const SKP_int nb_subfr /* I number of subframes */
-);
-
-/* Gains scalar dequantization, uniform on log scale */
-void SKP_Silk_gains_dequant(
- SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */
- const SKP_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */
- SKP_int8 *prev_ind, /* I/O last index in previous frame */
- const SKP_int conditional, /* I first gain is delta coded if 1 */
- const SKP_int nb_subfr /* I number of subframes */
-);
-
-/* Convert NLSF parameters to stable AR prediction filter coefficients */
-void SKP_Silk_NLSF2A_stable(
- SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */
- const SKP_int16 pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */
- const SKP_int LPC_order /* I LPC/LSF order */
-);
-
-/* Interpolate two vectors */
-void SKP_Silk_interpolate(
- SKP_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */
- const SKP_int16 x0[ MAX_LPC_ORDER ], /* I first vector */
- const SKP_int16 x1[ MAX_LPC_ORDER ], /* I second vector */
- const SKP_int ifact_Q2, /* I interp. factor, weight on 2nd vector */
- const SKP_int d /* I number of parameters */
-);
-
-/* LTP tap quantizer */
-void SKP_Silk_quant_LTP_gains(
- SKP_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */
- SKP_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */
- SKP_int8 *periodicity_index, /* O Periodicity Index */
- const SKP_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Error Weights in Q18 */
- SKP_int mu_Q9, /* I Mu value (R/D tradeoff) */
- SKP_int lowComplexity, /* I Flag for low complexity */
- const SKP_int nb_subfr /* I number of subframes */
-);
-
-/* Entropy constrained matrix-weighted VQ, for a single input data vector */
-void SKP_Silk_VQ_WMat_EC(
- SKP_int8 *ind, /* O index of best codebook vector */
- SKP_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/
- const SKP_int16 *in_Q14, /* I input vector to be quantized */
- const SKP_int32 *W_Q18, /* I weighting matrix */
- const SKP_int8 *cb_Q7, /* I codebook */
- const SKP_uint8 *cl_Q5, /* I code length for each codebook vector */
- const SKP_int mu_Q9, /* I tradeoff between weighted error and rate */
- SKP_int L /* I number of vectors in codebook */
-);
-
-/***********************************/
-/* Noise shaping quantization (NSQ)*/
-/***********************************/
-void SKP_Silk_NSQ(
- const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- SideInfoIndices *psIndices, /* I/O Quantization Indices */
- const SKP_int16 x[], /* I prefiltered input signal */
- SKP_int8 pulses[], /* O quantized qulse signal */
- const SKP_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefficients */
- const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefficients */
- const SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
- const SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
- const SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ], /* I */
- const SKP_int Lambda_Q10, /* I */
- const SKP_int LTP_scale_Q14 /* I LTP state scaling */
-);
-
-/* Noise shaping using delayed decision */
-void SKP_Silk_NSQ_del_dec(
- const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */
- SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
- SideInfoIndices *psIndices, /* I/O Quantization Indices */
- const SKP_int16 x[], /* I Prefiltered input signal */
- SKP_int8 pulses[], /* O Quantized pulse signal */
- const SKP_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Prediction coefs */
- const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I LT prediction coefs */
- const SKP_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I */
- const SKP_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
- const SKP_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I */
- const SKP_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */
- const SKP_int pitchL[ MAX_NB_SUBFR ], /* I */
- const SKP_int Lambda_Q10, /* I */
- const SKP_int LTP_scale_Q14 /* I LTP state scaling */
-);
-
-/************/
-/* Silk VAD */
-/************/
-/* Initialize the Silk VAD */
-SKP_int SKP_Silk_VAD_Init( /* O Return value, 0 if success */
- SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
-);
-
-/* Silk VAD noise level estimation */
-void SKP_Silk_VAD_GetNoiseLevels(
- const SKP_int32 pX[ VAD_N_BANDS ], /* I subband energies */
- SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
-);
-
-/* Get speech activity level in Q8 */
-SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
- SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
- const SKP_int16 pIn[] /* I PCM input */
-);
-
-/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
-void SKP_Silk_HP_variable_cutoff(
- SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
- SKP_int16 *out, /* O high-pass filtered output signal */
- const SKP_int16 *in, /* I input signal */
- const SKP_int frame_length /* I length of input */
-);
-
-/* Low-pass filter with variable cutoff frequency based on */
-/* piece-wise linear interpolation between elliptic filters */
-/* Start by setting transition_frame_no = 1; */
-void SKP_Silk_LP_variable_cutoff(
- SKP_Silk_LP_state *psLP, /* I/O LP filter state */
- SKP_int16 *signal, /* I/O Low-pass filtered output signal */
- const SKP_int frame_length /* I Frame length */
-);
-
-/******************/
-/* NLSF Quantizer */
-/******************/
-/* Limit, stabilize, convert and quantize NLSFs */
-void SKP_Silk_process_NLSFs(
- SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
- SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
- SKP_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
- const SKP_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
-);
-
-SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD value in Q25 */
- SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
- SKP_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */
- const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
- const SKP_int16 *pW_Q5, /* I NLSF weight vector [ LPC_ORDER ] */
- const SKP_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */
- const SKP_int nSurvivors, /* I Max survivors after first stage */
- const SKP_int signalType /* I Signal type: 0/1/2 */
-);
-
-/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
-void SKP_Silk_NLSF_VQ(
- SKP_int32 err_Q26[], /* O Quantization errors [K] */
- const SKP_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
- const SKP_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
- const SKP_int K, /* I Number of codebook vectors */
- const SKP_int LPC_order /* I Number of LPCs */
-);
-
-/* Delayed-decision quantizer for NLSF residuals */
-SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */
- SKP_int8 indices[], /* O Quantization indices [ order ] */
- const SKP_int16 x_Q10[], /* I Input [ order ] */
- const SKP_int16 w_Q5[], /* I Weights [ order ] */
- const SKP_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */
- const SKP_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */
- const SKP_uint8 ec_rates_Q5[], /* I Rates [] */
- const SKP_int quant_step_size_Q16, /* I Quantization step size */
- const SKP_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */
- const SKP_int32 mu_Q20, /* I R/D tradeoff */
- const SKP_int16 order /* I Number of input values */
-);
-
-/* Unpack predictor values and indices for entropy coding tables */
-void SKP_Silk_NLSF_unpack(
- SKP_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */
- SKP_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */
- const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
- const SKP_int CB1_index /* I Index of vector in first LSF codebook */
-);
-
-/***********************/
-/* NLSF vector decoder */
-/***********************/
-void SKP_Silk_NLSF_decode(
- SKP_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */
- SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */
- const SKP_Silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */
-);
-
-/****************************************************/
-/* Decoder Functions */
-/****************************************************/
-SKP_int SKP_Silk_create_decoder(
- SKP_Silk_decoder_state **ppsDec /* I/O Decoder state pointer pointer */
-);
-
-SKP_int SKP_Silk_free_decoder(
- SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */
-);
-
-SKP_int SKP_Silk_init_decoder(
- SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */
-);
-
-/* Set decoder sampling rate */
-void SKP_Silk_decoder_set_fs(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state pointer */
- SKP_int fs_kHz /* I Sampling frequency (kHz) */
-);
-
-/****************/
-/* Decode frame */
-/****************/
-SKP_int SKP_Silk_decode_frame(
- SKP_Silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int16 pOut[], /* O Pointer to output speech frame */
- SKP_int32 *pN, /* O Pointer to size of output frame */
- SKP_int lostFlag /* I 0: no loss, 1 loss, 2 decode fec */
-);
-
-/* Decode LBRR side info and excitation */
-void SKP_Silk_LBRR_extract(
- SKP_Silk_decoder_state *psDec, /* I/O State */
- ec_dec *psRangeDec /* I/O Compressor data structure */
-);
-
-/* Decode indices from payload v4 Bitstream */
-void SKP_Silk_decode_indices(
- SKP_Silk_decoder_state *psDec, /* I/O State */
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int FrameIndex, /* I Frame number */
- SKP_int decode_LBRR /* I Flag indicating LBRR data is being decoded */
-);
-
-/* Decode parameters from payload */
-void SKP_Silk_decode_parameters(
- SKP_Silk_decoder_state *psDec, /* I/O State */
- SKP_Silk_decoder_control *psDecCtrl /* I/O Decoder control */
-);
-
-/* Core decoder. Performs inverse NSQ operation LTP + LPC */
-void SKP_Silk_decode_core(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I Decoder control */
- SKP_int16 xq[], /* O Decoded speech */
- const SKP_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */
-);
-
-/* Decode quantization indices of excitation (Shell coding) */
-void SKP_Silk_decode_pulses(
- ec_dec *psRangeDec, /* I/O Compressor data structure */
- SKP_int pulses[], /* O Excitation signal */
- const SKP_int signalType, /* I Sigtype */
- const SKP_int quantOffsetType, /* I quantOffsetType */
- const SKP_int frame_length /* I Frame length */
-);
-
-/******************/
-/* CNG */
-/******************/
-
-/* Reset CNG */
-void SKP_Silk_CNG_Reset(
- SKP_Silk_decoder_state *psDec /* I/O Decoder state */
-);
-
-/* Updates CNG estimate, and applies the CNG when packet was lost */
-void SKP_Silk_CNG(
- SKP_Silk_decoder_state *psDec, /* I/O Decoder state */
- SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */
- SKP_int16 signal[], /* I/O Signal */
- SKP_int length /* I Length of residual */
-);
-
-/* Encoding of various parameters */
-void SKP_Silk_encode_indices(
- SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
- ec_enc *psRangeEnc, /* I/O Compressor data structure */
- SKP_int FrameIndex, /* I Frame number */
- SKP_int encode_LBRR /* I Flag indicating LBRR data is being encoded */
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/silk/SKP_Silk_pitch_analysis_core.c
+++ /dev/null
@@ -1,744 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-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 Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. 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.
-***********************************************************************/
-
-/***********************************************************
-* Pitch analyser function
-********************************************************** */
-#include "SKP_Silk_SigProc_FIX.h"
-#include "SKP_Silk_pitch_est_defines.h"
-#include "SKP_debug.h"
-
-#define SCRATCH_SIZE 22
-
-/************************************************************/
-/* Internally used functions */
-/************************************************************/
-void SKP_FIX_P_Ana_calc_corr_st3(
- SKP_int32 cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ],/* (O) 3 DIM correlation array */
- const SKP_int16 signal[], /* I vector to correlate */
- SKP_int start_lag, /* I lag offset to search around */
- SKP_int sf_length, /* I length of a 5 ms subframe */
- SKP_int nb_subfr, /* I number of subframes */
- SKP_int complexity /* I Complexity setting */