Commit 494ce976 authored by Koen Vos's avatar Koen Vos Committed by Jean-Marc Valin
Browse files

Squashed commit of the following:

commit dfe4d46f9abf6b0e96e66370d428da4e283204ce
Author: Jean-Marc Valin <jean-marc.valin@octasic.com>
Date:   Mon May 2 09:59:45 2011 -0400

    SILK file list update

commit 5faf541d86445eb8ce1775ea206e88afe83c7107
Author: Jean-Marc Valin <jean-marc.valin@octasic.com>
Date:   Mon May 2 09:51:29 2011 -0400

    Makefiles update

commit f5d70b3ccbe209cc07a1a604fffca93ea34bc64b
Author: Koen Vos <koen.vos@skype.net>
Date:   Mon May 2 09:50:33 2011 -0400

    SILK stereo update and MSVC build update
parent fe741259
......@@ -62,6 +62,8 @@ ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
# Directives
CINCLUDES += silk/ \
silk/float/ \
silk/fixed/ \
libcelt/ \
src/
......
......@@ -45,7 +45,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
......@@ -61,7 +61,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
......@@ -74,6 +74,7 @@
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\win32\config.h" />
<ClInclude Include="..\msvc\config.h" />
<ClInclude Include="arch.h" />
<ClInclude Include="bands.h" />
......
......@@ -96,6 +96,9 @@
<ClInclude Include="..\msvc\config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\win32\config.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="bands.c">
......
File mode changed from 100755 to 100644

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus", "src\hybrid.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
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_common", "silk\silk_common.vcxproj", "{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcelt", "celt\libcelt\libcelt.vcxproj", "{245603E3-F580-41A5-9632-B25FE3372CBF}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus", "src\opus.vcxproj", "{219EC965-228A-1824-174D-96449D05F88A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "src_common", "silk\src_common\src_common.vcxproj", "{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}"
ProjectSection(ProjectDependencies) = postProject
{245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_fixed", "silk\fixed\silk_fixed.vcxproj", "{8484C90D-1561-402F-A91D-2DB10F8C5171}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "src_SigProc_FIX", "silk\src_SigProc_FIX\src_SigProc_FIX.vcxproj", "{950F7176-3D29-4CBF-8C40-58B918EAEBB2}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_float", "silk\float\silk_float.vcxproj", "{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "src_SigProc_FLP", "silk\src_SigProc_FLP\src_SigProc_FLP.vcxproj", "{06D10292-A23C-4C5E-9C0F-28737769206F}"
ProjectSection(ProjectDependencies) = postProject
{950F7176-3D29-4CBF-8C40-58B918EAEBB2} = {950F7176-3D29-4CBF-8C40-58B918EAEBB2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "src_FIX", "silk\src_FIX\src_FIX.vcxproj", "{8484C90D-1561-402F-A91D-2DB10F8C5171}"
ProjectSection(ProjectDependencies) = postProject
{950F7176-3D29-4CBF-8C40-58B918EAEBB2} = {950F7176-3D29-4CBF-8C40-58B918EAEBB2}
{06D10292-A23C-4C5E-9C0F-28737769206F} = {06D10292-A23C-4C5E-9C0F-28737769206F}
{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}") = "src_FLP", "silk\src_FLP\src_FLP.vcxproj", "{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}"
ProjectSection(ProjectDependencies) = postProject
{950F7176-3D29-4CBF-8C40-58B918EAEBB2} = {950F7176-3D29-4CBF-8C40-58B918EAEBB2}
{06D10292-A23C-4C5E-9C0F-28737769206F} = {06D10292-A23C-4C5E-9C0F-28737769206F}
{245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF}
{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcelt", "libcelt\libcelt.vcxproj", "{245603E3-F580-41A5-9632-B25FE3372CBF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -45,26 +17,14 @@ Global
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{219EC965-228A-1824-174D-96449D05F88A}.Debug|Win32.ActiveCfg = Debug|Win32
{219EC965-228A-1824-174D-96449D05F88A}.Debug|Win32.Build.0 = Debug|Win32
{219EC965-228A-1824-174D-96449D05F88A}.Release|Win32.ActiveCfg = Release|Win32
{219EC965-228A-1824-174D-96449D05F88A}.Release|Win32.Build.0 = Release|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.ActiveCfg = Debug|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.Build.0 = Debug|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.ActiveCfg = Release|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.Build.0 = Release|Win32
{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|Win32.ActiveCfg = Debug|Win32
{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Debug|Win32.Build.0 = Debug|Win32
{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|Win32.ActiveCfg = Release|Win32
{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}.Release|Win32.Build.0 = Release|Win32
{950F7176-3D29-4CBF-8C40-58B918EAEBB2}.Debug|Win32.ActiveCfg = Debug|Win32
{950F7176-3D29-4CBF-8C40-58B918EAEBB2}.Debug|Win32.Build.0 = Debug|Win32
{950F7176-3D29-4CBF-8C40-58B918EAEBB2}.Release|Win32.ActiveCfg = Release|Win32
{950F7176-3D29-4CBF-8C40-58B918EAEBB2}.Release|Win32.Build.0 = Release|Win32
{06D10292-A23C-4C5E-9C0F-28737769206F}.Debug|Win32.ActiveCfg = Debug|Win32
{06D10292-A23C-4C5E-9C0F-28737769206F}.Debug|Win32.Build.0 = Debug|Win32
{06D10292-A23C-4C5E-9C0F-28737769206F}.Release|Win32.ActiveCfg = Release|Win32
{06D10292-A23C-4C5E-9C0F-28737769206F}.Release|Win32.Build.0 = Release|Win32
{219EC965-228A-1824-174D-96449D05F88A}.Debug|Win32.ActiveCfg = Debug|Win32
{219EC965-228A-1824-174D-96449D05F88A}.Debug|Win32.Build.0 = Debug|Win32
{219EC965-228A-1824-174D-96449D05F88A}.Release|Win32.ActiveCfg = Release|Win32
{219EC965-228A-1824-174D-96449D05F88A}.Release|Win32.Build.0 = Release|Win32
{8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|Win32.ActiveCfg = Debug|Win32
{8484C90D-1561-402F-A91D-2DB10F8C5171}.Debug|Win32.Build.0 = Debug|Win32
{8484C90D-1561-402F-A91D-2DB10F8C5171}.Release|Win32.ActiveCfg = Release|Win32
......@@ -73,6 +33,10 @@ Global
{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Debug|Win32.Build.0 = Debug|Win32
{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|Win32.ActiveCfg = Release|Win32
{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}.Release|Win32.Build.0 = Release|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.ActiveCfg = Debug|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Debug|Win32.Build.0 = Debug|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.ActiveCfg = Release|Win32
{245603E3-F580-41A5-9632-B25FE3372CBF}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -151,7 +151,7 @@ SKP_INLINE SKP_int32 SKP_DIV32_varQ( /* O returns a good approximation of
/* Convert to Qres domain */
lshift = 29 + a_headrm - b_headrm - Qres;
if( lshift <= 0 ) {
if( lshift < 0 ) {
return SKP_LSHIFT_SAT32(result, -lshift);
} else {
if( lshift < 32){
......
......@@ -73,7 +73,4 @@ void SKP_Silk_LPC_analysis_filter(
/* Saturate output */
out[ ix ] = ( SKP_int16 )SKP_SAT16( out32 );
}
/* Set first LPC d samples to zero instead of undefined */
SKP_memset( out, 0, d * sizeof( SKP_int16 ) );
}
......@@ -63,7 +63,6 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
fac_Q16 );
}
} else { /* ( fac_Q16 - ( 1 << 16 ) ) is in range of a 16-bit int */
SKP_assert( fac_Q16 - ( 1 << 16 ) == SKP_SAT16( fac_Q16 - ( 1 << 16 ) ) );
/* Piece-wise linear interpolation of B and A */
for( nb = 0; nb < TRANSITION_NB; nb++ ) {
......@@ -106,7 +105,7 @@ void SKP_Silk_LP_variable_cutoff(
SKP_assert( psLP->transition_frame_no >= 0 && psLP->transition_frame_no <= TRANSITION_FRAMES );
/* Interpolate filter coefficients if needed */
/* Run filter if needed */
if( psLP->mode != 0 ) {
/* Calculate index and interpolation factor for interpolation */
#if( TRANSITION_INT_STEPS == 64 )
......
......@@ -25,12 +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.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "SKP_Silk_tuning_parameters.h"
#if FIXED_POINT
#ifdef FIXED_POINT
#include "SKP_Silk_main_FIX.h"
#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX
#else
......@@ -64,8 +60,9 @@ SKP_INLINE SKP_int SKP_Silk_setup_LBRR(
SKP_int SKP_Silk_control_encoder(
SKP_Silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */
const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */
const SKP_int allow_bw_switch /* I Flag to allow switching audio bandwidth */
const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */
const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
const SKP_int channelNb /* I Channel number */
)
{
SKP_int fs_kHz, ret = 0;
......@@ -77,7 +74,9 @@ SKP_int SKP_Silk_control_encoder(
psEnc->sCmn.minInternal_fs_Hz = encControl->minInternalSampleRate;
psEnc->sCmn.desiredInternal_fs_Hz = encControl->desiredInternalSampleRate;
psEnc->sCmn.useInBandFEC = encControl->useInBandFEC;
psEnc->sCmn.nChannels = encControl->nChannels;
psEnc->sCmn.allow_bandwidth_switch = allow_bw_switch;
psEnc->sCmn.channelNb = channelNb;
if( psEnc->sCmn.controlled_since_last_payload != 0 && psEnc->sCmn.prefillFlag == 0 ) {
if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) {
......@@ -140,7 +139,7 @@ SKP_int SKP_Silk_setup_resamplers(
} else {
/* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */
SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * ( MAX_API_FS_KHZ / 8 ) ];
#if FIXED_POINT
#ifdef FIXED_POINT
SKP_int16 *x_bufFIX = psEnc->x_buf;
#else
SKP_int16 x_bufFIX[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];
......@@ -148,7 +147,7 @@ SKP_int SKP_Silk_setup_resamplers(
nSamples_temp = SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + LA_SHAPE_MS * psEnc->sCmn.fs_kHz;
#if !FIXED_POINT
#ifndef FIXED_POINT
SKP_float2short_array( x_bufFIX, psEnc->x_buf, nSamples_temp );
#endif
......@@ -178,7 +177,7 @@ SKP_int SKP_Silk_setup_resamplers(
/* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */
ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, nSamples_temp );
}
#if !FIXED_POINT
#ifndef FIXED_POINT
SKP_short2float_array( psEnc->x_buf, x_bufFIX, ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * fs_kHz );
#endif
}
......@@ -235,7 +234,7 @@ SKP_int SKP_Silk_setup_fs(
SKP_assert( psEnc->sCmn.nb_subfr == 2 || psEnc->sCmn.nb_subfr == 4 );
if( psEnc->sCmn.fs_kHz != fs_kHz ) {
/* reset part of the state */
#if FIXED_POINT
#ifdef FIXED_POINT
SKP_memset( &psEnc->sShape, 0, sizeof( SKP_Silk_shape_state_FIX ) );
SKP_memset( &psEnc->sPrefilt, 0, sizeof( SKP_Silk_prefilter_state_FIX ) );
#else
......
......@@ -31,14 +31,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SKP_Silk_SDK_API.h"
#include "SKP_Silk_main.h"
/************************/
/* Decoder Super Struct */
/************************/
typedef struct {
SKP_Silk_decoder_state channel_state[ DECODER_NUM_CHANNELS ];
stereo_state sStereo;
SKP_int nChannels;
} SKP_Silk_decoder;
/*********************/
/* Decoder functions */
/*********************/
......@@ -78,10 +79,11 @@ SKP_int SKP_Silk_SDK_Decode(
SKP_int32 *nSamplesOut /* O: Number of samples decoded */
)
{
SKP_int i, n, prev_fs_kHz, doResample, flags, nFlags, MS_predictorIx, ret = SKP_SILK_NO_ERROR;
SKP_int i, n, prev_fs_kHz, doResample, flags, nFlags, ret = SKP_SILK_NO_ERROR;
SKP_int32 nSamplesOutDec, LBRR_symbol;
SKP_int16 samplesOut1_tmp[ 2 * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ];
SKP_int16 samplesOut2_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ];
SKP_int MS_pred_Q14[ 2 ] = { 0 };
SKP_int16 *dec_out_ptr, *resample_out_ptr;
SKP_Silk_decoder *psDec = ( SKP_Silk_decoder * )decState;
SKP_Silk_decoder_state *channel_state = psDec->channel_state;
......@@ -200,7 +202,7 @@ SKP_int SKP_Silk_SDK_Decode(
/* Get MS predictor index */
if( decControl->nChannels == 2 ) {
MS_predictorIx = ec_dec_icdf( psRangeDec, SKP_Silk_stereo_predictor_iCDF, 8 );
SKP_Silk_stereo_decode_pred( psRangeDec, MS_pred_Q14 );
}
/* Call decoder for one frame */
......@@ -210,7 +212,7 @@ SKP_int SKP_Silk_SDK_Decode(
/* Convert Mid/Side to Left/Right */
if( decControl->nChannels == 2 ) {
SKP_Silk_stereo_MS_to_LR( &psDec->sStereo, dec_out_ptr, &dec_out_ptr[ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], MS_predictorIx, channel_state[ 0 ].fs_kHz, nSamplesOutDec );
SKP_Silk_stereo_MS_to_LR( &psDec->sStereo, dec_out_ptr, &dec_out_ptr[ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], MS_pred_Q14, channel_state[ 0 ].fs_kHz, nSamplesOutDec );
}
/* Number of output samples */
......
......@@ -164,7 +164,7 @@ void SKP_Silk_decode_core(
LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], B_Q14[ 4 ] );
pred_lag_ptr++;
/* Generate LPC residual */
/* Generate LPC excitation */
pres_Q10[ i ] = SKP_ADD32( pexc_Q10[ i ], SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) );
/* Update states */
......@@ -196,7 +196,7 @@ void SKP_Silk_decode_core(
LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - j - 1 ], A_Q12_tmp[ j ] );
}
/* Add prediction to LPC residual */
/* Add prediction to LPC excitation */
vec_Q10[ i ] = SKP_ADD32( pres_Q10[ i ], LPC_pred_Q10 );
/* Update states */
......
......@@ -47,10 +47,6 @@ extern "C"
#define MAX_FRAMES_PER_PACKET 3
#ifndef FIXED_POINT
# define FIXED_POINT 0
#endif
/* Limits on bitrate */
#define MIN_TARGET_RATE_BPS 5000
#define MAX_TARGET_RATE_BPS 80000
......@@ -78,9 +74,9 @@ extern "C"
#define TYPE_VOICED 2
/* Setting for stereo processing */
#define STEREO_QUANT_STEPS 15
#define STEREO_QUANT_HYSTERESIS 0.25
#define STEREO_INTERPOL_LENGTH_MS 10
#define STEREO_QUANT_TAB_SIZE 16
#define STEREO_QUANT_SUB_STEPS 5
#define STEREO_INTERP_LEN_MS 8 /* must be even */
/* Range of pitch lag estimates */
#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */
......
......@@ -25,9 +25,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "SKP_Silk_define.h"
#include "SKP_Silk_SDK_API.h"
......@@ -35,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SKP_Silk_typedef.h"
#include "SKP_Silk_structs.h"
#include "SKP_Silk_tuning_parameters.h"
#if FIXED_POINT
#ifdef FIXED_POINT
#include "SKP_Silk_main_FIX.h"
#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX
#define SKP_Silk_encode_frame_Fxx SKP_Silk_encode_frame_FIX
......@@ -142,11 +139,12 @@ SKP_int SKP_Silk_SDK_Encode(
const SKP_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */
)
{
SKP_int n, i, nBits, flags, tmp_payloadSize_ms, tmp_complexity, MS_predictorIx = 0, ret = 0;
SKP_int n, i, nBits, flags, tmp_payloadSize_ms, tmp_complexity, ret = 0;
SKP_int nSamplesToBuffer, nBlocksOf10ms, nSamplesFromInput = 0;
SKP_int speech_act_thr_for_switch_Q8;
SKP_int32 TargetRate_bps, channelRate_bps, LBRR_symbol;
SKP_Silk_encoder *psEnc = ( SKP_Silk_encoder * )encState;
SKP_int MS_predictorIx[ 2 ] = { 0 };
SKP_int16 buf[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ];
/* Check values in encoder control structure */
......@@ -201,7 +199,7 @@ SKP_int SKP_Silk_SDK_Encode(
TargetRate_bps = SKP_RSHIFT32( encControl->bitRate, encControl->nChannels - 1 );
for( n = 0; n < encControl->nChannels; n++ ) {
if( ( ret = SKP_Silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, TargetRate_bps, psEnc->allowBandwidthSwitch ) ) != 0 ) {
if( ( ret = SKP_Silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, TargetRate_bps, psEnc->allowBandwidthSwitch, n ) ) != 0 ) {
SKP_assert( 0 );
return ret;
}
......@@ -287,9 +285,8 @@ SKP_int SKP_Silk_SDK_Encode(
/* Convert Left/Right to Mid/Side */
if( encControl->nChannels == 2 ) {
SKP_Silk_stereo_LR_to_MS( &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf,
&MS_predictorIx, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length );
ec_enc_icdf( psRangeEnc, MS_predictorIx, SKP_Silk_stereo_predictor_iCDF, 8 );
SKP_Silk_stereo_LR_to_MS( psRangeEnc, &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf,
psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length );
}
......@@ -316,12 +313,11 @@ SKP_int SKP_Silk_SDK_Encode(
if( encControl->nChannels == 1 ) {
channelRate_bps = TargetRate_bps;
} else if( n == 0 ) {
channelRate_bps = SKP_SMULWW( TargetRate_bps, SKP_FIX_CONST( 0.6, 16 ) );
channelRate_bps = SKP_RSHIFT( TargetRate_bps, 1 ) + 2000;
} else {
channelRate_bps = SKP_SMULWB( TargetRate_bps, SKP_FIX_CONST( 0.4, 16 ) );
channelRate_bps = SKP_RSHIFT( TargetRate_bps, 1 ) - 2000;
}
SKP_Silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, channelRate_bps );
//SKP_Silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, TargetRate_bps / 2 );
if( ( ret = SKP_Silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc ) ) != 0 ) {
SKP_assert( 0 );
}
......
......@@ -25,11 +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.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if FIXED_POINT
#ifdef FIXED_POINT
#include "SKP_Silk_main_FIX.h"
#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX
#else
......
......@@ -52,10 +52,10 @@ extern "C"
/* 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 *predictorIx, /* O Index for predictor filter */
SKP_int fs_kHz, /* I Samples rate (kHz) */
SKP_int frame_length /* I Number of samples */
);
......@@ -65,11 +65,30 @@ void SKP_Silk_stereo_MS_to_LR(
stereo_state *state, /* I/O State */
SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */
SKP_int16 x2[], /* I/O Right input signal, becomes side signal */
SKP_int predictorIx, /* I Index for predictor filter */
const SKP_int32 pred_Q13[], /* I Predictors */
SKP_int fs_kHz, /* I Samples rate (kHz) */
SKP_int frame_length /* I Number of samples */
);
/* Find least-squares prediction gain for one signal based on another and quantize it */
SKP_int32 SKP_Silk_stereo_find_predictor( /* O Returns predictor in Q13 */
const SKP_int16 x[], /* I Basis signal */
const SKP_int16 y[], /* I Target signal */
SKP_int length /* I Number of samples */
);
/* Quantize mid/side predictors and entropy code the quantization indices */
void SKP_Silk_stereo_encode_pred(
ec_enc *psRangeEnc, /* I/O Compressor data structure */
SKP_int32 pred_Q13[] /* I/O Predictors (out: quantized) */
);
/* Decode mid/side predictors */
void SKP_Silk_stereo_decode_pred(
ec_dec *psRangeDec, /* I/O Compressor data structure */
SKP_int32 pred_Q13[] /* O Predictors */
);
/* Encodes signs of excitation */
void SKP_Silk_encode_signs(
ec_enc *psRangeEnc, /* I/O Compressor data structure */
......
......@@ -29,66 +29,79 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* 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 *predictorIx, /* O Index for predictor filter */
SKP_int fs_kHz, /* I Samples rate (kHz) */
SKP_int frame_length /* I Number of samples */
)
{
SKP_int n, scale, scale1, scale2;
SKP_int32 sum, diff, nrg1, nrg2, corr, predictor_Q16, pred_Q16, delta_Q16;
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 ];
x1[ n ] = (SKP_int16)SKP_RSHIFT32( sum + 1, 1 );
x2[ n ] = (SKP_int16)SKP_RSHIFT32( diff, 1 );
mid[ n + 2 ] = (SKP_int16)SKP_RSHIFT_ROUND( sum, 1 );
side[ n + 2 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( diff, 1 ) );
}
/* Find predictor */
SKP_Silk_sum_sqr_shift( &nrg1, &scale1, x1, frame_length );
SKP_Silk_sum_sqr_shift( &nrg2, &scale2, x2, frame_length );
if( scale1 > scale2 ) {
scale = scale1;
} else {
scale = scale2;
nrg1 = SKP_RSHIFT32( nrg1, scale2 - scale1 );
/* 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;
}
corr = SKP_Silk_inner_prod_aligned_scale( x1, x2, scale, frame_length );
predictor_Q16 = SKP_DIV32_varQ( corr, nrg1 + 1, 16 );
/* Hysteresis */
if( predictor_Q16 > state->predictor_prev_Q16 ) {
predictor_Q16 -= SKP_FIX_CONST( STEREO_QUANT_HYSTERESIS / STEREO_QUANT_STEPS, 16 );
} else {
predictor_Q16 += SKP_FIX_CONST( STEREO_QUANT_HYSTERESIS / STEREO_QUANT_STEPS, 16 );
/* 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;
}
/* Quantize */
*predictorIx = SKP_RSHIFT_ROUND( SKP_MUL( predictor_Q16 + 65536, STEREO_QUANT_STEPS - 1 ), 17 );
*predictorIx = SKP_LIMIT( *predictorIx, 0, STEREO_QUANT_STEPS - 1 );
/* 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 );
predictor_Q16 = SKP_SMLABB( -65536, *predictorIx, ( 1 << 17 ) / ( STEREO_QUANT_STEPS - 1 ) );
/* Quantize and encode predictors */
SKP_Silk_stereo_encode_pred( psRangeEnc, pred_Q13 );
/* Subtract prediction from side channel */
if( predictor_Q16 != state->predictor_prev_Q16 ) {
/* Interpolate predictor */
pred_Q16 = -state->predictor_prev_Q16;
delta_Q16 = -SKP_DIV32_16( predictor_Q16 - state->predictor_prev_Q16, STEREO_INTERPOL_LENGTH_MS * fs_kHz );
for( n = 0; n < STEREO_INTERPOL_LENGTH_MS * fs_kHz; n++ ) {
pred_Q16 += delta_Q16;
x2[ n ] = (SKP_int16)SKP_SAT16( SKP_SMLAWB( x2[ n ], pred_Q16, x1[ n ] ) );
}
} else {
n = 0;
/* 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 ) );
}
pred_Q16 = -predictor_Q16;
for( ; n < frame_length; n++ ) {
x2[ n ] = (SKP_int16)SKP_SAT16( SKP_SMLAWB( x2[ n ], pred_Q16, x1[ n ] ) );
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 ];
state->predictor_prev_Q16 = predictor_Q16;
SKP_memcpy( x1, mid + 1, frame_length * sizeof( SKP_int16 ) );
}
......@@ -32,40 +32,52 @@ void SKP_Silk_stereo_MS_to_LR(
stereo_state *state, /* I/O State */
SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */
SKP_int16 x2[], /* I/O Right input signal, becomes side signal */
SKP_int predictorIx, /* I Index for predictor filter */
const SKP_int32 pred_Q13[], /* I Predictors */
SKP_int fs_kHz, /* I Samples rate (kHz) */
SKP_int frame_length /* I Number of samples */
)
{
SKP_int n;
SKP_int32 sum, diff, predictor_Q16, pred_Q16, delta_Q16;
SKP_int n, denom_Q16, delta0_Q13, delta1_Q13;
SKP_int32 sum, diff, pred0_Q13, pred1_Q13;
SKP_int16 mid[ MAX_FRAME_LENGTH + 2 ], side[ MAX_FRAME_LENGTH + 2 ];
/* Dequantize */
predictor_Q16 = SKP_SMLABB( -65536, predictorIx, ( 1 << 17 ) / ( STEREO_QUANT_STEPS - 1 ) );
/* Buffering */
SKP_memcpy( mid, state->sMid, 2 * sizeof( SKP_int16 ) );
SKP_memcpy( side, state->sSide, 2 * sizeof( SKP_int16 ) );