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
This commit is contained in:
Jean-Marc Valin 2011-05-19 17:17:44 -04:00
parent c77b96333b
commit 103302b375
192 changed files with 3849 additions and 3866 deletions

View file

@ -11,16 +11,23 @@ destdir="opus_source"
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

View file

@ -1,66 +0,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 */

View file

@ -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" />

View file

@ -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>
@ -119,9 +116,6 @@
<ClCompile Include="entenc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="header.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="kiss_fft.c">
<Filter>Source Files</Filter>
</ClCompile>

View file

@ -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

View file

@ -1,107 +0,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 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 */
)
{
SKP_int n, denom_Q16, delta0_Q13, delta1_Q13;
SKP_int32 sum, diff, pred_Q13[ 2 ], pred0_Q13, pred1_Q13;
SKP_int16 mid[ MAX_FRAME_LENGTH + 2 ], side[ MAX_FRAME_LENGTH + 2 ];
SKP_int16 LP_mid[ MAX_FRAME_LENGTH ], HP_mid[ MAX_FRAME_LENGTH ];
SKP_int16 LP_side[ MAX_FRAME_LENGTH ], HP_side[ MAX_FRAME_LENGTH ];
/* Convert to basic mid/side signals */
for( n = 0; n < frame_length; n++ ) {
sum = x1[ n ] + (SKP_int32)x2[ n ];
diff = x1[ n ] - (SKP_int32)x2[ n ];
mid[ n + 2 ] = (SKP_int16)SKP_RSHIFT_ROUND( sum, 1 );
side[ n + 2 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( diff, 1 ) );
}
/* Buffering */
SKP_memcpy( mid, state->sMid, 2 * sizeof( SKP_int16 ) );
SKP_memcpy( side, state->sSide, 2 * sizeof( SKP_int16 ) );
SKP_memcpy( state->sMid, &mid[ frame_length ], 2 * sizeof( SKP_int16 ) );
SKP_memcpy( state->sSide, &side[ frame_length ], 2 * sizeof( SKP_int16 ) );
/* LP and HP filter mid signal */
for( n = 0; n < frame_length; n++ ) {
sum = SKP_RSHIFT_ROUND( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 2 );
LP_mid[ n ] = sum;
HP_mid[ n ] = mid[ n + 1 ] - sum;
}
/* LP and HP filter side signal */
for( n = 0; n < frame_length; n++ ) {
sum = SKP_RSHIFT_ROUND( SKP_ADD_LSHIFT( side[ n ] + side[ n + 2 ], side[ n + 1 ], 1 ), 2 );
LP_side[ n ] = sum;
HP_side[ n ] = side[ n + 1 ] - sum;
}
/* Find predictors */
pred_Q13[ 0 ] = SKP_Silk_stereo_find_predictor( LP_mid, LP_side, frame_length );
pred_Q13[ 1 ] = SKP_Silk_stereo_find_predictor( HP_mid, HP_side, frame_length );
/* Quantize and encode predictors */
SKP_Silk_stereo_encode_pred( psRangeEnc, pred_Q13 );
/* Interpolate predictors and subtract prediction from side channel */
pred0_Q13 = -state->pred_prev_Q13[ 0 ];
pred1_Q13 = -state->pred_prev_Q13[ 1 ];
denom_Q16 = SKP_DIV32_16( 1 << 16, STEREO_INTERP_LEN_MS * fs_kHz );
delta0_Q13 = -SKP_RSHIFT_ROUND( SKP_SMULBB( pred_Q13[ 0 ] - state->pred_prev_Q13[ 0 ], denom_Q16 ), 16 );
delta1_Q13 = -SKP_RSHIFT_ROUND( SKP_SMULBB( pred_Q13[ 1 ] - state->pred_prev_Q13[ 1 ], denom_Q16 ), 16 );
for( n = 0; n < STEREO_INTERP_LEN_MS * fs_kHz; n++ ) {
pred0_Q13 += delta0_Q13;
pred1_Q13 += delta1_Q13;
sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */
sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )side[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */
sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */
x2[ n ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) );
}
pred0_Q13 = -pred_Q13[ 0 ];
pred1_Q13 = -pred_Q13[ 1 ];
for( n = STEREO_INTERP_LEN_MS * fs_kHz; n < frame_length; n++ ) {
sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */
sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )side[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */
sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */
x2[ n ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) );
}
state->pred_prev_Q13[ 0 ] = pred_Q13[ 0 ];
state->pred_prev_Q13[ 1 ] = pred_Q13[ 1 ];
SKP_memcpy( x1, mid + 1, frame_length * sizeof( SKP_int16 ) );
}

View file

@ -1,117 +0,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_TABLES_H
#define SKP_SILK_TABLES_H
#include "SKP_Silk_define.h"
#include "SKP_Silk_structs.h"
#ifdef __cplusplus
extern "C"
{
#endif
/* entropy coding tables */
extern const SKP_uint8 SKP_Silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ]; /* 24 */
extern const SKP_uint8 SKP_Silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 41 */
extern const SKP_uint8 SKP_Silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ]; /* 32 */
extern const SKP_uint8 SKP_Silk_pitch_delta_iCDF[ 21 ]; /* 21 */
extern const SKP_uint8 SKP_Silk_pitch_contour_iCDF[ 34 ]; /* 34 */
extern const SKP_uint8 SKP_Silk_pitch_contour_NB_iCDF[ 11 ]; /* 11 */
extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_iCDF[ 12 ]; /* 12 */
extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_NB_iCDF[ 3 ]; /* 3 */
extern const SKP_uint8 SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ]; /* 180 */
extern const SKP_uint8 SKP_Silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ]; /* 162 */
extern const SKP_uint8 SKP_Silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */
extern const SKP_uint8 SKP_Silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */
extern const SKP_uint8 SKP_Silk_max_pulses_table[ 4 ]; /* 4 */
extern const SKP_uint8 SKP_Silk_shell_code_table0[ 44 ]; /* 44 */
extern const SKP_uint8 SKP_Silk_shell_code_table1[ 65 ]; /* 65 */
extern const SKP_uint8 SKP_Silk_shell_code_table2[ 90 ]; /* 90 */
extern const SKP_uint8 SKP_Silk_shell_code_table3[ 152 ]; /* 152 */
extern const SKP_uint8 SKP_Silk_shell_code_table_offsets[ MAX_PULSES + 1 ]; /* 17 */
extern const SKP_uint8 SKP_Silk_lsb_iCDF[ 2 ]; /* 2 */
extern const SKP_uint8 SKP_Silk_sign_iCDF[ 36 ]; /* 36 */
extern const SKP_uint8 SKP_Silk_uniform2_iCDF[ 2 ]; /* 2 */
extern const SKP_uint8 SKP_Silk_uniform3_iCDF[ 3 ]; /* 3 */
extern const SKP_uint8 SKP_Silk_uniform4_iCDF[ 4 ]; /* 4 */
extern const SKP_uint8 SKP_Silk_uniform5_iCDF[ 5 ]; /* 5 */
extern const SKP_uint8 SKP_Silk_uniform6_iCDF[ 6 ]; /* 6 */
extern const SKP_uint8 SKP_Silk_uniform8_iCDF[ 8 ]; /* 8 */
extern const SKP_uint8 SKP_Silk_NLSF_EXT_iCDF[ 7 ]; /* 7 */
extern const SKP_uint8 SKP_Silk_LTP_per_index_iCDF[ 3 ]; /* 3 */
extern const SKP_uint8 * const SKP_Silk_LTP_gain_iCDF_ptrs[ NB_LTP_CBKS ]; /* 3 */
extern const SKP_uint8 * const SKP_Silk_LTP_gain_BITS_Q5_ptrs[ NB_LTP_CBKS ]; /* 3 */
extern const SKP_int16 SKP_Silk_LTP_gain_middle_avg_RD_Q14;
extern const SKP_int8 * const SKP_Silk_LTP_vq_ptrs_Q7[ NB_LTP_CBKS ]; /* 168 */
extern const SKP_int8 SKP_Silk_LTP_vq_sizes[ NB_LTP_CBKS ]; /* 3 */
extern const SKP_uint8 SKP_Silk_LTPscale_iCDF[ 3 ]; /* 4 */
extern const SKP_int16 SKP_Silk_LTPScales_table_Q14[ 3 ];
extern const SKP_uint8 SKP_Silk_type_offset_VAD_iCDF[ 4 ]; /* 4 */
extern const SKP_uint8 SKP_Silk_type_offset_no_VAD_iCDF[ 2 ]; /* 2 */
extern const SKP_int16 SKP_Silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ]; /* 32 */
extern const SKP_uint8 SKP_Silk_stereo_pred_joint_iCDF[ 25 ]; /* 25 */
extern const SKP_uint8 * const SKP_Silk_LBRR_flags_iCDF_ptr[ 2 ]; /* 10 */
extern const SKP_uint8 SKP_Silk_NLSF_interpolation_factor_iCDF[ 5 ]; /* 5 */
extern const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB_WB;
extern const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB_NB_MB;
/* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */
extern const SKP_int32 TargetRate_table_NB[ TARGET_RATE_TAB_SZ ];
extern const SKP_int32 TargetRate_table_MB[ TARGET_RATE_TAB_SZ ];
extern const SKP_int32 TargetRate_table_WB[ TARGET_RATE_TAB_SZ ];
extern const SKP_int16 SNR_table_Q1[ TARGET_RATE_TAB_SZ ];
/* Quantization offsets */
extern const SKP_int16 SKP_Silk_Quantization_Offsets_Q10[ 2 ][ 2 ];
/* Interpolation points for filter coefficients used in the bandwidth transition smoother */
extern const SKP_int32 SKP_Silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ];
extern const SKP_int32 SKP_Silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ];
#ifdef __cplusplus
}
#endif
#endif

View file

@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
void SKP_Silk_LTP_analysis_filter_FIX(
void silk_LTP_analysis_filter_FIX(
SKP_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
const SKP_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */
const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */

View file

@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
void SKP_Silk_LTP_scale_ctrl_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state FIX */
SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O encoder control FIX */
void silk_LTP_scale_ctrl_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state FIX */
silk_encoder_control_FIX *psEncCtrl /* I/O encoder control FIX */
)
{
SKP_int round_loss;
@ -40,13 +40,13 @@ void SKP_Silk_LTP_scale_ctrl_FIX(
psEnc->prevLTPredCodGain_Q7 = psEncCtrl->LTPredCodGain_Q7;
/* Only scale if first frame in packet */
if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
if( psEnc->sCmn.nFramesEncoded == 0 ) {
round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket - 1;
psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT(
SKP_SMULWB( SKP_SMULBB( round_loss, psEnc->HPLTPredCodGain_Q7 ), SKP_FIX_CONST( 0.1, 9 ) ), 0, 2 );
SKP_SMULWB( SKP_SMULBB( round_loss, psEnc->HPLTPredCodGain_Q7 ), SILK_FIX_CONST( 0.1, 9 ) ), 0, 2 );
} else {
/* Default is minimum scaling */
psEnc->sCmn.indices.LTP_scaleIndex = 0;
}
psEncCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ];
psEncCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ];
}

View file

@ -29,10 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Correlation Matrix Computations for LS estimate.
**********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
/* Calculates correlation vector X'*t */
void SKP_Silk_corrVector_FIX(
void silk_corrVector_FIX(
const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const SKP_int16 *t, /* I target vector [L] */
const SKP_int L, /* I Length of vectors */
@ -61,14 +61,14 @@ void SKP_Silk_corrVector_FIX(
} else {
SKP_assert( rshifts == 0 );
for( lag = 0; lag < order; lag++ ) {
Xt[ lag ] = SKP_Silk_inner_prod_aligned( ptr1, ptr2, L ); /* X[:,lag]'*t */
Xt[ lag ] = silk_inner_prod_aligned( ptr1, ptr2, L ); /* X[:,lag]'*t */
ptr1--; /* Go to next column of X */
}
}
}
/* Calculates correlation matrix X'*X */
void SKP_Silk_corrMatrix_FIX(
void silk_corrMatrix_FIX(
const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const SKP_int L, /* I Length of vectors */
const SKP_int order, /* I Max lag for correlation */
@ -82,9 +82,9 @@ void SKP_Silk_corrMatrix_FIX(
const SKP_int16 *ptr1, *ptr2;
/* Calculate energy to find shift used to fit in 32 bits */
SKP_Silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 );
silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 );
/* Add shifts to get the desired head room */
head_room_rshifts = SKP_max( head_room - SKP_Silk_CLZ32( energy ), 0 );
head_room_rshifts = SKP_max( head_room - silk_CLZ32( energy ), 0 );
energy = SKP_RSHIFT32( energy, head_room_rshifts );
rshifts_local += head_room_rshifts;
@ -134,7 +134,7 @@ void SKP_Silk_corrMatrix_FIX(
} else {
for( lag = 1; lag < order; lag++ ) {
/* Inner product of column 0 and column lag: X[:,0]'*X[:,lag] */
energy = SKP_Silk_inner_prod_aligned( ptr1, ptr2, L );
energy = silk_inner_prod_aligned( ptr1, ptr2, L );
matrix_ptr( XX, lag, 0, order ) = energy;
matrix_ptr( XX, 0, lag, order ) = energy;
/* Calculate remaining off diagonal: X[:,j]'*X[:,j + lag] */

View file

@ -25,19 +25,19 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/****************/
/* Encode frame */
/****************/
SKP_int SKP_Silk_encode_frame_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
SKP_int silk_encode_frame_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
SKP_int32 *pnBytesOut, /* O Number of payload bytes */
ec_enc *psRangeEnc /* I/O compressor data structure */
)
{
SKP_Silk_encoder_control_FIX sEncCtrl;
silk_encoder_control_FIX sEncCtrl;
SKP_int ret = 0;
SKP_int16 *x_frame, *res_pitch_frame;
SKP_int16 xfw[ MAX_FRAME_LENGTH ];
@ -58,16 +58,16 @@ TIC(ENCODE_FRAME)
/* Voice Activity Detection */
/****************************/
TIC(VAD)
ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf );
ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf - 1 );
TOC(VAD)
/**************************************************/
/* Convert speech activity into VAD and DTX flags */
/**************************************************/
if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
if( psEnc->sCmn.nFramesEncoded == 0 ) {
psEnc->sCmn.inDTX = psEnc->sCmn.useDTX;
}
if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {
if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {
psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY;
psEnc->sCmn.noSpeechCounter++;
if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) {
@ -76,76 +76,76 @@ TOC(VAD)
psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX;
psEnc->sCmn.inDTX = 0;
}
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 0;
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 0;
} else {
psEnc->sCmn.noSpeechCounter = 0;
psEnc->sCmn.inDTX = 0;
psEnc->sCmn.indices.signalType = TYPE_UNVOICED;
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 1;
}
/*******************************************/
/* High-pass filtering of the input signal */
/*******************************************/
TIC(HP_IN)
SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length );
TOC(HP_IN)
/***************************************/
/* Ensure smooth bandwidth transitions */
SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length );
/***************************************/
silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length );
/*******************************************/
/* Copy new frame to front of input buffer */
/*******************************************/
SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
/*****************************************/
/* Find pitch lags, initial LPC analysis */
/*****************************************/
TIC(FIND_PITCH)
SKP_Silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame );
silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame );
TOC(FIND_PITCH)
/************************/
/* Noise shape analysis */
/************************/
TIC(NOISE_SHAPE_ANALYSIS)
SKP_Silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
TOC(NOISE_SHAPE_ANALYSIS)
/***************************************************/
/* Find linear prediction coefficients (LPC + LTP) */
/***************************************************/
TIC(FIND_PRED_COEF)
SKP_Silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame );
silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame );
TOC(FIND_PRED_COEF)
/****************************************/
/* Process gains */
/****************************************/
TIC(PROCESS_GAINS)
SKP_Silk_process_gains_FIX( psEnc, &sEncCtrl );
silk_process_gains_FIX( psEnc, &sEncCtrl );
TOC(PROCESS_GAINS)
/****************************************/
/* Low Bitrate Redundant Encoding */
/****************************************/
TIC(LBRR)
SKP_Silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw );
TOC(LBRR)
/*****************************************/
/* Prefiltering for noise shaper */
/*****************************************/
TIC(PREFILTER)
SKP_Silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame );
silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame );
TOC(PREFILTER)
/****************************************/
/* Low Bitrate Redundant Encoding */
/****************************************/
TIC(LBRR)
silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw );
TOC(LBRR)
/*****************************************/
/* Noise shaping quantization */
/*****************************************/
TIC(NSQ)
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
SKP_Silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 );
} else {
SKP_Silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses,
sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14,
sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 );
}
@ -170,14 +170,14 @@ TOC(NSQ)
/* Encode Parameters */
/****************************************/
TIC(ENCODE_PARAMS)
SKP_Silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesAnalyzed, 0 );
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0 );
TOC(ENCODE_PARAMS)
/****************************************/
/* Encode Excitation Signal */
/****************************************/
TIC(ENCODE_PULSES)
SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
TOC(ENCODE_PULSES)
@ -185,12 +185,12 @@ TOC(ENCODE_PULSES)
/* Finalize payload */
/****************************************/
psEnc->sCmn.first_frame_after_reset = 0;
if( ++psEnc->sCmn.nFramesAnalyzed >= psEnc->sCmn.nFramesPerPacket ) {
if( ++psEnc->sCmn.nFramesEncoded >= psEnc->sCmn.nFramesPerPacket ) {
/* Payload size */
*pnBytesOut = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
/* Reset the number of frames in payload buffer */
psEnc->sCmn.nFramesAnalyzed = 0;
psEnc->sCmn.nFramesEncoded = 0;
} else {
/* No payload this time */
*pnBytesOut = 0;
@ -243,30 +243,30 @@ TOC(ENCODE_FRAME)
}
/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */
void SKP_Silk_LBRR_encode_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
void silk_LBRR_encode_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
const SKP_int16 xfw[] /* I Input signal */
)
{
SKP_int32 TempGains_Q16[ MAX_NB_SUBFR ];
SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesAnalyzed ];
SKP_Silk_nsq_state sNSQ_LBRR;
SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ];
silk_nsq_state sNSQ_LBRR;
/*******************************************/
/* Control use of inband LBRR */
/*******************************************/
if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {
psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;
if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {
psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1;
/* Copy noise shaping quantizer state and quantization indices from regular encoding */
SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( SKP_Silk_nsq_state ) );
SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) );
SKP_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) );
/* Save original gains */
SKP_memcpy( TempGains_Q16, psEncCtrl->Gains_Q16, psEnc->sCmn.nb_subfr * sizeof( SKP_int32 ) );
if( psEnc->sCmn.nFramesAnalyzed == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed - 1 ] == 0 ) {
if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) {
/* First frame in packet or previous frame not LBRR coded */
psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex;
@ -277,20 +277,20 @@ void SKP_Silk_LBRR_encode_FIX(
/* Decode to get gains in sync with decoder */
/* Overwrite unquantized gains with quantized gains */
SKP_Silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices,
&psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr );
silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices,
&psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr );
/*****************************************/
/* Noise shaping quantization */
/*****************************************/
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
SKP_Silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw,
psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesAnalyzed ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14,
silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw,
psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14,
psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14,
psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 );
} else {
SKP_Silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw,
psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesAnalyzed ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14,
silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw,
psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14,
psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14,
psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 );
}

View file

