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

SILK update

parent 4e28e742
......@@ -35,7 +35,6 @@ src_common/SKP_Silk_decode_indices.c \
src_common/SKP_Silk_decode_pulses.c \
src_common/SKP_Silk_decoder_set_fs.c \
src_common/SKP_Silk_dec_API.c \
src_common/SKP_Silk_detect_SWB_input.c \
src_common/SKP_Silk_enc_API.c \
src_common/SKP_Silk_encode_indices.c \
src_common/SKP_Silk_encode_pulses.c \
......@@ -96,7 +95,6 @@ src_SigProc_FIX/SKP_Silk_apply_sine_window.c \
src_SigProc_FIX/SKP_Silk_array_maxabs.c \
src_SigProc_FIX/SKP_Silk_autocorr.c \
src_SigProc_FIX/SKP_Silk_biquad_alt.c \
src_SigProc_FIX/SKP_Silk_biquad.c \
src_SigProc_FIX/SKP_Silk_burg_modified.c \
src_SigProc_FIX/SKP_Silk_bwexpander_32.c \
src_SigProc_FIX/SKP_Silk_bwexpander.c \
......
......@@ -278,14 +278,9 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
/* Unsupported number of frames */
SKP_assert( 0 );
}
if( psEnc->sCmn.fs_kHz == 24 ) {
psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_SWB, 9 );
psEnc->sCmn.bitrate_threshold_up = SKP_int32_MAX;
psEnc->sCmn.bitrate_threshold_down = SWB2WB_BITRATE_BPS;
psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform12_iCDF;
} else if( psEnc->sCmn.fs_kHz == 16 ) {
if( psEnc->sCmn.fs_kHz == 16 ) {
psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );
psEnc->sCmn.bitrate_threshold_up = WB2SWB_BITRATE_BPS;
psEnc->sCmn.bitrate_threshold_up = SKP_int32_MAX;
psEnc->sCmn.bitrate_threshold_down = WB2MB_BITRATE_BPS;
psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
} else if( psEnc->sCmn.fs_kHz == 12 ) {
......@@ -332,7 +327,11 @@ SKP_INLINE SKP_int SKP_Silk_setup_rate(
} else if( psEnc->sCmn.fs_kHz == 16 ) {
rateTable = TargetRate_table_WB;
} else {
rateTable = TargetRate_table_SWB;
SKP_assert( 0 );
}
/* Reduce bitrate for 10 ms modes in these calculations */
if( psEnc->sCmn.nb_subfr == 2 ) {
TargetRate_bps -= REDUCE_BITRATE_10_MS_BPS;
}
for( k = 1; k < TARGET_RATE_TAB_SZ; k++ ) {
/* Find bitrate interval in table and interpolate */
......
......@@ -205,7 +205,7 @@ TOC(ENCODE_PARAMS)
frame_terminator = SKP_SILK_NO_LBRR;
/* Add the frame termination info to stream */
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_FrameTermination_iCDF, 8 );
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_LBRR_Present_iCDF, 8 );
/* Code excitation signal */
for( i = 0; i < psEnc->sCmn.nFramesInPayloadBuf; i++ ) {
......@@ -240,10 +240,6 @@ TOC(ENCODE_PARAMS)
psEnc->BufferedInChannel_ms = SKP_LIMIT_int( psEnc->BufferedInChannel_ms, 0, 100 );
psEnc->sCmn.nBytesInPayloadBuf = nBytes;
if( psEnc->speech_activity_Q8 > SKP_FIX_CONST( WB_DETECT_ACTIVE_SPEECH_LEVEL_THRES, 8 ) ) {
psEnc->sCmn.sSWBdetect.ActiveSpeech_ms = SKP_ADD_POS_SAT32( psEnc->sCmn.sSWBdetect.ActiveSpeech_ms, SKP_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) );
}
TOC(ENCODE_FRAME)
#ifdef SAVE_ALL_INTERNAL_DATA
......@@ -338,8 +334,6 @@ void SKP_Silk_LBRR_encode_FIX(
Rate_only_parameters = 15500;
} else if( psEnc->sCmn.fs_kHz == 16 ) {
Rate_only_parameters = 17500;
} else if( psEnc->sCmn.fs_kHz == 24 ) {
Rate_only_parameters = 19500;
} else {
SKP_assert( 0 );
}
......@@ -412,7 +406,7 @@ void SKP_Silk_LBRR_encode_FIX(
frame_terminator = SKP_SILK_LAST_FRAME;
/* Add the frame termination info to stream */
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_FrameTermination_iCDF, 8 );
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_LBRR_Present_iCDF, 8 );
/*********************************************/
/* Encode quantization indices of excitation */
......@@ -452,7 +446,7 @@ void SKP_Silk_LBRR_encode_FIX(
/* Encode that more frames follows */
frame_terminator = SKP_SILK_MORE_FRAMES;
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_FrameTermination_iCDF, 8 );
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_LBRR_Present_iCDF, 8 );
}
/* Restore original Gains */
......
......@@ -165,11 +165,6 @@ void SKP_Silk_noise_shape_analysis_FIX(
psEncCtrl->current_SNR_dB_Q7 = psEnc->SNR_dB_Q7 - SKP_SMULWB( SKP_LSHIFT( ( SKP_int32 )psEnc->BufferedInChannel_ms, 7 ),
SKP_FIX_CONST( 0.1, 16 ) );
/* Reduce SNR for 10 ms frames */
if( psEnc->sCmn.nb_subfr == 2 ) {
psEncCtrl->current_SNR_dB_Q7 -= SKP_FIX_CONST( 1.5, 7 );
}
/* Reduce SNR_dB if inband FEC used */
if( psEnc->speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {
psEncCtrl->current_SNR_dB_Q7 -= SKP_RSHIFT( psEnc->inBandFEC_SNR_comp_Q8, 1 );
......
......@@ -281,14 +281,9 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
/* Unsupported number of frames */
SKP_assert( 0 );
}
if( psEnc->sCmn.fs_kHz == 24 ) {
psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_SWB, 9 );
psEnc->sCmn.bitrate_threshold_up = SKP_int32_MAX;
psEnc->sCmn.bitrate_threshold_down = SWB2WB_BITRATE_BPS;
psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform12_iCDF;
} else if( psEnc->sCmn.fs_kHz == 16 ) {
if( psEnc->sCmn.fs_kHz == 16 ) {
psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );
psEnc->sCmn.bitrate_threshold_up = WB2SWB_BITRATE_BPS;
psEnc->sCmn.bitrate_threshold_up = SKP_int32_MAX;
psEnc->sCmn.bitrate_threshold_down = WB2MB_BITRATE_BPS;
psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
} else if( psEnc->sCmn.fs_kHz == 12 ) {
......@@ -335,7 +330,11 @@ SKP_INLINE SKP_int SKP_Silk_setup_rate(
} else if( psEnc->sCmn.fs_kHz == 16 ) {
rateTable = TargetRate_table_WB;
} else {
rateTable = TargetRate_table_SWB;
SKP_assert( 0 );
}
/* Reduce bitrate for 10 ms modes in these calculations */
if( psEnc->sCmn.nb_subfr == 2 ) {
TargetRate_bps -= REDUCE_BITRATE_10_MS_BPS;
}
for( k = 1; k < TARGET_RATE_TAB_SZ; k++ ) {
/* Find bitrate interval in table and interpolate */
......
......@@ -162,7 +162,7 @@ TOC(LBRR)
/* Noise shaping quantization */
/*****************************************/
TIC(NSQ)
SKP_Silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, xfw, &psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ], 0 );
SKP_Silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, xfw, &psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf * MAX_FRAME_LENGTH ], 0 );
TOC(NSQ)
/****************************************/
......@@ -202,12 +202,12 @@ TOC(ENCODE_PARAMS)
frame_terminator = SKP_SILK_NO_LBRR;
/* Add the frame termination info to stream */
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_FrameTermination_iCDF, 8 );
ec_enc_icdf( psRangeEnc, frame_terminator, SKP_Silk_LBRR_Present_iCDF, 8 );
/* Code excitation signal */
for( i = 0; i < psEnc->sCmn.nFramesInPayloadBuf; i++ ) {
SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.signalType[ i ], psEnc->sCmn.quantOffsetType[ i ],
&psEnc->sCmn.q[ i * psEnc->sCmn.frame_length ], psEnc->sCmn.frame_length );
&psEnc->sCmn.q[ i * MAX_FRAME_LENGTH ], psEnc->sCmn.frame_length );
}
/* Payload length so far */
......@@ -225,7 +225,7 @@ TOC(ENCODE_PARAMS)
/* Take into account the q signal that isn't in the bitstream yet */
nBytes += SKP_Silk_pulses_to_bytes( &psEnc->sCmn,
&psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ] );
&psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf * MAX_FRAME_LENGTH ] );
}
/* Simulate number of ms buffered in channel because of exceeding TargetRate */
......@@ -234,10 +234,6 @@ TOC(ENCODE_PARAMS)
psEnc->BufferedInChannel_ms = SKP_LIMIT_float( psEnc->BufferedInChannel_ms, 0.0f, 100.0f );
psEnc->sCmn.nBytesInPayloadBuf = nBytes;
if( psEnc->speech_activity > WB_DETECT_ACTIVE_SPEECH_LEVEL_THRES ) {
psEnc->sCmn.sSWBdetect.ActiveSpeech_ms = SKP_ADD_POS_SAT32( psEnc->sCmn.sSWBdetect.ActiveSpeech_ms, SUB_FRAME_LENGTH_MS * psEnc->sCmn.nb_subfr );
}
TOC(ENCODE_FRAME)
#ifdef SAVE_ALL_INTERNAL_DATA
//DEBUG_STORE_DATA( xf.dat, pIn_HP_LP, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
......@@ -307,8 +303,6 @@ void SKP_Silk_LBRR_encode_FLP(
Rate_only_parameters = 15500;
} else if( psEnc->sCmn.fs_kHz == 16 ) {
Rate_only_parameters = 17500;
} else if( psEnc->sCmn.fs_kHz == 24 ) {
Rate_only_parameters = 19500;
} else {
SKP_assert( 0 );
}
......@@ -334,9 +328,9 @@ void SKP_Silk_LBRR_encode_FLP(
/*****************************************/
/* Noise shaping quantization */
/*****************************************/
SKP_Silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, xfw, &psEnc->sCmn.q_LBRR[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ], 1 );
SKP_Silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, xfw, &psEnc->sCmn.q_LBRR[ psEnc->sCmn.nFramesInPayloadBuf * MAX_FRAME_LENGTH ], 1 );
} else {
SKP_memset( &psEnc->sCmn.q_LBRR[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ], 0, psEnc->sCmn.frame_length * sizeof( SKP_int8 ) );
SKP_memset( &psEnc->sCmn.q_LBRR[ psEnc->sCmn.nFramesInPayloadBuf * MAX_FRAME_LENGTH ], 0, psEnc->sCmn.frame_length * sizeof( SKP_int8 ) );
psEncCtrl->sCmn.LTP_scaleIndex = 0;
}
/****************************************/
......@@ -379,7 +373,7 @@ void SKP_Silk_LBRR_encode_FLP(
/*********************************************/
for( i = 0; i < nFramesInPayloadBuf; i++ ) {
SKP_Silk_encode_pulses( &psEnc->sCmn.sRC_LBRR, psEnc->sCmn.signalType[ i ], psEnc->sCmn.quantOffsetType[ i ],
&psEnc->sCmn.q_LBRR[ i * psEnc->sCmn.frame_length ], psEnc->sCmn.frame_length );
&psEnc->sCmn.q_LBRR[ i * MAX_FRAME_LENGTH ], psEnc->sCmn.frame_length );
}
/* Payload length so far */
......
......@@ -144,11 +144,6 @@ void SKP_Silk_noise_shape_analysis_FLP(
/* Reduce SNR_dB values if recent bitstream has exceeded TargetRate */
psEncCtrl->current_SNR_dB = psEnc->SNR_dB - 0.1f * psEnc->BufferedInChannel_ms;
/* Reduce SNR for 10 ms frames */
if( psEnc->sCmn.nb_subfr == 2 ) {
psEncCtrl->current_SNR_dB -= 1.5f;
}
/* Reduce SNR_dB if inband FEC used */
if( psEnc->speech_activity > LBRR_SPEECH_ACTIVITY_THRES ) {
psEncCtrl->current_SNR_dB -= psEnc->inBandFEC_SNR_comp;
......
......@@ -150,18 +150,6 @@ void SKP_Silk_allpass_int(
const SKP_int32 len /* I: Number of samples */
);
/*!
* second order ARMA filter
* can handle (slowly) varying coefficients
*/
void SKP_Silk_biquad(
const SKP_int16 *in, /* I: input signal */
const SKP_int16 *B, /* I: MA coefficients, Q13 [3] */
const SKP_int16 *A, /* I: AR coefficients, Q13 [2] */
SKP_int32 *S, /* I/O: state vector [2] */
SKP_int16 *out, /* O: output signal */
const SKP_int32 len /* I: signal length */
);
/*!
* second order ARMA filter;
* slower than biquad() but uses more precise coefficients
......
/***********************************************************************
Copyright (c) 2006-2010, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of Skype Limited, nor the names of specific
contributors, may be used to endorse or promote products derived from
this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
/* *
* SKP_Silk_biquad.c *
* *
* Second order ARMA filter *
* Can handle slowly varying filter coefficients *
* *
* Copyright 2006 (c), Skype Limited *
* Date: 060221 *
* */
#include "SKP_Silk_SigProc_FIX.h"
/* Second order ARMA filter */
/* Can handle slowly varying filter coefficients */
void SKP_Silk_biquad(
const SKP_int16 *in, /* I: input signal */
const SKP_int16 *B, /* I: MA coefficients, Q13 [3] */
const SKP_int16 *A, /* I: AR coefficients, Q13 [2] */
SKP_int32 *S, /* I/O: state vector [2] */
SKP_int16 *out, /* O: output signal */
const SKP_int32 len /* I: signal length */
)
{
SKP_int k, in16;
SKP_int32 A0_neg, A1_neg, S0, S1, out32;
S0 = S[ 0 ];
S1 = S[ 1 ];
A0_neg = -A[ 0 ];
A1_neg = -A[ 1 ];
for( k = 0; k < len; k++ ) {
/* S[ 0 ], S[ 1 ]: Q13 */
in16 = in[ k ];
out32 = SKP_SMLABB( S0, in16, B[ 0 ] );
S0 = SKP_SMLABB( S1, in16, B[ 1 ] );
S0 += SKP_LSHIFT( SKP_SMULWB( out32, A0_neg ), 3 );
S1 = SKP_LSHIFT( SKP_SMULWB( out32, A1_neg ), 3 );
S1 = SKP_SMLABB( S1, in16, B[ 2 ] );
out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( out32, 13 ) );
}
S[ 0 ] = S0;
S[ 1 ] = S1;
}
......@@ -37,7 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SKP_Silk_SigProc_FIX.h"
#define MAX_FRAME_SIZE 544 // subfr_length * nb_subfr = ( 0.005 * 24000 + 16 ) * 4 = 544
#define MAX_FRAME_SIZE 384 // subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384
#define MAX_NB_SUBFR 4
#define QA 25
......
/***********************************************************************
Copyright (c) 2006-2010, Skype Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, (subject to the limitations in the disclaimer below)
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of Skype Limited, nor the names of specific
contributors, may be used to endorse or promote products derived from
this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
/* *
* SKP_debug.c *
* *
* This contains code to help debugging *
* *
* Copyright 2009 (c), Skype Limited *
* Date: 090629 *
* */
#include "SKP_debug.h"
#include "../src_SigProc_FIX/SKP_Silk_SigProc_FIX.h"
#ifdef _WIN32
#if (defined(_WIN32) || defined(_WINCE))
#include <windows.h> /* timer */
#else // Linux or Mac
#include <sys/time.h>
#endif
unsigned long GetHighResolutionTime() /* O: time in usec*/
{
/* Returns a time counter in microsec */
/* the resolution is platform dependent */
/* but is typically 1.62 us resolution */
LARGE_INTEGER lpPerformanceCount;
LARGE_INTEGER lpFrequency;
QueryPerformanceCounter(&lpPerformanceCount);
QueryPerformanceFrequency(&lpFrequency);
return (unsigned long)((1000000*(lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart);
}
#else // Linux or Mac
unsigned long GetHighResolutionTime() /* O: time in usec*/
{
struct timeval tv;
gettimeofday(&tv, 0);
return((tv.tv_sec*1000000)+(tv.tv_usec));
}
#endif
#if SKP_TIC_TOC
int SKP_Timer_nTimers = 0;
int SKP_Timer_depth_ctr = 0;
char SKP_Timer_tags[SKP_NUM_TIMERS_MAX][SKP_NUM_TIMERS_MAX_TAG_LEN];
#ifdef WIN32
LARGE_INTEGER SKP_Timer_start[SKP_NUM_TIMERS_MAX];
#else
unsigned long SKP_Timer_start[SKP_NUM_TIMERS_MAX];
#endif
unsigned int SKP_Timer_cnt[SKP_NUM_TIMERS_MAX];
SKP_int64 SKP_Timer_min[SKP_NUM_TIMERS_MAX];
SKP_int64 SKP_Timer_sum[SKP_NUM_TIMERS_MAX];
SKP_int64 SKP_Timer_max[SKP_NUM_TIMERS_MAX];
SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX];
#ifdef WIN32
void SKP_TimerSave(char *file_name)
{
if( SKP_Timer_nTimers > 0 )
{
int k;
FILE *fp;
LARGE_INTEGER lpFrequency;
LARGE_INTEGER lpPerformanceCount1, lpPerformanceCount2;
int del = 0x7FFFFFFF;
double avg, sum_avg;
/* estimate overhead of calling performance counters */
for( k = 0; k < 1000; k++ ) {
QueryPerformanceCounter(&lpPerformanceCount1);
QueryPerformanceCounter(&lpPerformanceCount2);
lpPerformanceCount2.QuadPart -= lpPerformanceCount1.QuadPart;
if( (int)lpPerformanceCount2.LowPart < del )
del = lpPerformanceCount2.LowPart;
}
QueryPerformanceFrequency(&lpFrequency);
/* print results to file */
sum_avg = 0.0f;
for( k = 0; k < SKP_Timer_nTimers; k++ ) {
if (SKP_Timer_depth[k] == 0) {
sum_avg += (1e6 * SKP_Timer_sum[k] / SKP_Timer_cnt[k] - del) / lpFrequency.QuadPart * SKP_Timer_cnt[k];
}
}
fp = fopen(file_name, "w");
fprintf(fp, " min avg %% max count\n");
for( k = 0; k < SKP_Timer_nTimers; k++ ) {
if (SKP_Timer_depth[k] == 0) {
fprintf(fp, "%-28s", SKP_Timer_tags[k]);
} else if (SKP_Timer_depth[k] == 1) {
fprintf(fp, " %-27s", SKP_Timer_tags[k]);
} else if (SKP_Timer_depth[k] == 2) {
fprintf(fp, " %-26s", SKP_Timer_tags[k]);
} else if (SKP_Timer_depth[k] == 3) {
fprintf(fp, " %-25s", SKP_Timer_tags[k]);
} else {
fprintf(fp, " %-24s", SKP_Timer_tags[k]);
}
avg = (1e6 * SKP_Timer_sum[k] / SKP_Timer_cnt[k] - del) / lpFrequency.QuadPart;
fprintf(fp, "%8.2f", (1e6 * (SKP_max_64(SKP_Timer_min[k] - del, 0))) / lpFrequency.QuadPart);
fprintf(fp, "%12.2f %6.2f", avg, 100.0 * avg / sum_avg * SKP_Timer_cnt[k]);
fprintf(fp, "%12.2f", (1e6 * (SKP_max_64(SKP_Timer_max[k] - del, 0))) / lpFrequency.QuadPart);
fprintf(fp, "%10d\n", SKP_Timer_cnt[k]);
}
fprintf(fp, " microseconds\n");
fclose(fp);
}
}
#else
void SKP_TimerSave(char *file_name)
{
if( SKP_Timer_nTimers > 0 )
{
int k;
FILE *fp;
/* print results to file */
fp = fopen(file_name, "w");
fprintf(fp, " min avg max count\n");
for( k = 0; k < SKP_Timer_nTimers; k++ )
{
if (SKP_Timer_depth[k] == 0) {
fprintf(fp, "%-28s", SKP_Timer_tags[k]);
} else if (SKP_Timer_depth[k] == 1) {
fprintf(fp, " %-27s", SKP_Timer_tags[k]);
} else if (SKP_Timer_depth[k] == 2) {
fprintf(fp, " %-26s", SKP_Timer_tags[k]);
} else if (SKP_Timer_depth[k] == 3) {
fprintf(fp, " %-25s", SKP_Timer_tags[k]);
} else {
fprintf(fp, " %-24s", SKP_Timer_tags[k]);
}
fprintf(fp, "%d ", SKP_Timer_min[k]);
fprintf(fp, "%f ", (double)SKP_Timer_sum[k] / (double)SKP_Timer_cnt[k]);
fprintf(fp, "%d ", SKP_Timer_max[k]);
fprintf(fp, "%10d\n", SKP_Timer_cnt[k]);
}
fprintf(fp, " microseconds\n");
fclose(fp);
}
}
#endif
#endif /* SKP_TIC_TOC */
#if SKP_DEBUG
FILE *SKP_debug_store_fp[ SKP_NUM_STORES_MAX ];
int SKP_debug_store_count = 0;
#endif /* SKP_DEBUG */
......@@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
void SKP_Silk_decode_pitch(
SKP_int lagIndex, /* I */
SKP_int contourIndex, /* O */
SKP_int pitch_lags[], /* O 4 pitch values */
SKP_int pitch_lags[], /* O pitch values */
const SKP_int Fs_kHz, /* I sampling frequency (kHz) */
const SKP_int nb_subfr /* I number of sub frames */
)
......@@ -47,7 +47,7 @@ void SKP_Silk_decode_pitch(
Lag_CB_ptr = &SKP_Silk_CB_lags_stage2[ 0 ][ 0 ];
cbk_size = PE_NB_CBKS_STAGE2_EXT;
} else {
SKP_assert( PE_MAX_NB_SUBFR >> 1 == nb_subfr );
SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 );
Lag_CB_ptr = &SKP_Silk_CB_lags_stage2_10_ms[ 0 ][ 0 ];
cbk_size = PE_NB_CBKS_STAGE2_10MS;
}
......@@ -56,7 +56,7 @@ void SKP_Silk_decode_pitch(
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ];
cbk_size = PE_NB_CBKS_STAGE3_MAX;
} else {
SKP_assert( PE_MAX_NB_SUBFR >> 1 == nb_subfr );
SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 );
Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ];
cbk_size = PE_NB_CBKS_STAGE3_10MS;
}
......
......@@ -103,7 +103,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u
SKP_int32 delta_lag_log2_sqr_Q7, lag_log2_Q7, prevLag_log2_Q7, prev_lag_bias_Q15, corr_thres_Q15;
const SKP_int8 *Lag_CB_ptr;
/* Check for valid sampling frequency */
SKP_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 || Fs_kHz == 24 );
SKP_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 );
/* Check for valid complexity setting */
SKP_assert( complexity >= SKP_Silk_PE_MIN_COMPLEX );
......@@ -136,10 +136,6 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u
SKP_int32 R23[ 6 ];
SKP_memset( R23, 0, 6 * sizeof( SKP_int32 ) );
SKP_Silk_resampler_down2_3( R23, signal_8kHz, signal, frame_length );
} else if( Fs_kHz == 24 ) {
SKP_int32 filt_state_fix[ 8 ];
SKP_memset( filt_state_fix, 0, 8 * sizeof(SKP_int32) );
SKP_Silk_resampler_down3( filt_state_fix, signal_8kHz, signal, frame_length );
} else {
SKP_assert( Fs_kHz == 8 );
SKP_memcpy( signal_8kHz, signal, frame_length_8kHz * sizeof(SKP_int16) );
......@@ -372,8 +368,6 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u
prevLag = SKP_DIV32_16( SKP_LSHIFT( prevLag, 1 ), 3 );
} else if( Fs_kHz == 16 ) {
prevLag = SKP_RSHIFT( prevLag, 1 );
} else if( Fs_kHz == 24 ) {
prevLag = SKP_DIV32_16( prevLag, 3 );
}
prevLag_log2_Q7 = SKP_Silk_lin2log( (SKP_int32)prevLag );
} else {
......@@ -570,7 +564,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u
CCmax = SKP_max( CCmax, 0 );
*LTPCorr_Q15 = (SKP_int)SKP_Silk_SQRT_APPROX( SKP_LSHIFT( CCmax, 13 ) ); /* Output normalized correlation */
for( k = 0; k < nb_subfr; k++ ) {
pitch_out[ k ] = lag + SKP_Silk_CB_lags_stage2[ k ][ CBimax ];
pitch_out[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size );
}
*lagIndex = lag - min_lag_8kHz;
*contourIndex = CBimax;
......
......@@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Definitions For Fix pitch estimator */
/************************************************************/
#define PE_MAX_FS_KHZ 24 /* Maximum sampling frequency used */
#define PE_MAX_FS_KHZ 16 /* Maximum sampling frequency used */
#define PE_MAX_NB_SUBFR 4
#define PE_SUBFR_LENGTH_MS 5 /* 5 ms */
......
......@@ -91,7 +91,6 @@
<ClCompile Include="SKP_Silk_apply_sine_window.c" />
<ClCompile Include="SKP_Silk_array_maxabs.c" />
<ClCompile Include="SKP_Silk_autocorr.c" />
<ClCompile Include="SKP_Silk_biquad.c" />
<ClCompile Include="SKP_Silk_biquad_alt.c" />
<ClCompile Include="SKP_Silk_burg_modified.c" />
<ClCompile Include="SKP_Silk_bwexpander.c" />
......
......@@ -65,9 +65,6 @@
<ClCompile Include="SKP_Silk_autocorr.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_biquad.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SKP_Silk_biquad_alt.c">
<Filter>Source Files</Filter>
</ClCompile>
......
......@@ -37,11 +37,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SKP_Silk_SigProc_FLP.h"
#define MAX_FRAME_SIZE 544 // subfr_length * nb_subfr = ( 0.005 * 24000 + 16 ) * 4 = 544
#define MAX_FRAME_SIZE 384 // subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384