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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 opus_int complexity, /* I Complexity setting
*/ | 65 opus_int complexity, /* I Complexity setting
*/ |
66 int arch /* I Run-time architectur
e */ | 66 int arch /* I Run-time architectur
e */ |
67 ); | 67 ); |
68 | 68 |
69 static void silk_P_Ana_calc_energy_st3( | 69 static void silk_P_Ana_calc_energy_st3( |
70 silk_pe_stage3_vals energies_st3[], /* O 3 DIM energy array *
/ | 70 silk_pe_stage3_vals energies_st3[], /* O 3 DIM energy array *
/ |
71 const opus_int16 frame[], /* I vector to calc energ
y in */ | 71 const opus_int16 frame[], /* I vector to calc energ
y in */ |
72 opus_int start_lag, /* I lag offset to search
around */ | 72 opus_int start_lag, /* I lag offset to search
around */ |
73 opus_int sf_length, /* I length of one 5 ms s
ubframe */ | 73 opus_int sf_length, /* I length of one 5 ms s
ubframe */ |
74 opus_int nb_subfr, /* I number of subframes
*/ | 74 opus_int nb_subfr, /* I number of subframes
*/ |
75 opus_int complexity /* I Complexity setting
*/ | 75 opus_int complexity, /* I Complexity setting
*/ |
| 76 int arch /* I Run-time architectur
e */ |
76 ); | 77 ); |
77 | 78 |
78 /*************************************************************/ | 79 /*************************************************************/ |
79 /* FIXED POINT CORE PITCH ANALYSIS FUNCTION */ | 80 /* FIXED POINT CORE PITCH ANALYSIS FUNCTION */ |
80 /*************************************************************/ | 81 /*************************************************************/ |
81 opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0
voiced, 1 unvoiced */ | 82 opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0
voiced, 1 unvoiced */ |
82 const opus_int16 *frame, /* I Signal of length PE_
FRAME_LENGTH_MS*Fs_kHz */ | 83 const opus_int16 *frame, /* I Signal of length PE_
FRAME_LENGTH_MS*Fs_kHz */ |
83 opus_int *pitch_out, /* O 4 pitch lag values
*/ | 84 opus_int *pitch_out, /* O 4 pitch lag values
*/ |
84 opus_int16 *lagIndex, /* O Lag Index
*/ | 85 opus_int16 *lagIndex, /* O Lag Index
*/ |
85 opus_int8 *contourIndex, /* O Pitch contour Index
*/ | 86 opus_int8 *contourIndex, /* O Pitch contour Index
*/ |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 basis_ptr = target_ptr - MIN_LAG_4KHZ; | 189 basis_ptr = target_ptr - MIN_LAG_4KHZ; |
189 | 190 |
190 /* Check that we are within range of the array */ | 191 /* Check that we are within range of the array */ |
191 silk_assert( basis_ptr >= frame_4kHz ); | 192 silk_assert( basis_ptr >= frame_4kHz ); |
192 silk_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_4kHz + frame_length_4kH
z ); | 193 silk_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_4kHz + frame_length_4kH
z ); |
193 | 194 |
194 celt_pitch_xcorr( target_ptr, target_ptr - MAX_LAG_4KHZ, xcorr32, SF_LEN
GTH_8KHZ, MAX_LAG_4KHZ - MIN_LAG_4KHZ + 1, arch ); | 195 celt_pitch_xcorr( target_ptr, target_ptr - MAX_LAG_4KHZ, xcorr32, SF_LEN
GTH_8KHZ, MAX_LAG_4KHZ - MIN_LAG_4KHZ + 1, arch ); |
195 | 196 |
196 /* Calculate first vector products before loop */ | 197 /* Calculate first vector products before loop */ |
197 cross_corr = xcorr32[ MAX_LAG_4KHZ - MIN_LAG_4KHZ ]; | 198 cross_corr = xcorr32[ MAX_LAG_4KHZ - MIN_LAG_4KHZ ]; |
198 normalizer = silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_
8KHZ ); | 199 normalizer = silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_
8KHZ, arch ); |
199 normalizer = silk_ADD32( normalizer, silk_inner_prod_aligned( basis_ptr,
basis_ptr, SF_LENGTH_8KHZ ) ); | 200 normalizer = silk_ADD32( normalizer, silk_inner_prod_aligned( basis_ptr,
basis_ptr, SF_LENGTH_8KHZ, arch ) ); |
200 normalizer = silk_ADD32( normalizer, silk_SMULBB( SF_LENGTH_8KHZ, 4000 )
); | 201 normalizer = silk_ADD32( normalizer, silk_SMULBB( SF_LENGTH_8KHZ, 4000 )
); |
201 | 202 |
202 matrix_ptr( C, k, 0, CSTRIDE_4KHZ ) = | 203 matrix_ptr( C, k, 0, CSTRIDE_4KHZ ) = |
203 (opus_int16)silk_DIV32_varQ( cross_corr, normalizer, 13 + 1 );
/* Q13 */ | 204 (opus_int16)silk_DIV32_varQ( cross_corr, normalizer, 13 + 1 );
/* Q13 */ |
204 | 205 |
205 /* From now on normalizer is computed recursively */ | 206 /* From now on normalizer is computed recursively */ |
206 for( d = MIN_LAG_4KHZ + 1; d <= MAX_LAG_4KHZ; d++ ) { | 207 for( d = MIN_LAG_4KHZ + 1; d <= MAX_LAG_4KHZ; d++ ) { |
207 basis_ptr--; | 208 basis_ptr--; |
208 | 209 |
209 /* Check that we are within range of the array */ | 210 /* Check that we are within range of the array */ |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 ****************************************************************************
*****/ | 328 ****************************************************************************
*****/ |
328 silk_memset( C, 0, nb_subfr * CSTRIDE_8KHZ * sizeof( opus_int16 ) ); | 329 silk_memset( C, 0, nb_subfr * CSTRIDE_8KHZ * sizeof( opus_int16 ) ); |
329 | 330 |
330 target_ptr = &frame_8kHz[ PE_LTP_MEM_LENGTH_MS * 8 ]; | 331 target_ptr = &frame_8kHz[ PE_LTP_MEM_LENGTH_MS * 8 ]; |
331 for( k = 0; k < nb_subfr; k++ ) { | 332 for( k = 0; k < nb_subfr; k++ ) { |
332 | 333 |
333 /* Check that we are within range of the array */ | 334 /* Check that we are within range of the array */ |
334 silk_assert( target_ptr >= frame_8kHz ); | 335 silk_assert( target_ptr >= frame_8kHz ); |
335 silk_assert( target_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length_8k
Hz ); | 336 silk_assert( target_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length_8k
Hz ); |
336 | 337 |
337 energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_
ptr, SF_LENGTH_8KHZ ), 1 ); | 338 energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_
ptr, SF_LENGTH_8KHZ, arch ), 1 ); |
338 for( j = 0; j < length_d_comp; j++ ) { | 339 for( j = 0; j < length_d_comp; j++ ) { |
339 d = d_comp[ j ]; | 340 d = d_comp[ j ]; |
340 basis_ptr = target_ptr - d; | 341 basis_ptr = target_ptr - d; |
341 | 342 |
342 /* Check that we are within range of the array */ | 343 /* Check that we are within range of the array */ |
343 silk_assert( basis_ptr >= frame_8kHz ); | 344 silk_assert( basis_ptr >= frame_8kHz ); |
344 silk_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length
_8kHz ); | 345 silk_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length
_8kHz ); |
345 | 346 |
346 cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, SF_LENG
TH_8KHZ ); | 347 cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, SF_LENG
TH_8KHZ, arch ); |
347 if( cross_corr > 0 ) { | 348 if( cross_corr > 0 ) { |
348 energy_basis = silk_inner_prod_aligned( basis_ptr, basis_ptr, SF
_LENGTH_8KHZ ); | 349 energy_basis = silk_inner_prod_aligned( basis_ptr, basis_ptr, SF
_LENGTH_8KHZ, arch ); |
349 matrix_ptr( C, k, d - ( MIN_LAG_8KHZ - 2 ), CSTRIDE_8KHZ ) = | 350 matrix_ptr( C, k, d - ( MIN_LAG_8KHZ - 2 ), CSTRIDE_8KHZ ) = |
350 (opus_int16)silk_DIV32_varQ( cross_corr, | 351 (opus_int16)silk_DIV32_varQ( cross_corr, |
351 silk_ADD32( energy_target, | 352 silk_ADD32( energy_target, |
352 energy_basis ), | 353 energy_basis ), |
353 13 + 1 );
/* Q13 */ | 354 13 + 1 );
/* Q13 */ |
354 } else { | 355 } else { |
355 matrix_ptr( C, k, d - ( MIN_LAG_8KHZ - 2 ), CSTRIDE_8KHZ ) = 0; | 356 matrix_ptr( C, k, d - ( MIN_LAG_8KHZ - 2 ), CSTRIDE_8KHZ ) = 0; |
356 } | 357 } |
357 } | 358 } |
358 target_ptr += SF_LENGTH_8KHZ; | 359 target_ptr += SF_LENGTH_8KHZ; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } else { | 513 } else { |
513 nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; | 514 nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; |
514 cbk_size = PE_NB_CBKS_STAGE3_10MS; | 515 cbk_size = PE_NB_CBKS_STAGE3_10MS; |
515 Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; | 516 Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; |
516 } | 517 } |
517 | 518 |
518 /* Calculate the correlations and energies needed in stage 3 */ | 519 /* Calculate the correlations and energies needed in stage 3 */ |
519 ALLOC( energies_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); | 520 ALLOC( energies_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); |
520 ALLOC( cross_corr_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); | 521 ALLOC( cross_corr_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); |
521 silk_P_Ana_calc_corr_st3( cross_corr_st3, input_frame_ptr, start_lag, s
f_length, nb_subfr, complexity, arch ); | 522 silk_P_Ana_calc_corr_st3( cross_corr_st3, input_frame_ptr, start_lag, s
f_length, nb_subfr, complexity, arch ); |
522 silk_P_Ana_calc_energy_st3( energies_st3, input_frame_ptr, start_lag, sf
_length, nb_subfr, complexity ); | 523 silk_P_Ana_calc_energy_st3( energies_st3, input_frame_ptr, start_lag, sf
_length, nb_subfr, complexity, arch ); |
523 | 524 |
524 lag_counter = 0; | 525 lag_counter = 0; |
525 silk_assert( lag == silk_SAT16( lag ) ); | 526 silk_assert( lag == silk_SAT16( lag ) ); |
526 contour_bias_Q15 = silk_DIV32_16( SILK_FIX_CONST( PE_FLATCONTOUR_BIAS, 1
5 ), lag ); | 527 contour_bias_Q15 = silk_DIV32_16( SILK_FIX_CONST( PE_FLATCONTOUR_BIAS, 1
5 ), lag ); |
527 | 528 |
528 target_ptr = &input_frame_ptr[ PE_LTP_MEM_LENGTH_MS * Fs_kHz ]; | 529 target_ptr = &input_frame_ptr[ PE_LTP_MEM_LENGTH_MS * Fs_kHz ]; |
529 energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_
ptr, nb_subfr * sf_length ), 1 ); | 530 energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_
ptr, nb_subfr * sf_length, arch ), 1 ); |
530 for( d = start_lag; d <= end_lag; d++ ) { | 531 for( d = start_lag; d <= end_lag; d++ ) { |
531 for( j = 0; j < nb_cbk_search; j++ ) { | 532 for( j = 0; j < nb_cbk_search; j++ ) { |
532 cross_corr = 0; | 533 cross_corr = 0; |
533 energy = energy_target; | 534 energy = energy_target; |
534 for( k = 0; k < nb_subfr; k++ ) { | 535 for( k = 0; k < nb_subfr; k++ ) { |
535 cross_corr = silk_ADD32( cross_corr, | 536 cross_corr = silk_ADD32( cross_corr, |
536 matrix_ptr( cross_corr_st3, k, j, | 537 matrix_ptr( cross_corr_st3, k, j, |
537 nb_cbk_search )[ lag_counter ] ); | 538 nb_cbk_search )[ lag_counter ] ); |
538 energy = silk_ADD32( energy, | 539 energy = silk_ADD32( energy, |
539 matrix_ptr( energies_st3, k, j, | 540 matrix_ptr( energies_st3, k, j, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 /********************************************************************/ | 665 /********************************************************************/ |
665 /* Calculate the energies for first two subframes. The energies are */ | 666 /* Calculate the energies for first two subframes. The energies are */ |
666 /* calculated recursively. */ | 667 /* calculated recursively. */ |
667 /********************************************************************/ | 668 /********************************************************************/ |
668 static void silk_P_Ana_calc_energy_st3( | 669 static void silk_P_Ana_calc_energy_st3( |
669 silk_pe_stage3_vals energies_st3[], /* O 3 DIM energy array
*/ | 670 silk_pe_stage3_vals energies_st3[], /* O 3 DIM energy array
*/ |
670 const opus_int16 frame[], /* I vector to calc ener
gy in */ | 671 const opus_int16 frame[], /* I vector to calc ener
gy in */ |
671 opus_int start_lag, /* I lag offset to searc
h around */ | 672 opus_int start_lag, /* I lag offset to searc
h around */ |
672 opus_int sf_length, /* I length of one 5 ms
subframe */ | 673 opus_int sf_length, /* I length of one 5 ms
subframe */ |
673 opus_int nb_subfr, /* I number of subframes
*/ | 674 opus_int nb_subfr, /* I number of subframes
*/ |
674 opus_int complexity /* I Complexity setting
*/ | 675 opus_int complexity, /* I Complexity setting
*/ |
| 676 int arch /* I Run-time architectu
re */ |
675 ) | 677 ) |
676 { | 678 { |
677 const opus_int16 *target_ptr, *basis_ptr; | 679 const opus_int16 *target_ptr, *basis_ptr; |
678 opus_int32 energy; | 680 opus_int32 energy; |
679 opus_int k, i, j, lag_counter; | 681 opus_int k, i, j, lag_counter; |
680 opus_int nb_cbk_search, delta, idx, cbk_size, lag_diff; | 682 opus_int nb_cbk_search, delta, idx, cbk_size, lag_diff; |
681 VARDECL( opus_int32, scratch_mem ); | 683 VARDECL( opus_int32, scratch_mem ); |
682 const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; | 684 const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; |
683 SAVE_STACK; | 685 SAVE_STACK; |
684 | 686 |
(...skipping 13 matching lines...) Expand all Loading... |
698 cbk_size = PE_NB_CBKS_STAGE3_10MS; | 700 cbk_size = PE_NB_CBKS_STAGE3_10MS; |
699 } | 701 } |
700 ALLOC( scratch_mem, SCRATCH_SIZE, opus_int32 ); | 702 ALLOC( scratch_mem, SCRATCH_SIZE, opus_int32 ); |
701 | 703 |
702 target_ptr = &frame[ silk_LSHIFT( sf_length, 2 ) ]; | 704 target_ptr = &frame[ silk_LSHIFT( sf_length, 2 ) ]; |
703 for( k = 0; k < nb_subfr; k++ ) { | 705 for( k = 0; k < nb_subfr; k++ ) { |
704 lag_counter = 0; | 706 lag_counter = 0; |
705 | 707 |
706 /* Calculate the energy for first lag */ | 708 /* Calculate the energy for first lag */ |
707 basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0,
2 ) ); | 709 basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0,
2 ) ); |
708 energy = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length ); | 710 energy = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length, arch
); |
709 silk_assert( energy >= 0 ); | 711 silk_assert( energy >= 0 ); |
710 scratch_mem[ lag_counter ] = energy; | 712 scratch_mem[ lag_counter ] = energy; |
711 lag_counter++; | 713 lag_counter++; |
712 | 714 |
713 lag_diff = ( matrix_ptr( Lag_range_ptr, k, 1, 2 ) - matrix_ptr( Lag_ran
ge_ptr, k, 0, 2 ) + 1 ); | 715 lag_diff = ( matrix_ptr( Lag_range_ptr, k, 1, 2 ) - matrix_ptr( Lag_ran
ge_ptr, k, 0, 2 ) + 1 ); |
714 for( i = 1; i < lag_diff; i++ ) { | 716 for( i = 1; i < lag_diff; i++ ) { |
715 /* remove part outside new window */ | 717 /* remove part outside new window */ |
716 energy -= silk_SMULBB( basis_ptr[ sf_length - i ], basis_ptr[ sf_len
gth - i ] ); | 718 energy -= silk_SMULBB( basis_ptr[ sf_length - i ], basis_ptr[ sf_len
gth - i ] ); |
717 silk_assert( energy >= 0 ); | 719 silk_assert( energy >= 0 ); |
718 | 720 |
(...skipping 16 matching lines...) Expand all Loading... |
735 matrix_ptr( energies_st3, k, i, nb_cbk_search )[ j ] = | 737 matrix_ptr( energies_st3, k, i, nb_cbk_search )[ j ] = |
736 scratch_mem[ idx + j ]; | 738 scratch_mem[ idx + j ]; |
737 silk_assert( | 739 silk_assert( |
738 matrix_ptr( energies_st3, k, i, nb_cbk_search )[ j ] >= 0 ); | 740 matrix_ptr( energies_st3, k, i, nb_cbk_search )[ j ] >= 0 ); |
739 } | 741 } |
740 } | 742 } |
741 target_ptr += sf_length; | 743 target_ptr += sf_length; |
742 } | 744 } |
743 RESTORE_STACK; | 745 RESTORE_STACK; |
744 } | 746 } |
OLD | NEW |