@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/* Finds LPC vector from correlations, and converts to NLSF */
void SKP_Silk_find_LPC_FIX(
void silk_find_LPC_FIX(
SKP_int16 NLSF_Q15[], /* O NLSFs */
SKP_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
const SKP_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
@ -58,21 +58,21 @@ void SKP_Silk_find_LPC_FIX(
*interpIndex = 4;
/* Burg AR analysis for the full frame */
SKP_Silk_burg_modified( &res_nrg, &res_nrg_Q, a_Q16, x, subfr_length, nb_subfr, SKP_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order );
silk_burg_modified( &res_nrg, &res_nrg_Q, a_Q16, x, subfr_length, nb_subfr, SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order );
if( firstFrameAfterReset ) {
SKP_Silk_bwexpander_32( a_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP_FIRST_FRAME, 16 ) );
silk_bwexpander_32( a_Q16, LPC_order, SILK_FIX_CONST( FIND_LPC_CHIRP_FIRST_FRAME, 16 ) );
} else {
SKP_Silk_bwexpander_32( a_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP, 16 ) );
silk_bwexpander_32( a_Q16, LPC_order, SILK_FIX_CONST( FIND_LPC_CHIRP, 16 ) );
}
if( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) {
/* Optimal solution for last 10 ms */
SKP_Silk_burg_modified( &res_tmp_nrg, &res_tmp_nrg_Q, a_tmp_Q16, x + ( MAX_NB_SUBFR >> 1 ) * subfr_length,
subfr_length, ( MAX_NB_SUBFR >> 1 ), SKP_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order );
silk_burg_modified( &res_tmp_nrg, &res_tmp_nrg_Q, a_tmp_Q16, x + ( MAX_NB_SUBFR >> 1 ) * subfr_length,
subfr_length, ( MAX_NB_SUBFR >> 1 ), SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order );
SKP_Silk_bwexpander_32( a_tmp_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP, 16 ) );
silk_bwexpander_32( a_tmp_Q16, LPC_order, SILK_FIX_CONST( FIND_LPC_CHIRP, 16 ) );
/* subtract residual energy here, as that's easier than adding it to the */
/* residual energy of the first 10 ms in each iteration of the search below */
@ -88,22 +88,22 @@ void SKP_Silk_find_LPC_FIX(
}
/* Convert to NLSFs */
SKP_Silk_A2NLSF( NLSF_Q15, a_tmp_Q16, LPC_order );
silk_A2NLSF( NLSF_Q15, a_tmp_Q16, LPC_order );
/* Search over interpolation indices to find the one with lowest residual energy */
res_nrg_2nd = SKP_int32_MAX;
for( k = 3; k >= 0; k-- ) {
/* Interpolate NLSFs for first half */
SKP_Silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order );
silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order );
/* Convert to LPC for residual energy evaluation */
SKP_Silk_NLSF2A_stable( a_tmp_Q12, NLSF0_Q15, LPC_order );
silk_NLSF2A_stable( a_tmp_Q12, NLSF0_Q15, LPC_order );
/* Calculate residual energy with NLSF interpolation */
SKP_Silk_LPC_analysis_filter( LPC_res, x, a_tmp_Q12, 2 * subfr_length, LPC_order );
silk_LPC_analysis_filter( LPC_res, x, a_tmp_Q12, 2 * subfr_length, LPC_order );
SKP_Silk_sum_sqr_shift( &res_nrg0, &rshift0, LPC_res + LPC_order, subfr_length - LPC_order );
SKP_Silk_sum_sqr_shift( &res_nrg1, &rshift1, LPC_res + LPC_order + subfr_length, subfr_length - LPC_order );
silk_sum_sqr_shift( &res_nrg0, &rshift0, LPC_res + LPC_order, subfr_length - LPC_order );
silk_sum_sqr_shift( &res_nrg1, &rshift1, LPC_res + LPC_order + subfr_length, subfr_length - LPC_order );
/* Add subframe energies from first half frame */
shift = rshift0 - rshift1;
@ -150,7 +150,7 @@ void SKP_Silk_find_LPC_FIX(
if( *interpIndex == 4 ) {
/* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */
SKP_Silk_A2NLSF( NLSF_Q15, a_Q16, LPC_order );
silk_A2NLSF( NLSF_Q15, a_Q16, LPC_order );
}
SKP_assert( *interpIndex == 4 || ( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) );

View file

@ -25,18 +25,18 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/* Head room for correlations */
#define LTP_CORRS_HEAD_ROOM 2
void SKP_Silk_fit_LTP(
void silk_fit_LTP(
SKP_int32 LTP_coefs_Q16[ LTP_ORDER ],
SKP_int16 LTP_coefs_Q14[ LTP_ORDER ]
);
void SKP_Silk_find_LTP_FIX(
void silk_find_LTP_FIX(
SKP_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
SKP_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
SKP_int *LTPredCodGain_Q7, /* O LTP coding gain */
@ -71,37 +71,37 @@ void SKP_Silk_find_LTP_FIX(
for( k = 0; k < nb_subfr; k++ ) {
lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 );
SKP_Silk_sum_sqr_shift( &rr[ k ], &rr_shifts, r_ptr, subfr_length ); /* rr[ k ] in Q( -rr_shifts ) */
silk_sum_sqr_shift( &rr[ k ], &rr_shifts, r_ptr, subfr_length ); /* rr[ k ] in Q( -rr_shifts ) */
/* Assure headroom */
LZs = SKP_Silk_CLZ32( rr[k] );
LZs = silk_CLZ32( rr[k] );
if( LZs < LTP_CORRS_HEAD_ROOM ) {
rr[ k ] = SKP_RSHIFT_ROUND( rr[ k ], LTP_CORRS_HEAD_ROOM - LZs );
rr_shifts += ( LTP_CORRS_HEAD_ROOM - LZs );
}
corr_rshifts[ k ] = rr_shifts;
SKP_Silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, LTP_CORRS_HEAD_ROOM, WLTP_ptr, &corr_rshifts[ k ] ); /* WLTP_fix_ptr in Q( -corr_rshifts[ k ] ) */
silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, LTP_CORRS_HEAD_ROOM, WLTP_ptr, &corr_rshifts[ k ] ); /* WLTP_fix_ptr in Q( -corr_rshifts[ k ] ) */
/* The correlation vector always has lower max abs value than rr and/or RR so head room is assured */
SKP_Silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ] ); /* Rr_fix_ptr in Q( -corr_rshifts[ k ] ) */
silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ] ); /* Rr_fix_ptr in Q( -corr_rshifts[ k ] ) */
if( corr_rshifts[ k ] > rr_shifts ) {
rr[ k ] = SKP_RSHIFT( rr[ k ], corr_rshifts[ k ] - rr_shifts ); /* rr[ k ] in Q( -corr_rshifts[ k ] ) */
}
SKP_assert( rr[ k ] >= 0 );
regu = 1;
regu = SKP_SMLAWB( regu, rr[ k ], SKP_FIX_CONST( LTP_DAMPING/3, 16 ) );
regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, 0, 0, LTP_ORDER ), SKP_FIX_CONST( LTP_DAMPING/3, 16 ) );
regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, LTP_ORDER-1, LTP_ORDER-1, LTP_ORDER ), SKP_FIX_CONST( LTP_DAMPING/3, 16 ) );
SKP_Silk_regularize_correlations_FIX( WLTP_ptr, &rr[k], regu, LTP_ORDER );
regu = SKP_SMLAWB( regu, rr[ k ], SILK_FIX_CONST( LTP_DAMPING/3, 16 ) );
regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, 0, 0, LTP_ORDER ), SILK_FIX_CONST( LTP_DAMPING/3, 16 ) );
regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, LTP_ORDER-1, LTP_ORDER-1, LTP_ORDER ), SILK_FIX_CONST( LTP_DAMPING/3, 16 ) );
silk_regularize_correlations_FIX( WLTP_ptr, &rr[k], regu, LTP_ORDER );
SKP_Silk_solve_LDL_FIX( WLTP_ptr, LTP_ORDER, Rr, b_Q16 ); /* WLTP_fix_ptr and Rr_fix_ptr both in Q(-corr_rshifts[k]) */
silk_solve_LDL_FIX( WLTP_ptr, LTP_ORDER, Rr, b_Q16 ); /* WLTP_fix_ptr and Rr_fix_ptr both in Q(-corr_rshifts[k]) */
/* Limit and store in Q14 */
SKP_Silk_fit_LTP( b_Q16, b_Q14_ptr );
silk_fit_LTP( b_Q16, b_Q14_ptr );
/* Calculate residual energy */
nrg[ k ] = SKP_Silk_residual_energy16_covar_FIX( b_Q14_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER, 14 ); /* nrg_fix in Q( -corr_rshifts[ k ] ) */
nrg[ k ] = silk_residual_energy16_covar_FIX( b_Q14_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER, 14 ); /* nrg_fix in Q( -corr_rshifts[ k ] ) */
/* temp = Wght[ k ] / ( nrg[ k ] * Wght[ k ] + 0.01f * subfr_length ); */
extra_shifts = SKP_min_int( corr_rshifts[ k ], LTP_CORRS_HEAD_ROOM );
@ -117,13 +117,13 @@ void SKP_Silk_find_LTP_FIX(
for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) {
WLTP_max = SKP_max( WLTP_ptr[ i ], WLTP_max );
}
lshift = SKP_Silk_CLZ32( WLTP_max ) - 1 - 3; /* keep 3 bits free for vq_nearest_neighbor_fix */
lshift = silk_CLZ32( WLTP_max ) - 1 - 3; /* keep 3 bits free for vq_nearest_neighbor_fix */
SKP_assert( 26 - 18 + lshift >= 0 );
if( 26 - 18 + lshift < 31 ) {
temp32 = SKP_min_32( temp32, SKP_LSHIFT( ( SKP_int32 )1, 26 - 18 + lshift ) );
}
SKP_Silk_scale_vector32_Q26_lshift_18( WLTP_ptr, temp32, LTP_ORDER * LTP_ORDER ); /* WLTP_ptr in Q( 18 - corr_rshifts[ k ] ) */
silk_scale_vector32_Q26_lshift_18( WLTP_ptr, temp32, LTP_ORDER * LTP_ORDER ); /* WLTP_ptr in Q( 18 - corr_rshifts[ k ] ) */
w[ k ] = matrix_ptr( WLTP_ptr, LTP_ORDER/2, LTP_ORDER/2, LTP_ORDER ); /* w in Q( 18 - corr_rshifts[ k ] ) */
SKP_assert( w[k] >= 0 );
@ -149,10 +149,10 @@ void SKP_Silk_find_LTP_FIX(
}
LPC_LTP_res_nrg = SKP_max( LPC_LTP_res_nrg, 1 ); /* avoid division by zero */
div_Q16 = SKP_DIV32_varQ( LPC_res_nrg, LPC_LTP_res_nrg, 16 );
*LTPredCodGain_Q7 = ( SKP_int )SKP_SMULBB( 3, SKP_Silk_lin2log( div_Q16 ) - ( 16 << 7 ) );
div_Q16 = silk_DIV32_varQ( LPC_res_nrg, LPC_LTP_res_nrg, 16 );
*LTPredCodGain_Q7 = ( SKP_int )SKP_SMULBB( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) );
SKP_assert( *LTPredCodGain_Q7 == ( SKP_int )SKP_SAT16( SKP_MUL( 3, SKP_Silk_lin2log( div_Q16 ) - ( 16 << 7 ) ) ) );
SKP_assert( *LTPredCodGain_Q7 == ( SKP_int )SKP_SAT16( SKP_MUL( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) ) ) );
}
/* smoothing */
@ -175,14 +175,14 @@ void SKP_Silk_find_LTP_FIX(
max_abs_d_Q14 = SKP_max_32( max_abs_d_Q14, SKP_abs( d_Q14[ k ] ) );
/* w[ k ] is in Q( 18 - corr_rshifts[ k ] ) */
/* Find bits needed in Q( 18 - maxRshifts ) */
max_w_bits = SKP_max_32( max_w_bits, 32 - SKP_Silk_CLZ32( w[ k ] ) + corr_rshifts[ k ] - maxRshifts );
max_w_bits = SKP_max_32( max_w_bits, 32 - silk_CLZ32( w[ k ] ) + corr_rshifts[ k ] - maxRshifts );
}
/* max_abs_d_Q14 = (5 << 15); worst case, i.e. LTP_ORDER * -SKP_int16_MIN */
SKP_assert( max_abs_d_Q14 <= ( 5 << 15 ) );
/* How many bits is needed for w*d' in Q( 18 - maxRshifts ) in the worst case, of all d_Q14's being equal to max_abs_d_Q14 */
extra_shifts = max_w_bits + 32 - SKP_Silk_CLZ32( max_abs_d_Q14 ) - 14;
extra_shifts = max_w_bits + 32 - silk_CLZ32( max_abs_d_Q14 ) - 14;
/* Subtract what we got available; bits in output var plus maxRshifts */
extra_shifts -= ( 32 - 1 - 2 + maxRshifts ); /* Keep sign bit free as well as 2 bits for accumulation */
@ -197,7 +197,7 @@ void SKP_Silk_find_LTP_FIX(
temp32 = SKP_ADD32( temp32, SKP_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ) ); /* Q( 18 - maxRshifts_wxtra ) */
wd = SKP_ADD32( wd, SKP_LSHIFT( SKP_SMULWW( SKP_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ), d_Q14[ k ] ), 2 ) ); /* Q( 18 - maxRshifts_wxtra ) */
}
m_Q12 = SKP_DIV32_varQ( wd, temp32, 12 );
m_Q12 = silk_DIV32_varQ( wd, temp32, 12 );
b_Q14_ptr = b_Q14;
for( k = 0; k < nb_subfr; k++ ) {
@ -210,8 +210,8 @@ void SKP_Silk_find_LTP_FIX(
g_Q26 = SKP_MUL(
SKP_DIV32(
SKP_FIX_CONST( LTP_SMOOTHING, 26 ),
SKP_RSHIFT( SKP_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ), /* Q10 */
SILK_FIX_CONST( LTP_SMOOTHING, 26 ),
SKP_RSHIFT( SILK_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ), /* Q10 */
SKP_LSHIFT_SAT32( SKP_SUB_SAT32( ( SKP_int32 )m_Q12, SKP_RSHIFT( d_Q14[ k ], 2 ) ), 4 ) ); /* Q16 */
temp32 = 0;
@ -228,7 +228,7 @@ void SKP_Silk_find_LTP_FIX(
TOC(find_LTP_FIX)
}
void SKP_Silk_fit_LTP(
void silk_fit_LTP(
SKP_int32 LTP_coefs_Q16[ LTP_ORDER ],
SKP_int16 LTP_coefs_Q14[ LTP_ORDER ]
)

View file

@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/* Find pitch lags */
void SKP_Silk_find_pitch_lags_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
void silk_find_pitch_lags_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
SKP_int16 res[], /* O residual */
const SKP_int16 x[] /* I Speech signal */
)
@ -64,7 +64,7 @@ void SKP_Silk_find_pitch_lags_FIX(
/* First LA_LTP samples */
x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length;
Wsig_ptr = Wsig;
SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );
silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );
/* Middle un - windowed samples */
Wsig_ptr += psEnc->sCmn.la_pitch;
@ -74,22 +74,22 @@ void SKP_Silk_find_pitch_lags_FIX(
/* Last LA_LTP samples */
Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );
x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );
SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );
silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );
/* Calculate autocorrelation sequence */
SKP_Silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 );
silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 );
/* Add white noise, as fraction of energy */
auto_corr[ 0 ] = SKP_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SKP_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1;
auto_corr[ 0 ] = SKP_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1;
/* Calculate the reflection coefficients using schur */
res_nrg = SKP_Silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder );
res_nrg = silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder );
/* Prediction gain */
psEncCtrl->predGain_Q16 = SKP_DIV32_varQ( auto_corr[ 0 ], SKP_max_int( res_nrg, 1 ), 16 );
psEncCtrl->predGain_Q16 = silk_DIV32_varQ( auto_corr[ 0 ], SKP_max_int( res_nrg, 1 ), 16 );
/* Convert reflection coefficients to prediction coefficients */
SKP_Silk_k2a( A_Q24, rc_Q15, psEnc->sCmn.pitchEstimationLPCOrder );
silk_k2a( A_Q24, rc_Q15, psEnc->sCmn.pitchEstimationLPCOrder );
/* Convert From 32 bit Q24 to 16 bit Q12 coefs */
for( i = 0; i < psEnc->sCmn.pitchEstimationLPCOrder; i++ ) {
@ -97,26 +97,26 @@ void SKP_Silk_find_pitch_lags_FIX(
}
/* Do BWE */
SKP_Silk_bwexpander( A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, SKP_FIX_CONST( FIND_PITCH_BANDWITH_EXPANSION, 16 ) );
silk_bwexpander( A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, SILK_FIX_CONST( FIND_PITCH_BANDWITH_EXPANSION, 16 ) );
/*****************************************/
/* LPC analysis filtering */
/*****************************************/
SKP_Silk_LPC_analysis_filter( res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );
silk_LPC_analysis_filter( res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );
if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) {
/* Threshold for pitch estimator */
thrhld_Q15 = SKP_FIX_CONST( 0.6, 15 );
thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.004, 15 ), psEnc->sCmn.pitchEstimationLPCOrder );
thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.1, 7 ), psEnc->sCmn.speech_activity_Q8 );
thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.15, 15 ), SKP_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) );
thrhld_Q15 = SKP_SMLAWB( thrhld_Q15, SKP_FIX_CONST( -0.1, 16 ), psEnc->sCmn.input_tilt_Q15 );
thrhld_Q15 = SILK_FIX_CONST( 0.6, 15 );
thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SILK_FIX_CONST( -0.004, 15 ), psEnc->sCmn.pitchEstimationLPCOrder );
thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SILK_FIX_CONST( -0.1, 7 ), psEnc->sCmn.speech_activity_Q8 );
thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SILK_FIX_CONST( -0.15, 15 ), SKP_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) );
thrhld_Q15 = SKP_SMLAWB( thrhld_Q15, SILK_FIX_CONST( -0.1, 16 ), psEnc->sCmn.input_tilt_Q15 );
thrhld_Q15 = SKP_SAT16( thrhld_Q15 );
/*****************************************/
/* Call pitch estimator */
/*****************************************/
if( SKP_Silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex,
if( silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex,
&psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16,
( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 )
{

View file

@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
void SKP_Silk_find_pred_coefs_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
void silk_find_pred_coefs_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
const SKP_int16 res_pitch[], /* I Residual from pitch analysis */
const SKP_int16 x[] /* I Speech signal */
)
@ -52,7 +52,7 @@ void SKP_Silk_find_pred_coefs_FIX(
/* Divide to Q16 */
SKP_assert( psEncCtrl->Gains_Q16[ i ] > 0 );
/* Invert and normalize gains, and ensure that maximum invGains_Q16 is within range of a 16 bit int */
invGains_Q16[ i ] = SKP_DIV32_varQ( min_gain_Q16, psEncCtrl->Gains_Q16[ i ], 16 - 2 );
invGains_Q16[ i ] = silk_DIV32_varQ( min_gain_Q16, psEncCtrl->Gains_Q16[ i ], 16 - 2 );
/* Ensure Wght_Q15 a minimum value 1 */
invGains_Q16[ i ] = SKP_max( invGains_Q16[ i ], 363 );
@ -73,19 +73,19 @@ void SKP_Silk_find_pred_coefs_FIX(
SKP_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >= psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 );
/* LTP analysis */
SKP_Silk_find_LTP_FIX( psEncCtrl->LTPCoef_Q14, WLTP, &psEncCtrl->LTPredCodGain_Q7,
silk_find_LTP_FIX( psEncCtrl->LTPCoef_Q14, WLTP, &psEncCtrl->LTPredCodGain_Q7,
res_pitch, psEncCtrl->pitchL, Wght_Q15, psEnc->sCmn.subfr_length,
psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length, LTP_corrs_rshift );
/* Quantize LTP gain parameters */
SKP_Silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex,
silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex,
WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr);
/* Control LTP scaling */
SKP_Silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl );
silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl );
/* Create LTP residual */
SKP_Silk_LTP_analysis_filter_FIX( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef_Q14,
silk_LTP_analysis_filter_FIX( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef_Q14,
psEncCtrl->pitchL, invGains_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder );
} else {
@ -96,7 +96,7 @@ void SKP_Silk_find_pred_coefs_FIX(
x_ptr = x - psEnc->sCmn.predictLPCOrder;
x_pre_ptr = LPC_in_pre;
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
SKP_Silk_scale_copy_vector16( x_pre_ptr, x_ptr, invGains_Q16[ i ],
silk_scale_copy_vector16( x_pre_ptr, x_ptr, invGains_Q16[ i ],
psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder );
x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder;
x_ptr += psEnc->sCmn.subfr_length;
@ -108,18 +108,18 @@ void SKP_Silk_find_pred_coefs_FIX(
/* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */
TIC(FIND_LPC)
SKP_Silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15,
silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15,
psEnc->sCmn.useInterpolatedNLSFs, psEnc->sCmn.first_frame_after_reset, psEnc->sCmn.predictLPCOrder,
LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );
TOC(FIND_LPC)
/* Quantize LSFs */
TIC(PROCESS_LSFS)
SKP_Silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
TOC(PROCESS_LSFS)
/* Calculate residual energy using quantized LPC coefficients */
SKP_Silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains,
silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains,
psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder );
/* Copy to prediction struct for use in next frame for fluctuation reduction */

View file

@ -86,26 +86,28 @@
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="SKP_Silk_corrMatrix_FIX.c" />
<ClCompile Include="SKP_Silk_encode_frame_FIX.c" />
<ClCompile Include="SKP_Silk_find_LPC_FIX.c" />
<ClCompile Include="SKP_Silk_find_LTP_FIX.c" />
<ClCompile Include="SKP_Silk_find_pitch_lags_FIX.c" />
<ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c" />
<ClCompile Include="SKP_Silk_LTP_analysis_filter_FIX.c" />
<ClCompile Include="SKP_Silk_LTP_scale_ctrl_FIX.c" />
<ClCompile Include="SKP_Silk_noise_shape_analysis_FIX.c" />
<ClCompile Include="SKP_Silk_prefilter_FIX.c" />
<ClCompile Include="SKP_Silk_process_gains_FIX.c" />
<ClCompile Include="SKP_Silk_regularize_correlations_FIX.c" />
<ClCompile Include="SKP_Silk_residual_energy16_FIX.c" />
<ClCompile Include="SKP_Silk_residual_energy_FIX.c" />
<ClCompile Include="SKP_Silk_solve_LS_FIX.c" />
<ClCompile Include="SKP_Silk_warped_autocorrelation_FIX.c" />
<ClCompile Include="silk_corrMatrix_FIX.c" />
<ClCompile Include="silk_encode_frame_FIX.c" />
<ClCompile Include="silk_find_LPC_FIX.c" />
<ClCompile Include="silk_find_LTP_FIX.c" />
<ClCompile Include="silk_find_pitch_lags_FIX.c" />
<ClCompile Include="silk_find_pred_coefs_FIX.c" />
<ClCompile Include="silk_LTP_analysis_filter_FIX.c" />
<ClCompile Include="silk_LTP_scale_ctrl_FIX.c" />
<ClCompile Include="silk_noise_shape_analysis_FIX.c" />
<ClCompile Include="silk_prefilter_FIX.c" />
<ClCompile Include="silk_process_gains_FIX.c" />
<ClCompile Include="silk_regularize_correlations_FIX.c" />
<ClCompile Include="silk_residual_energy16_FIX.c" />
<ClCompile Include="silk_residual_energy_FIX.c" />
<ClCompile Include="silk_solve_LS_FIX.c" />
<ClCompile Include="silk_warped_autocorrelation_FIX.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="SKP_Silk_main_FIX.h" />
<ClInclude Include="SKP_Silk_structs_FIX.h" />
<ClInclude Include="..\..\win32\config.h" />
<ClInclude Include="..\silk_SigProc_FIX.h" />
<ClInclude Include="silk_main_FIX.h" />
<ClInclude Include="silk_structs_FIX.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -18,60 +18,66 @@
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="SKP_Silk_LTP_scale_ctrl_FIX.c">
<ClCompile Include="silk_corrMatrix_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_noise_shape_analysis_FIX.c">
<ClCompile Include="silk_encode_frame_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_prefilter_FIX.c">
<ClCompile Include="silk_find_LPC_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_process_gains_FIX.c">
<ClCompile Include="silk_find_LTP_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_regularize_correlations_FIX.c">
<ClCompile Include="silk_find_pitch_lags_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_residual_energy_FIX.c">
<ClCompile Include="silk_find_pred_coefs_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_residual_energy16_FIX.c">
<ClCompile Include="silk_LTP_analysis_filter_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_solve_LS_FIX.c">
<ClCompile Include="silk_LTP_scale_ctrl_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_warped_autocorrelation_FIX.c">
<ClCompile Include="silk_noise_shape_analysis_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_corrMatrix_FIX.c">
<ClCompile Include="silk_prefilter_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_encode_frame_FIX.c">
<ClCompile Include="silk_process_gains_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_LPC_FIX.c">
<ClCompile Include="silk_regularize_correlations_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_LTP_FIX.c">
<ClCompile Include="silk_residual_energy16_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_pitch_lags_FIX.c">
<ClCompile Include="silk_residual_energy_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c">
<ClCompile Include="silk_solve_LS_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_LTP_analysis_filter_FIX.c">
<ClCompile Include="silk_warped_autocorrelation_FIX.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SKP_Silk_main_FIX.h">
<ClInclude Include="..\..\win32\config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SKP_Silk_structs_FIX.h">
<ClInclude Include="silk_main_FIX.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\silk_SigProc_FIX.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="silk_structs_FIX.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

View file

@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef SKP_SILK_MAIN_FIX_H
#define SKP_SILK_MAIN_FIX_H
#ifndef SILK_MAIN_FIX_H
#define SILK_MAIN_FIX_H
#include "SKP_Silk_SigProc_FIX.h"
#include "SKP_Silk_structs_FIX.h"
#include "SKP_Silk_control.h"
#include "SKP_Silk_main.h"
#include "SKP_Silk_PLC.h"
#include "SKP_debug.h"
#include "silk_SigProc_FIX.h"
#include "silk_structs_FIX.h"
#include "silk_control.h"
#include "silk_main.h"
#include "silk_PLC.h"
#include "silk_debug.h"
#include "entenc.h"
#ifndef FORCE_CPP_BUILD
@ -43,33 +43,42 @@ extern "C"
#endif
#endif
#define silk_encoder_state_Fxx silk_encoder_state_FIX
#define silk_encode_frame_Fxx silk_encode_frame_FIX
/*********************/
/* Encoder Functions */
/*********************/
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
void silk_HP_variable_cutoff(
silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */
const SKP_int nChannels /* I Number of channels */
);
/* Encoder main function */
SKP_int SKP_Silk_encode_frame_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
SKP_int silk_encode_frame_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
SKP_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
ec_enc *psRangeEnc /* I/O compressor data structure */
);
/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */
void SKP_Silk_LBRR_encode_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
void silk_LBRR_encode_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */
const SKP_int16 xfw[] /* I Input signal */
);
/* Initializes the Silk encoder state */
SKP_int SKP_Silk_init_encoder(
SKP_Silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
SKP_int silk_init_encoder(
silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
);
/* Control the Silk encoder */
SKP_int SKP_Silk_control_encoder(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk encoder state */
SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */
SKP_int silk_control_encoder(
silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk encoder state */
silk_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 */
@ -78,9 +87,9 @@ SKP_int SKP_Silk_control_encoder(
/****************/
/* Prefiltering */
/****************/
void SKP_Silk_prefilter_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
const SKP_Silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
void silk_prefilter_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
SKP_int16 xw[], /* O Weighted signal */
const SKP_int16 x[] /* I Speech signal */
);
@ -89,15 +98,15 @@ void SKP_Silk_prefilter_FIX(
/* Noise shaping analysis */
/**************************/
/* Compute noise shaping coefficients and initial gain values */
void SKP_Silk_noise_shape_analysis_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
void silk_noise_shape_analysis_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
const SKP_int16 *pitch_res, /* I LPC residual from pitch analysis */
const SKP_int16 *x /* I Input signal [ frame_length + la_shape ] */
);
/* Autocorrelations for a warped frequency axis */
void SKP_Silk_warped_autocorrelation_FIX(
void silk_warped_autocorrelation_FIX(
SKP_int32 *corr, /* O Result [order + 1] */
SKP_int *scale, /* O Scaling of the correlation vector */
const SKP_int16 *input, /* I Input data to correlate */
@ -107,32 +116,32 @@ void SKP_Silk_warped_autocorrelation_FIX(
);
/* Calculation of LTP state scaling */
void SKP_Silk_LTP_scale_ctrl_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O encoder control */
void silk_LTP_scale_ctrl_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
silk_encoder_control_FIX *psEncCtrl /* I/O encoder control */
);
/**********************************************/
/* Prediction Analysis */
/**********************************************/
/* Find pitch lags */
void SKP_Silk_find_pitch_lags_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
void silk_find_pitch_lags_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
SKP_int16 res[], /* O residual */
const SKP_int16 x[] /* I Speech signal */
);
/* Find LPC and LTP coefficients */
void SKP_Silk_find_pred_coefs_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
void silk_find_pred_coefs_FIX(
silk_encoder_state_FIX *psEnc, /* I/O encoder state */
silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
const SKP_int16 res_pitch[], /* I Residual from pitch analysis */
const SKP_int16 x[] /* I Speech signal */
);
/* LPC analysis */
void SKP_Silk_find_LPC_FIX(
void silk_find_LPC_FIX(
SKP_int16 NLSF_Q15[], /* O NLSFs */
SKP_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */
const SKP_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */
@ -145,7 +154,7 @@ void SKP_Silk_find_LPC_FIX(
);
/* LTP analysis */
void SKP_Silk_find_LTP_FIX(
void silk_find_LTP_FIX(
SKP_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
SKP_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
SKP_int *LTPredCodGain_Q7, /* O LTP coding gain */
@ -158,7 +167,7 @@ void SKP_Silk_find_LTP_FIX(
SKP_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */
);
void SKP_Silk_LTP_analysis_filter_FIX(
void silk_LTP_analysis_filter_FIX(
SKP_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
const SKP_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */
const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
@ -171,11 +180,11 @@ void SKP_Silk_LTP_analysis_filter_FIX(
/* Calculates residual energies of input subframes where all subframes have LPC_order */
/* of preceeding samples */
void SKP_Silk_residual_energy_FIX(
void silk_residual_energy_FIX(
SKP_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
SKP_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
const SKP_int16 x[], /* I Input signal */
const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
const SKP_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
const SKP_int subfr_length, /* I Subframe length */
const SKP_int nb_subfr, /* I Number of subframes */
@ -183,7 +192,7 @@ void SKP_Silk_residual_energy_FIX(
);
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
SKP_int32 SKP_Silk_residual_energy16_covar_FIX(
SKP_int32 silk_residual_energy16_covar_FIX(
const SKP_int16 *c, /* I Prediction vector */
const SKP_int32 *wXX, /* I Correlation matrix */
const SKP_int32 *wXx, /* I Correlation vector */
@ -193,16 +202,16 @@ SKP_int32 SKP_Silk_residual_energy16_covar_FIX(
);
/* Processing of gains */
void SKP_Silk_process_gains_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control */
void silk_process_gains_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control */
);
/******************/
/* Linear Algebra */
/******************/
/* Calculates correlation matrix X'*X */
void SKP_Silk_corrMatrix_FIX(
void silk_corrMatrix_FIX(
const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const SKP_int L, /* I Length of vectors */
const SKP_int order, /* I Max lag for correlation */
@ -212,7 +221,7 @@ void SKP_Silk_corrMatrix_FIX(
);
/* Calculates correlation vector X'*t */
void SKP_Silk_corrVector_FIX(
void silk_corrVector_FIX(
const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
const SKP_int16 *t, /* I Target vector [L] */
const SKP_int L, /* I Length of vectors */
@ -222,7 +231,7 @@ void SKP_Silk_corrVector_FIX(
);
/* Add noise to matrix diagonal */
void SKP_Silk_regularize_correlations_FIX(
void silk_regularize_correlations_FIX(
SKP_int32 *XX, /* I/O Correlation matrices */
SKP_int32 *xx, /* I/O Correlation values */
SKP_int32 noise, /* I Noise to add */
@ -230,7 +239,7 @@ void SKP_Silk_regularize_correlations_FIX(
);
/* Solves Ax = b, assuming A is symmetric */
void SKP_Silk_solve_LDL_FIX(
void silk_solve_LDL_FIX(
SKP_int32 *A, /* I Pointer to symetric square matrix A */
SKP_int M, /* I Size of matrix */
const SKP_int32 *b, /* I Pointer to b vector */
@ -242,4 +251,4 @@ void SKP_Silk_solve_LDL_FIX(
}
#endif /* __cplusplus */
#endif /* FORCE_CPP_BUILD */
#endif /* SKP_SILK_MAIN_FIX_H */
#endif /* SILK_MAIN_FIX_H */

View file

@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/* Compute gain to make warped filter coefficients have a zero mean log frequency response on a */
/* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.) */
@ -43,8 +43,8 @@ SKP_INLINE SKP_int32 warped_gain( // gain in Q16
for( i = order - 2; i >= 0; i-- ) {
gain_Q24 = SKP_SMLAWB( coefs_Q24[ i ], gain_Q24, lambda_Q16 );
}
gain_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 );
return SKP_INVERSE32_varQ( gain_Q24, 40 );
gain_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 );
return silk_INVERSE32_varQ( gain_Q24, 40 );
}
/* Convert warped filter coefficients to monic pseudo-warped coefficients and limit maximum */
@ -67,11 +67,11 @@ SKP_INLINE void limit_warped_coefs(
coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 );
}
lambda_Q16 = -lambda_Q16;
nom_Q16 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 );
den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 );
gain_syn_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );
den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 );
gain_ana_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );
nom_Q16 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 );
den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 );
gain_syn_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 );
den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 );
gain_ana_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 );
for( i = 0; i < order; i++ ) {
coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] );
coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] );
@ -97,19 +97,19 @@ SKP_INLINE void limit_warped_coefs(
coefs_syn_Q24[ i - 1 ] = SKP_SMLAWB( coefs_syn_Q24[ i - 1 ], coefs_syn_Q24[ i ], lambda_Q16 );
coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 );
}
gain_syn_Q16 = SKP_INVERSE32_varQ( gain_syn_Q16, 32 );
gain_ana_Q16 = SKP_INVERSE32_varQ( gain_ana_Q16, 32 );
gain_syn_Q16 = silk_INVERSE32_varQ( gain_syn_Q16, 32 );
gain_ana_Q16 = silk_INVERSE32_varQ( gain_ana_Q16, 32 );
for( i = 0; i < order; i++ ) {
coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] );
coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] );
}
/* Apply bandwidth expansion */
chirp_Q16 = SKP_FIX_CONST( 0.99, 16 ) - SKP_DIV32_varQ(
SKP_SMULWB( maxabs_Q24 - limit_Q24, SKP_SMLABB( SKP_FIX_CONST( 0.8, 10 ), SKP_FIX_CONST( 0.1, 10 ), iter ) ),
chirp_Q16 = SILK_FIX_CONST( 0.99, 16 ) - silk_DIV32_varQ(
SKP_SMULWB( maxabs_Q24 - limit_Q24, SKP_SMLABB( SILK_FIX_CONST( 0.8, 10 ), SILK_FIX_CONST( 0.1, 10 ), iter ) ),
SKP_MUL( maxabs_Q24, ind + 1 ), 22 );
SKP_Silk_bwexpander_32( coefs_syn_Q24, order, chirp_Q16 );
SKP_Silk_bwexpander_32( coefs_ana_Q24, order, chirp_Q16 );
silk_bwexpander_32( coefs_syn_Q24, order, chirp_Q16 );
silk_bwexpander_32( coefs_ana_Q24, order, chirp_Q16 );
/* Convert to monic warped coefficients */
lambda_Q16 = -lambda_Q16;
@ -118,11 +118,11 @@ SKP_INLINE void limit_warped_coefs(
coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 );
}
lambda_Q16 = -lambda_Q16;
nom_Q16 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 );
den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 );
gain_syn_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );
den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 );
gain_ana_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );
nom_Q16 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 );
den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 );
gain_syn_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 );
den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 );
gain_ana_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 );
for( i = 0; i < order; i++ ) {
coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] );
coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] );
@ -134,14 +134,14 @@ SKP_INLINE void limit_warped_coefs(
/**************************************************************/
/* Compute noise shaping coefficients and initial gain values */
/**************************************************************/
void SKP_Silk_noise_shape_analysis_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
void silk_noise_shape_analysis_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
const SKP_int16 *pitch_res, /* I LPC residual from pitch analysis */
const SKP_int16 *x /* I Input signal [ frame_length + la_shape ] */
)
{
SKP_Silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
SKP_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0;
SKP_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32;
SKP_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7;
@ -167,26 +167,26 @@ void SKP_Silk_noise_shape_analysis_FIX(
+ psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 );
/* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */
psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( SNR_adj_dB_Q7 -
SKP_FIX_CONST( 18.0, 7 ), 4 ) ), 1 );
psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( silk_sigm_Q15( SKP_RSHIFT_ROUND( SNR_adj_dB_Q7 -
SILK_FIX_CONST( 18.0, 7 ), 4 ) ), 1 );
/* Reduce coding SNR during low speech activity */
if( psEnc->sCmn.useCBR == 0 ) {
b_Q8 = SKP_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8;
b_Q8 = SILK_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8;
b_Q8 = SKP_SMULWB( SKP_LSHIFT( b_Q8, 8 ), b_Q8 );
SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7,
SKP_SMULBB( SKP_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), // Q11
SKP_SMULWB( SKP_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); // Q12
SKP_SMULBB( SILK_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), // Q11
SKP_SMULWB( SILK_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); // Q12
}
if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
/* Reduce gains for periodic signals */
SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SKP_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 );
SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 );
} else {
/* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */
SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7,
SKP_SMLAWB( SKP_FIX_CONST( 6.0, 9 ), -SKP_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ),
SKP_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 );
SKP_SMLAWB( SILK_FIX_CONST( 6.0, 9 ), -SILK_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ),
SILK_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 );
}
/*************************/
@ -204,10 +204,10 @@ void SKP_Silk_noise_shape_analysis_FIX(
log_energy_prev_Q7 = 0;
pitch_res_ptr = pitch_res;
for( k = 0; k < SKP_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; k++ ) {
SKP_Silk_sum_sqr_shift( &nrg, &scale, pitch_res_ptr, nSamples );
silk_sum_sqr_shift( &nrg, &scale, pitch_res_ptr, nSamples );
nrg += SKP_RSHIFT( nSamples, scale ); // Q(-scale)
log_energy_Q7 = SKP_Silk_lin2log( nrg );
log_energy_Q7 = silk_lin2log( nrg );
if( k > 0 ) {
energy_variation_Q7 += SKP_abs( log_energy_Q7 - log_energy_prev_Q7 );
}
@ -215,29 +215,29 @@ void SKP_Silk_noise_shape_analysis_FIX(
pitch_res_ptr += nSamples;
}
psEncCtrl->sparseness_Q8 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_SMULWB( energy_variation_Q7 -
SKP_FIX_CONST( 5.0, 7 ), SKP_FIX_CONST( 0.1, 16 ) ) ), 7 );
psEncCtrl->sparseness_Q8 = SKP_RSHIFT( silk_sigm_Q15( SKP_SMULWB( energy_variation_Q7 -
SILK_FIX_CONST( 5.0, 7 ), SILK_FIX_CONST( 0.1, 16 ) ) ), 7 );
/* Set quantization offset depending on sparseness measure */
if( psEncCtrl->sparseness_Q8 > SKP_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) {
if( psEncCtrl->sparseness_Q8 > SILK_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) {
psEnc->sCmn.indices.quantOffsetType = 0;
} else {
psEnc->sCmn.indices.quantOffsetType = 1;
}
/* Increase coding SNR for sparse signals */
SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SKP_FIX_CONST( SPARSE_SNR_INCR_dB, 15 ), psEncCtrl->sparseness_Q8 - SKP_FIX_CONST( 0.5, 8 ) );
SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( SPARSE_SNR_INCR_dB, 15 ), psEncCtrl->sparseness_Q8 - SILK_FIX_CONST( 0.5, 8 ) );
}
/*******************************/
/* Control bandwidth expansion */
/*******************************/
/* More BWE for signals with high prediction gain */
strength_Q16 = SKP_SMULWB( psEncCtrl->predGain_Q16, SKP_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) );
BWExp1_Q16 = BWExp2_Q16 = SKP_DIV32_varQ( SKP_FIX_CONST( BANDWIDTH_EXPANSION, 16 ),
SKP_SMLAWW( SKP_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 );
delta_Q16 = SKP_SMULWB( SKP_FIX_CONST( 1.0, 16 ) - SKP_SMULBB( 3, psEncCtrl->coding_quality_Q14 ),
SKP_FIX_CONST( LOW_RATE_BANDWIDTH_EXPANSION_DELTA, 16 ) );
strength_Q16 = SKP_SMULWB( psEncCtrl->predGain_Q16, SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) );
BWExp1_Q16 = BWExp2_Q16 = silk_DIV32_varQ( SILK_FIX_CONST( BANDWIDTH_EXPANSION, 16 ),
SKP_SMLAWW( SILK_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 );
delta_Q16 = SKP_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SKP_SMULBB( 3, psEncCtrl->coding_quality_Q14 ),
SILK_FIX_CONST( LOW_RATE_BANDWIDTH_EXPANSION_DELTA, 16 ) );
BWExp1_Q16 = SKP_SUB32( BWExp1_Q16, delta_Q16 );
BWExp2_Q16 = SKP_ADD32( BWExp2_Q16, delta_Q16 );
/* BWExp1 will be applied after BWExp2, so make it relative */
@ -245,7 +245,7 @@ void SKP_Silk_noise_shape_analysis_FIX(
if( psEnc->sCmn.warping_Q16 > 0 ) {
/* Slightly more warping in analysis will move quantization noise up in frequency, where it's better masked */
warping_Q16 = SKP_SMLAWB( psEnc->sCmn.warping_Q16, psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( 0.01, 18 ) );
warping_Q16 = SKP_SMLAWB( psEnc->sCmn.warping_Q16, psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( 0.01, 18 ) );
} else {
warping_Q16 = 0;
}
@ -259,33 +259,33 @@ void SKP_Silk_noise_shape_analysis_FIX(
flat_part = psEnc->sCmn.fs_kHz * 3;
slope_part = SKP_RSHIFT( psEnc->sCmn.shapeWinLength - flat_part, 1 );
SKP_Silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part );
silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part );
shift = slope_part;
SKP_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(SKP_int16) );
shift += flat_part;
SKP_Silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part );
silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part );
/* Update pointer: next LPC analysis block */
x_ptr += psEnc->sCmn.subfr_length;
if( psEnc->sCmn.warping_Q16 > 0 ) {
/* Calculate warped auto correlation */
SKP_Silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder );
silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder );
} else {
/* Calculate regular auto correlation */
SKP_Silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 );
silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 );
}
/* Add white noise, as a fraction of energy */
auto_corr[0] = SKP_ADD32( auto_corr[0], SKP_max_32( SKP_SMULWB( SKP_RSHIFT( auto_corr[ 0 ], 4 ),
SKP_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) );
SILK_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) );
/* Calculate the reflection coefficients using schur */
nrg = SKP_Silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder );
nrg = silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder );
SKP_assert( nrg >= 0 );
/* Convert reflection coefficients to prediction coefficients */
SKP_Silk_k2a_Q16( AR2_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder );
silk_k2a_Q16( AR2_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder );
Qnrg = -scale; // range: -12...30
SKP_assert( Qnrg >= -12 );
@ -297,7 +297,7 @@ void SKP_Silk_noise_shape_analysis_FIX(
nrg >>= 1;
}
tmp32 = SKP_Silk_SQRT_APPROX( nrg );
tmp32 = silk_SQRT_APPROX( nrg );
Qnrg >>= 1; // range: -6...15
sqrt_nrg[ k ] = tmp32;
@ -312,25 +312,25 @@ void SKP_Silk_noise_shape_analysis_FIX(
}
/* Bandwidth expansion for synthesis filter shaping */
SKP_Silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 );
silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 );
/* Compute noise shaping filter coefficients */
SKP_memcpy( AR1_Q24, AR2_Q24, psEnc->sCmn.shapingLPCOrder * sizeof( SKP_int32 ) );
/* Bandwidth expansion for analysis filter shaping */
SKP_assert( BWExp1_Q16 <= SKP_FIX_CONST( 1.0, 16 ) );
SKP_Silk_bwexpander_32( AR1_Q24, psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 );
SKP_assert( BWExp1_Q16 <= SILK_FIX_CONST( 1.0, 16 ) );
silk_bwexpander_32( AR1_Q24, psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 );
/* Ratio of prediction gains, in energy domain */
SKP_Silk_LPC_inverse_pred_gain_Q24( &pre_nrg_Q30, AR2_Q24, psEnc->sCmn.shapingLPCOrder );
SKP_Silk_LPC_inverse_pred_gain_Q24( &nrg, AR1_Q24, psEnc->sCmn.shapingLPCOrder );
silk_LPC_inverse_pred_gain_Q24( &pre_nrg_Q30, AR2_Q24, psEnc->sCmn.shapingLPCOrder );
silk_LPC_inverse_pred_gain_Q24( &nrg, AR1_Q24, psEnc->sCmn.shapingLPCOrder );
//psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ) = 0.3f + 0.7f * pre_nrg / nrg;
pre_nrg_Q30 = SKP_LSHIFT32( SKP_SMULWB( pre_nrg_Q30, SKP_FIX_CONST( 0.7, 15 ) ), 1 );
psEncCtrl->GainsPre_Q14[ k ] = ( SKP_int ) SKP_FIX_CONST( 0.3, 14 ) + SKP_DIV32_varQ( pre_nrg_Q30, nrg, 14 );
pre_nrg_Q30 = SKP_LSHIFT32( SKP_SMULWB( pre_nrg_Q30, SILK_FIX_CONST( 0.7, 15 ) ), 1 );
psEncCtrl->GainsPre_Q14[ k ] = ( SKP_int ) SILK_FIX_CONST( 0.3, 14 ) + silk_DIV32_varQ( pre_nrg_Q30, nrg, 14 );
/* Convert to monic warped prediction coefficients and limit absolute values */
limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SKP_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder );
limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SILK_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder );
/* Convert from Q24 to Q13 and store in int16 */
for( i = 0; i < psEnc->sCmn.shapingLPCOrder; i++ ) {
@ -343,8 +343,8 @@ void SKP_Silk_noise_shape_analysis_FIX(
/* Gain tweaking */
/*****************/
/* Increase gains during low speech activity and put lower limit on gains */
gain_mult_Q16 = SKP_Silk_log2lin( -SKP_SMLAWB( -SKP_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7, SKP_FIX_CONST( 0.16, 16 ) ) );
gain_add_Q16 = SKP_Silk_log2lin( SKP_SMLAWB( SKP_FIX_CONST( 16.0, 7 ), SKP_FIX_CONST( MIN_QGAIN_DB, 7 ), SKP_FIX_CONST( 0.16, 16 ) ) );
gain_mult_Q16 = silk_log2lin( -SKP_SMLAWB( -SILK_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7, SILK_FIX_CONST( 0.16, 16 ) ) );
gain_add_Q16 = silk_log2lin( SKP_SMLAWB( SILK_FIX_CONST( 16.0, 7 ), SILK_FIX_CONST( MIN_QGAIN_DB, 7 ), SILK_FIX_CONST( 0.16, 16 ) ) );
SKP_assert( gain_mult_Q16 > 0 );
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
psEncCtrl->Gains_Q16[ k ] = SKP_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 );
@ -352,8 +352,8 @@ void SKP_Silk_noise_shape_analysis_FIX(
psEncCtrl->Gains_Q16[ k ] = SKP_ADD_POS_SAT32( psEncCtrl->Gains_Q16[ k ], gain_add_Q16 );
}
gain_mult_Q16 = SKP_FIX_CONST( 1.0, 16 ) + SKP_RSHIFT_ROUND( SKP_MLA( SKP_FIX_CONST( INPUT_TILT, 26 ),
psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ), 10 );
gain_mult_Q16 = SILK_FIX_CONST( 1.0, 16 ) + SKP_RSHIFT_ROUND( SKP_MLA( SILK_FIX_CONST( INPUT_TILT, 26 ),
psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ), 10 );
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
psEncCtrl->GainsPre_Q14[ k ] = SKP_SMULWB( gain_mult_Q16, psEncCtrl->GainsPre_Q14[ k ] );
}
@ -362,55 +362,55 @@ void SKP_Silk_noise_shape_analysis_FIX(
/* Control low-frequency shaping and noise tilt */
/************************************************/
/* Less low frequency shaping for noisy inputs */
strength_Q16 = SKP_MUL( SKP_FIX_CONST( LOW_FREQ_SHAPING, 4 ), SKP_SMLAWB( SKP_FIX_CONST( 1.0, 12 ),
SKP_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SKP_FIX_CONST( 1.0, 15 ) ) );
strength_Q16 = SKP_MUL( SILK_FIX_CONST( LOW_FREQ_SHAPING, 4 ), SKP_SMLAWB( SILK_FIX_CONST( 1.0, 12 ),
SILK_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SILK_FIX_CONST( 1.0, 15 ) ) );
strength_Q16 = SKP_RSHIFT( SKP_MUL( strength_Q16, psEnc->sCmn.speech_activity_Q8 ), 8 );
if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
/* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */
/*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/
SKP_int fs_kHz_inv = SKP_DIV32_16( SKP_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz );
SKP_int fs_kHz_inv = SKP_DIV32_16( SILK_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz );
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
b_Q14 = fs_kHz_inv + SKP_DIV32_16( SKP_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] );
b_Q14 = fs_kHz_inv + SKP_DIV32_16( SILK_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] );
/* Pack two coefficients in one int32 */
psEncCtrl->LF_shp_Q14[ k ] = SKP_LSHIFT( SKP_FIX_CONST( 1.0, 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, b_Q14 ), 16 );
psEncCtrl->LF_shp_Q14[ k ] |= (SKP_uint16)( b_Q14 - SKP_FIX_CONST( 1.0, 14 ) );
psEncCtrl->LF_shp_Q14[ k ] = SKP_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, b_Q14 ), 16 );
psEncCtrl->LF_shp_Q14[ k ] |= (SKP_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) );
}
SKP_assert( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SKP_FIX_CONST( 0.5, 24 ) ); // Guarantees that second argument to SMULWB() is within range of an SKP_int16
Tilt_Q16 = - SKP_FIX_CONST( HP_NOISE_COEF, 16 ) -
SKP_SMULWB( SKP_FIX_CONST( 1.0, 16 ) - SKP_FIX_CONST( HP_NOISE_COEF, 16 ),
SKP_SMULWB( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) );
SKP_assert( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SILK_FIX_CONST( 0.5, 24 ) ); // Guarantees that second argument to SMULWB() is within range of an SKP_int16
Tilt_Q16 = - SILK_FIX_CONST( HP_NOISE_COEF, 16 ) -
SKP_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SILK_FIX_CONST( HP_NOISE_COEF, 16 ),
SKP_SMULWB( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) );
} else {
b_Q14 = SKP_DIV32_16( 21299, psEnc->sCmn.fs_kHz ); // 1.3_Q0 = 21299_Q14
/* Pack two coefficients in one int32 */
psEncCtrl->LF_shp_Q14[ 0 ] = SKP_LSHIFT( SKP_FIX_CONST( 1.0, 14 ) - b_Q14 -
SKP_SMULWB( strength_Q16, SKP_SMULWB( SKP_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 );
psEncCtrl->LF_shp_Q14[ 0 ] |= (SKP_uint16)( b_Q14 - SKP_FIX_CONST( 1.0, 14 ) );
psEncCtrl->LF_shp_Q14[ 0 ] = SKP_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 -
SKP_SMULWB( strength_Q16, SKP_SMULWB( SILK_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 );
psEncCtrl->LF_shp_Q14[ 0 ] |= (SKP_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) );
for( k = 1; k < psEnc->sCmn.nb_subfr; k++ ) {
psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ 0 ];
}
Tilt_Q16 = -SKP_FIX_CONST( HP_NOISE_COEF, 16 );
Tilt_Q16 = -SILK_FIX_CONST( HP_NOISE_COEF, 16 );
}
/****************************/
/* HARMONIC SHAPING CONTROL */
/****************************/
/* Control boosting of harmonic frequencies */
HarmBoost_Q16 = SKP_SMULWB( SKP_SMULWB( SKP_FIX_CONST( 1.0, 17 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ),
psEnc->LTPCorr_Q15 ), SKP_FIX_CONST( LOW_RATE_HARMONIC_BOOST, 16 ) );
HarmBoost_Q16 = SKP_SMULWB( SKP_SMULWB( SILK_FIX_CONST( 1.0, 17 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ),
psEnc->LTPCorr_Q15 ), SILK_FIX_CONST( LOW_RATE_HARMONIC_BOOST, 16 ) );
/* More harmonic boost for noisy input signals */
HarmBoost_Q16 = SKP_SMLAWB( HarmBoost_Q16,
SKP_FIX_CONST( 1.0, 16 ) - SKP_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), SKP_FIX_CONST( LOW_INPUT_QUALITY_HARMONIC_BOOST, 16 ) );
SILK_FIX_CONST( 1.0, 16 ) - SKP_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), SILK_FIX_CONST( LOW_INPUT_QUALITY_HARMONIC_BOOST, 16 ) );
if( USE_HARM_SHAPING && psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
/* More harmonic noise shaping for high bitrates or noisy input */
HarmShapeGain_Q16 = SKP_SMLAWB( SKP_FIX_CONST( HARMONIC_SHAPING, 16 ),
SKP_FIX_CONST( 1.0, 16 ) - SKP_SMULWB( SKP_FIX_CONST( 1.0, 18 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ),
psEncCtrl->input_quality_Q14 ), SKP_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) );
HarmShapeGain_Q16 = SKP_SMLAWB( SILK_FIX_CONST( HARMONIC_SHAPING, 16 ),
SILK_FIX_CONST( 1.0, 16 ) - SKP_SMULWB( SILK_FIX_CONST( 1.0, 18 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ),
psEncCtrl->input_quality_Q14 ), SILK_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) );
/* Less harmonic noise shaping for less periodic signals */
HarmShapeGain_Q16 = SKP_SMULWB( SKP_LSHIFT( HarmShapeGain_Q16, 1 ),
SKP_Silk_SQRT_APPROX( SKP_LSHIFT( psEnc->LTPCorr_Q15, 15 ) ) );
silk_SQRT_APPROX( SKP_LSHIFT( psEnc->LTPCorr_Q15, 15 ) ) );
} else {
HarmShapeGain_Q16 = 0;
}
@ -420,11 +420,11 @@ void SKP_Silk_noise_shape_analysis_FIX(
/*************************/
for( k = 0; k < MAX_NB_SUBFR; k++ ) {
psShapeSt->HarmBoost_smth_Q16 =
SKP_SMLAWB( psShapeSt->HarmBoost_smth_Q16, HarmBoost_Q16 - psShapeSt->HarmBoost_smth_Q16, SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
SKP_SMLAWB( psShapeSt->HarmBoost_smth_Q16, HarmBoost_Q16 - psShapeSt->HarmBoost_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
psShapeSt->HarmShapeGain_smth_Q16 =
SKP_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
SKP_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
psShapeSt->Tilt_smth_Q16 =
SKP_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
SKP_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
psEncCtrl->HarmBoost_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmBoost_smth_Q16, 2 );
psEncCtrl->HarmShapeGain_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 );

View file

@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/* SKP_Silk_prefilter. Prefilter for finding Quantizer input signal */
SKP_INLINE void SKP_Silk_prefilt_FIX(
SKP_Silk_prefilter_state_FIX *P, /* I/O state */
/* silk_prefilter. Prefilter for finding Quantizer input signal */
SKP_INLINE void silk_prefilt_FIX(
silk_prefilter_state_FIX *P, /* I/O state */
SKP_int32 st_res_Q12[], /* I short term residual signal */
SKP_int16 xw[], /* O prefiltered signal */
SKP_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
@ -40,7 +40,7 @@ SKP_INLINE void SKP_Silk_prefilt_FIX(
SKP_int length /* I Length of signals */
);
void SKP_Silk_warped_LPC_analysis_filter_FIX(
void silk_warped_LPC_analysis_filter_FIX(
SKP_int32 state[], /* I/O State [order + 1] */
SKP_int16 res[], /* O Residual signal [length] */
const SKP_int16 coef_Q13[], /* I Coefficients [order] */
@ -81,14 +81,14 @@ void SKP_Silk_warped_LPC_analysis_filter_FIX(
}
}
void SKP_Silk_prefilter_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
const SKP_Silk_encoder_control_FIX *psEncCtrl, /* I Encoder control FIX */
void silk_prefilter_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control FIX */
SKP_int16 xw[], /* O Weighted signal */
const SKP_int16 x[] /* I Speech signal */
)
{
SKP_Silk_prefilter_state_FIX *P = &psEnc->sPrefilt;
silk_prefilter_state_FIX *P = &psEnc->sPrefilt;
SKP_int j, k, lag;
SKP_int32 tmp_32;
const SKP_int16 *AR1_shp_Q13;
@ -120,13 +120,13 @@ void SKP_Silk_prefilter_FIX(
AR1_shp_Q13 = &psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER ];
/* Short term FIR filtering*/
SKP_Silk_warped_LPC_analysis_filter_FIX( P->sAR_shp, st_res, AR1_shp_Q13, px,
silk_warped_LPC_analysis_filter_FIX( P->sAR_shp, st_res, AR1_shp_Q13, px,
psEnc->sCmn.warping_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.shapingLPCOrder );
/* reduce (mainly) low frequencies during harmonic emphasis */
B_Q12[ 0 ] = SKP_RSHIFT_ROUND( psEncCtrl->GainsPre_Q14[ k ], 2 );
tmp_32 = SKP_SMLABB( SKP_FIX_CONST( INPUT_TILT, 26 ), psEncCtrl->HarmBoost_Q14[ k ], HarmShapeGain_Q12 ); /* Q26 */
tmp_32 = SKP_SMLABB( tmp_32, psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ); /* Q26 */
tmp_32 = SKP_SMLABB( SILK_FIX_CONST( INPUT_TILT, 26 ), psEncCtrl->HarmBoost_Q14[ k ], HarmShapeGain_Q12 ); /* Q26 */
tmp_32 = SKP_SMLABB( tmp_32, psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ); /* Q26 */
tmp_32 = SKP_SMULWB( tmp_32, -psEncCtrl->GainsPre_Q14[ k ] ); /* Q24 */
tmp_32 = SKP_RSHIFT_ROUND( tmp_32, 12 ); /* Q12 */
B_Q12[ 1 ]= SKP_SAT16( tmp_32 );
@ -137,7 +137,7 @@ void SKP_Silk_prefilter_FIX(
}
P->sHarmHP = st_res[ psEnc->sCmn.subfr_length - 1 ];
SKP_Silk_prefilt_FIX( P, x_filt_Q12, pxw, HarmShapeFIRPacked_Q12, Tilt_Q14,
silk_prefilt_FIX( P, x_filt_Q12, pxw, HarmShapeFIRPacked_Q12, Tilt_Q14,
LF_shp_Q14, lag, psEnc->sCmn.subfr_length );
px += psEnc->sCmn.subfr_length;
@ -147,9 +147,9 @@ void SKP_Silk_prefilter_FIX(
P->lagPrev = psEncCtrl->pitchL[ MAX_NB_SUBFR - 1 ];
}
/* SKP_Silk_prefilter. Prefilter for finding Quantizer input signal */
SKP_INLINE void SKP_Silk_prefilt_FIX(
SKP_Silk_prefilter_state_FIX *P, /* I/O state */
/* silk_prefilter. Prefilter for finding Quantizer input signal */
SKP_INLINE void silk_prefilt_FIX(
silk_prefilter_state_FIX *P, /* I/O state */
SKP_int32 st_res_Q12[], /* I short term residual signal */
SKP_int16 xw[], /* O prefiltered signal */
SKP_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */

View file

@ -25,23 +25,23 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/* Processing of gains */
void SKP_Silk_process_gains_FIX(
SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state_FIX */
SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control_FIX */
void silk_process_gains_FIX(
silk_encoder_state_FIX *psEnc, /* I/O Encoder state_FIX */
silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control_FIX */
)
{
SKP_Silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
SKP_int k;
SKP_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10;
/* Gain reduction when LTP coding gain is high */
if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
/*s = -0.5f * SKP_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) ); */
s_Q16 = -SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - SKP_FIX_CONST( 12.0, 7 ), 4 ) );
s_Q16 = -silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - SILK_FIX_CONST( 12.0, 7 ), 4 ) );
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
psEncCtrl->Gains_Q16[ k ] = SKP_SMLAWB( psEncCtrl->Gains_Q16[ k ], psEncCtrl->Gains_Q16[ k ], s_Q16 );
}
@ -49,8 +49,8 @@ void SKP_Silk_process_gains_FIX(
/* Limit the quantized signal */
/* InvMaxSqrVal = pow( 2.0f, 0.33f * ( 21.0f - SNR_dB ) ) / subfr_length; */
InvMaxSqrVal_Q16 = SKP_DIV32_16( SKP_Silk_log2lin(
SKP_SMULWB( SKP_FIX_CONST( 21 + 16 / 0.33, 7 ) - psEnc->sCmn.SNR_dB_Q7, SKP_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length );
InvMaxSqrVal_Q16 = SKP_DIV32_16( silk_log2lin(
SKP_SMULWB( SILK_FIX_CONST( 21 + 16 / 0.33, 7 ) - psEnc->sCmn.SNR_dB_Q7, SILK_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length );
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
/* Soft limit on ratio residual energy and squared gains */
@ -71,23 +71,23 @@ void SKP_Silk_process_gains_FIX(
/* recalculate with higher precision */
gain_squared = SKP_SMLAWW( SKP_LSHIFT( ResNrgPart, 16 ), gain, gain );
SKP_assert( gain_squared > 0 );
gain = SKP_Silk_SQRT_APPROX( gain_squared ); /* Q8 */
gain = silk_SQRT_APPROX( gain_squared ); /* Q8 */
gain = SKP_min( gain, SKP_int32_MAX >> 8 );
psEncCtrl->Gains_Q16[ k ] = SKP_LSHIFT_SAT32( gain, 8 ); /* Q16 */
} else {
gain = SKP_Silk_SQRT_APPROX( gain_squared ); /* Q0 */
gain = silk_SQRT_APPROX( gain_squared ); /* Q0 */
gain = SKP_min( gain, SKP_int32_MAX >> 16 );
psEncCtrl->Gains_Q16[ k ] = SKP_LSHIFT_SAT32( gain, 16 ); /* Q16 */
}
}
/* Noise shaping quantization */
SKP_Silk_gains_quant( psEnc->sCmn.indices.GainsIndices, psEncCtrl->Gains_Q16,
&psShapeSt->LastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr );
silk_gains_quant( psEnc->sCmn.indices.GainsIndices, psEncCtrl->Gains_Q16,
&psShapeSt->LastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr );
/* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */
if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEnc->sCmn.input_tilt_Q15, 8 ) > SKP_FIX_CONST( 1.0, 7 ) ) {
if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEnc->sCmn.input_tilt_Q15, 8 ) > SILK_FIX_CONST( 1.0, 7 ) ) {
psEnc->sCmn.indices.quantOffsetType = 0;
} else {
psEnc->sCmn.indices.quantOffsetType = 1;
@ -95,14 +95,14 @@ void SKP_Silk_process_gains_FIX(
}
/* Quantizer boundary adjustment */
quant_offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ];
psEncCtrl->Lambda_Q10 = SKP_FIX_CONST( LAMBDA_OFFSET, 10 )
+ SKP_SMULBB( SKP_FIX_CONST( LAMBDA_DELAYED_DECISIONS, 10 ), psEnc->sCmn.nStatesDelayedDecision )
+ SKP_SMULWB( SKP_FIX_CONST( LAMBDA_SPEECH_ACT, 18 ), psEnc->sCmn.speech_activity_Q8 )
+ SKP_SMULWB( SKP_FIX_CONST( LAMBDA_INPUT_QUALITY, 12 ), psEncCtrl->input_quality_Q14 )
+ SKP_SMULWB( SKP_FIX_CONST( LAMBDA_CODING_QUALITY, 12 ), psEncCtrl->coding_quality_Q14 )
+ SKP_SMULWB( SKP_FIX_CONST( LAMBDA_QUANT_OFFSET, 16 ), quant_offset_Q10 );
quant_offset_Q10 = silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ];
psEncCtrl->Lambda_Q10 = SILK_FIX_CONST( LAMBDA_OFFSET, 10 )
+ SKP_SMULBB( SILK_FIX_CONST( LAMBDA_DELAYED_DECISIONS, 10 ), psEnc->sCmn.nStatesDelayedDecision )
+ SKP_SMULWB( SILK_FIX_CONST( LAMBDA_SPEECH_ACT, 18 ), psEnc->sCmn.speech_activity_Q8 )
+ SKP_SMULWB( SILK_FIX_CONST( LAMBDA_INPUT_QUALITY, 12 ), psEncCtrl->input_quality_Q14 )
+ SKP_SMULWB( SILK_FIX_CONST( LAMBDA_CODING_QUALITY, 12 ), psEncCtrl->coding_quality_Q14 )
+ SKP_SMULWB( SILK_FIX_CONST( LAMBDA_QUANT_OFFSET, 16 ), quant_offset_Q10 );
SKP_assert( psEncCtrl->Lambda_Q10 > 0 );
SKP_assert( psEncCtrl->Lambda_Q10 < SKP_FIX_CONST( 2, 10 ) );
SKP_assert( psEncCtrl->Lambda_Q10 < SILK_FIX_CONST( 2, 10 ) );
}

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
/* Add noise to matrix diagonal */
void SKP_Silk_regularize_correlations_FIX(
void silk_regularize_correlations_FIX(
SKP_int32 *XX, /* I/O Correlation matrices */
SKP_int32 *xx, /* I/O Correlation values */
SKP_int32 noise, /* I Noise to add */

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
SKP_int32 SKP_Silk_residual_energy16_covar_FIX(
SKP_int32 silk_residual_energy16_covar_FIX(
const SKP_int16 *c, /* I Prediction vector */
const SKP_int32 *wXX, /* I Correlation matrix */
const SKP_int32 *wXx, /* I Correlation vector */
@ -55,10 +55,10 @@ SKP_int32 SKP_Silk_residual_energy16_covar_FIX(
for( i = 0; i < D; i++ ) {
c_max = SKP_max_32( c_max, SKP_abs( ( SKP_int32 )c[ i ] ) );
}
Qxtra = SKP_min_int( Qxtra, SKP_Silk_CLZ32( c_max ) - 17 );
Qxtra = SKP_min_int( Qxtra, silk_CLZ32( c_max ) - 17 );
w_max = SKP_max_32( wXX[ 0 ], wXX[ D * D - 1 ] );
Qxtra = SKP_min_int( Qxtra, SKP_Silk_CLZ32( SKP_MUL( D, SKP_RSHIFT( SKP_SMULWB( w_max, c_max ), 4 ) ) ) - 5 );
Qxtra = SKP_min_int( Qxtra, silk_CLZ32( SKP_MUL( D, SKP_RSHIFT( SKP_SMULWB( w_max, c_max ), 4 ) ) ) - 5 );
Qxtra = SKP_max_int( Qxtra, 0 );
for( i = 0; i < D; i++ ) {
cn[ i ] = SKP_LSHIFT( ( SKP_int )c[ i ], Qxtra );

View file

@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
/* Calculates residual energies of input subframes where all subframes have LPC_order */
/* of preceeding samples */
void SKP_Silk_residual_energy_FIX(
void silk_residual_energy_FIX(
SKP_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
SKP_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
const SKP_int16 x[], /* I Input signal */
const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
const SKP_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
const SKP_int subfr_length, /* I Subframe length */
const SKP_int nb_subfr, /* I Number of subframes */
@ -51,13 +51,13 @@ void SKP_Silk_residual_energy_FIX(
/* Filter input to create the LPC residual for each frame half, and measure subframe energies */
for( i = 0; i < nb_subfr >> 1; i++ ) {
/* Calculate half frame LPC residual signal including preceeding samples */
SKP_Silk_LPC_analysis_filter( LPC_res, x_ptr, a_Q12[ i ], ( MAX_NB_SUBFR >> 1 ) * offset, LPC_order );
silk_LPC_analysis_filter( LPC_res, x_ptr, a_Q12[ i ], ( MAX_NB_SUBFR >> 1 ) * offset, LPC_order );
/* Point to first subframe of the just calculated LPC residual signal */
LPC_res_ptr = LPC_res + LPC_order;
for( j = 0; j < ( MAX_NB_SUBFR >> 1 ); j++ ) {
/* Measure subframe energy */
SKP_Silk_sum_sqr_shift( &nrgs[ i * ( MAX_NB_SUBFR >> 1 ) + j ], &rshift, LPC_res_ptr, subfr_length );
silk_sum_sqr_shift( &nrgs[ i * ( MAX_NB_SUBFR >> 1 ) + j ], &rshift, LPC_res_ptr, subfr_length );
/* Set Q values for the measured energy */
nrgsQ[ i * ( MAX_NB_SUBFR >> 1 ) + j ] = -rshift;
@ -72,8 +72,8 @@ void SKP_Silk_residual_energy_FIX(
/* Apply the squared subframe gains */
for( i = 0; i < nb_subfr; i++ ) {
/* Fully upscale gains and energies */
lz1 = SKP_Silk_CLZ32( nrgs[ i ] ) - 1;
lz2 = SKP_Silk_CLZ32( gains[ i ] ) - 1;
lz1 = silk_CLZ32( nrgs[ i ] ) - 1;
lz2 = silk_CLZ32( gains[ i ] ) - 1;
tmp32 = SKP_LSHIFT32( gains[ i ], lz2 );

View file

@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FIX.h"
#include "silk_tuning_parameters.h"
/*****************************/
/* Internal function headers */
@ -38,7 +38,7 @@ typedef struct {
} inv_D_t;
/* Factorize square matrix A into LDL form */
SKP_INLINE void SKP_Silk_LDL_factorize_FIX(
SKP_INLINE void silk_LDL_factorize_FIX(
SKP_int32 *A, /* I/O Pointer to Symetric Square Matrix */
SKP_int M, /* I Size of Matrix */
SKP_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
@ -46,7 +46,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX(
);
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX(
SKP_INLINE void silk_LS_SolveFirst_FIX(
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
SKP_int M, /* I Dim of Matrix equation */
const SKP_int32 *b, /* I b Vector */
@ -54,21 +54,21 @@ SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX(
);
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
SKP_INLINE void SKP_Silk_LS_SolveLast_FIX(
SKP_INLINE void silk_LS_SolveLast_FIX(
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
const SKP_int M, /* I Dim of Matrix equation */
const SKP_int32 *b, /* I b Vector */
SKP_int32 *x_Q16 /* O x Vector */
);
SKP_INLINE void SKP_Silk_LS_divide_Q16_FIX(
SKP_INLINE void silk_LS_divide_Q16_FIX(
SKP_int32 T[], /* I/O Numenator vector */
inv_D_t *inv_D, /* I 1 / D vector */
SKP_int M /* I dimension */
);
/* Solves Ax = b, assuming A is symmetric */
void SKP_Silk_solve_LDL_FIX(
void silk_solve_LDL_FIX(
SKP_int32 *A, /* I Pointer to symetric square matrix A */
SKP_int M, /* I Size of matrix */
const SKP_int32 *b, /* I Pointer to b vector */
@ -85,27 +85,27 @@ void SKP_Silk_solve_LDL_FIX(
Factorize A by LDL such that A = L*D*L',
where L is lower triangular with ones on diagonal
****************************************************/
SKP_Silk_LDL_factorize_FIX( A, M, L_Q16, inv_D );
silk_LDL_factorize_FIX( A, M, L_Q16, inv_D );
/****************************************************
* substitute D*L'*x = Y. ie:
L*D*L'*x = b => L*Y = b <=> Y = inv(L)*b
******************************************************/
SKP_Silk_LS_SolveFirst_FIX( L_Q16, M, b, Y );
silk_LS_SolveFirst_FIX( L_Q16, M, b, Y );
/****************************************************
D*L'*x = Y <=> L'*x = inv(D)*Y, because D is
diagonal just multiply with 1/d_i
****************************************************/
SKP_Silk_LS_divide_Q16_FIX( Y, inv_D, M );
silk_LS_divide_Q16_FIX( Y, inv_D, M );
/****************************************************
x = inv(L') * inv(D) * Y
*****************************************************/
SKP_Silk_LS_SolveLast_FIX( L_Q16, M, Y, x_Q16 );
silk_LS_SolveLast_FIX( L_Q16, M, Y, x_Q16 );
}
SKP_INLINE void SKP_Silk_LDL_factorize_FIX(
SKP_INLINE void silk_LDL_factorize_FIX(
SKP_int32 *A, /* I Pointer to Symetric Square Matrix */
SKP_int M, /* I Size of Matrix */
SKP_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */
@ -121,7 +121,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX(
SKP_assert( M <= MAX_MATRIX_SIZE );
status = 1;
diag_min_value = SKP_max_32( SKP_SMMUL( SKP_ADD_SAT32( A[ 0 ], A[ SKP_SMULBB( M, M ) - 1 ] ), SKP_FIX_CONST( FIND_LTP_COND_FAC, 31 ) ), 1 << 9 );
diag_min_value = SKP_max_32( SKP_SMMUL( SKP_ADD_SAT32( A[ 0 ], A[ SKP_SMULBB( M, M ) - 1 ] ), SILK_FIX_CONST( FIND_LTP_COND_FAC, 31 ) ), 1 << 9 );
for( loop_count = 0; loop_count < M && status == 1; loop_count++ ) {
status = 0;
for( j = 0; j < M; j++ ) {
@ -145,7 +145,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX(
D_Q0[ j ] = tmp_32; /* always < max(Correlation) */
/* two-step division */
one_div_diag_Q36 = SKP_INVERSE32_varQ( tmp_32, 36 ); /* Q36 */
one_div_diag_Q36 = silk_INVERSE32_varQ( tmp_32, 36 ); /* Q36 */
one_div_diag_Q40 = SKP_LSHIFT( one_div_diag_Q36, 4 ); /* Q40 */
err = SKP_SUB32( 1 << 24, SKP_SMULWW( tmp_32, one_div_diag_Q40 ) ); /* Q24 */
one_div_diag_Q48 = SKP_SMULWW( err, one_div_diag_Q40 ); /* Q48 */
@ -177,7 +177,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX(
SKP_assert( status == 0 );
}
SKP_INLINE void SKP_Silk_LS_divide_Q16_FIX(
SKP_INLINE void silk_LS_divide_Q16_FIX(
SKP_int32 T[], /* I/O Numenator vector */
inv_D_t *inv_D, /* I 1 / D vector */
SKP_int M /* I Order */
@ -197,7 +197,7 @@ SKP_INLINE void SKP_Silk_LS_divide_Q16_FIX(
}
/* Solve Lx = b, when L is lower triangular and has ones on the diagonal */
SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX(
SKP_INLINE void silk_LS_SolveFirst_FIX(
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
SKP_int M, /* I Dim of Matrix equation */
const SKP_int32 *b, /* I b Vector */
@ -219,7 +219,7 @@ SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX(
}
/* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */
SKP_INLINE void SKP_Silk_LS_SolveLast_FIX(
SKP_INLINE void silk_LS_SolveLast_FIX(
const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */
const SKP_int M, /* I Dim of Matrix equation */
const SKP_int32 *b, /* I b Vector */

View file

@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef SKP_SILK_STRUCTS_FIX_H
#define SKP_SILK_STRUCTS_FIX_H
#ifndef SILK_STRUCTS_FIX_H
#define SILK_STRUCTS_FIX_H
#include "SKP_Silk_typedef.h"
#include "SKP_Silk_main.h"
#include "SKP_Silk_structs.h"
#include "silk_typedef.h"
#include "silk_main.h"
#include "silk_structs.h"
#ifdef __cplusplus
extern "C"
@ -45,7 +45,7 @@ typedef struct {
SKP_int32 HarmBoost_smth_Q16;
SKP_int32 HarmShapeGain_smth_Q16;
SKP_int32 Tilt_smth_Q16;
} SKP_Silk_shape_state_FIX;
} silk_shape_state_FIX;
/********************************/
/* Prefilter state */
@ -59,15 +59,15 @@ typedef struct {
SKP_int sHarmHP;
SKP_int32 rand_seed;
SKP_int lagPrev;
} SKP_Silk_prefilter_state_FIX;
} silk_prefilter_state_FIX;
/********************************/
/* Encoder state FIX */
/********************************/
typedef struct {
SKP_Silk_encoder_state sCmn; /* Common struct, shared with floating-point code */
SKP_Silk_shape_state_FIX sShape; /* Shape state */
SKP_Silk_prefilter_state_FIX sPrefilt; /* Prefilter State */
silk_encoder_state sCmn; /* Common struct, shared with floating-point code */
silk_shape_state_FIX sShape; /* Shape state */
silk_prefilter_state_FIX sPrefilt; /* Prefilter State */
/* Buffer for find pitch and noise shape analysis */
SKP_DWORD_ALIGN SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];
@ -76,7 +76,7 @@ typedef struct {
/* Parameters For LTP scaling Control */
SKP_int prevLTPredCodGain_Q7;
SKP_int HPLTPredCodGain_Q7;
} SKP_Silk_encoder_state_FIX;
} silk_encoder_state_FIX;
/************************/
/* Encoder control FIX */
@ -109,7 +109,19 @@ typedef struct {
SKP_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */
SKP_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */
} SKP_Silk_encoder_control_FIX;
} silk_encoder_control_FIX;
/************************/
/* Encoder Super Struct */
/************************/
typedef struct {
silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ];
stereo_enc_state sStereo;
SKP_int32 nBitsExceeded;
SKP_int nChannels;
SKP_int timeSinceSwitchAllowed_ms;
SKP_int allowBandwidthSwitch;
} silk_encoder;
#ifdef __cplusplus

View file

@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FIX.h"
#include "silk_main_FIX.h"
#define QC 10
#define QS 14
/* Autocorrelations for a warped frequency axis */
void SKP_Silk_warped_autocorrelation_FIX(
void silk_warped_autocorrelation_FIX(
SKP_int32 *corr, /* O Result [order + 1] */
SKP_int *scale, /* O Scaling of the correlation vector */
const SKP_int16 *input, /* I Input data to correlate */
@ -67,7 +67,7 @@ void SKP_Silk_warped_autocorrelation_FIX(
corr_QC[ order ] += SKP_RSHIFT64( SKP_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC );
}
lsh = SKP_Silk_CLZ64( corr_QC[ 0 ] ) - 35;
lsh = silk_CLZ64( corr_QC[ 0 ] ) - 35;
lsh = SKP_LIMIT( lsh, -12 - QC, 30 - QC );
*scale = -( QC + lsh );
SKP_assert( *scale >= -30 && *scale <= 12 );

View file

@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include <stdlib.h>
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
/*******************************************/
/* LPC analysis filter */
@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*******************************************/
/* 16th order LPC analysis filter, does not write first 16 samples */
void SKP_Silk_LPC_analysis_filter16_FLP(
void silk_LPC_analysis_filter16_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -74,7 +74,7 @@ void SKP_Silk_LPC_analysis_filter16_FLP(
}
/* 14th order LPC analysis filter, does not write first 14 samples */
void SKP_Silk_LPC_analysis_filter14_FLP(
void silk_LPC_analysis_filter14_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -110,7 +110,7 @@ void SKP_Silk_LPC_analysis_filter14_FLP(
}
/* 12th order LPC analysis filter, does not write first 12 samples */
void SKP_Silk_LPC_analysis_filter12_FLP(
void silk_LPC_analysis_filter12_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -144,7 +144,7 @@ void SKP_Silk_LPC_analysis_filter12_FLP(
}
/* 10th order LPC analysis filter, does not write first 10 samples */
void SKP_Silk_LPC_analysis_filter10_FLP(
void silk_LPC_analysis_filter10_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -176,7 +176,7 @@ void SKP_Silk_LPC_analysis_filter10_FLP(
}
/* 8th order LPC analysis filter, does not write first 8 samples */
void SKP_Silk_LPC_analysis_filter8_FLP(
void silk_LPC_analysis_filter8_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -206,7 +206,7 @@ void SKP_Silk_LPC_analysis_filter8_FLP(
}
/* 6th order LPC analysis filter, does not write first 6 samples */
void SKP_Silk_LPC_analysis_filter6_FLP(
void silk_LPC_analysis_filter6_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -240,7 +240,7 @@ void SKP_Silk_LPC_analysis_filter6_FLP(
/* first Order output samples are not set */
/*******************************************/
void SKP_Silk_LPC_analysis_filter_FLP(
void silk_LPC_analysis_filter_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -252,27 +252,27 @@ void SKP_Silk_LPC_analysis_filter_FLP(
switch( Order ) {
case 6:
SKP_Silk_LPC_analysis_filter6_FLP( r_LPC, PredCoef, s, length );
silk_LPC_analysis_filter6_FLP( r_LPC, PredCoef, s, length );
break;
case 8:
SKP_Silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length );
silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length );
break;
case 10:
SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length );
silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length );
break;
case 12:
SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length );
silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length );
break;
case 14:
SKP_Silk_LPC_analysis_filter14_FLP( r_LPC, PredCoef, s, length );
silk_LPC_analysis_filter14_FLP( r_LPC, PredCoef, s, length );
break;
case 16:
SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length );
silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length );
break;
default:

View file

@ -25,23 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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"
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FIX.h"
#include "silk_SigProc_FLP.h"
#define RC_THRESHOLD 0.9999f
/* compute inverse of LPC prediction gain, and */
/* test if LPC coefficients are stable (all poles within unit circle) */
/* this code is based on SKP_Silk_a2k_FLP() */
SKP_int SKP_Silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
/* this code is based on silk_a2k_FLP() */
SKP_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
SKP_float *invGain, /* O: inverse prediction gain, energy domain */
const SKP_float *A, /* I: prediction coefficients [order] */
SKP_int32 order /* I: prediction order */
@ -49,7 +41,7 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, oth
{
SKP_int k, n;
double rc, rc_mult1, rc_mult2;
SKP_float Atmp[ 2 ][ SKP_Silk_MAX_ORDER_LPC ];
SKP_float Atmp[ 2 ][ SILK_MAX_ORDER_LPC ];
SKP_float *Aold, *Anew;
Anew = Atmp[ order & 1 ];

View file

@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
void SKP_Silk_LTP_analysis_filter_FLP(
void silk_LTP_analysis_filter_FLP(
SKP_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
const SKP_float *x, /* I Input signal, with preceeding samples */
const SKP_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */

View file

@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
void SKP_Silk_LTP_scale_ctrl_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
void silk_LTP_scale_ctrl_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
)
{
SKP_int round_loss;
@ -41,12 +41,12 @@ void SKP_Silk_LTP_scale_ctrl_FLP(
psEnc->prevLTPredCodGain = psEncCtrl->LTPredCodGain;
/* Only scale if first frame in packet */
if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
if( psEnc->sCmn.nFramesEncoded == 0 ) {
round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket;
psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT( round_loss * psEnc->HPLTPredCodGain * 0.1f, 0.0f, 2.0f );
} else {
/* Default is minimum scaling */
psEnc->sCmn.indices.LTP_scaleIndex = 0;
}
psEncCtrl->LTP_scale = (SKP_float)SKP_Silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f;
psEncCtrl->LTP_scale = (SKP_float)silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f;
}

View file

@ -25,12 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef _SILK_SIGPROC_FLP_H_
#define _SILK_SIGPROC_FLP_H_
#ifndef _SKP_SILK_SIGPROC_FLP_H_
#define _SKP_SILK_SIGPROC_FLP_H_
#include "SKP_Silk_SigProc_FIX.h"
#include "float_cast.h"
#include "silk_SigProc_FIX.h"
#include <math.h>
#ifdef __cplusplus
@ -43,7 +41,7 @@ extern "C"
/********************************************************************/
/* Chirp (bw expand) LP AR filter */
void SKP_Silk_bwexpander_FLP(
void silk_bwexpander_FLP(
SKP_float *ar, /* io AR filter to be expanded (without leading 1) */
const SKP_int d, /* i length of ar */
const SKP_float chirp /* i chirp factor (typically in range (0..1) ) */
@ -51,34 +49,34 @@ void SKP_Silk_bwexpander_FLP(
/* compute inverse of LPC prediction gain, and */
/* test if LPC coefficients are stable (all poles within unit circle) */
/* this code is based on SKP_Silk_FLP_a2k() */
SKP_int SKP_Silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
/* this code is based on silk_FLP_a2k() */
SKP_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */
SKP_float *invGain, /* O: inverse prediction gain, energy domain */
const SKP_float *A, /* I: prediction coefficients [order] */
SKP_int32 order /* I: prediction order */
);
SKP_float SKP_Silk_schur_FLP( /* O returns residual energy */
SKP_float silk_schur_FLP( /* O returns residual energy */
SKP_float refl_coef[], /* O reflection coefficients (length order) */
const SKP_float auto_corr[], /* I autocorrelation sequence (length order+1) */
SKP_int order /* I order */
);
void SKP_Silk_k2a_FLP(
void silk_k2a_FLP(
SKP_float *A, /* O: prediction coefficients [order] */
const SKP_float *rc, /* I: reflection coefficients [order] */
SKP_int32 order /* I: prediction order */
);
/* Solve the normal equations using the Levinson-Durbin recursion */
SKP_float SKP_Silk_levinsondurbin_FLP( /* O prediction error energy */
SKP_float silk_levinsondurbin_FLP( /* O prediction error energy */
SKP_float A[], /* O prediction coefficients [order] */
const SKP_float corr[], /* I input auto-correlations [order + 1] */
const SKP_int order /* I prediction order */
);
/* compute autocorrelation */
void SKP_Silk_autocorrelation_FLP(
void silk_autocorrelation_FLP(
SKP_float *results, /* o result (length correlationCount) */
const SKP_float *inputData, /* i input data to correlate */
SKP_int inputDataSize, /* i length of input */
@ -90,7 +88,7 @@ void SKP_Silk_autocorrelation_FLP(
#define SigProc_PE_MID_COMPLEX 1
#define SigProc_PE_MAX_COMPLEX 2
SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
const SKP_float *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 */
@ -106,15 +104,15 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
#define PI (3.1415926536f)
void SKP_Silk_insertion_sort_decreasing_FLP(
void silk_insertion_sort_decreasing_FLP(
SKP_float *a, /* I/O: Unsorted / Sorted vector */
SKP_int *index, /* O: Index vector for the sorted elements */
SKP_int *idx, /* O: Index vector for the sorted elements */
const SKP_int L, /* I: Vector length */
const SKP_int K /* I: Number of correctly sorted positions */
);
/* Compute reflection coefficients from input signal */
SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy */
SKP_float silk_burg_modified_FLP( /* O returns residual energy */
SKP_float A[], /* O prediction coefficients (length order) */
const SKP_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
@ -124,14 +122,14 @@ SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy
);
/* multiply a vector by a constant */
void SKP_Silk_scale_vector_FLP(
void silk_scale_vector_FLP(
SKP_float *data1,
SKP_float gain,
SKP_int dataSize
);
/* copy and multiply a vector by a constant */
void SKP_Silk_scale_copy_vector_FLP(
void silk_scale_copy_vector_FLP(
SKP_float *data_out,
const SKP_float *data_in,
SKP_float gain,
@ -139,14 +137,14 @@ void SKP_Silk_scale_copy_vector_FLP(
);
/* inner product of two SKP_float arrays, with result as double */
double SKP_Silk_inner_product_FLP(
double silk_inner_product_FLP(
const SKP_float *data1,
const SKP_float *data2,
SKP_int dataSize
);
/* sum of squares of a SKP_float array, with result as double */
double SKP_Silk_energy_FLP(
double silk_energy_FLP(
const SKP_float *data,
SKP_int dataSize
);
@ -169,16 +167,15 @@ SKP_INLINE SKP_float SKP_sigmoid(SKP_float x)
}
/* floating-point to integer conversion (rounding) */
#if 1
/* use implementation in float_cast.h */
#define SKP_float2int(x) float2int(x)
#else
SKP_INLINE SKP_int32 SKP_float2int(SKP_float x)
SKP_INLINE SKP_int32 SKP_float2int(double x)
{
double y = x;
return (SKP_int32)( ( y > 0 ) ? y + 0.5 : y - 0.5 );
}
#ifdef _WIN32
double t = x + 6755399441055744.0;
return *((SKP_int32 *)( &t ));
#else
return (SKP_int32)( ( x > 0 ) ? x + 0.5 : x - 0.5 );
#endif
}
/* floating-point to integer conversion (rounding) */
SKP_INLINE void SKP_float2short_array(
@ -189,7 +186,13 @@ SKP_INLINE void SKP_float2short_array(
{
SKP_int32 k;
for (k = length-1; k >= 0; k--) {
out[k] = (SKP_int16)SKP_SAT16( float2int( in[k] ) );
#ifdef _WIN32
double t = in[k] + 6755399441055744.0;
out[k] = (SKP_int16)SKP_SAT16(*(( SKP_int32 * )( &t )));
#else
double x = in[k];
out[k] = (SKP_int16)SKP_SAT16( ( x > 0 ) ? x + 0.5 : x - 0.5 );
#endif
}
}
@ -206,7 +209,8 @@ SKP_INLINE void SKP_short2float_array(
}
}
#define SKP_round(x) (SKP_float)((x)>=0 ? (SKP_int64)((x)+0.5) : (SKP_int64)((x)-0.5))
/* using log2() helps the fixed-point conversion */
SKP_INLINE SKP_float silk_log2( double x ) { return ( SKP_float )( 3.32192809488736 * log10( x ) ); }
#ifdef __cplusplus
}

View file

@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.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 */
void SKP_Silk_apply_sine_window_FLP(
void silk_apply_sine_window_FLP(
SKP_float px_win[], /* O Pointer to windowed signal */
const SKP_float px[], /* I Pointer to input signal */
const SKP_int win_type, /* I Selects a window type */

View file

@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_typedef.h"
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_typedef.h"
#include "silk_SigProc_FLP.h"
/* compute autocorrelation */
void SKP_Silk_autocorrelation_FLP(
void silk_autocorrelation_FLP(
SKP_float *results, /* O result (length correlationCount) */
const SKP_float *inputData, /* I input data to correlate */
SKP_int inputDataSize, /* I length of input */
@ -43,6 +43,6 @@ void SKP_Silk_autocorrelation_FLP(
}
for( i = 0; i < correlationCount; i++ ) {
results[ i ] = (SKP_float)SKP_Silk_inner_product_FLP( inputData, inputData + i, inputDataSize - i );
results[ i ] = (SKP_float)silk_inner_product_FLP( inputData, inputData + i, inputDataSize - i );
}
}

View file

@ -25,23 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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: 091130 *
*/
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
#define MAX_FRAME_SIZE 384 // subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384
#define MAX_NB_SUBFR 4
/* Compute reflection coefficients from input signal */
SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy */
SKP_float silk_burg_modified_FLP( /* O returns residual energy */
SKP_float A[], /* O prediction coefficients (length order) */
const SKP_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */
const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */
@ -53,23 +43,23 @@ SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy
SKP_int k, n, s;
double C0, num, nrg_f, nrg_b, rc, Atmp, tmp1, tmp2;
const SKP_float *x_ptr;
double C_first_row[ SKP_Silk_MAX_ORDER_LPC ], C_last_row[ SKP_Silk_MAX_ORDER_LPC ];
double CAf[ SKP_Silk_MAX_ORDER_LPC + 1 ], CAb[ SKP_Silk_MAX_ORDER_LPC + 1 ];
double Af[ SKP_Silk_MAX_ORDER_LPC ];
double C_first_row[ SILK_MAX_ORDER_LPC ], C_last_row[ SILK_MAX_ORDER_LPC ];
double CAf[ SILK_MAX_ORDER_LPC + 1 ], CAb[ SILK_MAX_ORDER_LPC + 1 ];
double Af[ SILK_MAX_ORDER_LPC ];
SKP_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE );
SKP_assert( nb_subfr <= MAX_NB_SUBFR );
/* Compute autocorrelations, added over subframes */
C0 = SKP_Silk_energy_FLP( x, nb_subfr * subfr_length );
SKP_memset( C_first_row, 0, SKP_Silk_MAX_ORDER_LPC * sizeof( double ) );
C0 = silk_energy_FLP( x, nb_subfr * subfr_length );
SKP_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( double ) );
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_Silk_inner_product_FLP( x_ptr, x_ptr + n, subfr_length - n );
C_first_row[ n - 1 ] += silk_inner_product_FLP( x_ptr, x_ptr + n, subfr_length - n );
}
}
SKP_memcpy( C_last_row, C_first_row, SKP_Silk_MAX_ORDER_LPC * sizeof( double ) );
SKP_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( double ) );
/* Initialize */
CAb[ 0 ] = CAf[ 0 ] = C0 + WhiteNoiseFrac * C0 + 1e-9f;

View file

@ -26,11 +26,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
/* Chirp (bw expand) LP AR filter */
void SKP_Silk_bwexpander_FLP(
void silk_bwexpander_FLP(
SKP_float *ar, /* I/O AR filter to be expanded (without leading 1) */
const SKP_int d, /* I length of ar */
const SKP_float chirp /* I chirp factor (typically in range (0..1) ) */

View file

@ -29,10 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Correlation matrix computations for LS estimate.
**********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
/* Calculates correlation vector X'*t */
void SKP_Silk_corrVector_FLP(
void silk_corrVector_FLP(
const SKP_float *x, /* I x vector [L+order-1] used to create X */
const SKP_float *t, /* I Target vector [L] */
const SKP_int L, /* I Length of vecors */
@ -46,13 +46,13 @@ void SKP_Silk_corrVector_FLP(
ptr1 = &x[ Order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] */
for( lag = 0; lag < Order; lag++ ) {
/* Calculate X[:,lag]'*t */
Xt[ lag ] = (SKP_float)SKP_Silk_inner_product_FLP( ptr1, t, L );
Xt[ lag ] = (SKP_float)silk_inner_product_FLP( ptr1, t, L );
ptr1--; /* Next column of X */
}
}
/* Calculates correlation matrix X'*X */
void SKP_Silk_corrMatrix_FLP(
void silk_corrMatrix_FLP(
const SKP_float *x, /* I x vector [ L+order-1 ] used to create X */
const SKP_int L, /* I Length of vectors */
const SKP_int Order, /* I Max lag for correlation */
@ -64,7 +64,7 @@ void SKP_Silk_corrMatrix_FLP(
const SKP_float *ptr1, *ptr2;
ptr1 = &x[ Order - 1 ]; /* First sample of column 0 of X */
energy = SKP_Silk_energy_FLP( ptr1, L ); /* X[:,0]'*X[:,0] */
energy = silk_energy_FLP( ptr1, L ); /* X[:,0]'*X[:,0] */
matrix_ptr( XX, 0, 0, Order ) = ( SKP_float )energy;
for( j = 1; j < Order; j++ ) {
/* Calculate X[:,j]'*X[:,j] */
@ -75,7 +75,7 @@ void SKP_Silk_corrMatrix_FLP(
ptr2 = &x[ Order - 2 ]; /* First sample of column 1 of X */
for( lag = 1; lag < Order; lag++ ) {
/* Calculate X[:,0]'*X[:,lag] */
energy = SKP_Silk_inner_product_FLP( ptr1, ptr2, L );
energy = silk_inner_product_FLP( ptr1, ptr2, L );
matrix_ptr( XX, lag, 0, Order ) = ( SKP_float )energy;
matrix_ptr( XX, 0, lag, Order ) = ( SKP_float )energy;
/* Calculate X[:,j]'*X[:,j + lag] */

View file

@ -25,22 +25,21 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
/****************/
/* Encode frame */
/****************/
SKP_int SKP_Silk_encode_frame_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_int silk_encode_frame_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_int32 *pnBytesOut, /* O Number of payload bytes */
ec_enc *psRangeEnc /* I/O compressor data structure */
)
{
SKP_Silk_encoder_control_FLP sEncCtrl;
silk_encoder_control_FLP sEncCtrl;
SKP_int i, ret = 0;
SKP_float *x_frame, *res_pitch_frame;
SKP_int16 pIn_HP[ MAX_FRAME_LENGTH ];
SKP_float xfw[ MAX_FRAME_LENGTH ];
SKP_float res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];
@ -59,16 +58,16 @@ TIC(ENCODE_FRAME)
/* Voice Activity Detection */
/****************************/
TIC(VAD)
ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf );
ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf - 1 );
TOC(VAD)
/**************************************************/
/* Convert speech activity into VAD and DTX flags */
/**************************************************/
if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
if( psEnc->sCmn.nFramesEncoded == 0 ) {
psEnc->sCmn.inDTX = psEnc->sCmn.useDTX;
}
if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {
if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {
psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY;
psEnc->sCmn.noSpeechCounter++;
if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) {
@ -77,28 +76,23 @@ TOC(VAD)
psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX;
psEnc->sCmn.inDTX = 0;
}
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 0;
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 0;
} else {
psEnc->sCmn.noSpeechCounter = 0;
psEnc->sCmn.inDTX = 0;
psEnc->sCmn.indices.signalType = TYPE_UNVOICED;
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 1;
}
/*******************************************/
/* High-pass filtering of the input signal */
/*******************************************/
TIC(HP_IN)
SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, pIn_HP, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length );
TOC(HP_IN)
/***************************************/
/* Ensure smooth bandwidth transitions */
SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, pIn_HP, psEnc->sCmn.frame_length );
/***************************************/
silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length );
/*******************************************/
/* Copy new frame to front of input buffer */
/*******************************************/
SKP_short2float_array( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, pIn_HP, psEnc->sCmn.frame_length );
SKP_short2float_array( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length );
/* Add tiny signal to avoid high CPU load from denormalized floating point numbers */
for( i = 0; i < 8; i++ ) {
@ -109,49 +103,49 @@ TOC(HP_IN)
/* Find pitch lags, initial LPC analysis */
/*****************************************/
TIC(FIND_PITCH)
SKP_Silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame );
silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame );
TOC(FIND_PITCH)
/************************/
/* Noise shape analysis */
/************************/
TIC(NOISE_SHAPE_ANALYSIS)
SKP_Silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame );
TOC(NOISE_SHAPE_ANALYSIS)
/***************************************************/
/* Find linear prediction coefficients (LPC + LTP) */
/***************************************************/
TIC(FIND_PRED_COEF)
SKP_Silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame );
silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame );
TOC(FIND_PRED_COEF)
/****************************************/
/* Process gains */
/****************************************/
TIC(PROCESS_GAINS)
SKP_Silk_process_gains_FLP( psEnc, &sEncCtrl );
silk_process_gains_FLP( psEnc, &sEncCtrl );
TOC(PROCESS_GAINS)
/****************************************/
/* Low Bitrate Redundant Encoding */
/****************************************/
TIC(LBRR)
SKP_Silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw );
TOC(LBRR)
/*****************************************/
/* Prefiltering for noise shaper */
/*****************************************/
TIC(PREFILTER)
SKP_Silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame );
silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame );
TOC(PREFILTER)
/****************************************/
/* Low Bitrate Redundant Encoding */
/****************************************/
TIC(LBRR)
silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw );
TOC(LBRR)
/*****************************************/
/* Noise shaping quantization */
/*****************************************/
TIC(NSQ)
SKP_Silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw );
silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw );
TOC(NSQ)
/* Update input buffer */
@ -173,14 +167,14 @@ TOC(NSQ)
/* Encode Parameters */
/****************************************/
TIC(ENCODE_PARAMS)
SKP_Silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesAnalyzed, 0 );
silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0 );
TOC(ENCODE_PARAMS)
/****************************************/
/* Encode Excitation Signal */
/****************************************/
TIC(ENCODE_PULSES)
SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType,
psEnc->sCmn.pulses, psEnc->sCmn.frame_length );
TOC(ENCODE_PULSES)
@ -188,12 +182,12 @@ TOC(ENCODE_PULSES)
/* Finalize payload */
/****************************************/
psEnc->sCmn.first_frame_after_reset = 0;
if( ++psEnc->sCmn.nFramesAnalyzed >= psEnc->sCmn.nFramesPerPacket ) {
if( ++psEnc->sCmn.nFramesEncoded >= psEnc->sCmn.nFramesPerPacket ) {
/* Payload size */
*pnBytesOut = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
/* Reset the number of frames in payload buffer */
psEnc->sCmn.nFramesAnalyzed = 0;
psEnc->sCmn.nFramesEncoded = 0;
} else {
/* No payload this time */
*pnBytesOut = 0;
@ -222,32 +216,32 @@ TOC(ENCODE_FRAME)
}
/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */
void SKP_Silk_LBRR_encode_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_LBRR_encode_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
const SKP_float xfw[] /* I Input signal */
)
{
SKP_int k;
SKP_int32 Gains_Q16[ MAX_NB_SUBFR ];
SKP_float TempGains[ MAX_NB_SUBFR ];
SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesAnalyzed ];
SKP_Silk_nsq_state sNSQ_LBRR;
SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ];
silk_nsq_state sNSQ_LBRR;
/*******************************************/
/* Control use of inband LBRR */
/*******************************************/
if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {
psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;
if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {
psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1;
/* Copy noise shaping quantizer state and quantization indices from regular encoding */
SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( SKP_Silk_nsq_state ) );
SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) );
SKP_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) );
/* Save original gains */
SKP_memcpy( TempGains, psEncCtrl->Gains, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );
if( psEnc->sCmn.nFramesAnalyzed == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed - 1 ] == 0 ) {
if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) {
/* First frame in packet or previous frame not LBRR coded */
psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex;
@ -257,19 +251,19 @@ void SKP_Silk_LBRR_encode_FLP(
}
/* Decode to get gains in sync with decoder */
SKP_Silk_gains_dequant( Gains_Q16, psIndices_LBRR->GainsIndices,
&psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr );
silk_gains_dequant( Gains_Q16, psIndices_LBRR->GainsIndices,
&psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr );
/* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
psEncCtrl->Gains[ k ] = Gains_Q16[ k ] / 65536.0f;
psEncCtrl->Gains[ k ] = Gains_Q16[ k ] * ( 1.0f / 65536.0f );
}
/*****************************************/
/* Noise shaping quantization */
/*****************************************/
SKP_Silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, psIndices_LBRR, &sNSQ_LBRR,
psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesAnalyzed ], xfw );
silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, psIndices_LBRR, &sNSQ_LBRR,
psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], xfw );
/* Restore original gains */
SKP_memcpy( psEncCtrl->Gains, TempGains, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
/* sum of squares of a SKP_float array, with result as double */
double SKP_Silk_energy_FLP(
double silk_energy_FLP(
const SKP_float *data,
SKP_int dataSize
)

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
void SKP_Silk_find_LPC_FLP(
void silk_find_LPC_FLP(
SKP_int16 NLSF_Q15[], /* O NLSFs */
SKP_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
const SKP_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
@ -53,39 +53,39 @@ void SKP_Silk_find_LPC_FLP(
*interpIndex = 4;
/* Burg AR analysis for the full frame */
res_nrg = SKP_Silk_burg_modified_FLP( a, x, subfr_length, nb_subfr, FIND_LPC_COND_FAC, LPC_order );
res_nrg = silk_burg_modified_FLP( a, x, subfr_length, nb_subfr, FIND_LPC_COND_FAC, LPC_order );
if( firstFrameAfterReset ) {
SKP_Silk_bwexpander_FLP( a, LPC_order, FIND_LPC_CHIRP_FIRST_FRAME );
silk_bwexpander_FLP( a, LPC_order, FIND_LPC_CHIRP_FIRST_FRAME );
} else {
SKP_Silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP );
silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP );
}
if( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) {
/* Optimal solution for last 10 ms; subtract residual energy here, as that's easier than */
/* adding it to the residual energy of the first 10 ms in each iteration of the search below */
res_nrg -= SKP_Silk_burg_modified_FLP( a_tmp, x + ( MAX_NB_SUBFR / 2 ) * subfr_length,
res_nrg -= silk_burg_modified_FLP( a_tmp, x + ( MAX_NB_SUBFR / 2 ) * subfr_length,
subfr_length, MAX_NB_SUBFR / 2, FIND_LPC_COND_FAC, LPC_order );
SKP_Silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP );
silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP );
/* Convert to NLSFs */
SKP_Silk_A2NLSF_FLP( NLSF_Q15, a_tmp, LPC_order );
silk_A2NLSF_FLP( NLSF_Q15, a_tmp, LPC_order );
/* Search over interpolation indices to find the one with lowest residual energy */
res_nrg_2nd = SKP_float_MAX;
for( k = 3; k >= 0; k-- ) {
/* Interpolate NLSFs for first half */
SKP_Silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order );
silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order );
/* Convert to LPC for residual energy evaluation */
SKP_Silk_NLSF2A_stable_FLP( a_tmp, NLSF0_Q15, LPC_order );
silk_NLSF2A_stable_FLP( a_tmp, NLSF0_Q15, LPC_order );
/* Calculate residual energy with LSF interpolation */
SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a_tmp, x, 2 * subfr_length, LPC_order );
silk_LPC_analysis_filter_FLP( LPC_res, a_tmp, x, 2 * subfr_length, LPC_order );
res_nrg_interp =
SKP_Silk_energy_FLP( LPC_res + LPC_order, subfr_length - LPC_order ) +
SKP_Silk_energy_FLP( LPC_res + LPC_order + subfr_length, subfr_length - LPC_order );
silk_energy_FLP( LPC_res + LPC_order, subfr_length - LPC_order ) +
silk_energy_FLP( LPC_res + LPC_order + subfr_length, subfr_length - LPC_order );
/* Determine whether current interpolated NLSFs are best so far */
if( res_nrg_interp < res_nrg ) {
@ -102,7 +102,7 @@ void SKP_Silk_find_LPC_FLP(
if( *interpIndex == 4 ) {
/* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */
SKP_Silk_A2NLSF_FLP( NLSF_Q15, a, LPC_order );
silk_A2NLSF_FLP( NLSF_Q15, a, LPC_order );
}
SKP_assert( *interpIndex == 4 || ( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) );

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
void SKP_Silk_find_LTP_FLP(
void silk_find_LTP_FLP(
SKP_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
SKP_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
SKP_float *LTPredCodGain, /* O LTP coding gain */
@ -54,22 +54,22 @@ void SKP_Silk_find_LTP_FLP(
for( k = 0; k < nb_subfr; k++ ) {
lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 );
SKP_Silk_corrMatrix_FLP( lag_ptr, subfr_length, LTP_ORDER, WLTP_ptr );
SKP_Silk_corrVector_FLP( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr );
silk_corrMatrix_FLP( lag_ptr, subfr_length, LTP_ORDER, WLTP_ptr );
silk_corrVector_FLP( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr );
rr[ k ] = ( SKP_float )SKP_Silk_energy_FLP( r_ptr, subfr_length );
rr[ k ] = ( SKP_float )silk_energy_FLP( r_ptr, subfr_length );
regu = 1.0f + rr[ k ] +
matrix_ptr( WLTP_ptr, 0, 0, LTP_ORDER ) +
matrix_ptr( WLTP_ptr, LTP_ORDER-1, LTP_ORDER-1, LTP_ORDER );
regu *= LTP_DAMPING / 3;
SKP_Silk_regularize_correlations_FLP( WLTP_ptr, &rr[ k ], regu, LTP_ORDER );
SKP_Silk_solve_LDL_FLP( WLTP_ptr, LTP_ORDER, Rr, b_ptr );
silk_regularize_correlations_FLP( WLTP_ptr, &rr[ k ], regu, LTP_ORDER );
silk_solve_LDL_FLP( WLTP_ptr, LTP_ORDER, Rr, b_ptr );
/* Calculate residual energy */
nrg[ k ] = SKP_Silk_residual_energy_covar_FLP( b_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER );
nrg[ k ] = silk_residual_energy_covar_FLP( b_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER );
temp = Wght[ k ] / ( nrg[ k ] * Wght[ k ] + 0.01f * subfr_length );
SKP_Silk_scale_vector_FLP( WLTP_ptr, temp, LTP_ORDER * LTP_ORDER );
silk_scale_vector_FLP( WLTP_ptr, temp, LTP_ORDER * LTP_ORDER );
w[ k ] = matrix_ptr( WLTP_ptr, LTP_ORDER / 2, LTP_ORDER / 2, LTP_ORDER );
r_ptr += subfr_length;
@ -87,7 +87,7 @@ void SKP_Silk_find_LTP_FLP(
}
SKP_assert( LPC_LTP_res_nrg > 0 );
*LTPredCodGain = 3.0f * SKP_Silk_log2( LPC_res_nrg / LPC_LTP_res_nrg );
*LTPredCodGain = 3.0f * silk_log2( LPC_res_nrg / LPC_LTP_res_nrg );
}
/* Smoothing */

View file

@ -26,12 +26,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include <stdlib.h>
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
void SKP_Silk_find_pitch_lags_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_find_pitch_lags_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
SKP_float res[], /* O Residual */
const SKP_float x[] /* I Speech signal */
)
@ -64,7 +64,7 @@ void SKP_Silk_find_pitch_lags_FLP(
/* First LA_LTP samples */
x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length;
Wsig_ptr = Wsig;
SKP_Silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );
silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );
/* Middle non-windowed samples */
Wsig_ptr += psEnc->sCmn.la_pitch;
@ -74,30 +74,30 @@ void SKP_Silk_find_pitch_lags_FLP(
/* Last LA_LTP samples */
Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 );
x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 );
SKP_Silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );
silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );
/* Calculate autocorrelation sequence */
SKP_Silk_autocorrelation_FLP( auto_corr, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 );
silk_autocorrelation_FLP( auto_corr, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 );
/* Add white noise, as a fraction of the energy */
auto_corr[ 0 ] += auto_corr[ 0 ] * FIND_PITCH_WHITE_NOISE_FRACTION + 1;
/* Calculate the reflection coefficients using Schur */
res_nrg = SKP_Silk_schur_FLP( refl_coef, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder );
res_nrg = silk_schur_FLP( refl_coef, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder );
/* Prediction gain */
psEncCtrl->predGain = auto_corr[ 0 ] / SKP_max_float( res_nrg, 1.0f );
/* Convert reflection coefficients to prediction coefficients */
SKP_Silk_k2a_FLP( A, refl_coef, psEnc->sCmn.pitchEstimationLPCOrder );
silk_k2a_FLP( A, refl_coef, psEnc->sCmn.pitchEstimationLPCOrder );
/* Bandwidth expansion */
SKP_Silk_bwexpander_FLP( A, psEnc->sCmn.pitchEstimationLPCOrder, FIND_PITCH_BANDWITH_EXPANSION );
silk_bwexpander_FLP( A, psEnc->sCmn.pitchEstimationLPCOrder, FIND_PITCH_BANDWITH_EXPANSION );
/*****************************************/
/* LPC analysis filtering */
/*****************************************/
SKP_Silk_LPC_analysis_filter_FLP( res, A, x_buf, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );
silk_LPC_analysis_filter_FLP( res, A, x_buf, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );
if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) {
/* Threshold for pitch estimator */
@ -110,7 +110,7 @@ void SKP_Silk_find_pitch_lags_FLP(
/*****************************************/
/* Call Pitch estimator */
/*****************************************/
if( SKP_Silk_pitch_analysis_core_FLP( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex,
if( silk_pitch_analysis_core_FLP( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex,
&psEnc->sCmn.indices.contourIndex, &psEnc->LTPCorr, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16 / 65536.0f,
thrhld, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 )
{

View file

@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
void SKP_Silk_find_pred_coefs_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_find_pred_coefs_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
const SKP_float res_pitch[], /* I Residual from pitch analysis */
const SKP_float x[] /* I Speech signal */
)
@ -56,7 +56,7 @@ void SKP_Silk_find_pred_coefs_FLP(
SKP_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >= psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 );
/* LTP analysis */
SKP_Silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain, res_pitch,
silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain, res_pitch,
psEncCtrl->pitchL, Wght, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length );
#ifdef SAVE_ALL_INTERNAL_DATA
@ -65,14 +65,14 @@ void SKP_Silk_find_pred_coefs_FLP(
#endif
/* Quantize LTP gain parameters */
SKP_Silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex,
silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex,
WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr );
/* Control LTP scaling */
SKP_Silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl );
silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl );
/* Create LTP residual */
SKP_Silk_LTP_analysis_filter_FLP( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef,
silk_LTP_analysis_filter_FLP( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef,
psEncCtrl->pitchL, invGains, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder );
} else {
@ -83,7 +83,7 @@ void SKP_Silk_find_pred_coefs_FLP(
x_ptr = x - psEnc->sCmn.predictLPCOrder;
x_pre_ptr = LPC_in_pre;
for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
SKP_Silk_scale_copy_vector_FLP( x_pre_ptr, x_ptr, invGains[ i ],
silk_scale_copy_vector_FLP( x_pre_ptr, x_ptr, invGains[ i ],
psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder );
x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder;
x_ptr += psEnc->sCmn.subfr_length;
@ -94,17 +94,17 @@ void SKP_Silk_find_pred_coefs_FLP(
}
/* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */
SKP_Silk_find_LPC_FLP( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15,
silk_find_LPC_FLP( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15,
psEnc->sCmn.useInterpolatedNLSFs, psEnc->sCmn.first_frame_after_reset, psEnc->sCmn.predictLPCOrder,
LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );
/* Quantize LSFs */
TIC(LSF_quant);
SKP_Silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );
TOC(LSF_quant);
/* Calculate residual energy using quantized LPC coefficients */
SKP_Silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains,
silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains,
psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder );
/* Copy to prediction struct for use in next frame for fluctuation reduction */

View file

@ -86,43 +86,43 @@
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="SKP_Silk_apply_sine_window_FLP.c" />
<ClCompile Include="SKP_Silk_autocorrelation_FLP.c" />
<ClCompile Include="SKP_Silk_burg_modified_FLP.c" />
<ClCompile Include="SKP_Silk_bwexpander_FLP.c" />
<ClCompile Include="SKP_Silk_corrMatrix_FLP.c" />
<ClCompile Include="SKP_Silk_encode_frame_FLP.c" />
<ClCompile Include="SKP_Silk_energy_FLP.c" />
<ClCompile Include="SKP_Silk_find_LPC_FLP.c" />
<ClCompile Include="SKP_Silk_find_LTP_FLP.c" />
<ClCompile Include="SKP_Silk_find_pitch_lags_FLP.c" />
<ClCompile Include="SKP_Silk_find_pred_coefs_FLP.c" />
<ClCompile Include="SKP_Silk_inner_product_FLP.c" />
<ClCompile Include="SKP_Silk_k2a_FLP.c" />
<ClCompile Include="SKP_Silk_levinsondurbin_FLP.c" />
<ClCompile Include="SKP_Silk_LPC_analysis_filter_FLP.c" />
<ClCompile Include="SKP_Silk_LPC_inv_pred_gain_FLP.c" />
<ClCompile Include="SKP_Silk_LTP_analysis_filter_FLP.c" />
<ClCompile Include="SKP_Silk_LTP_scale_ctrl_FLP.c" />
<ClCompile Include="SKP_Silk_noise_shape_analysis_FLP.c" />
<ClCompile Include="SKP_Silk_pitch_analysis_core_FLP.c" />
<ClCompile Include="SKP_Silk_prefilter_FLP.c" />
<ClCompile Include="SKP_Silk_process_gains_FLP.c" />
<ClCompile Include="SKP_Silk_regularize_correlations_FLP.c" />
<ClCompile Include="SKP_Silk_residual_energy_FLP.c" />
<ClCompile Include="SKP_Silk_scale_copy_vector_FLP.c" />
<ClCompile Include="SKP_Silk_scale_vector_FLP.c" />
<ClCompile Include="SKP_Silk_schur_FLP.c" />
<ClCompile Include="SKP_Silk_solve_LS_FLP.c" />
<ClCompile Include="SKP_Silk_sort_FLP.c" />
<ClCompile Include="SKP_Silk_warped_autocorrelation_FLP.c" />
<ClCompile Include="SKP_Silk_wrappers_FLP.c" />
<ClCompile Include="silk_apply_sine_window_FLP.c" />
<ClCompile Include="silk_autocorrelation_FLP.c" />
<ClCompile Include="silk_burg_modified_FLP.c" />
<ClCompile Include="silk_bwexpander_FLP.c" />
<ClCompile Include="silk_corrMatrix_FLP.c" />
<ClCompile Include="silk_encode_frame_FLP.c" />
<ClCompile Include="silk_energy_FLP.c" />
<ClCompile Include="silk_find_LPC_FLP.c" />
<ClCompile Include="silk_find_LTP_FLP.c" />
<ClCompile Include="silk_find_pitch_lags_FLP.c" />
<ClCompile Include="silk_find_pred_coefs_FLP.c" />
<ClCompile Include="silk_inner_product_FLP.c" />
<ClCompile Include="silk_k2a_FLP.c" />
<ClCompile Include="silk_levinsondurbin_FLP.c" />
<ClCompile Include="silk_LPC_analysis_filter_FLP.c" />
<ClCompile Include="silk_LPC_inv_pred_gain_FLP.c" />
<ClCompile Include="silk_LTP_analysis_filter_FLP.c" />
<ClCompile Include="silk_LTP_scale_ctrl_FLP.c" />
<ClCompile Include="silk_noise_shape_analysis_FLP.c" />
<ClCompile Include="silk_pitch_analysis_core_FLP.c" />
<ClCompile Include="silk_prefilter_FLP.c" />
<ClCompile Include="silk_process_gains_FLP.c" />
<ClCompile Include="silk_regularize_correlations_FLP.c" />
<ClCompile Include="silk_residual_energy_FLP.c" />
<ClCompile Include="silk_scale_copy_vector_FLP.c" />
<ClCompile Include="silk_scale_vector_FLP.c" />
<ClCompile Include="silk_schur_FLP.c" />
<ClCompile Include="silk_solve_LS_FLP.c" />
<ClCompile Include="silk_sort_FLP.c" />
<ClCompile Include="silk_warped_autocorrelation_FLP.c" />
<ClCompile Include="silk_wrappers_FLP.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\win32\config.h" />
<ClInclude Include="SKP_Silk_main_FLP.h" />
<ClInclude Include="SKP_Silk_SigProc_FLP.h" />
<ClInclude Include="SKP_Silk_structs_FLP.h" />
<ClInclude Include="silk_main_FLP.h" />
<ClInclude Include="silk_SigProc_FLP.h" />
<ClInclude Include="silk_structs_FLP.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -18,112 +18,112 @@
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="SKP_Silk_LPC_analysis_filter_FLP.c">
<ClCompile Include="silk_apply_sine_window_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_LPC_inv_pred_gain_FLP.c">
<ClCompile Include="silk_autocorrelation_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_LTP_analysis_filter_FLP.c">
<ClCompile Include="silk_burg_modified_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_LTP_scale_ctrl_FLP.c">
<ClCompile Include="silk_bwexpander_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_noise_shape_analysis_FLP.c">
<ClCompile Include="silk_corrMatrix_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_pitch_analysis_core_FLP.c">
<ClCompile Include="silk_encode_frame_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_prefilter_FLP.c">
<ClCompile Include="silk_energy_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_process_gains_FLP.c">
<ClCompile Include="silk_find_LPC_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_regularize_correlations_FLP.c">
<ClCompile Include="silk_find_LTP_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_residual_energy_FLP.c">
<ClCompile Include="silk_find_pitch_lags_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_scale_copy_vector_FLP.c">
<ClCompile Include="silk_find_pred_coefs_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_scale_vector_FLP.c">
<ClCompile Include="silk_inner_product_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_schur_FLP.c">
<ClCompile Include="silk_k2a_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_solve_LS_FLP.c">
<ClCompile Include="silk_levinsondurbin_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_sort_FLP.c">
<ClCompile Include="silk_LPC_analysis_filter_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_warped_autocorrelation_FLP.c">
<ClCompile Include="silk_LPC_inv_pred_gain_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_wrappers_FLP.c">
<ClCompile Include="silk_LTP_analysis_filter_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_apply_sine_window_FLP.c">
<ClCompile Include="silk_LTP_scale_ctrl_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_autocorrelation_FLP.c">
<ClCompile Include="silk_noise_shape_analysis_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_burg_modified_FLP.c">
<ClCompile Include="silk_pitch_analysis_core_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_bwexpander_FLP.c">
<ClCompile Include="silk_prefilter_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_corrMatrix_FLP.c">
<ClCompile Include="silk_process_gains_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_encode_frame_FLP.c">
<ClCompile Include="silk_regularize_correlations_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_energy_FLP.c">
<ClCompile Include="silk_residual_energy_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_LPC_FLP.c">
<ClCompile Include="silk_scale_copy_vector_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_LTP_FLP.c">
<ClCompile Include="silk_scale_vector_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_pitch_lags_FLP.c">
<ClCompile Include="silk_schur_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_find_pred_coefs_FLP.c">
<ClCompile Include="silk_solve_LS_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_inner_product_FLP.c">
<ClCompile Include="silk_sort_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_k2a_FLP.c">
<ClCompile Include="silk_warped_autocorrelation_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_levinsondurbin_FLP.c">
<ClCompile Include="silk_wrappers_FLP.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SKP_Silk_main_FLP.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SKP_Silk_SigProc_FLP.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SKP_Silk_structs_FLP.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\win32\config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="silk_main_FLP.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="silk_SigProc_FLP.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="silk_structs_FLP.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
/* inner product of two SKP_float arrays, with result as double */
double SKP_Silk_inner_product_FLP( /* O result */
double silk_inner_product_FLP( /* O result */
const SKP_float *data1, /* I vector 1 */
const SKP_float *data2, /* I vector 2 */
SKP_int dataSize /* I length of vectors */

View file

@ -25,26 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
/* *
* SKP_Silk_k2a.c *
* *
* step up function, converts reflection coefficients to prediction *
* coefficients *
* *
* Copyright 2008 (c), Skype Limited *
* Date: 080103 *
* */
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
/* step up function, converts reflection coefficients to prediction coefficients */
void SKP_Silk_k2a_FLP(
void silk_k2a_FLP(
SKP_float *A, /* O: prediction coefficients [order] */
const SKP_float *rc, /* I: reflection coefficients [order] */
SKP_int32 order /* I: prediction order */
)
{
SKP_int k, n;
SKP_float Atmp[ SKP_Silk_MAX_ORDER_LPC ];
SKP_float Atmp[ SILK_MAX_ORDER_LPC ];
for( k = 0; k < order; k++ ){
for( n = 0; n < k; n++ ){

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
/* Solve the normal equations using the Levinson-Durbin recursion */
SKP_float SKP_Silk_levinsondurbin_FLP( /* O prediction error energy */
SKP_float silk_levinsondurbin_FLP( /* O prediction error energy */
SKP_float A[], /* O prediction coefficients [order] */
const SKP_float corr[], /* I input auto-correlations [order + 1] */
const SKP_int order /* I prediction order */

View file

@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef SKP_SILK_MAIN_FLP_H
#define SKP_SILK_MAIN_FLP_H
#ifndef SILK_MAIN_FLP_H
#define SILK_MAIN_FLP_H
#include "SKP_Silk_SigProc_FLP.h"
#include "SKP_Silk_SigProc_FIX.h"
#include "SKP_Silk_structs_FLP.h"
#include "SKP_Silk_main.h"
#include "SKP_Silk_define.h"
#include "SKP_debug.h"
#include "silk_SigProc_FLP.h"
#include "silk_SigProc_FIX.h"
#include "silk_structs_FLP.h"
#include "silk_main.h"
#include "silk_define.h"
#include "silk_debug.h"
#include "entenc.h"
#ifdef __cplusplus
@ -41,33 +41,42 @@ extern "C"
{
#endif
#define silk_encoder_state_Fxx silk_encoder_state_FLP
#define silk_encode_frame_Fxx silk_encode_frame_FLP
/*********************/
/* Encoder Functions */
/*********************/
/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
void silk_HP_variable_cutoff(
silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */
const SKP_int nChannels /* I Number of channels */
);
/* Encoder main function */
SKP_int SKP_Silk_encode_frame_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_int silk_encode_frame_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_int32 *pnBytesOut, /* O Number of payload bytes; */
ec_enc *psRangeEnc /* I/O compressor data structure */
ec_enc *psRangeEnc /* I/O compressor data structure */
);
/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */
void SKP_Silk_LBRR_encode_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_LBRR_encode_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
const SKP_float xfw[] /* I Input signal */
);
/* Initializes the Silk encoder state */
SKP_int SKP_Silk_init_encoder(
SKP_Silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
SKP_int silk_init_encoder(
silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
);
/* Control the Silk encoder */
SKP_int SKP_Silk_control_encoder(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */
SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */
SKP_int silk_control_encoder(
silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */
silk_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 */
@ -76,9 +85,9 @@ SKP_int SKP_Silk_control_encoder(
/****************/
/* Prefiltering */
/****************/
void SKP_Silk_prefilter_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
const SKP_Silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */
void silk_prefilter_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */
SKP_float xw[], /* O Weighted signal */
const SKP_float x[] /* I Speech signal */
);
@ -87,15 +96,15 @@ void SKP_Silk_prefilter_FLP(
/* Noise shaping analysis */
/**************************/
/* Compute noise shaping coefficients and initial gain values */
void SKP_Silk_noise_shape_analysis_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_noise_shape_analysis_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
const SKP_float *pitch_res, /* I LPC residual from pitch analysis */
const SKP_float *x /* I Input signal [frame_length + la_shape] */
);
/* Autocorrelations for a warped frequency axis */
void SKP_Silk_warped_autocorrelation_FLP(
void silk_warped_autocorrelation_FLP(
SKP_float *corr, /* O Result [order + 1] */
const SKP_float *input, /* I Input data to correlate */
const SKP_float warping, /* I Warping coefficient */
@ -104,32 +113,32 @@ void SKP_Silk_warped_autocorrelation_FLP(
);
/* Calculation of LTP state scaling */
void SKP_Silk_LTP_scale_ctrl_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
void silk_LTP_scale_ctrl_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
);
/**********************************************/
/* Prediction Analysis */
/**********************************************/
/* Find pitch lags */
void SKP_Silk_find_pitch_lags_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_find_pitch_lags_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
SKP_float res[], /* O Residual */
const SKP_float x[] /* I Speech signal */
);
/* Find LPC and LTP coefficients */
void SKP_Silk_find_pred_coefs_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_find_pred_coefs_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
const SKP_float res_pitch[], /* I Residual from pitch analysis */
const SKP_float x[] /* I Speech signal */
);
/* LPC analysis */
void SKP_Silk_find_LPC_FLP(
void silk_find_LPC_FLP(
SKP_int16 NLSF_Q15[], /* O NLSFs */
SKP_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */
const SKP_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */
@ -142,7 +151,7 @@ void SKP_Silk_find_LPC_FLP(
);
/* LTP analysis */
void SKP_Silk_find_LTP_FLP(
void silk_find_LTP_FLP(
SKP_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
SKP_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
SKP_float *LTPredCodGain, /* O LTP coding gain */
@ -154,7 +163,7 @@ void SKP_Silk_find_LTP_FLP(
const SKP_int mem_offset /* I Number of samples in LTP memory */
);
void SKP_Silk_LTP_analysis_filter_FLP(
void silk_LTP_analysis_filter_FLP(
SKP_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
const SKP_float *x, /* I Input signal, with preceeding samples */
const SKP_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
@ -167,10 +176,10 @@ void SKP_Silk_LTP_analysis_filter_FLP(
/* Calculates residual energies of input subframes where all subframes have LPC_order */
/* of preceeding samples */
void SKP_Silk_residual_energy_FLP(
void silk_residual_energy_FLP(
SKP_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
const SKP_float x[], /* I Input signal */
const SKP_float a[ 2 ][ MAX_LPC_ORDER ],/* I AR coefs for each frame half */
SKP_float a[ 2 ][ MAX_LPC_ORDER ],/* I AR coefs for each frame half */
const SKP_float gains[], /* I Quantization gains */
const SKP_int subfr_length, /* I Subframe length */
const SKP_int nb_subfr, /* I number of subframes */
@ -178,7 +187,7 @@ void SKP_Silk_residual_energy_FLP(
);
/* 16th order LPC analysis filter */
void SKP_Silk_LPC_analysis_filter_FLP(
void silk_LPC_analysis_filter_FLP(
SKP_float r_LPC[], /* O LPC residual signal */
const SKP_float PredCoef[], /* I LPC coefficients */
const SKP_float s[], /* I Input signal */
@ -187,7 +196,7 @@ void SKP_Silk_LPC_analysis_filter_FLP(
);
/* LTP tap quantizer */
void SKP_Silk_quant_LTP_gains_FLP(
void silk_quant_LTP_gains_FLP(
SKP_float B[ 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 */
@ -201,15 +210,15 @@ void SKP_Silk_quant_LTP_gains_FLP(
/* NLSF Quantizer */
/******************/
/* Limit, stabilize, and quantize NLSFs */
void SKP_Silk_process_NLSFs_FLP(
SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
void silk_process_NLSFs_FLP(
silk_encoder_state *psEncC, /* I/O Encoder state */
SKP_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
const SKP_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
);
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residual energy */
SKP_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */
const SKP_float *c, /* I Filter coefficients */
SKP_float *wXX, /* I/O Weighted correlation matrix, reg. out */
const SKP_float *wXx, /* I Weighted correlation vector */
@ -218,7 +227,7 @@ SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residua
);
/* Entropy constrained MATRIX-weighted VQ, for a single input data vector */
void SKP_Silk_VQ_WMat_EC_FLP(
void silk_VQ_WMat_EC_FLP(
SKP_int *ind, /* O Index of best codebook vector */
SKP_float *rate_dist, /* O Best weighted quant. error + mu * rate */
const SKP_float *in, /* I Input vector to be quantized */
@ -230,16 +239,16 @@ void SKP_Silk_VQ_WMat_EC_FLP(
);
/* Processing of gains */
void SKP_Silk_process_gains_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
void silk_process_gains_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
);
/******************/
/* Linear Algebra */
/******************/
/* Calculates correlation matrix X'*X */
void SKP_Silk_corrMatrix_FLP(
void silk_corrMatrix_FLP(
const SKP_float *x, /* I x vector [ L+order-1 ] used to create X */
const SKP_int L, /* I Length of vectors */
const SKP_int Order, /* I Max lag for correlation */
@ -247,7 +256,7 @@ void SKP_Silk_corrMatrix_FLP(
);
/* Calculates correlation vector X'*t */
void SKP_Silk_corrVector_FLP(
void silk_corrVector_FLP(
const SKP_float *x, /* I x vector [L+order-1] used to create X */
const SKP_float *t, /* I Target vector [L] */
const SKP_int L, /* I Length of vecors */
@ -256,7 +265,7 @@ void SKP_Silk_corrVector_FLP(
);
/* Add noise to matrix diagonal */
void SKP_Silk_regularize_correlations_FLP(
void silk_regularize_correlations_FLP(
SKP_float *XX, /* I/O Correlation matrices */
SKP_float *xx, /* I/O Correlation values */
const SKP_float noise, /* I Noise energy to add */
@ -264,7 +273,7 @@ void SKP_Silk_regularize_correlations_FLP(
);
/* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix */
void SKP_Silk_solve_LDL_FLP(
void silk_solve_LDL_FLP(
SKP_float *A, /* I/O Symmetric square matrix, out: reg. */
const SKP_int M, /* I Size of matrix */
const SKP_float *b, /* I Pointer to b vector */
@ -275,7 +284,7 @@ void SKP_Silk_solve_LDL_FLP(
/* Window types: */
/* 1 -> sine window from 0 to pi/2 */
/* 2 -> sine window from pi/2 to pi */
void SKP_Silk_apply_sine_window_FLP(
void silk_apply_sine_window_FLP(
SKP_float px_win[], /* O Pointer to windowed signal */
const SKP_float px[], /* I Pointer to input signal */
const SKP_int win_type, /* I Selects a window type */
@ -285,14 +294,14 @@ void SKP_Silk_apply_sine_window_FLP(
/* Wrappers. Calls flp / fix code */
/* Convert AR filter coefficients to NLSF parameters */
void SKP_Silk_A2NLSF_FLP(
void silk_A2NLSF_FLP(
SKP_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
const SKP_float *pAR, /* I LPC coefficients [ LPC_order ] */
const SKP_int LPC_order /* I LPC order */
);
/* Convert NLSF parameters to AR prediction filter coefficients */
void SKP_Silk_NLSF2A_stable_FLP(
void silk_NLSF2A_stable_FLP(
SKP_float *pAR, /* O LPC coefficients [ LPC_order ] */
const SKP_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
const SKP_int LPC_order /* I LPC order */
@ -301,18 +310,15 @@ void SKP_Silk_NLSF2A_stable_FLP(
/****************************************/
/* Floating-point Silk NSQ wrapper */
/****************************************/
void SKP_Silk_NSQ_wrapper_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_NSQ_wrapper_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
SideInfoIndices *psIndices, /* I/O Quantization indices */
SKP_Silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
SKP_int8 pulses[], /* O Quantized pulse signal */
const SKP_float x[] /* I Prefiltered input signal */
);
/* using log2() helps the fixed-point conversion */
SKP_INLINE SKP_float SKP_Silk_log2( double x ) { return ( SKP_float )( 3.32192809488736 * log10( x ) ); }
#ifdef __cplusplus
}
#endif

View file

@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
/* Compute gain to make warped filter coefficients have a zero mean log frequency response on a */
/* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.) */
@ -100,8 +100,8 @@ SKP_INLINE void warped_true2monic_coefs(
/* Apply bandwidth expansion */
chirp = 0.99f - ( 0.8f + 0.1f * iter ) * ( maxabs - limit ) / ( maxabs * ( ind + 1 ) );
SKP_Silk_bwexpander_FLP( coefs_syn, order, chirp );
SKP_Silk_bwexpander_FLP( coefs_ana, order, chirp );
silk_bwexpander_FLP( coefs_syn, order, chirp );
silk_bwexpander_FLP( coefs_ana, order, chirp );
/* Convert to monic warped coefficients */
for( i = order - 1; i > 0; i-- ) {
@ -119,14 +119,14 @@ SKP_INLINE void warped_true2monic_coefs(
}
/* Compute noise shaping coefficients and initial gain values */
void SKP_Silk_noise_shape_analysis_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_noise_shape_analysis_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
const SKP_float *pitch_res, /* I LPC residual from pitch analysis */
const SKP_float *x /* I Input signal [frame_length + la_shape] */
)
{
SKP_Silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
SKP_int k, nSamples;
SKP_float SNR_adj_dB, HarmBoost, HarmShapeGain, Tilt;
SKP_float nrg, pre_nrg, log_energy, log_energy_prev, energy_variation;
@ -178,8 +178,8 @@ void SKP_Silk_noise_shape_analysis_FLP(
log_energy_prev = 0.0f;
pitch_res_ptr = pitch_res;
for( k = 0; k < SKP_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; k++ ) {
nrg = ( SKP_float )nSamples + ( SKP_float )SKP_Silk_energy_FLP( pitch_res_ptr, nSamples );
log_energy = SKP_Silk_log2( nrg );
nrg = ( SKP_float )nSamples + ( SKP_float )silk_energy_FLP( pitch_res_ptr, nSamples );
log_energy = silk_log2( nrg );
if( k > 0 ) {
energy_variation += SKP_abs_float( log_energy - log_energy_prev );
}
@ -227,29 +227,29 @@ void SKP_Silk_noise_shape_analysis_FLP(
flat_part = psEnc->sCmn.fs_kHz * 3;
slope_part = ( psEnc->sCmn.shapeWinLength - flat_part ) / 2;
SKP_Silk_apply_sine_window_FLP( x_windowed, x_ptr, 1, slope_part );
silk_apply_sine_window_FLP( x_windowed, x_ptr, 1, slope_part );
shift = slope_part;
SKP_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(SKP_float) );
shift += flat_part;
SKP_Silk_apply_sine_window_FLP( x_windowed + shift, x_ptr + shift, 2, slope_part );
silk_apply_sine_window_FLP( x_windowed + shift, x_ptr + shift, 2, slope_part );
/* Update pointer: next LPC analysis block */
x_ptr += psEnc->sCmn.subfr_length;
if( psEnc->sCmn.warping_Q16 > 0 ) {
/* Calculate warped auto correlation */
SKP_Silk_warped_autocorrelation_FLP( auto_corr, x_windowed, warping,
silk_warped_autocorrelation_FLP( auto_corr, x_windowed, warping,
psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder );
} else {
/* Calculate regular auto correlation */
SKP_Silk_autocorrelation_FLP( auto_corr, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 );
silk_autocorrelation_FLP( auto_corr, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 );
}
/* Add white noise, as a fraction of energy */
auto_corr[ 0 ] += auto_corr[ 0 ] * SHAPE_WHITE_NOISE_FRACTION;
/* Convert correlations to prediction coefficients, and compute residual energy */
nrg = SKP_Silk_levinsondurbin_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], auto_corr, psEnc->sCmn.shapingLPCOrder );
nrg = silk_levinsondurbin_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], auto_corr, psEnc->sCmn.shapingLPCOrder );
psEncCtrl->Gains[ k ] = ( SKP_float )sqrt( nrg );
if( psEnc->sCmn.warping_Q16 > 0 ) {
@ -258,7 +258,7 @@ void SKP_Silk_noise_shape_analysis_FLP(
}
/* Bandwidth expansion for synthesis filter shaping */
SKP_Silk_bwexpander_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp2 );
silk_bwexpander_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp2 );
/* Compute noise shaping filter coefficients */
SKP_memcpy(
@ -267,11 +267,11 @@ void SKP_Silk_noise_shape_analysis_FLP(
psEnc->sCmn.shapingLPCOrder * sizeof( SKP_float ) );
/* Bandwidth expansion for analysis filter shaping */
SKP_Silk_bwexpander_FLP( &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp1 );
silk_bwexpander_FLP( &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp1 );
/* Ratio of prediction gains, in energy domain */
SKP_Silk_LPC_inverse_pred_gain_FLP( &pre_nrg, &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder );
SKP_Silk_LPC_inverse_pred_gain_FLP( &nrg, &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder );
silk_LPC_inverse_pred_gain_FLP( &pre_nrg, &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder );
silk_LPC_inverse_pred_gain_FLP( &nrg, &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder );
psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg );
/* Convert to monic warped prediction coefficients and limit absolute values */

View file

@ -30,9 +30,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Pitch analyser function
*
******************************************************************************/
#include "SKP_Silk_SigProc_FLP.h"
#include "SKP_Silk_SigProc_FIX.h"
#include "SKP_Silk_pitch_est_defines.h"
#include "silk_SigProc_FLP.h"
#include "silk_SigProc_FIX.h"
#include "silk_pitch_est_defines.h"
#define SCRATCH_SIZE 22
@ -41,13 +41,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/************************************************************/
#define eps 1.192092896e-07f
/* using log2() helps the fixed-point conversion */
SKP_INLINE SKP_float SKP_P_log2(double x) { return (SKP_float)(3.32192809488736 * log10(x)); }
/************************************************************/
/* Internally used functions */
/************************************************************/
static void SKP_P_Ana_calc_corr_st3(
static void silk_P_Ana_calc_corr_st3(
SKP_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
const SKP_float signal[], /* I vector to correlate */
SKP_int start_lag, /* I start lag */
@ -56,7 +53,7 @@ static void SKP_P_Ana_calc_corr_st3(
SKP_int complexity /* I Complexity setting */
);
static void SKP_P_Ana_calc_energy_st3(
static void silk_P_Ana_calc_energy_st3(
SKP_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
const SKP_float signal[], /* I vector to correlate */
SKP_int start_lag, /* I start lag */
@ -68,7 +65,7 @@ static void SKP_P_Ana_calc_energy_st3(
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//% CORE PITCH ANALYSIS FUNCTION %
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */
const SKP_float *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 */
@ -142,14 +139,14 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
SKP_int16 signal_16_FIX[ 16 * PE_MAX_FRAME_LENGTH_MS ];
SKP_float2short_array( signal_16_FIX, signal, frame_length );
SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );
SKP_Silk_resampler_down2( filt_state, signal_8_FIX, signal_16_FIX, frame_length );
silk_resampler_down2( filt_state, signal_8_FIX, signal_16_FIX, frame_length );
SKP_short2float_array( signal_8kHz, signal_8_FIX, frame_length_8kHz );
} else if( Fs_kHz == 12 ) {
/* Resample to 12 -> 8 khz */
SKP_int16 signal_12_FIX[ 12 * PE_MAX_FRAME_LENGTH_MS ];
SKP_float2short_array( signal_12_FIX, signal, frame_length );
SKP_memset( filt_state, 0, 6 * sizeof( SKP_int32 ) );
SKP_Silk_resampler_down2_3( filt_state, signal_8_FIX, signal_12_FIX, frame_length );
silk_resampler_down2_3( filt_state, signal_8_FIX, signal_12_FIX, frame_length );
SKP_short2float_array( signal_8kHz, signal_8_FIX, frame_length_8kHz );
} else {
SKP_assert( Fs_kHz == 8 );
@ -158,7 +155,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
/* Decimate again to 4 kHz */
SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );
SKP_Silk_resampler_down2( filt_state, signal_4_FIX, signal_8_FIX, frame_length_8kHz );
silk_resampler_down2( filt_state, signal_4_FIX, signal_8_FIX, frame_length_8kHz );
SKP_short2float_array( signal_4kHz, signal_4_FIX, frame_length_4kHz );
/* Low-pass filter */
@ -182,8 +179,8 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
SKP_assert( basis_ptr + sf_length_8kHz <= signal_4kHz + frame_length_4kHz );
/* Calculate first vector products before loop */
cross_corr = SKP_Silk_inner_product_FLP( target_ptr, basis_ptr, sf_length_8kHz );
normalizer = SKP_Silk_energy_FLP( basis_ptr, sf_length_8kHz ) + sf_length_8kHz * 4000.0f;
cross_corr = silk_inner_product_FLP( target_ptr, basis_ptr, sf_length_8kHz );
normalizer = silk_energy_FLP( basis_ptr, sf_length_8kHz ) + sf_length_8kHz * 4000.0f;
C[ 0 ][ min_lag_4kHz ] += (SKP_float)(cross_corr / sqrt(normalizer));
@ -195,7 +192,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
SKP_assert( basis_ptr >= signal_4kHz );
SKP_assert( basis_ptr + sf_length_8kHz <= signal_4kHz + frame_length_4kHz );
cross_corr = SKP_Silk_inner_product_FLP(target_ptr, basis_ptr, sf_length_8kHz);
cross_corr = silk_inner_product_FLP(target_ptr, basis_ptr, sf_length_8kHz);
/* Add contribution of new sample and remove contribution from oldest sample */
normalizer +=
@ -215,7 +212,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
/* Sort */
length_d_srch = 4 + 2 * complexity;
SKP_assert( 3 * length_d_srch <= PE_D_SRCH_LENGTH );
SKP_Silk_insertion_sort_decreasing_FLP( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch );
silk_insertion_sort_decreasing_FLP( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch );
/* Escape if correlation is very low already here */
Cmax = C[ 0 ][ min_lag_4kHz ];
@ -273,7 +270,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
length_d_comp = 0;
for( i = min_lag_8kHz; i < max_lag_8kHz + 4; i++ ) {
if( d_comp[ i ] > 0 ) {
d_comp[ length_d_comp ] = i - 2;
d_comp[ length_d_comp ] = (SKP_int16)( i - 2 );
length_d_comp++;
}
}
@ -292,12 +289,12 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
target_ptr = &signal_8kHz[ PE_LTP_MEM_LENGTH_MS * 8 ];
}
for( k = 0; k < nb_subfr; k++ ) {
energy_tmp = SKP_Silk_energy_FLP( target_ptr, sf_length_8kHz );
energy_tmp = silk_energy_FLP( target_ptr, sf_length_8kHz );
for( j = 0; j < length_d_comp; j++ ) {
d = d_comp[ j ];
basis_ptr = target_ptr - d;
cross_corr = SKP_Silk_inner_product_FLP( basis_ptr, target_ptr, sf_length_8kHz );
energy = SKP_Silk_energy_FLP( basis_ptr, sf_length_8kHz );
cross_corr = silk_inner_product_FLP( basis_ptr, target_ptr, sf_length_8kHz );
energy = silk_energy_FLP( basis_ptr, sf_length_8kHz );
if (cross_corr > 0.0f) {
C[ k ][ d ] = (SKP_float)(cross_corr * cross_corr / (energy * energy_tmp + eps));
} else {
@ -322,7 +319,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
} else if( Fs_kHz == 16 ) {
prevLag = SKP_RSHIFT( prevLag, 1 );
}
prevLag_log2 = SKP_P_log2((SKP_float)prevLag);
prevLag_log2 = silk_log2((SKP_float)prevLag);
} else {
prevLag_log2 = 0;
}
@ -330,7 +327,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
/* Setup stage 2 codebook based on number of subframes */
if( nb_subfr == PE_MAX_NB_SUBFR ) {
cbk_size = PE_NB_CBKS_STAGE2_EXT;
Lag_CB_ptr = &SKP_Silk_CB_lags_stage2[ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ];
if( Fs_kHz == 8 && complexity > SigProc_PE_MIN_COMPLEX ) {
/* If input is 8 khz use a larger codebook here because it is last stage */
nb_cbk_search = PE_NB_CBKS_STAGE2_EXT;
@ -339,7 +336,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
}
} else {
cbk_size = PE_NB_CBKS_STAGE2_10MS;
Lag_CB_ptr = &SKP_Silk_CB_lags_stage2_10_ms[ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage2_10_ms[ 0 ][ 0 ];
nb_cbk_search = PE_NB_CBKS_STAGE2_10MS;
}
@ -365,7 +362,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
CCmax_new_b = CCmax_new;
/* Bias towards shorter lags */
lag_log2 = SKP_P_log2((SKP_float)d);
lag_log2 = silk_log2((SKP_float)d);
CCmax_new_b -= PE_SHORTLAG_BIAS * nb_subfr * lag_log2;
/* Bias towards previous lag */
@ -377,7 +374,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
if ( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */
CCmax_new > nb_subfr * search_thres2 * search_thres2 && /* Correlation needs to be high enough to be voiced */
SKP_Silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */
silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */
) {
CCmax_b = CCmax_new_b;
CCmax = CCmax_new;
@ -419,8 +416,8 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
CCmax = -1000.0f;
/* Calculate the correlations and energies needed in stage 3 */
SKP_P_Ana_calc_corr_st3( cross_corr_st3, signal, start_lag, sf_length, nb_subfr, complexity );
SKP_P_Ana_calc_energy_st3( energies_st3, signal, start_lag, sf_length, nb_subfr, complexity );
silk_P_Ana_calc_corr_st3( cross_corr_st3, signal, start_lag, sf_length, nb_subfr, complexity );
silk_P_Ana_calc_energy_st3( energies_st3, signal, start_lag, sf_length, nb_subfr, complexity );
lag_counter = 0;
SKP_assert( lag == SKP_SAT16( lag ) );
@ -428,13 +425,13 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
/* Setup cbk parameters acording to complexity setting and frame length */
if( nb_subfr == PE_MAX_NB_SUBFR ) {
nb_cbk_search = (SKP_int)SKP_Silk_nb_cbk_searchs_stage3[ complexity ];
nb_cbk_search = (SKP_int)silk_nb_cbk_searchs_stage3[ complexity ];
cbk_size = PE_NB_CBKS_STAGE3_MAX;
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
} else {
nb_cbk_search = PE_NB_CBKS_STAGE3_10MS;
cbk_size = PE_NB_CBKS_STAGE3_10MS;
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
}
for( d = start_lag; d <= end_lag; d++ ) {
@ -454,7 +451,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
}
if( CCmax_new > CCmax &&
( d + (SKP_int)SKP_Silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag
( d + (SKP_int)silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag
) {
CCmax = CCmax_new;
lag_new = d;
@ -484,7 +481,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
return 0;
}
static void SKP_P_Ana_calc_corr_st3(
static void silk_P_Ana_calc_corr_st3(
SKP_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
const SKP_float signal[], /* I vector to correlate */
SKP_int start_lag, /* I start lag */
@ -516,14 +513,14 @@ static void SKP_P_Ana_calc_corr_st3(
SKP_assert( complexity <= SigProc_PE_MAX_COMPLEX );
if( nb_subfr == PE_MAX_NB_SUBFR ){
Lag_range_ptr = &SKP_Silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ];
nb_cbk_search = SKP_Silk_nb_cbk_searchs_stage3[ complexity ];
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
cbk_size = PE_NB_CBKS_STAGE3_MAX;
} else {
SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1);
Lag_range_ptr = &SKP_Silk_Lag_range_stage3_10_ms[ 0 ][ 0 ];
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
nb_cbk_search = PE_NB_CBKS_STAGE3_10MS;
cbk_size = PE_NB_CBKS_STAGE3_10MS;
}
@ -538,7 +535,7 @@ static void SKP_P_Ana_calc_corr_st3(
for( j = lag_low; j <= lag_high; j++ ) {
basis_ptr = target_ptr - ( start_lag + j );
SKP_assert( lag_counter < SCRATCH_SIZE );
scratch_mem[ lag_counter ] = (SKP_float)SKP_Silk_inner_product_FLP( target_ptr, basis_ptr, sf_length );
scratch_mem[ lag_counter ] = (SKP_float)silk_inner_product_FLP( target_ptr, basis_ptr, sf_length );
lag_counter++;
}
@ -557,7 +554,7 @@ static void SKP_P_Ana_calc_corr_st3(
}
}
static void SKP_P_Ana_calc_energy_st3(
static void silk_P_Ana_calc_energy_st3(
SKP_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */
const SKP_float signal[], /* I vector to correlate */
SKP_int start_lag, /* I start lag */
@ -581,14 +578,14 @@ calculated recursively.
SKP_assert( complexity <= SigProc_PE_MAX_COMPLEX );
if( nb_subfr == PE_MAX_NB_SUBFR ){
Lag_range_ptr = &SKP_Silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ];
nb_cbk_search = SKP_Silk_nb_cbk_searchs_stage3[ complexity ];
Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ];
nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ];
cbk_size = PE_NB_CBKS_STAGE3_MAX;
} else {
SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1);
Lag_range_ptr = &SKP_Silk_Lag_range_stage3_10_ms[ 0 ][ 0 ];
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ];
Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
nb_cbk_search = PE_NB_CBKS_STAGE3_10MS;
cbk_size = PE_NB_CBKS_STAGE3_10MS;
}
@ -599,7 +596,7 @@ calculated recursively.
/* Calculate the energy for first lag */
basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0, 2 ) );
energy = SKP_Silk_energy_FLP( basis_ptr, sf_length ) + 1e-3;
energy = silk_energy_FLP( basis_ptr, sf_length ) + 1e-3;
SKP_assert( energy >= 0.0 );
scratch_mem[lag_counter] = (SKP_float)energy;
lag_counter++;

View file

@ -25,14 +25,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
/*
* SKP_Silk_prefilter. Prefilter for finding Quantizer input signal
* silk_prefilter. Prefilter for finding Quantizer input signal
*/
SKP_INLINE void SKP_Silk_prefilt_FLP(
SKP_Silk_prefilter_state_FLP *P,/* I/O state */
SKP_INLINE void silk_prefilt_FLP(
silk_prefilter_state_FLP *P,/* I/O state */
SKP_float st_res[], /* I */
SKP_float xw[], /* O */
SKP_float *HarmShapeFIR, /* I */
@ -43,7 +43,7 @@ SKP_INLINE void SKP_Silk_prefilt_FLP(
SKP_int length /* I */
);
void SKP_Silk_warped_LPC_analysis_filter_FLP(
void silk_warped_LPC_analysis_filter_FLP(
SKP_float state[], /* I/O State [order + 1] */
SKP_float res[], /* O Residual signal [length] */
const SKP_float coef[], /* I Coefficients [order] */
@ -85,16 +85,16 @@ void SKP_Silk_warped_LPC_analysis_filter_FLP(
}
/*
* SKP_Silk_prefilter. Main prefilter function
* silk_prefilter. Main prefilter function
*/
void SKP_Silk_prefilter_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
const SKP_Silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */
void silk_prefilter_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */
SKP_float xw[], /* O Weighted signal */
const SKP_float x[] /* I Speech signal */
)
{
SKP_Silk_prefilter_state_FLP *P = &psEnc->sPrefilt;
silk_prefilter_state_FLP *P = &psEnc->sPrefilt;
SKP_int j, k, lag;
SKP_float HarmShapeGain, Tilt, LF_MA_shp, LF_AR_shp;
SKP_float B[ 2 ];
@ -125,7 +125,7 @@ void SKP_Silk_prefilter_FLP(
AR1_shp = &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ];
/* Short term FIR filtering */
SKP_Silk_warped_LPC_analysis_filter_FLP( P->sAR_shp, st_res, AR1_shp, px,
silk_warped_LPC_analysis_filter_FLP( P->sAR_shp, st_res, AR1_shp, px,
(SKP_float)psEnc->sCmn.warping_Q16 / 65536.0f, psEnc->sCmn.subfr_length, psEnc->sCmn.shapingLPCOrder );
/* Reduce (mainly) low frequencies during harmonic emphasis */
@ -138,7 +138,7 @@ void SKP_Silk_prefilter_FLP(
}
P->sHarmHP = st_res[ psEnc->sCmn.subfr_length - 1 ];
SKP_Silk_prefilt_FLP( P, pxw, pxw, HarmShapeFIR, Tilt, LF_MA_shp, LF_AR_shp, lag, psEnc->sCmn.subfr_length );
silk_prefilt_FLP( P, pxw, pxw, HarmShapeFIR, Tilt, LF_MA_shp, LF_AR_shp, lag, psEnc->sCmn.subfr_length );
px += psEnc->sCmn.subfr_length;
pxw += psEnc->sCmn.subfr_length;
@ -149,8 +149,8 @@ void SKP_Silk_prefilter_FLP(
/*
* Prefilter for finding Quantizer input signal
*/
SKP_INLINE void SKP_Silk_prefilt_FLP(
SKP_Silk_prefilter_state_FLP *P,/* I/O state */
SKP_INLINE void silk_prefilt_FLP(
silk_prefilter_state_FLP *P,/* I/O state */
SKP_float st_res[], /* I */
SKP_float xw[], /* O */
SKP_float *HarmShapeFIR, /* I */

View file

@ -25,16 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
/* Processing of gains */
void SKP_Silk_process_gains_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
void silk_process_gains_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */
)
{
SKP_Silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
silk_shape_state_FLP *psShapeSt = &psEnc->sShape;
SKP_int k;
SKP_int32 pGains_Q16[ MAX_NB_SUBFR ];
SKP_float s, InvMaxSqrVal, gain, quant_offset;
@ -63,8 +63,8 @@ void SKP_Silk_process_gains_FLP(
}
/* Noise shaping quantization */
SKP_Silk_gains_quant( psEnc->sCmn.indices.GainsIndices, pGains_Q16,
&psShapeSt->LastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr );
silk_gains_quant( psEnc->sCmn.indices.GainsIndices, pGains_Q16,
&psShapeSt->LastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr );
/* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */
for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
@ -81,7 +81,7 @@ void SKP_Silk_process_gains_FLP(
}
/* Quantizer boundary adjustment */
quant_offset = SKP_Silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ] / 1024.0f;
quant_offset = silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ] / 1024.0f;
psEncCtrl->Lambda = LAMBDA_OFFSET
+ LAMBDA_DELAYED_DECISIONS * psEnc->sCmn.nStatesDelayedDecision
+ LAMBDA_SPEECH_ACT * psEnc->sCmn.speech_activity_Q8 * ( 1.0f / 256.0f )

View file

@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
void SKP_Silk_regularize_correlations_FLP(
void silk_regularize_correlations_FLP(
SKP_float *XX, /* I/O Correlation matrices */
SKP_float *xx, /* I/O Correlation values */
const SKP_float noise, /* I Noise energy to add */

View file

@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
#define MAX_ITERATIONS_RESIDUAL_NRG 10
#define REGULARIZATION_FACTOR 1e-8f
/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residual energy */
SKP_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */
const SKP_float *c, /* I Filter coefficients */
SKP_float *wXX, /* I/O Weighted correlation matrix, reg. out */
const SKP_float *wXx, /* I Weighted correlation vector */
@ -40,7 +40,7 @@ SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residua
)
{
SKP_int i, j, k;
SKP_float tmp, nrg, regularization;
SKP_float tmp, nrg = 0.0f, regularization;
/* Safety checks */
SKP_assert( D >= 0 );
@ -84,10 +84,10 @@ SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residua
/* Calculates residual energies of input subframes where all subframes have LPC_order */
/* of preceeding samples */
void SKP_Silk_residual_energy_FLP(
void silk_residual_energy_FLP(
SKP_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
const SKP_float x[], /* I Input signal */
const SKP_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
SKP_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
const SKP_float gains[], /* I Quantization gains */
const SKP_int subfr_length, /* I Subframe length */
const SKP_int nb_subfr, /* I number of subframes */
@ -101,13 +101,13 @@ void SKP_Silk_residual_energy_FLP(
shift = LPC_order + subfr_length;
/* Filter input to create the LPC residual for each frame half, and measure subframe energies */
SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a[ 0 ], x + 0 * shift, 2 * shift, LPC_order );
nrgs[ 0 ] = ( SKP_float )( gains[ 0 ] * gains[ 0 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) );
nrgs[ 1 ] = ( SKP_float )( gains[ 1 ] * gains[ 1 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) );
silk_LPC_analysis_filter_FLP( LPC_res, a[ 0 ], x + 0 * shift, 2 * shift, LPC_order );
nrgs[ 0 ] = ( SKP_float )( gains[ 0 ] * gains[ 0 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) );
nrgs[ 1 ] = ( SKP_float )( gains[ 1 ] * gains[ 1 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) );
if( nb_subfr == MAX_NB_SUBFR ) {
SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a[ 1 ], x + 2 * shift, 2 * shift, LPC_order );
nrgs[ 2 ] = ( SKP_float )( gains[ 2 ] * gains[ 2 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) );
nrgs[ 3 ] = ( SKP_float )( gains[ 3 ] * gains[ 3 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) );
silk_LPC_analysis_filter_FLP( LPC_res, a[ 1 ], x + 2 * shift, 2 * shift, LPC_order );
nrgs[ 2 ] = ( SKP_float )( gains[ 2 ] * gains[ 2 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) );
nrgs[ 3 ] = ( SKP_float )( gains[ 3 ] * gains[ 3 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) );
}
}

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
/* copy and multiply a vector by a constant */
void SKP_Silk_scale_copy_vector_FLP(
void silk_scale_copy_vector_FLP(
SKP_float *data_out,
const SKP_float *data_in,
SKP_float gain,

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_SigProc_FLP.h"
/* multiply a vector by a constant */
void SKP_Silk_scale_vector_FLP(
void silk_scale_vector_FLP(
SKP_float *data1,
SKP_float gain,
SKP_int dataSize

View file

@ -25,25 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
/* *
* SKP_Silk_schur.c *
* *
* Calculates the reflection coefficients from the correlation sequence *
* *
* Copyright 2008 (c), Skype Limited *
* Date: 080103 *
*/
#include "silk_SigProc_FLP.h"
#include "SKP_Silk_SigProc_FLP.h"
SKP_float SKP_Silk_schur_FLP( /* O returns residual energy */
SKP_float silk_schur_FLP( /* O returns residual energy */
SKP_float refl_coef[], /* O reflection coefficients (length order) */
const SKP_float auto_corr[], /* I autotcorrelation sequence (length order+1) */
SKP_int order /* I order */
)
{
SKP_int k, n;
SKP_float C[ SKP_Silk_MAX_ORDER_LPC + 1 ][ 2 ];
SKP_float C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ];
SKP_float Ctmp1, Ctmp2, rc_tmp;
/* Copy correlations */

View file

@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "SKP_Silk_tuning_parameters.h"
#include "silk_main_FLP.h"
#include "silk_tuning_parameters.h"
/**********************************************************************
* LDL Factorisation. Finds the upper triangular matrix L and the diagonal
* Matrix D (only the diagonal elements returned in a vector)such that
* the symmetric matric A is given by A = L*D*L'.
**********************************************************************/
void SKP_Silk_LDL_FLP(
void silk_LDL_FLP(
SKP_float *A, /* (I/O) Pointer to Symetric Square Matrix */
SKP_int M, /* (I) Size of Matrix */
SKP_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */
@ -44,7 +44,7 @@ void SKP_Silk_LDL_FLP(
* Function to solve linear equation Ax = b, when A is a MxM lower
* triangular matrix, with ones on the diagonal.
**********************************************************************/
void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP(
void silk_SolveWithLowerTriangularWdiagOnes_FLP(
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
SKP_int M, /* (I) Dim of Matrix equation */
const SKP_float *b, /* (I) b Vector */
@ -55,7 +55,7 @@ void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP(
* Function to solve linear equation (A^T)x = b, when A is a MxM lower
* triangular, with ones on the diagonal. (ie then A^T is upper triangular)
**********************************************************************/
void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
SKP_int M, /* (I) Dim of Matrix equation */
const SKP_float *b, /* (I) b Vector */
@ -66,7 +66,7 @@ void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
* Function to solve linear equation Ax = b, when A is a MxM
* symmetric square matrix - using LDL factorisation
**********************************************************************/
void SKP_Silk_solve_LDL_FLP(
void silk_solve_LDL_FLP(
SKP_float *A, /* I/O Symmetric square matrix, out: reg. */
const SKP_int M, /* I Size of matrix */
const SKP_float *b, /* I Pointer to b vector */
@ -84,13 +84,13 @@ void SKP_Silk_solve_LDL_FLP(
Factorize A by LDL such that A = L*D*(L^T),
where L is lower triangular with ones on diagonal
****************************************************/
SKP_Silk_LDL_FLP( A, M, &L[ 0 ][ 0 ], Dinv );
silk_LDL_FLP( A, M, &L[ 0 ][ 0 ], Dinv );
/****************************************************
* substitute D*(L^T) = T. ie:
L*D*(L^T)*x = b => L*T = b <=> T = inv(L)*b
******************************************************/
SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( &L[ 0 ][ 0 ], M, b, T );
silk_SolveWithLowerTriangularWdiagOnes_FLP( &L[ 0 ][ 0 ], M, b, T );
/****************************************************
D*(L^T)*x = T <=> (L^T)*x = inv(D)*T, because D is
@ -102,10 +102,10 @@ void SKP_Silk_solve_LDL_FLP(
/****************************************************
x = inv(L') * inv(D) * T
*****************************************************/
SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( &L[ 0 ][ 0 ], M, T, x );
silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( &L[ 0 ][ 0 ], M, T, x );
}
void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
SKP_int M, /* (I) Dim of Matrix equation */
const SKP_float *b, /* (I) b Vector */
@ -127,7 +127,7 @@ void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP(
}
}
void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP(
void silk_SolveWithLowerTriangularWdiagOnes_FLP(
const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */
SKP_int M, /* (I) Dim of Matrix equation */
const SKP_float *b, /* (I) b Vector */
@ -149,7 +149,7 @@ void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP(
}
}
void SKP_Silk_LDL_FLP(
void silk_LDL_FLP(
SKP_float *A, /* (I/O) Pointer to Symetric Square Matrix */
SKP_int M, /* (I) Size of Matrix */
SKP_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */

View file

@ -29,12 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Best case: O(n) for an already sorted array */
/* Worst case: O(n^2) for an inversely sorted array */
#include "SKP_Silk_typedef.h"
#include "SKP_Silk_SigProc_FLP.h"
#include "silk_typedef.h"
#include "silk_SigProc_FLP.h"
void SKP_Silk_insertion_sort_decreasing_FLP(
void silk_insertion_sort_decreasing_FLP(
SKP_float *a, /* I/O: Unsorted / Sorted vector */
SKP_int *index, /* O: Index vector for the sorted elements */
SKP_int *idx, /* O: Index vector for the sorted elements */
const SKP_int L, /* I: Vector length */
const SKP_int K /* I: Number of correctly sorted positions */
)
@ -49,18 +49,18 @@ void SKP_Silk_insertion_sort_decreasing_FLP(
/* Write start indices in index vector */
for( i = 0; i < K; i++ ) {
index[ i ] = i;
idx[ i ] = i;
}
/* Sort vector elements by value, decreasing order */
for( i = 1; i < K; i++ ) {
value = a[ i ];
for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) {
a[ j + 1 ] = a[ j ]; /* Shift value */
index[ j + 1 ] = index[ j ]; /* Shift index */
a[ j + 1 ] = a[ j ]; /* Shift value */
idx[ j + 1 ] = idx[ j ]; /* Shift index */
}
a[ j + 1 ] = value; /* Write value */
index[ j + 1 ] = i; /* Write index */
a[ j + 1 ] = value; /* Write value */
idx[ j + 1 ] = i; /* Write index */
}
/* If less than L values are asked check the remaining values, */
@ -69,11 +69,11 @@ void SKP_Silk_insertion_sort_decreasing_FLP(
value = a[ i ];
if( value > a[ K - 1 ] ) {
for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) {
a[ j + 1 ] = a[ j ]; /* Shift value */
index[ j + 1 ] = index[ j ]; /* Shift index */
a[ j + 1 ] = a[ j ]; /* Shift value */
idx[ j + 1 ] = idx[ j ]; /* Shift index */
}
a[ j + 1 ] = value; /* Write value */
index[ j + 1 ] = i; /* Write index */
a[ j + 1 ] = value; /* Write value */
idx[ j + 1 ] = i; /* Write index */
}
}
}

View file

@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef SKP_SILK_STRUCTS_FLP_H
#define SKP_SILK_STRUCTS_FLP_H
#ifndef SILK_STRUCTS_FLP_H
#define SILK_STRUCTS_FLP_H
#include "SKP_Silk_typedef.h"
#include "SKP_Silk_main.h"
#include "SKP_Silk_structs.h"
#include "silk_typedef.h"
#include "silk_main.h"
#include "silk_structs.h"
#ifdef __cplusplus
extern "C"
@ -45,7 +45,7 @@ typedef struct {
SKP_float HarmBoost_smth;
SKP_float HarmShapeGain_smth;
SKP_float Tilt_smth;
} SKP_Silk_shape_state_FLP;
} silk_shape_state_FLP;
/********************************/
/* Prefilter state */
@ -59,15 +59,15 @@ typedef struct {
SKP_float sHarmHP;
SKP_int32 rand_seed;
SKP_int lagPrev;
} SKP_Silk_prefilter_state_FLP;
} silk_prefilter_state_FLP;
/********************************/
/* Encoder state FLP */
/********************************/
typedef struct {
SKP_Silk_encoder_state sCmn; /* Common struct, shared with fixed-point code */
SKP_Silk_shape_state_FLP sShape; /* Noise shaping state */
SKP_Silk_prefilter_state_FLP sPrefilt; /* Prefilter State */
silk_encoder_state sCmn; /* Common struct, shared with fixed-point code */
silk_shape_state_FLP sShape; /* Noise shaping state */
silk_prefilter_state_FLP sPrefilt; /* Prefilter State */
/* Buffer for find pitch and noise shape analysis */
SKP_float x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */
@ -76,7 +76,7 @@ typedef struct {
/* Parameters for LTP scaling control */
SKP_float prevLTPredCodGain;
SKP_float HPLTPredCodGain;
} SKP_Silk_encoder_state_FLP;
} silk_encoder_state_FLP;
/************************/
/* Encoder control FLP */
@ -107,7 +107,20 @@ typedef struct {
SKP_float predGain;
SKP_float LTPredCodGain;
SKP_float ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */
} SKP_Silk_encoder_control_FLP;
} silk_encoder_control_FLP;
/************************/
/* Encoder Super Struct */
/************************/
typedef struct {
silk_encoder_state_FLP state_Fxx[ ENCODER_NUM_CHANNELS ];
stereo_enc_state sStereo;
SKP_int32 nBitsExceeded;
SKP_int nChannelsAPI;
SKP_int nChannelsInternal;
SKP_int timeSinceSwitchAllowed_ms;
SKP_int allowBandwidthSwitch;
} silk_encoder;
#ifdef __cplusplus
}

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
/* Autocorrelations for a warped frequency axis */
void SKP_Silk_warped_autocorrelation_FLP(
void silk_warped_autocorrelation_FLP(
SKP_float *corr, /* O Result [order + 1] */
const SKP_float *input, /* I Input data to correlate */
const SKP_float warping, /* I Warping coefficient */

View file

@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main_FLP.h"
#include "silk_main_FLP.h"
/* Wrappers. Calls flp / fix code */
/* Convert AR filter coefficients to NLSF parameters */
void SKP_Silk_A2NLSF_FLP(
void silk_A2NLSF_FLP(
SKP_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
const SKP_float *pAR, /* I LPC coefficients [ LPC_order ] */
const SKP_int LPC_order /* I LPC order */
@ -43,11 +43,11 @@ void SKP_Silk_A2NLSF_FLP(
a_fix_Q16[ i ] = SKP_float2int( pAR[ i ] * 65536.0f );
}
SKP_Silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order );
silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order );
}
/* Convert LSF parameters to AR prediction filter coefficients */
void SKP_Silk_NLSF2A_stable_FLP(
void silk_NLSF2A_stable_FLP(
SKP_float *pAR, /* O LPC coefficients [ LPC_order ] */
const SKP_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
const SKP_int LPC_order /* I LPC order */
@ -56,7 +56,7 @@ void SKP_Silk_NLSF2A_stable_FLP(
SKP_int i;
SKP_int16 a_fix_Q12[ MAX_LPC_ORDER ];
SKP_Silk_NLSF2A_stable( a_fix_Q12, NLSF_Q15, LPC_order );
silk_NLSF2A_stable( a_fix_Q12, NLSF_Q15, LPC_order );
for( i = 0; i < LPC_order; i++ ) {
pAR[ i ] = ( SKP_float )a_fix_Q12[ i ] * ( 1.0f / 4096.0f );
@ -66,8 +66,8 @@ void SKP_Silk_NLSF2A_stable_FLP(
/******************************************/
/* Floating-point NLSF processing wrapper */
/******************************************/
void SKP_Silk_process_NLSFs_FLP(
SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */
void silk_process_NLSFs_FLP(
silk_encoder_state *psEncC, /* I/O Encoder state */
SKP_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
const SKP_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
@ -76,7 +76,7 @@ void SKP_Silk_process_NLSFs_FLP(
SKP_int i, j;
SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];
SKP_Silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15);
silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15);
for( j = 0; j < 2; j++ ) {
for( i = 0; i < psEncC->predictLPCOrder; i++ ) {
@ -88,11 +88,11 @@ void SKP_Silk_process_NLSFs_FLP(
/****************************************/
/* Floating-point Silk NSQ wrapper */
/****************************************/
void SKP_Silk_NSQ_wrapper_FLP(
SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
void silk_NSQ_wrapper_FLP(
silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
SideInfoIndices *psIndices, /* I/O Quantization indices */
SKP_Silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
SKP_int8 pulses[], /* O Quantized pulse signal */
const SKP_float x[] /* I Prefiltered input signal */
)
@ -144,7 +144,7 @@ void SKP_Silk_NSQ_wrapper_FLP(
}
if( psIndices->signalType == TYPE_VOICED ) {
LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ];
LTP_scale_Q14 = silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ];
} else {
LTP_scale_Q14 = 0;
}
@ -154,10 +154,10 @@ void SKP_Silk_NSQ_wrapper_FLP(
/* Call NSQ */
if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {
SKP_Silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14,
silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14,
AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14 );
} else {
SKP_Silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14,
silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14,
AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14 );
}
}
@ -165,7 +165,7 @@ void SKP_Silk_NSQ_wrapper_FLP(
/***********************************************/
/* Floating-point Silk LTP quantiation wrapper */
/***********************************************/
void SKP_Silk_quant_LTP_gains_FLP(
void silk_quant_LTP_gains_FLP(
SKP_float B[ 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 */
@ -186,7 +186,7 @@ void SKP_Silk_quant_LTP_gains_FLP(
W_Q18[ i ] = (SKP_int32)SKP_float2int( W[ i ] * 262144.0f );
}
SKP_Silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, W_Q18, mu_Q10, lowComplexity, nb_subfr );
silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, W_Q18, mu_Q10, lowComplexity, nb_subfr );
for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) {
B[ i ] = (SKP_float)B_Q14[ i ] * ( 1.0f / 16384.0f );

View file

@ -29,9 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* 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 */
/* functions are accurate inverses of each other */
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
#include "silk_tables.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 ) */
@ -43,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Helper function for A2NLSF(..) */
/* Transforms polynomials from cos(n*f) to cos(f)^n */
SKP_INLINE void SKP_Silk_A2NLSF_trans_poly(
SKP_INLINE void silk_A2NLSF_trans_poly(
SKP_int32 *p, /* I/O Polynomial */
const SKP_int dd /* I Polynomial order (= filter order / 2 ) */
)
@ -59,7 +60,7 @@ SKP_INLINE void SKP_Silk_A2NLSF_trans_poly(
}
/* Helper function for A2NLSF(..) */
/* Polynomial evaluation */
SKP_INLINE SKP_int32 SKP_Silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */
SKP_INLINE SKP_int32 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 */
@ -76,7 +77,7 @@ SKP_INLINE SKP_int32 SKP_Silk_A2NLSF_eval_poly( /* return the polynomial eval
return y32;
}
SKP_INLINE void SKP_Silk_A2NLSF_init(
SKP_INLINE void silk_A2NLSF_init(
const SKP_int32 *a_Q16,
SKP_int32 *P,
SKP_int32 *Q,
@ -110,13 +111,13 @@ SKP_INLINE void SKP_Silk_A2NLSF_init(
}
/* Transform polynomials from cos(n*f) to cos(f)^n */
SKP_Silk_A2NLSF_trans_poly( P, dd );
SKP_Silk_A2NLSF_trans_poly( Q, dd );
silk_A2NLSF_trans_poly( P, dd );
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(
void 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) */
@ -126,8 +127,8 @@ void SKP_Silk_A2NLSF(
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 P[ SILK_MAX_ORDER_LPC / 2 + 1 ];
SKP_int32 Q[ SILK_MAX_ORDER_LPC / 2 + 1 ];
SKP_int32 *PQ[ 2 ];
SKP_int32 *p;
@ -137,19 +138,19 @@ void SKP_Silk_A2NLSF(
dd = SKP_RSHIFT( d, 1 );
SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd );
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 );
xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12
ylo = 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 );
ylo = silk_A2NLSF_eval_poly( p, xlo, dd );
root_ix = 1; /* Index of current root */
} else {
root_ix = 0; /* Index of current root */
@ -159,13 +160,13 @@ void SKP_Silk_A2NLSF(
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 */
xhi = silk_LSFCosTab_FIX_Q12[ k >> 1 ] +
( ( silk_LSFCosTab_FIX_Q12[ ( k + 1 ) >> 1 ] -
silk_LSFCosTab_FIX_Q12[ k >> 1 ] ) >> 1 ); /* Q12 */
#else
xhi = SKP_Silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */
xhi = silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */
#endif
yhi = SKP_Silk_A2NLSF_eval_poly( p, xhi, dd );
yhi = silk_A2NLSF_eval_poly( p, xhi, dd );
/* Detect zero crossing */
if( ( ylo <= 0 && yhi >= 0 ) || ( ylo >= 0 && yhi <= 0 ) ) {
@ -178,7 +179,7 @@ void SKP_Silk_A2NLSF(
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 );
ymid = silk_A2NLSF_eval_poly( p, xmid, dd );
/* Detect zero crossing */
if( ( ylo <= 0 && ymid >= 0 ) || ( ylo >= 0 && ymid <= 0 ) ) {
@ -228,11 +229,11 @@ void SKP_Silk_A2NLSF(
/* 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
xlo = silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] +
( ( silk_LSFCosTab_FIX_Q12[ k >> 1 ] -
silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] ) >> 1 ); // Q12
#else
xlo = SKP_Silk_LSFCosTab_FIX_Q12[ k - 1 ]; // Q12
xlo = silk_LSFCosTab_FIX_Q12[ k - 1 ]; // Q12
#endif
ylo = SKP_LSHIFT( 1 - ( root_ix & 2 ), 12 );
} else {
@ -257,17 +258,17 @@ void SKP_Silk_A2NLSF(
}
/* 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
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 );
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 );
xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12
ylo = 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 );
ylo = silk_A2NLSF_eval_poly( p, xlo, dd );
root_ix = 1; /* Index of current root */
} else {
root_ix = 0; /* Index of current root */

View file

@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef SKP_SILK_SDK_API_H
#define SKP_SILK_SDK_API_H
#ifndef SILK_API_H
#define SILK_API_H
#include "SKP_Silk_control.h"
#include "SKP_Silk_typedef.h"
#include "SKP_Silk_errors.h"
#include "silk_control.h"
#include "silk_typedef.h"
#include "silk_errors.h"
#include "entenc.h"
#include "entdec.h"
@ -46,7 +46,7 @@ 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;
} silk_TOC_struct;
/****************************************/
/* Encoder functions */
@ -55,24 +55,24 @@ typedef struct {
/***********************************************/
/* Get size in bytes of the Silk encoder state */
/***********************************************/
SKP_int SKP_Silk_SDK_Get_Encoder_Size( /* O: Returns error code */
SKP_int silk_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 */
SKP_int silk_InitEncoder( /* O: Returns error code */
void *encState, /* I/O: State */
SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
silk_EncControlStruct *encStatus /* O: Encoder Status */
);
/***************************************/
/* Read control structure from encoder */
/***************************************/
SKP_int SKP_Silk_SDK_QueryEncoder( /* O: Returns error code */
SKP_int silk_QueryEncoder( /* O: Returns error code */
const void *encState, /* I: State */
SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
silk_EncControlStruct *encStatus /* O: Encoder Status */
);
/**************************/
@ -80,9 +80,9 @@ SKP_int SKP_Silk_SDK_QueryEncoder( /* O: Returns error co
/**************************/
/* 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 */
SKP_int silk_Encode( /* O: Returns error code */
void *encState, /* I/O: State */
SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control status */
silk_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 */
@ -97,23 +97,23 @@ SKP_int SKP_Silk_SDK_Encode( /* O: Returns error co
/***********************************************/
/* Get size in bytes of the Silk decoder state */
/***********************************************/
SKP_int SKP_Silk_SDK_Get_Decoder_Size( /* O: Returns error code */
SKP_int silk_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 */
SKP_int silk_InitDecoder( /* O: Returns error code */
void *decState /* I/O: State */
);
/******************/
/* Decode a frame */
/******************/
SKP_int SKP_Silk_SDK_Decode( /* O: Returns error code */
SKP_int silk_Decode( /* O: Returns error code */
void* decState, /* I/O: State */
SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */
silk_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 */
@ -121,25 +121,14 @@ SKP_int SKP_Silk_SDK_Decode( /* O: Returns error co
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(
SKP_int silk_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 */
silk_TOC_struct *Silk_TOC /* O: Type of content */
);
#ifdef __cplusplus

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "silk_main.h"
/* Generates excitation for CNG LPC synthesis */
SKP_INLINE void SKP_Silk_CNG_exc(
SKP_INLINE void 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 */
@ -55,8 +55,8 @@ SKP_INLINE void SKP_Silk_CNG_exc(
*rand_seed = seed;
}
void SKP_Silk_CNG_Reset(
SKP_Silk_decoder_state *psDec /* I/O Decoder state */
void silk_CNG_Reset(
silk_decoder_state *psDec /* I/O Decoder state */
)
{
SKP_int i, NLSF_step_Q15, NLSF_acc_Q15;
@ -72,9 +72,9 @@ void SKP_Silk_CNG_Reset(
}
/* 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 */
void silk_CNG(
silk_decoder_state *psDec, /* I/O Decoder state */
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
SKP_int16 signal[], /* I/O Signal */
SKP_int length /* I Length of residual */
)
@ -83,12 +83,12 @@ void SKP_Silk_CNG(
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;
silk_CNG_struct *psCNG;
psCNG = &psDec->sCNG;
if( psDec->fs_kHz != psCNG->fs_kHz ) {
/* Reset state */
SKP_Silk_CNG_Reset( psDec );
silk_CNG_Reset( psDec );
psCNG->fs_kHz = psDec->fs_kHz;
}
@ -122,20 +122,20 @@ void SKP_Silk_CNG(
if( psDec->lossCnt ) {
/* Generate CNG excitation */
SKP_Silk_CNG_exc( CNG_sig, psCNG->CNG_exc_buf_Q10,
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 );
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,
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,
silk_LPC_synthesis_filter( CNG_sig, LPC_buf,
Gain_Q26, psCNG->CNG_synth_state, CNG_sig, length, psDec->LPC_order );
}
/* Mix with signal */

View file

@ -25,79 +25,74 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
#ifdef FIXED_POINT
#include "silk_main_FIX.h"
#else
#include "silk_main_FLP.h"
#endif
#include "silk_tuning_parameters.h"
/* 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 */
void silk_HP_variable_cutoff(
silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */
const SKP_int nChannels /* I Number of channels */
)
{
SKP_int quality_Q15;
SKP_float pitch_freq_low_Hz;
SKP_int quality_Q15, cutoff_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;
silk_encoder_state *psEncC1 = &state_Fxx[ 0 ].sCmn;
/*********************************************/
/* Estimate Low End of Pitch Frequency Range */
/*********************************************/
if( psEncC->prevSignalType == TYPE_VOICED ) {
if( psEncC1->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
pitch_freq_Hz_Q16 = SKP_DIV32_16( SKP_LSHIFT( SKP_MUL( psEncC1->fs_kHz, 1000 ), 16 ), psEncC1->prevLag );
pitch_freq_log_Q7 = silk_lin2log( pitch_freq_Hz_Q16 ) - ( 16 << 7 );
/* 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 ) );
quality_Q15 = psEncC1->input_quality_bands_Q15[ 0 ];
pitch_freq_log_Q7 = SKP_SMLAWB( pitch_freq_log_Q7, SKP_SMULWB( SKP_LSHIFT( -quality_Q15, 2 ), quality_Q15 ),
pitch_freq_log_Q7 - ( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ) ) );
//delta_freq = pitch_freq_log - psEnc->variable_HP_smth1;
delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEncC->variable_HP_smth1_Q15, 8 );
/* delta_freq = pitch_freq_log - psEnc->variable_HP_smth1; */
delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEncC1->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 ) );
/* limit delta, to reduce impact of outliers in pitch estimation */
delta_freq_Q7 = SKP_LIMIT_32( delta_freq_Q7, -SILK_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ), SILK_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 ) );
psEncC1->variable_HP_smth1_Q15 = SKP_SMLAWB( psEncC1->variable_HP_smth1_Q15,
SKP_SMULBB( psEncC1->speech_activity_Q8, delta_freq_Q7 ), SILK_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 ) );
psEncC1->variable_HP_smth2_Q15 = SKP_SMLAWB( psEncC1->variable_HP_smth2_Q15,
psEncC1->variable_HP_smth1_Q15 - psEncC1->variable_HP_smth2_Q15, SILK_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 ) );
cutoff_Hz = silk_log2lin( SKP_RSHIFT( psEncC1->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 ) );
cutoff_Hz = SKP_LIMIT_32( cutoff_Hz, SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 0 ), SILK_FIX_CONST( VARIABLE_HP_MAX_CUTOFF_HZ, 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 );
/* compute cut-off frequency, in radians */
/* Fc_num = 1.5 * 3.14159 * cutoff_Hz */
/* Fc_denom = 1e3f * psEncC1->fs_kHz */
SKP_assert( cutoff_Hz <= SKP_int32_MAX / SILK_FIX_CONST( 1.5 * 3.14159 / 1000, 19 ) );
Fc_Q19 = SKP_DIV32_16( SKP_SMULBB( SILK_FIX_CONST( 1.5 * 3.14159 / 1000, 19 ), cutoff_Hz ), psEncC1->fs_kHz );
SKP_assert( Fc_Q19 > 0 && Fc_Q19 < 32768 );
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 );
r_Q28 = SILK_FIX_CONST( 1.0, 28 ) - SKP_MUL( SILK_FIX_CONST( 0.92, 9 ), Fc_Q19 );
/* b = r * [ 1; -2; 1 ]; */
/* a = [ 1; -2 * r * ( 1 - 0.5 * Fc^2 ); r^2 ]; */
@ -105,13 +100,17 @@ void SKP_Silk_HP_variable_cutoff(
B_Q28[ 1 ] = SKP_LSHIFT( -r_Q28, 1 );
B_Q28[ 2 ] = r_Q28;
// -r * ( 2 - Fc * Fc );
/* -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[ 0 ] = SKP_SMULWW( r_Q22, SKP_SMULWW( Fc_Q19, Fc_Q19 ) - SILK_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 );
silk_biquad_alt( psEncC1->inputBuf, B_Q28, A_Q28, psEncC1->In_HP_State, psEncC1->inputBuf, psEncC1->frame_length );
if( nChannels == 2 ) {
silk_biquad_alt( state_Fxx[ 1 ].sCmn.inputBuf, B_Q28, A_Q28, state_Fxx[ 1 ].sCmn.In_HP_State,
state_Fxx[ 1 ].sCmn.inputBuf, state_Fxx[ 1 ].sCmn.frame_length );
}
}

View file

@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
/*! \file silk_Inlines.h
* \brief silk_Inlines.h defines inline signal processing functions.
*/
#ifndef _SKP_SILK_FIX_INLINES_H_
#define _SKP_SILK_FIX_INLINES_H_
#ifndef _SILK_FIX_INLINES_H_
#define _SILK_FIX_INLINES_H_
#ifdef __cplusplus
extern "C"
@ -38,35 +38,35 @@ extern "C"
#endif
/* count leading zeros of SKP_int64 */
SKP_INLINE SKP_int32 SKP_Silk_CLZ64(SKP_int64 in)
SKP_INLINE SKP_int32 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 );
return 32 + silk_CLZ32( (SKP_int32) in );
} else {
/* Search in the upper 32 bits */
return SKP_Silk_CLZ32( in_upper );
return 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_INLINE void 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);
SKP_int32 lzeros = silk_CLZ32(in);
* lz = lzeros;
* frac_Q7 = SKP_ROR32(in, 24 - lzeros) & 0x7f;
* frac_Q7 = silk_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_INLINE SKP_int32 silk_SQRT_APPROX(SKP_int32 x)
{
SKP_int32 y, lz, frac_Q7;
@ -74,7 +74,7 @@ SKP_INLINE SKP_int32 SKP_Silk_SQRT_APPROX(SKP_int32 x)
return 0;
}
SKP_Silk_CLZ_FRAC(x, &lz, &frac_Q7);
silk_CLZ_FRAC(x, &lz, &frac_Q7);
if( lz & 1 ) {
y = 32768;
@ -91,35 +91,8 @@ SKP_INLINE SKP_int32 SKP_Silk_SQRT_APPROX(SKP_int32 x)
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" */
SKP_INLINE SKP_int32 silk_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) */
@ -132,9 +105,9 @@ SKP_INLINE SKP_int32 SKP_DIV32_varQ( /* O returns a good approximation of
SKP_assert( Qres >= 0 );
/* Compute number of bits head room and normalize inputs */
a_headrm = SKP_Silk_CLZ32( SKP_abs(a32) ) - 1;
a_headrm = 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;
b_headrm = silk_CLZ32( SKP_abs(b32) ) - 1;
b32_nrm = SKP_LSHIFT(b32, b_headrm); /* Q: b_headrm */
/* Inverse of b32, with 14 bits of precision */
@ -164,7 +137,7 @@ SKP_INLINE SKP_int32 SKP_DIV32_varQ( /* O returns a good approximation of
}
/* 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" */
SKP_INLINE SKP_int32 silk_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) */
)
@ -176,7 +149,7 @@ SKP_INLINE SKP_int32 SKP_INVERSE32_varQ( /* O returns a good approximation
SKP_assert( Qres > 0 );
/* Compute number of bits head room and normalize input */
b_headrm = SKP_Silk_CLZ32( SKP_abs(b32) ) - 1;
b_headrm = silk_CLZ32( SKP_abs(b32) ) - 1;
b32_nrm = SKP_LSHIFT(b32, b_headrm); /* Q: b_headrm */
/* Inverse of b32, with 14 bits of precision */
@ -209,4 +182,4 @@ SKP_INLINE SKP_int32 SKP_INVERSE32_varQ( /* O returns a good approximation
}
#endif
#endif //_SKP_SILK_FIX_INLINES_H_
#endif //_SILK_FIX_INLINES_H_

View file

@ -25,7 +25,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/*******************************************/
/* LPC analysis filter */
@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* first Order output samples are not set */
/*******************************************/
void SKP_Silk_LPC_analysis_filter(
void 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] */

View file

@ -25,24 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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"
#include "silk_SigProc_FIX.h"
#define QA 16
#define A_LIMIT SKP_FIX_CONST( 0.99975, QA )
#define A_LIMIT SILK_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 ],
SKP_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ],
/* I: Prediction coefficients */
const SKP_int order /* I: Prediction order */
)
@ -69,7 +61,7 @@ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, o
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 */
rc_mult2_Q16 = silk_INVERSE32_varQ( rc_mult1_Q30, 46 ); /* 16 = 46 - 30 */
/* Update inverse gain */
/* invGain_Q30 range: [ 0 : 2^30 ] */
@ -82,7 +74,7 @@ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, o
Anew_QA = A_QA[ k & 1 ];
/* Update AR coefficient */
headrm = SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1;
headrm = 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 );
@ -111,14 +103,14 @@ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, o
}
/* For input in Q12 domain */
SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */
SKP_int 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 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
SKP_int32 *Anew_QA;
Anew_QA = Atmp_QA[ order & 1 ];
@ -132,14 +124,14 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, oth
}
/* For input in Q13 domain */
SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13( /* O: Returns 1 if unstable, otherwise 0 */
SKP_int 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 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
SKP_int32 *Anew_QA;
Anew_QA = Atmp_QA[ order & 1 ];
@ -153,14 +145,14 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13( /* O: Returns 1 if unstable, oth
}
/* For input in Q24 domain */
SKP_int SKP_Silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */
SKP_int 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 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
SKP_int32 *Anew_QA;
Anew_QA = Atmp_QA[ order & 1 ];

View file

@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_typedef.h"
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_typedef.h"
#include "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(
void 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 */
@ -42,7 +42,7 @@ void SKP_Silk_LPC_stabilize(
SKP_int i, idx = 0;
SKP_int32 invGain_Q30;
SKP_Silk_bwexpander_32( a_Q16, L, bwe_Q16 );
silk_bwexpander_32( a_Q16, L, bwe_Q16 );
/***************************/
/* Limit range of the LPCs */
@ -66,7 +66,7 @@ void SKP_Silk_LPC_stabilize(
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 );
silk_bwexpander_32( a_Q16, L, sc_Q16 );
} else {
break;
}
@ -80,12 +80,12 @@ void SKP_Silk_LPC_stabilize(
/**********************/
/* 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
while( silk_LPC_inverse_pred_gain( &invGain_Q30, a_Q12, L ) == 1 ) {
silk_bwexpander( a_Q12, L, 65339 ); // 0.997 in Q16
}
}
void SKP_Silk_LPC_fit(
void 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 */
@ -119,7 +119,7 @@ void SKP_Silk_LPC_fit(
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 );
silk_bwexpander_32( a_Q24, L, sc_Q16 );
} else {
break;
}

View file

@ -26,15 +26,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
/* *
* SKP_Silk_LPC_synthesis_filter.c *
* silk_LPC_synthesis_filter.c *
* Coefficients are in Q12 *
* *
* even order AR filter *
* */
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* even order AR filter */
void SKP_Silk_LPC_synthesis_filter(
void 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 */

View file

@ -26,15 +26,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
/* *
* SKP_Silk_LPC_synthesis_order16.c *
* silk_LPC_synthesis_order16.c *
* Coefficients are in Q12 *
* *
* 16th order AR filter *
* */
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* 16th order AR filter */
void SKP_Silk_LPC_synthesis_order16(const SKP_int16 *in, /* I: excitation signal */
void 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] */

View file

@ -32,10 +32,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[0.95 : 0.15 : 0.35] normalized cut off frequencies.
*/
#include "SKP_Silk_main.h"
#include "silk_main.h"
/* Helper function, interpolates the filter taps */
SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
SKP_INLINE void silk_LP_interpolate_filter_taps(
SKP_int32 B_Q28[ TRANSITION_NB ],
SKP_int32 A_Q28[ TRANSITION_NA ],
const SKP_int ind,
@ -50,16 +50,16 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
/* 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 ],
silk_Transition_LP_B_Q28[ ind ][ nb ],
silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] -
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 ],
silk_Transition_LP_A_Q28[ ind ][ na ],
silk_Transition_LP_A_Q28[ ind + 1 ][ na ] -
silk_Transition_LP_A_Q28[ ind ][ na ],
fac_Q16 );
}
} else { /* ( fac_Q16 - ( 1 << 16 ) ) is in range of a 16-bit int */
@ -67,26 +67,26 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
/* 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 ],
silk_Transition_LP_B_Q28[ ind + 1 ][ nb ],
silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] -
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 ],
silk_Transition_LP_A_Q28[ ind + 1 ][ na ],
silk_Transition_LP_A_Q28[ ind + 1 ][ na ] -
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 ) );
SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ ind ], TRANSITION_NB * sizeof( SKP_int32 ) );
SKP_memcpy( A_Q28, 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 ) );
SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NB * sizeof( SKP_int32 ) );
SKP_memcpy( A_Q28, silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NA * sizeof( SKP_int32 ) );
}
}
@ -94,8 +94,8 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
/* 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 */
void silk_LP_variable_cutoff(
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 */
)
@ -120,13 +120,13 @@ void SKP_Silk_LP_variable_cutoff(
SKP_assert( ind < TRANSITION_INT_NUM );
/* Interpolate filter coefficients */
SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 );
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 );
silk_biquad_alt( signal, B_Q28, A_Q28, psLP->In_LP_State, signal, frame_length );
}
}

View file

@ -29,12 +29,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* 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 */
/* functions are accurate inverses of each other */
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
#include "silk_tables.h"
/* helper function for NLSF2A(..) */
SKP_INLINE void SKP_Silk_NLSF2A_find_poly(
SKP_INLINE void 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) */
@ -56,20 +57,20 @@ SKP_INLINE void SKP_Silk_NLSF2A_find_poly(
}
/* compute whitening filter coefficients from normalized line spectral frequencies */
void SKP_Silk_NLSF2A(
void 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 cos_LSF_Q20[SILK_MAX_ORDER_LPC];
SKP_int32 P[SILK_MAX_ORDER_LPC/2+1], Q[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 a_int32[SILK_MAX_ORDER_LPC];
SKP_int32 maxabs, absval, idx=0, sc_Q16;
SKP_assert( LSF_COS_TAB_SZ_FIX == 128 );
@ -89,8 +90,8 @@ void SKP_Silk_NLSF2A(
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 */
cos_val = silk_LSFCosTab_FIX_Q12[ f_int ]; /* Q12 */
delta = 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 */
@ -99,8 +100,8 @@ void SKP_Silk_NLSF2A(
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 );
silk_NLSF2A_find_poly( P, &cos_LSF_Q20[0], dd );
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++ ) {
@ -130,7 +131,7 @@ void SKP_Silk_NLSF2A(
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 );
silk_bwexpander_32( a_int32, d, sc_Q16 );
} else {
break;
}

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "silk_main.h"
/* Convert NLSF parameters to stable AR prediction filter coefficients */
void SKP_Silk_NLSF2A_stable(
void 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 */
@ -37,12 +37,12 @@ void SKP_Silk_NLSF2A_stable(
SKP_int i;
SKP_int32 invGain_Q30;
SKP_Silk_NLSF2A( pAR_Q12, pNLSF, LPC_order );
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 */
if( silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) {
silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) ); /* 10_Q16 = 0.00015 */
} else {
break;
}

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "silk_main.h"
/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
void SKP_Silk_NLSF_VQ(
void 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] */

View file

@ -25,7 +25,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/*
R. Laroia, N. Phamdo and N. Farvardin, "Robust and Efficient Quantization of Speech LSP
@ -36,7 +36,7 @@ Signal Processing, pp. 641-644, 1991.
#define Q_OUT 5
/* Laroia low complexity NLSF weights */
void SKP_Silk_NLSF_VQ_weights_laroia(
void 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) */

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "silk_main.h"
/* Predictive dequantizer for NLSF residuals */
void SKP_Silk_NLSF_residual_dequant( /* O Returns RD value in Q30 */
void 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 ] */
@ -43,9 +43,9 @@ void SKP_Silk_NLSF_residual_dequant( /* O Returns RD v
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 ) );
out_Q10 = SKP_SUB16( out_Q10, SILK_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_ADD16( out_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
}
out_Q10 = SKP_SMLAWB( pred_Q10, out_Q10, quant_step_size_Q16 );
x_Q10[ i ] = out_Q10;
@ -56,10 +56,10 @@ void SKP_Silk_NLSF_residual_dequant( /* O Returns RD v
/***********************/
/* NLSF vector decoder */
/***********************/
void SKP_Silk_NLSF_decode(
void 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 */
const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */
)
{
SKP_int i;
@ -77,20 +77,20 @@ void SKP_Silk_NLSF_decode(
}
/* Unpack entropy table indices and predictor for current CB1 index */
SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, NLSFIndices[ 0 ] );
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 );
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 );
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 ) );
W_tmp_Q9 = 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 );
silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order );
}

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "silk_main.h"
/* Delayed-decision quantizer for NLSF residuals */
SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */
SKP_int32 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 ] */
@ -72,15 +72,15 @@ SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value
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 ) );
out0_Q10 = SKP_SUB16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
out1_Q10 = SKP_SUB16( out1_Q10, SILK_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 ) );
out1_Q10 = SKP_SUB16( out1_Q10, SILK_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 ) );
out0_Q10 = SKP_ADD16( out0_Q10, SILK_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_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) );
out1_Q10 = SKP_ADD16( out1_Q10, SILK_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 );

View file

@ -25,17 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "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_int32 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 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 */
@ -71,13 +71,13 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v
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 );
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 );
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 );
silk_insertion_sort_increasing( err_Q26, tempIndices1, psNLSF_CB->nVectors, nSurvivors );
/* Loop over survivors */
for( s = 0; s < nSurvivors; s++ ) {
@ -91,11 +91,11 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v
}
/* Weights from codebook vector */
SKP_Silk_NLSF_VQ_weights_laroia( W_tmp_Q5, NLSF_tmp_Q15, psNLSF_CB->order );
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 ) );
W_tmp_Q9 = 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 );
}
@ -105,10 +105,10 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v
}
/* Unpack entropy table indices and predictor for current CB1 index */
SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 );
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,
RD_Q25[ s ] = 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 */
@ -118,33 +118,33 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v
} else {
prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ];
}
bits_q7 = ( 8 << 7 ) - SKP_Silk_lin2log( prob_Q8 );
bits_q7 = ( 8 << 7 ) - 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 );
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 );
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 );
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 );
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 ) );
W_tmp_Q9 = 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 ) );
@ -164,7 +164,7 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v
} else {
prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ];
}
Rate_Q7 = ( 8 << 7 ) - SKP_Silk_lin2log( prob_Q8 );
Rate_Q7 = ( 8 << 7 ) - 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 ) {

View file

@ -33,13 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Euclidean distance to input vector */
/* - Output are sorted NLSF coefficients */
/* */
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* Constant Definitions */
#define MAX_LOOPS 20
/* NLSF stabilizer, for a single input data vector */
void SKP_Silk_NLSF_stabilize(
void 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 */
@ -119,7 +119,7 @@ void SKP_Silk_NLSF_stabilize(
/* 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 );
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] );

View file

@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "silk_main.h"
/* Unpack predictor values and indices for entropy coding tables */
void SKP_Silk_NLSF_unpack(
void 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 silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
const SKP_int CB1_index /* I Index of vector in first LSF codebook */
)
{

View file

@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "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 */
SKP_INLINE void silk_nsq_scale_states(
const silk_encoder_state *psEncC, /* I Encoder State */
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 */
@ -40,8 +40,8 @@ SKP_INLINE void SKP_Silk_nsq_scale_states(
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_INLINE void silk_noise_shape_quantizer(
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 */
@ -62,9 +62,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
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 */
void silk_NSQ(
const silk_encoder_state *psEncC, /* I/O Encoder State */
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 */
@ -96,7 +96,7 @@ void SKP_Silk_NSQ(
SKP_assert( NSQ->prev_inv_gain_Q16 != 0 );
offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ];
offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ];
if( psIndices->NLSFInterpCoef_Q2 == 4 ) {
LSF_interpolation_flag = 0;
@ -129,7 +129,7 @@ void SKP_Silk_NSQ(
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 ],
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;
@ -137,9 +137,9 @@ void SKP_Silk_NSQ(
}
}
SKP_Silk_nsq_scale_states( psEncC, NSQ, x, x_sc_Q10, sLTP, sLTP_Q16, k, LTP_scale_Q14, Gains_Q16, pitchL );
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,
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 );
@ -163,10 +163,10 @@ void SKP_Silk_NSQ(
}
/***********************************/
/* SKP_Silk_noise_shape_quantizer */
/* silk_noise_shape_quantizer */
/***********************************/
SKP_INLINE void SKP_Silk_noise_shape_quantizer(
SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */
SKP_INLINE void silk_noise_shape_quantizer(
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 */
@ -356,9 +356,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
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 */
SKP_INLINE void silk_nsq_scale_states(
const silk_encoder_state *psEncC, /* I Encoder State */
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 */
@ -372,7 +372,7 @@ SKP_INLINE void SKP_Silk_nsq_scale_states(
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 = silk_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );
inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );
lag = pitchL[ subfr ];
@ -391,7 +391,7 @@ SKP_INLINE void SKP_Silk_nsq_scale_states(
/* 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 );
gain_adj_Q16 = silk_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++ ) {

View file

@ -25,7 +25,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "silk_main.h"
typedef struct {
SKP_int32 sLPC_Q14[ MAX_FRAME_LENGTH / MAX_NB_SUBFR + NSQ_LPC_BUF_LENGTH ];
@ -50,9 +50,9 @@ typedef struct {
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 */
SKP_INLINE void silk_nsq_del_dec_scale_states(
const silk_encoder_state *psEncC, /* I Encoder State */
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 */
@ -69,8 +69,8 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
/******************************************/
/* 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 */
SKP_INLINE void silk_noise_shape_quantizer_del_dec(
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 */
@ -98,9 +98,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
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 */
void silk_NSQ_del_dec(
const silk_encoder_state *psEncC, /* I/O Encoder State */
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 */
@ -148,7 +148,7 @@ void SKP_Silk_NSQ_del_dec(
SKP_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) );
}
offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ];
offset_Q10 = 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 );
@ -228,7 +228,7 @@ void SKP_Silk_NSQ_del_dec(
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 ],
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;
@ -236,10 +236,10 @@ void SKP_Silk_NSQ_del_dec(
}
}
SKP_Silk_nsq_del_dec_scale_states( psEncC, NSQ, psDelDec, x, x_sc_Q10, sLTP, sLTP_Q16, k,
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,
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 );
@ -292,8 +292,8 @@ void SKP_Silk_NSQ_del_dec(
/******************************************/
/* 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 */
SKP_INLINE void silk_noise_shape_quantizer_del_dec(
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 */
@ -596,9 +596,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
}
}
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 */
SKP_INLINE void silk_nsq_del_dec_scale_states(
const silk_encoder_state *psEncC, /* I Encoder State */
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 */
@ -616,7 +616,7 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
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 = silk_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );
inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );
lag = pitchL[ subfr ];
@ -635,7 +635,7 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
/* 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 );
gain_adj_Q16 = silk_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++ ) {

View file

@ -25,24 +25,24 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "SKP_Silk_PLC.h"
#include "silk_main.h"
#include "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 */
void silk_PLC_Reset(
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 */
void silk_PLC(
silk_decoder_state *psDec, /* I Decoder state */
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 */
@ -50,7 +50,7 @@ void SKP_Silk_PLC(
{
/* PLC control function */
if( psDec->fs_kHz != psDec->sPLC.fs_kHz ) {
SKP_Silk_PLC_Reset( psDec );
silk_PLC_Reset( psDec );
psDec->sPLC.fs_kHz = psDec->fs_kHz;
}
@ -58,30 +58,30 @@ void SKP_Silk_PLC(
/****************************/
/* Generate Signal */
/****************************/
SKP_Silk_PLC_conceal( psDec, psDecCtrl, signal, length );
silk_PLC_conceal( psDec, psDecCtrl, signal, length );
psDec->lossCnt++;
} else {
/****************************/
/* Update state */
/****************************/
SKP_Silk_PLC_update( psDec, psDecCtrl, signal, length );
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 */
void silk_PLC_update(
silk_decoder_state *psDec, /* (I/O) Decoder state */
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;
silk_PLC_struct *psPLC;
psPLC = &psDec->sPLC;
@ -146,9 +146,9 @@ void SKP_Silk_PLC_update(
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 */
void silk_PLC_conceal(
silk_decoder_state *psDec, /* I/O Decoder state */
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
SKP_int16 signal[], /* O concealed signal */
SKP_int length /* I length of residual */
)
@ -160,14 +160,14 @@ void SKP_Silk_PLC_conceal(
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;
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 ) );
silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SILK_FIX_CONST( BWE_COEF, 16 ) );
/* Find random noise component */
/* Scale previous excitation signal */
@ -180,8 +180,8 @@ void SKP_Silk_PLC_conceal(
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 );
silk_sum_sqr_shift( &energy1, &shift1, exc_buf, psDec->subfr_length );
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 */
@ -218,7 +218,7 @@ void SKP_Silk_PLC_conceal(
/* 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 );
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 );
@ -328,27 +328,27 @@ void SKP_Silk_PLC_conceal(
}
/* 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 */
void silk_PLC_glue_frames(
silk_decoder_state *psDec, /* I/O decoder state */
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;
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 );
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 );
silk_sum_sqr_shift( &energy, &energy_shift, signal, length );
/* Normalize energies */
if( energy_shift > psPLC->conc_energy_shift ) {
@ -362,14 +362,14 @@ void SKP_Silk_PLC_glue_frames(
SKP_int32 frac_Q24, LZ;
SKP_int32 gain_Q16, slope_Q16;
LZ = SKP_Silk_CLZ32( psPLC->conc_energy );
LZ = 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 );
gain_Q16 = SKP_LSHIFT( 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 );

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef SKP_SILK_PLC_FIX_H
#define SKP_SILK_PLC_FIX_H
#ifndef SILK_PLC_FIX_H
#define SILK_PLC_FIX_H
#include "SKP_Silk_main.h"
#include "silk_main.h"
#define BWE_COEF 0.99
#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */
@ -42,35 +42,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#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 silk_PLC_Reset(
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 */
void silk_PLC(
silk_decoder_state *psDec, /* I/O Decoder state */
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 */
void silk_PLC_update(
silk_decoder_state *psDec, /* I/O Decoder state */
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 */
void silk_PLC_conceal(
silk_decoder_state *psDec, /* I/O Decoder state */
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 */
void silk_PLC_glue_frames(
silk_decoder_state *psDec, /* I/O decoder state */
silk_decoder_control *psDecCtrl, /* I/O Decoder control */
SKP_int16 signal[], /* I/O signal */
SKP_int length /* I length of signal */
);

View file

@ -25,26 +25,23 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef _SKP_SILK_SIGPROC_FIX_H_
#define _SKP_SILK_SIGPROC_FIX_H_
#ifndef _SILK_SIGPROC_FIX_H_
#define _SILK_SIGPROC_FIX_H_
#ifdef __cplusplus
extern "C"
{
#endif
//#define SKP_MACRO_COUNT /* Used to enable WMOPS counting */
//#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"
#define SILK_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */
#include <stdlib.h> /* for abs() */
#include <string.h> /* for memset(), memcpy(), memmove() */
#include "silk_typedef.h"
#include "silk_resampler_structs.h"
#include "silk_macros.h"
/********************************************************************/
@ -54,25 +51,24 @@ extern "C"
/*!
* 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_int silk_resampler_init(
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 */
SKP_int silk_resampler_clear(
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_int silk_resampler(
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 */
@ -81,7 +77,7 @@ SKP_int SKP_Silk_resampler(
/*!
Upsample 2x, low quality
*/
void SKP_Silk_resampler_up2(
void 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 ] */
@ -91,7 +87,7 @@ void SKP_Silk_resampler_up2(
/*!
* Downsample 2x, mediocre quality
*/
void SKP_Silk_resampler_down2(
void 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) ] */
@ -102,7 +98,7 @@ void SKP_Silk_resampler_down2(
/*!
* Downsample by a factor 2/3, low quality
*/
void SKP_Silk_resampler_down2_3(
void 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 ] */
@ -112,7 +108,7 @@ void SKP_Silk_resampler_down2_3(
/*!
* Downsample by a factor 3, low quality
*/
void SKP_Silk_resampler_down3(
void 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 ] */
@ -124,11 +120,11 @@ void SKP_Silk_resampler_down3(
* slower than biquad() but uses more precise coefficients
* can handle (slowly) varying coefficients
*/
void SKP_Silk_biquad_alt(
void 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_int32 *S, /* I/O: State vector [2] */
SKP_int16 *out, /* O: output signal */
const SKP_int32 len /* I: signal length (must be even) */
);
@ -136,19 +132,19 @@ void SKP_Silk_biquad_alt(
/*!
* variable order MA filter. Prediction error filter implementation. Coeficients negated and starting with coef to x[n - 1]
*/
void SKP_Silk_MA_Prediction(
void 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 */
const SKP_int32 order /* I: Filter order */
);
/*!
* 16th order AR filter for LPC synthesis, coefficients are in Q12
*/
void SKP_Silk_LPC_synthesis_order16(
void 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 */
@ -158,8 +154,8 @@ void SKP_Silk_LPC_synthesis_order16(
);
/* variable order MA prediction error filter. */
/* Inverse filter of SKP_Silk_LPC_synthesis_filter */
void SKP_Silk_LPC_analysis_filter(
/* Inverse filter of silk_LPC_synthesis_filter */
void 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] */
@ -168,7 +164,7 @@ void SKP_Silk_LPC_analysis_filter(
);
/* even order AR filter */
void SKP_Silk_LPC_synthesis_filter(
void 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 */
@ -179,14 +175,14 @@ void SKP_Silk_LPC_synthesis_filter(
);
/* Chirp (bandwidth expand) LP AR filter */
void SKP_Silk_bwexpander(
void 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(
void 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 */
@ -194,20 +190,20 @@ void SKP_Silk_bwexpander_32(
/* 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_int 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_int 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(
void 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] */
@ -221,24 +217,24 @@ void SKP_Silk_ana_filt_bank_1(
/* 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 */
SKP_int32 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);
SKP_int 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 */
SKP_int32 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 */
SKP_int16 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(
void 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 */
@ -248,7 +244,7 @@ void SKP_Silk_sum_sqr_shift(
/* 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_int32 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 */
@ -257,21 +253,21 @@ SKP_int32 SKP_Silk_schur( /* O: Returns residual energy
/* 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 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(
void 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(
void 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 */
@ -282,7 +278,7 @@ void SKP_Silk_k2a_Q16(
/* 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(
void 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 */
@ -290,7 +286,7 @@ void SKP_Silk_apply_sine_window(
);
/* Compute autocorrelation */
void SKP_Silk_autocorr(
void 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 */
@ -299,11 +295,11 @@ void SKP_Silk_autocorr(
);
/* Pitch estimator */
#define SKP_Silk_PE_MIN_COMPLEX 0
#define SKP_Silk_PE_MID_COMPLEX 1
#define SKP_Silk_PE_MAX_COMPLEX 2
#define SILK_PE_MIN_COMPLEX 0
#define SILK_PE_MID_COMPLEX 1
#define SILK_PE_MAX_COMPLEX 2
void SKP_Silk_decode_pitch(
void silk_decode_pitch(
SKP_int16 lagIndex, /* I */
SKP_int8 contourIndex, /* O */
SKP_int pitch_lags[], /* O 4 pitch values */
@ -311,7 +307,7 @@ void SKP_Silk_decode_pitch(
const SKP_int nb_subfr /* I number of sub frames */
);
SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */
SKP_int 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 */
@ -325,14 +321,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u
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(
void 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 */
@ -341,54 +330,54 @@ void SKP_Silk_LPC_fit(
/* 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(
void 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(
void 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(
void silk_insertion_sort_increasing(
SKP_int32 *a, /* I/O Unsorted / Sorted vector */
SKP_int *index, /* O: Index vector for the sorted elements */
SKP_int *idx, /* 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(
void silk_insertion_sort_decreasing_int16(
SKP_int16 *a, /* I/O: Unsorted / Sorted vector */
SKP_int *index, /* O: Index vector for the sorted elements */
SKP_int *idx, /* 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(
void 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(
void 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(
void 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(
void 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) */
@ -400,7 +389,7 @@ void SKP_Silk_burg_modified(
);
/* Copy and multiply a vector by a constant */
void SKP_Silk_scale_copy_vector16(
void silk_scale_copy_vector16(
SKP_int16 *data_out,
const SKP_int16 *data_in,
SKP_int32 gain_Q16, /* I: gain in Q16 */
@ -408,7 +397,7 @@ void SKP_Silk_scale_copy_vector16(
);
/* Some for the LTP related function requires Q26 to work.*/
void SKP_Silk_scale_vector32_Q26_lshift_18(
void silk_scale_vector32_Q26_lshift_18(
SKP_int32 *data1, /* I/O: Q0/Q18 */
SKP_int32 gain_Q26, /* I: Q26 */
SKP_int dataSize /* I: length */
@ -419,20 +408,20 @@ void SKP_Silk_scale_vector32_Q26_lshift_18(
/********************************************************************/
/* return sum(inVec1[i]*inVec2[i]) */
SKP_int32 SKP_Silk_inner_prod_aligned(
SKP_int32 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(
SKP_int32 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(
SKP_int64 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 */
@ -446,7 +435,7 @@ SKP_int64 SKP_Silk_inner_prod16_aligned_64(
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_INLINE SKP_int32 silk_ROR32( SKP_int32 a32, SKP_int rot )
{
SKP_uint32 x = (SKP_uint32) a32;
SKP_uint32 r = (SKP_uint32) rot;
@ -506,7 +495,7 @@ SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot )
#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
// These macros enables checking for overflow in 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))
@ -581,15 +570,15 @@ SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot )
#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_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(SKP_abs(a)) + (32-silk_CLZ32(SKP_abs(b))))) )
#define SKP_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(SKP_abs(a)) + (16-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))
#define SILK_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)
@ -660,9 +649,9 @@ SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)
// 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"
#include "silk_Inlines.h"
#include "silk_MacroCount.h"
#include "silk_MacroDebug.h"
#ifdef __cplusplus
}

View file

@ -26,19 +26,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include <stdlib.h>
#include "SKP_Silk_main.h"
#include "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 silk_VAD_Init( /* O Return value, 0 if success */
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 ) );
SKP_memset( psSilk_VAD, 0, sizeof( silk_VAD_state ) );
/* init noise levels */
/* Initialize array with approx pink noise levels (psd proportional to inverse of frequency) */
@ -62,13 +62,13 @@ SKP_int SKP_Silk_VAD_Init( /* O Return value, 0
}
/* Weighting factors for tilt measure */
const static SKP_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 };
static const 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 */
SKP_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */
silk_encoder_state *psEncC, /* I/O Encoder state */
const SKP_int16 pIn[] /* I PCM input */
)
{
@ -81,7 +81,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
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;
silk_VAD_state *psSilk_VAD = &psEncC->sVAD;
/* Safety checks */
SKP_assert( VAD_N_BANDS == 4 );
@ -93,13 +93,13 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
/* 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 );
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 ) );
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 ) );
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) */
@ -156,7 +156,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
/********************/
/* Noise estimation */
/********************/
SKP_Silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD );
silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD );
/***********************************************/
/* Signal-plus-noise to noise ratio estimation */
@ -174,7 +174,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
}
/* Convert to log domain */
SNR_Q7 = SKP_Silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128;
SNR_Q7 = silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128;
/* Sum-of-squares */
sumSquared = SKP_SMLABB( sumSquared, SNR_Q7, SNR_Q7 ); /* Q14 */
@ -182,7 +182,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
/* 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 );
SNR_Q7 = SKP_SMULWB( SKP_LSHIFT( silk_SQRT_APPROX( speech_nrg ), 6 ), SNR_Q7 );
}
input_tilt = SKP_SMLAWB( input_tilt, tiltWeights[ b ], SNR_Q7 );
} else {
@ -194,17 +194,17 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
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 */
pSNR_dB_Q7 = ( SKP_int16 )( 3 * 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 );
SA_Q15 = 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 );
psEncC->input_tilt_Q15 = SKP_LSHIFT( silk_sigm_Q15( input_tilt ) - 16384, 1 );
/**************************************************/
/* Scale the sigmoid output based on power levels */
@ -226,7 +226,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
}
/* square-root */
speech_nrg = SKP_Silk_SQRT_APPROX( speech_nrg );
speech_nrg = silk_SQRT_APPROX( speech_nrg );
SA_Q15 = SKP_SMULWB( 32768 + speech_nrg, SA_Q15 );
}
@ -249,9 +249,9 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
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 );
SNR_Q7 = 3 * ( 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 ) );
psEncC->input_quality_bands_Q15[ b ] = silk_sigm_Q15( SKP_RSHIFT( SNR_Q7 - 16 * 128, 4 ) );
}
return( ret );
@ -260,9 +260,9 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s
/**************************/
/* Noise level estimation */
/**************************/
void SKP_Silk_VAD_GetNoiseLevels(
void 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 */
silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */
)
{
SKP_int k;

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_main.h"
#include "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(
void 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 */

View file

@ -25,15 +25,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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"
#include "silk_SigProc_FIX.h"
/* Coefficients for 2-band filter bank based on first-order allpass filters */
// old
@ -41,7 +33,7 @@ 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(
void 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] */

View file

@ -25,7 +25,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* Apply sine window to signal vector. */
/* Window types: */
@ -43,7 +43,7 @@ static SKP_int16 freq_table_Q16[ 27 ] = {
2313, 2214, 2123, 2038, 1961, 1889, 1822, 1760, 1702,
};
void SKP_Silk_apply_sine_window(
void 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 */

View file

@ -25,19 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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"
#include "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 */
SKP_int16 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 */
)

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* Compute autocorrelation */
void SKP_Silk_autocorr(
void 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 */
@ -42,13 +42,13 @@ void SKP_Silk_autocorr(
corrCount = SKP_min_int( inputDataSize, correlationCount );
/* compute energy (zero-lag correlation) */
corr64 = SKP_Silk_inner_prod16_aligned_64( inputData, inputData, inputDataSize );
corr64 = 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 );
lz = silk_CLZ64( corr64 );
/* scaling: number of right shifts applied to correlations */
nRightShifts = 35 - lz;
@ -59,14 +59,14 @@ void SKP_Silk_autocorr(
/* 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 );
results[ i ] = SKP_LSHIFT( 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 ) );
results[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( silk_inner_prod16_aligned_64( inputData, inputData + i, inputDataSize - i ), nRightShifts ) );
}
}
}

View file

@ -26,16 +26,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
/* *
* SKP_Silk_biquad_alt.c *
* silk_biquad_alt.c *
* *
* Second order ARMA filter *
* Can handle slowly varying filter coefficients *
* */
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* Second order ARMA filter, alternative implementation */
void SKP_Silk_biquad_alt(
void 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] */

View file

@ -25,17 +25,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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"
#include "silk_SigProc_FIX.h"
#define MAX_FRAME_SIZE 384 // subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384
#define MAX_NB_SUBFR 4
@ -46,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MAX_RSHIFTS (32 - QA)
/* Compute reflection coefficients from input signal */
void SKP_Silk_burg_modified(
void 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) */
@ -61,25 +51,25 @@ void SKP_Silk_burg_modified(
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 C_first_row[ SILK_MAX_ORDER_LPC ];
SKP_int32 C_last_row[ SILK_MAX_ORDER_LPC ];
SKP_int32 Af_QA[ SILK_MAX_ORDER_LPC ];
SKP_int32 CAf[ SKP_Silk_MAX_ORDER_LPC + 1 ];
SKP_int32 CAb[ SKP_Silk_MAX_ORDER_LPC + 1 ];
SKP_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ];
SKP_int32 CAb[ 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 );
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;
lz = silk_CLZ32( C0 ) - 1;
rshifts_extra = N_BITS_HEAD_ROOM - lz;
if( rshifts_extra > 0 ) {
rshifts_extra = SKP_min( rshifts_extra, MAX_RSHIFTS - rshifts );
@ -90,13 +80,13 @@ void SKP_Silk_burg_modified(
}
rshifts += rshifts_extra;
}
SKP_memset( C_first_row, 0, SKP_Silk_MAX_ORDER_LPC * sizeof( SKP_int32 ) );
SKP_memset( C_first_row, 0, 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 );
silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n ), rshifts );
}
}
} else {
@ -104,11 +94,11 @@ void SKP_Silk_burg_modified(
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 );
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 ) );
SKP_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( SKP_int32 ) );
/* Initialize */
CAb[ 0 ] = CAf[ 0 ] = C0 + SKP_SMMUL( WhiteNoiseFrac_Q32, C0 ) + 1; // Q(-rshifts)
@ -171,7 +161,7 @@ void SKP_Silk_burg_modified(
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 = silk_CLZ32( SKP_abs( Atmp_QA ) ) - 1;
lz = SKP_min( 32 - QA, lz );
Atmp1 = SKP_LSHIFT32( Atmp_QA, lz ); // Q( QA + lz )
@ -188,7 +178,7 @@ void SKP_Silk_burg_modified(
/* Calculate the next order reflection (parcor) coefficient */
if( SKP_abs( num ) < nrg ) {
rc_Q31 = SKP_DIV32_varQ( num, nrg, 31 );
rc_Q31 = silk_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 ) );

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* Chirp (bandwidth expand) LP AR filter */
void SKP_Silk_bwexpander(
void 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) */

View file

@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#include "SKP_Silk_SigProc_FIX.h"
#include "silk_SigProc_FIX.h"
/* Chirp (bandwidth expand) LP AR filter */
void SKP_Silk_bwexpander_32(
void 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 */

Some files were not shown because too many files have changed in this diff Show more