Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: silk/fixed/noise_shape_analysis_FIX.c

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « silk/fixed/main_FIX.h ('k') | silk/fixed/pitch_analysis_core_FIX.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 #endif 30 #endif
31 31
32 #include "main_FIX.h" 32 #include "main_FIX.h"
33 #include "stack_alloc.h" 33 #include "stack_alloc.h"
34 #include "tuning_parameters.h" 34 #include "tuning_parameters.h"
35 35
36 /* Compute gain to make warped filter coefficients have a zero mean log frequenc y response on a */ 36 /* Compute gain to make warped filter coefficients have a zero mean log frequenc y response on a */
37 /* non-warped frequency scale. (So that it can be implemented with a minimum-pha se monic filter.) */ 37 /* non-warped frequency scale. (So that it can be implemented with a minimum-pha se monic filter.) */
38 /* Note: A monic filter is one with the first coefficient equal to 1.0. In Silk we omit the first */ 38 /* Note: A monic filter is one with the first coefficient equal to 1.0. In Silk we omit the first */
39 /* coefficient in an array of coefficients, for monic filters. */ 39 /* coefficient in an array of coefficients, for monic filters. */
40 static inline opus_int32 warped_gain( /* gain in Q16*/ 40 static OPUS_INLINE opus_int32 warped_gain( /* gain in Q16*/
41 const opus_int32 *coefs_Q24, 41 const opus_int32 *coefs_Q24,
42 opus_int lambda_Q16, 42 opus_int lambda_Q16,
43 opus_int order 43 opus_int order
44 ) { 44 ) {
45 opus_int i; 45 opus_int i;
46 opus_int32 gain_Q24; 46 opus_int32 gain_Q24;
47 47
48 lambda_Q16 = -lambda_Q16; 48 lambda_Q16 = -lambda_Q16;
49 gain_Q24 = coefs_Q24[ order - 1 ]; 49 gain_Q24 = coefs_Q24[ order - 1 ];
50 for( i = order - 2; i >= 0; i-- ) { 50 for( i = order - 2; i >= 0; i-- ) {
51 gain_Q24 = silk_SMLAWB( coefs_Q24[ i ], gain_Q24, lambda_Q16 ); 51 gain_Q24 = silk_SMLAWB( coefs_Q24[ i ], gain_Q24, lambda_Q16 );
52 } 52 }
53 gain_Q24 = silk_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 ); 53 gain_Q24 = silk_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 );
54 return silk_INVERSE32_varQ( gain_Q24, 40 ); 54 return silk_INVERSE32_varQ( gain_Q24, 40 );
55 } 55 }
56 56
57 /* Convert warped filter coefficients to monic pseudo-warped coefficients and li mit maximum */ 57 /* Convert warped filter coefficients to monic pseudo-warped coefficients and li mit maximum */
58 /* amplitude of monic warped coefficients by using bandwidth expansion on the tr ue coefficients */ 58 /* amplitude of monic warped coefficients by using bandwidth expansion on the tr ue coefficients */
59 static inline void limit_warped_coefs( 59 static OPUS_INLINE void limit_warped_coefs(
60 opus_int32 *coefs_syn_Q24, 60 opus_int32 *coefs_syn_Q24,
61 opus_int32 *coefs_ana_Q24, 61 opus_int32 *coefs_ana_Q24,
62 opus_int lambda_Q16, 62 opus_int lambda_Q16,
63 opus_int32 limit_Q24, 63 opus_int32 limit_Q24,
64 opus_int order 64 opus_int order
65 ) { 65 ) {
66 opus_int i, iter, ind = 0; 66 opus_int i, iter, ind = 0;
67 opus_int32 tmp, maxabs_Q24, chirp_Q16, gain_syn_Q16, gain_ana_Q16; 67 opus_int32 tmp, maxabs_Q24, chirp_Q16, gain_syn_Q16, gain_ana_Q16;
68 opus_int32 nom_Q16, den_Q24; 68 opus_int32 nom_Q16, den_Q24;
69 69
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 silk_assert( 0 ); 138 silk_assert( 0 );
139 } 139 }
140 140
141 /**************************************************************/ 141 /**************************************************************/
142 /* Compute noise shaping coefficients and initial gain values */ 142 /* Compute noise shaping coefficients and initial gain values */
143 /**************************************************************/ 143 /**************************************************************/
144 void silk_noise_shape_analysis_FIX( 144 void silk_noise_shape_analysis_FIX(
145 silk_encoder_state_FIX *psEnc, /* I /O Encoder state FIX */ 145 silk_encoder_state_FIX *psEnc, /* I /O Encoder state FIX */
146 silk_encoder_control_FIX *psEncCtrl, /* I /O Encoder control FIX */ 146 silk_encoder_control_FIX *psEncCtrl, /* I /O Encoder control FIX */
147 const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */ 147 const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
148 const opus_int16 *x /* I Input signal [ frame_length + la_shape ] */ 148 const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */
149 int arch /* I Run-time architecture */
149 ) 150 )
150 { 151 {
151 silk_shape_state_FIX *psShapeSt = &psEnc->sShape; 152 silk_shape_state_FIX *psShapeSt = &psEnc->sShape;
152 opus_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0; 153 opus_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0;
153 opus_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp3 2; 154 opus_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp3 2;
154 opus_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_var iation_Q7; 155 opus_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_var iation_Q7;
155 opus_int32 delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8; 156 opus_int32 delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8;
156 opus_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ]; 157 opus_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ];
157 opus_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ]; 158 opus_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ];
158 opus_int32 AR1_Q24[ MAX_SHAPE_LPC_ORDER ]; 159 opus_int32 AR1_Q24[ MAX_SHAPE_LPC_ORDER ];
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part ); 275 silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part );
275 276
276 /* Update pointer: next LPC analysis block */ 277 /* Update pointer: next LPC analysis block */
277 x_ptr += psEnc->sCmn.subfr_length; 278 x_ptr += psEnc->sCmn.subfr_length;
278 279
279 if( psEnc->sCmn.warping_Q16 > 0 ) { 280 if( psEnc->sCmn.warping_Q16 > 0 ) {
280 /* Calculate warped auto correlation */ 281 /* Calculate warped auto correlation */
281 silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warp ing_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder ); 282 silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warp ing_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder );
282 } else { 283 } else {
283 /* Calculate regular auto correlation */ 284 /* Calculate regular auto correlation */
284 silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLe ngth, psEnc->sCmn.shapingLPCOrder + 1 ); 285 silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLe ngth, psEnc->sCmn.shapingLPCOrder + 1, arch );
285 } 286 }
286 287
287 /* Add white noise, as a fraction of energy */ 288 /* Add white noise, as a fraction of energy */
288 auto_corr[0] = silk_ADD32( auto_corr[0], silk_max_32( silk_SMULWB( silk_ RSHIFT( auto_corr[ 0 ], 4 ), 289 auto_corr[0] = silk_ADD32( auto_corr[0], silk_max_32( silk_SMULWB( silk_ RSHIFT( auto_corr[ 0 ], 4 ),
289 SILK_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) ); 290 SILK_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) );
290 291
291 /* Calculate the reflection coefficients using schur */ 292 /* Calculate the reflection coefficients using schur */
292 nrg = silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrde r ); 293 nrg = silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrde r );
293 silk_assert( nrg >= 0 ); 294 silk_assert( nrg >= 0 );
294 295
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 silk_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); 436 silk_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
436 psShapeSt->Tilt_smth_Q16 = 437 psShapeSt->Tilt_smth_Q16 =
437 silk_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); 438 silk_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );
438 439
439 psEncCtrl->HarmBoost_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psSha peSt->HarmBoost_smth_Q16, 2 ); 440 psEncCtrl->HarmBoost_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psSha peSt->HarmBoost_smth_Q16, 2 );
440 psEncCtrl->HarmShapeGain_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psSha peSt->HarmShapeGain_smth_Q16, 2 ); 441 psEncCtrl->HarmShapeGain_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psSha peSt->HarmShapeGain_smth_Q16, 2 );
441 psEncCtrl->Tilt_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psSha peSt->Tilt_smth_Q16, 2 ); 442 psEncCtrl->Tilt_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psSha peSt->Tilt_smth_Q16, 2 );
442 } 443 }
443 RESTORE_STACK; 444 RESTORE_STACK;
444 } 445 }
OLDNEW
« no previous file with comments | « silk/fixed/main_FIX.h ('k') | silk/fixed/pitch_analysis_core_FIX.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698