Commit 103302b3 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

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
parent c77b9633
......@@ -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
......
/* 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 */
......@@ -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" />
......
......@@ -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>
......
......@@ -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
......
/***********************************************************************
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
......@@ -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 */
......
......@@ -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 ];
}
......@@ -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] */
......
......@@ -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;
}
/***************************************/
/* Ensure smooth bandwidth transitions */
/***************************************/
silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length );
/*******************************************/
/* High-pass filtering of the input signal */
/* Copy new frame to front of input buffer */
/*******************************************/
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)
SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
/* 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 );
/*****************************************/
/* 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 );