X-Git-Url: https://git.xiph.org/?p=opus.git;a=blobdiff_plain;f=src_FLP%2FSKP_Silk_LPC_analysis_filter_FLP.c;h=b340f5592ad103e144b92b8223399508c6d27a11;hp=3bbe58683748d8d5047d197e93fe3b479bdbe793;hb=fcf95bac9330e8e6db1184496ae33007a7c7a9cf;hpb=fd1a5db140d51e7188e5126db2edc0ab923cfa8c diff --git a/src_FLP/SKP_Silk_LPC_analysis_filter_FLP.c b/src_FLP/SKP_Silk_LPC_analysis_filter_FLP.c index 3bbe5868..b340f559 100644 --- a/src_FLP/SKP_Silk_LPC_analysis_filter_FLP.c +++ b/src_FLP/SKP_Silk_LPC_analysis_filter_FLP.c @@ -1,5 +1,5 @@ /*********************************************************************** -Copyright (c) 2006-2010, Skype Limited. All rights reserved. +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: @@ -35,74 +35,74 @@ 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_FLP( +/* 16th order LPC analysis filter, does not write first 16 samples */ +void SKP_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 */ - const SKP_int length, /* I Length of input signal */ - const SKP_int Order /* I LPC order */ + const SKP_int length /* I Length of input signal */ ) { - SKP_assert( Order <= length ); - - switch( Order ) { - case 8: - SKP_Silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length ); - break; - - case 10: - SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length ); - break; + SKP_int ix; + SKP_float LPC_pred; + const SKP_float *s_ptr; - case 12: - SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length ); - break; + for ( ix = 16; ix < length; ix++) { + s_ptr = &s[ix - 1]; - case 16: - SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length ); - break; + /* short-term prediction */ + LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + + s_ptr[ -1 ] * PredCoef[ 1 ] + + s_ptr[ -2 ] * PredCoef[ 2 ] + + s_ptr[ -3 ] * PredCoef[ 3 ] + + s_ptr[ -4 ] * PredCoef[ 4 ] + + s_ptr[ -5 ] * PredCoef[ 5 ] + + s_ptr[ -6 ] * PredCoef[ 6 ] + + s_ptr[ -7 ] * PredCoef[ 7 ] + + s_ptr[ -8 ] * PredCoef[ 8 ] + + s_ptr[ -9 ] * PredCoef[ 9 ] + + s_ptr[ -10 ] * PredCoef[ 10 ] + + s_ptr[ -11 ] * PredCoef[ 11 ] + + s_ptr[ -12 ] * PredCoef[ 12 ] + + s_ptr[ -13 ] * PredCoef[ 13 ] + + s_ptr[ -14 ] * PredCoef[ 14 ] + + s_ptr[ -15 ] * PredCoef[ 15 ]; - default: - SKP_assert( 0 ); - break; + /* prediction error */ + r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; } - - /* Set first LPC Order samples to zero instead of undefined */ - SKP_memset( r_LPC, 0, Order * sizeof( SKP_float ) ); } -/* 16th order LPC analysis filter, does not write first 16 samples */ -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( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ const SKP_int length /* I Length of input signal */ ) { - SKP_int ix = 16; + SKP_int ix; SKP_float LPC_pred; const SKP_float *s_ptr; - for ( ; ix < length; ix++) { + for ( ix = 14; ix < length; ix++) { s_ptr = &s[ix - 1]; /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[-1] * PredCoef[ 1 ] + - s_ptr[-2] * PredCoef[ 2 ] + - s_ptr[-3] * PredCoef[ 3 ] + - s_ptr[-4] * PredCoef[ 4 ] + - s_ptr[-5] * PredCoef[ 5 ] + - s_ptr[-6] * PredCoef[ 6 ] + - s_ptr[-7] * PredCoef[ 7 ] + - s_ptr[-8] * PredCoef[ 8 ] + - s_ptr[-9] * PredCoef[ 9 ] + - s_ptr[-10] * PredCoef[ 10 ] + - s_ptr[-11] * PredCoef[ 11 ] + - s_ptr[-12] * PredCoef[ 12 ] + - s_ptr[-13] * PredCoef[ 13 ] + - s_ptr[-14] * PredCoef[ 14 ] + - s_ptr[-15] * PredCoef[ 15 ]; + LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + + s_ptr[ -1 ] * PredCoef[ 1 ] + + s_ptr[ -2 ] * PredCoef[ 2 ] + + s_ptr[ -3 ] * PredCoef[ 3 ] + + s_ptr[ -4 ] * PredCoef[ 4 ] + + s_ptr[ -5 ] * PredCoef[ 5 ] + + s_ptr[ -6 ] * PredCoef[ 6 ] + + s_ptr[ -7 ] * PredCoef[ 7 ] + + s_ptr[ -8 ] * PredCoef[ 8 ] + + s_ptr[ -9 ] * PredCoef[ 9 ] + + s_ptr[ -10 ] * PredCoef[ 10 ] + + s_ptr[ -11 ] * PredCoef[ 11 ] + + s_ptr[ -12 ] * PredCoef[ 12 ] + + s_ptr[ -13 ] * PredCoef[ 13 ]; /* prediction error */ r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; @@ -117,26 +117,26 @@ void SKP_Silk_LPC_analysis_filter12_FLP( const SKP_int length /* I Length of input signal */ ) { - SKP_int ix = 12; + SKP_int ix; SKP_float LPC_pred; const SKP_float *s_ptr; - for ( ; ix < length; ix++) { + for ( ix = 12; ix < length; ix++) { s_ptr = &s[ix - 1]; /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[-1] * PredCoef[ 1 ] + - s_ptr[-2] * PredCoef[ 2 ] + - s_ptr[-3] * PredCoef[ 3 ] + - s_ptr[-4] * PredCoef[ 4 ] + - s_ptr[-5] * PredCoef[ 5 ] + - s_ptr[-6] * PredCoef[ 6 ] + - s_ptr[-7] * PredCoef[ 7 ] + - s_ptr[-8] * PredCoef[ 8 ] + - s_ptr[-9] * PredCoef[ 9 ] + - s_ptr[-10] * PredCoef[ 10 ] + - s_ptr[-11] * PredCoef[ 11 ]; + LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + + s_ptr[ -1 ] * PredCoef[ 1 ] + + s_ptr[ -2 ] * PredCoef[ 2 ] + + s_ptr[ -3 ] * PredCoef[ 3 ] + + s_ptr[ -4 ] * PredCoef[ 4 ] + + s_ptr[ -5 ] * PredCoef[ 5 ] + + s_ptr[ -6 ] * PredCoef[ 6 ] + + s_ptr[ -7 ] * PredCoef[ 7 ] + + s_ptr[ -8 ] * PredCoef[ 8 ] + + s_ptr[ -9 ] * PredCoef[ 9 ] + + s_ptr[ -10 ] * PredCoef[ 10 ] + + s_ptr[ -11 ] * PredCoef[ 11 ]; /* prediction error */ r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; @@ -151,24 +151,24 @@ void SKP_Silk_LPC_analysis_filter10_FLP( const SKP_int length /* I Length of input signal */ ) { - SKP_int ix = 10; + SKP_int ix; SKP_float LPC_pred; const SKP_float *s_ptr; - for ( ; ix < length; ix++) { + for ( ix = 10; ix < length; ix++) { s_ptr = &s[ix - 1]; /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[-1] * PredCoef[ 1 ] + - s_ptr[-2] * PredCoef[ 2 ] + - s_ptr[-3] * PredCoef[ 3 ] + - s_ptr[-4] * PredCoef[ 4 ] + - s_ptr[-5] * PredCoef[ 5 ] + - s_ptr[-6] * PredCoef[ 6 ] + - s_ptr[-7] * PredCoef[ 7 ] + - s_ptr[-8] * PredCoef[ 8 ] + - s_ptr[-9] * PredCoef[ 9 ]; + LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + + s_ptr[ -1 ] * PredCoef[ 1 ] + + s_ptr[ -2 ] * PredCoef[ 2 ] + + s_ptr[ -3 ] * PredCoef[ 3 ] + + s_ptr[ -4 ] * PredCoef[ 4 ] + + s_ptr[ -5 ] * PredCoef[ 5 ] + + s_ptr[ -6 ] * PredCoef[ 6 ] + + s_ptr[ -7 ] * PredCoef[ 7 ] + + s_ptr[ -8 ] * PredCoef[ 8 ] + + s_ptr[ -9 ] * PredCoef[ 9 ]; /* prediction error */ r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; @@ -183,11 +183,11 @@ void SKP_Silk_LPC_analysis_filter8_FLP( const SKP_int length /* I Length of input signal */ ) { - SKP_int ix = 8; + SKP_int ix; SKP_float LPC_pred; const SKP_float *s_ptr; - for ( ; ix < length; ix++) { + for ( ix = 8; ix < length; ix++) { s_ptr = &s[ix - 1]; /* short-term prediction */ @@ -204,3 +204,76 @@ void SKP_Silk_LPC_analysis_filter8_FLP( r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; } } + +/* 6th order LPC analysis filter, does not write first 6 samples */ +void SKP_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 */ + const SKP_int length /* I Length of input signal */ +) +{ + SKP_int ix; + SKP_float LPC_pred; + const SKP_float *s_ptr; + + for ( ix = 6; ix < length; ix++) { + s_ptr = &s[ix - 1]; + + /* short-term prediction */ + LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + + s_ptr[ -1 ] * PredCoef[ 1 ] + + s_ptr[ -2 ] * PredCoef[ 2 ] + + s_ptr[ -3 ] * PredCoef[ 3 ] + + s_ptr[ -4 ] * PredCoef[ 4 ] + + s_ptr[ -5 ] * PredCoef[ 5 ]; + + /* prediction error */ + r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; + } +} + +void SKP_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 */ + const SKP_int length, /* I Length of input signal */ + const SKP_int Order /* I LPC order */ +) +{ + SKP_assert( Order <= length ); + + switch( Order ) { + case 6: + SKP_Silk_LPC_analysis_filter6_FLP( r_LPC, PredCoef, s, length ); + break; + + case 8: + SKP_Silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length ); + break; + + case 10: + SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length ); + break; + + case 12: + SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length ); + break; + + case 14: + SKP_Silk_LPC_analysis_filter14_FLP( r_LPC, PredCoef, s, length ); + break; + + case 16: + SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length ); + break; + + default: + SKP_assert( 0 ); + break; + } + + /* Set first LPC Order samples to zero instead of undefined */ + SKP_memset( r_LPC, 0, Order * sizeof( SKP_float ) ); +} +