| 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 18 matching lines...) Expand all Loading... |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #include "main.h" | 32 #include "main.h" |
| 33 | 33 |
| 34 /*********************************************/ | 34 /*********************************************/ |
| 35 /* Decode quantization indices of excitation */ | 35 /* Decode quantization indices of excitation */ |
| 36 /*********************************************/ | 36 /*********************************************/ |
| 37 void silk_decode_pulses( | 37 void silk_decode_pulses( |
| 38 ec_dec *psRangeDec, /* I/O Compress
or data structure */ | 38 ec_dec *psRangeDec, /* I/O Compress
or data structure */ |
| 39 opus_int pulses[], /* O Excitati
on signal */ | 39 opus_int16 pulses[], /* O Excitati
on signal */ |
| 40 const opus_int signalType, /* I Sigtype
*/ | 40 const opus_int signalType, /* I Sigtype
*/ |
| 41 const opus_int quantOffsetType, /* I quantOff
setType */ | 41 const opus_int quantOffsetType, /* I quantOff
setType */ |
| 42 const opus_int frame_length /* I Frame le
ngth */ | 42 const opus_int frame_length /* I Frame le
ngth */ |
| 43 ) | 43 ) |
| 44 { | 44 { |
| 45 opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex; | 45 opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex; |
| 46 opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ], nLshifts[ MAX_NB_SHELL_BLOCKS
]; | 46 opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ], nLshifts[ MAX_NB_SHELL_BLOCKS
]; |
| 47 opus_int *pulses_ptr; | 47 opus_int16 *pulses_ptr; |
| 48 const opus_uint8 *cdf_ptr; | 48 const opus_uint8 *cdf_ptr; |
| 49 | 49 |
| 50 /*********************/ | 50 /*********************/ |
| 51 /* Decode rate level */ | 51 /* Decode rate level */ |
| 52 /*********************/ | 52 /*********************/ |
| 53 RateLevelIndex = ec_dec_icdf( psRangeDec, silk_rate_levels_iCDF[ signalType
>> 1 ], 8 ); | 53 RateLevelIndex = ec_dec_icdf( psRangeDec, silk_rate_levels_iCDF[ signalType
>> 1 ], 8 ); |
| 54 | 54 |
| 55 /* Calculate number of shell blocks */ | 55 /* Calculate number of shell blocks */ |
| 56 silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH
); | 56 silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH
); |
| 57 iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH ); | 57 iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH ); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 /***************************************************/ | 80 /***************************************************/ |
| 81 /* Shell decoding */ | 81 /* Shell decoding */ |
| 82 /***************************************************/ | 82 /***************************************************/ |
| 83 for( i = 0; i < iter; i++ ) { | 83 for( i = 0; i < iter; i++ ) { |
| 84 if( sum_pulses[ i ] > 0 ) { | 84 if( sum_pulses[ i ] > 0 ) { |
| 85 silk_shell_decoder( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGT
H ) ], psRangeDec, sum_pulses[ i ] ); | 85 silk_shell_decoder( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGT
H ) ], psRangeDec, sum_pulses[ i ] ); |
| 86 } else { | 86 } else { |
| 87 silk_memset( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ],
0, SHELL_CODEC_FRAME_LENGTH * sizeof( opus_int ) ); | 87 silk_memset( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ],
0, SHELL_CODEC_FRAME_LENGTH * sizeof( pulses[0] ) ); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 /***************************************************/ | 91 /***************************************************/ |
| 92 /* LSB Decoding */ | 92 /* LSB Decoding */ |
| 93 /***************************************************/ | 93 /***************************************************/ |
| 94 for( i = 0; i < iter; i++ ) { | 94 for( i = 0; i < iter; i++ ) { |
| 95 if( nLshifts[ i ] > 0 ) { | 95 if( nLshifts[ i ] > 0 ) { |
| 96 nLS = nLshifts[ i ]; | 96 nLS = nLshifts[ i ]; |
| 97 pulses_ptr = &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ]; | 97 pulses_ptr = &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ]; |
| 98 for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) { | 98 for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) { |
| 99 abs_q = pulses_ptr[ k ]; | 99 abs_q = pulses_ptr[ k ]; |
| 100 for( j = 0; j < nLS; j++ ) { | 100 for( j = 0; j < nLS; j++ ) { |
| 101 abs_q = silk_LSHIFT( abs_q, 1 ); | 101 abs_q = silk_LSHIFT( abs_q, 1 ); |
| 102 abs_q += ec_dec_icdf( psRangeDec, silk_lsb_iCDF, 8 ); | 102 abs_q += ec_dec_icdf( psRangeDec, silk_lsb_iCDF, 8 ); |
| 103 } | 103 } |
| 104 pulses_ptr[ k ] = abs_q; | 104 pulses_ptr[ k ] = abs_q; |
| 105 } | 105 } |
| 106 /* Mark the number of pulses non-zero for sign decoding. */ | 106 /* Mark the number of pulses non-zero for sign decoding. */ |
| 107 sum_pulses[ i ] |= nLS << 5; | 107 sum_pulses[ i ] |= nLS << 5; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 /****************************************/ | 111 /****************************************/ |
| 112 /* Decode and add signs to pulse signal */ | 112 /* Decode and add signs to pulse signal */ |
| 113 /****************************************/ | 113 /****************************************/ |
| 114 silk_decode_signs( psRangeDec, pulses, frame_length, signalType, quantOffset
Type, sum_pulses ); | 114 silk_decode_signs( psRangeDec, pulses, frame_length, signalType, quantOffset
Type, sum_pulses ); |
| 115 } | 115 } |
| OLD | NEW |