| OLD | NEW |
| 1 /*********************************************************************** | 1 /*********************************************************************** |
| 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
| 4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
| 5 are met: | 5 are met: |
| 6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
| 7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
| 8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
| 9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
| 10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "SigProc_FIX.h" | 32 #include "SigProc_FIX.h" |
| 33 #include "celt_lpc.h" | 33 #include "celt_lpc.h" |
| 34 | 34 |
| 35 /*******************************************/ | 35 /*******************************************/ |
| 36 /* LPC analysis filter */ | 36 /* LPC analysis filter */ |
| 37 /* NB! State is kept internally and the */ | 37 /* NB! State is kept internally and the */ |
| 38 /* filter always starts with zero state */ | 38 /* filter always starts with zero state */ |
| 39 /* first d output samples are set to zero */ | 39 /* first d output samples are set to zero */ |
| 40 /*******************************************/ | 40 /*******************************************/ |
| 41 | 41 |
| 42 /* OPT: Using celt_fir() for this function should be faster, but it may cause |
| 43 integer overflows in intermediate values (not final results), which the |
| 44 current implementation silences by casting to unsigned. Enabling |
| 45 this should be safe in pretty much all cases, even though it is not technical
ly |
| 46 C89-compliant. */ |
| 47 #define USE_CELT_FIR 0 |
| 48 |
| 42 void silk_LPC_analysis_filter( | 49 void silk_LPC_analysis_filter( |
| 43 opus_int16 *out, /* O Output signal
*/ | 50 opus_int16 *out, /* O Output signal
*/ |
| 44 const opus_int16 *in, /* I Input signal
*/ | 51 const opus_int16 *in, /* I Input signal
*/ |
| 45 const opus_int16 *B, /* I MA prediction coeffi
cients, Q12 [order] */ | 52 const opus_int16 *B, /* I MA prediction coeffi
cients, Q12 [order] */ |
| 46 const opus_int32 len, /* I Signal length
*/ | 53 const opus_int32 len, /* I Signal length
*/ |
| 47 const opus_int32 d, /* I Filter order
*/ | 54 const opus_int32 d, /* I Filter order
*/ |
| 48 int arch /* I Run-time architectur
e */ | 55 int arch /* I Run-time architectur
e */ |
| 49 ) | 56 ) |
| 50 { | 57 { |
| 51 opus_int j; | 58 opus_int j; |
| 52 #ifdef FIXED_POINT | 59 #if defined(FIXED_POINT) && USE_CELT_FIR |
| 53 opus_int16 mem[SILK_MAX_ORDER_LPC]; | |
| 54 opus_int16 num[SILK_MAX_ORDER_LPC]; | 60 opus_int16 num[SILK_MAX_ORDER_LPC]; |
| 55 #else | 61 #else |
| 56 int ix; | 62 int ix; |
| 57 opus_int32 out32_Q12, out32; | 63 opus_int32 out32_Q12, out32; |
| 58 const opus_int16 *in_ptr; | 64 const opus_int16 *in_ptr; |
| 59 #endif | 65 #endif |
| 60 | 66 |
| 61 silk_assert( d >= 6 ); | 67 silk_assert( d >= 6 ); |
| 62 silk_assert( (d & 1) == 0 ); | 68 silk_assert( (d & 1) == 0 ); |
| 63 silk_assert( d <= len ); | 69 silk_assert( d <= len ); |
| 64 | 70 |
| 65 #ifdef FIXED_POINT | 71 #if defined(FIXED_POINT) && USE_CELT_FIR |
| 66 silk_assert( d <= SILK_MAX_ORDER_LPC ); | 72 silk_assert( d <= SILK_MAX_ORDER_LPC ); |
| 67 for ( j = 0; j < d; j++ ) { | 73 for ( j = 0; j < d; j++ ) { |
| 68 num[ j ] = -B[ j ]; | 74 num[ j ] = -B[ j ]; |
| 69 } | 75 } |
| 70 for (j=0;j<d;j++) { | 76 celt_fir( in + d, num, out + d, len - d, d, arch ); |
| 71 mem[ j ] = in[ d - j - 1 ]; | |
| 72 } | |
| 73 celt_fir( in + d, num, out + d, len - d, d, mem, arch ); | |
| 74 for ( j = 0; j < d; j++ ) { | 77 for ( j = 0; j < d; j++ ) { |
| 75 out[ j ] = 0; | 78 out[ j ] = 0; |
| 76 } | 79 } |
| 77 #else | 80 #else |
| 78 (void)arch; | 81 (void)arch; |
| 79 for( ix = d; ix < len; ix++ ) { | 82 for( ix = d; ix < len; ix++ ) { |
| 80 in_ptr = &in[ ix - 1 ]; | 83 in_ptr = &in[ ix - 1 ]; |
| 81 | 84 |
| 82 out32_Q12 = silk_SMULBB( in_ptr[ 0 ], B[ 0 ] ); | 85 out32_Q12 = silk_SMULBB( in_ptr[ 0 ], B[ 0 ] ); |
| 83 /* Allowing wrap around so that two wraps can cancel each other. The rar
e | 86 /* Allowing wrap around so that two wraps can cancel each other. The rar
e |
| (...skipping 15 matching lines...) Expand all Loading... |
| 99 out32 = silk_RSHIFT_ROUND( out32_Q12, 12 ); | 102 out32 = silk_RSHIFT_ROUND( out32_Q12, 12 ); |
| 100 | 103 |
| 101 /* Saturate output */ | 104 /* Saturate output */ |
| 102 out[ ix ] = (opus_int16)silk_SAT16( out32 ); | 105 out[ ix ] = (opus_int16)silk_SAT16( out32 ); |
| 103 } | 106 } |
| 104 | 107 |
| 105 /* Set first d output samples to zero */ | 108 /* Set first d output samples to zero */ |
| 106 silk_memset( out, 0, d * sizeof( opus_int16 ) ); | 109 silk_memset( out, 0, d * sizeof( opus_int16 ) ); |
| 107 #endif | 110 #endif |
| 108 } | 111 } |
| OLD | NEW |