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. |
11 - Neither the name of Internet Society, IETF or IETF Trust, nor the | 11 - Neither the name of Internet Society, IETF or IETF Trust, nor the |
12 names of specific contributors, may be used to endorse or promote | 12 names of specific contributors, may be used to endorse or promote |
13 products derived from this software without specific prior written | 13 products derived from this software without specific prior written |
14 permission. | 14 permission. |
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” | 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 POSSIBILITY OF SUCH DAMAGE. | 25 POSSIBILITY OF SUCH DAMAGE. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 opus_int silk_InitDecoder( /* O Returns error co
de */ | 62 opus_int silk_InitDecoder( /* O Returns error co
de */ |
63 void *decState /* I/O State
*/ | 63 void *decState /* I/O State
*/ |
64 ) | 64 ) |
65 { | 65 { |
66 opus_int n, ret = SILK_NO_ERROR; | 66 opus_int n, ret = SILK_NO_ERROR; |
67 silk_decoder_state *channel_state = ((silk_decoder *)decState)->channel_stat
e; | 67 silk_decoder_state *channel_state = ((silk_decoder *)decState)->channel_stat
e; |
68 | 68 |
69 for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { | 69 for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { |
70 ret = silk_init_decoder( &channel_state[ n ] ); | 70 ret = silk_init_decoder( &channel_state[ n ] ); |
71 } | 71 } |
| 72 silk_memset(&((silk_decoder *)decState)->sStereo, 0, sizeof(((silk_decoder *
)decState)->sStereo)); |
| 73 /* Not strictly needed, but it's cleaner that way */ |
| 74 ((silk_decoder *)decState)->prev_decode_only_middle = 0; |
72 | 75 |
73 return ret; | 76 return ret; |
74 } | 77 } |
75 | 78 |
76 /* Decode a frame */ | 79 /* Decode a frame */ |
77 opus_int silk_Decode( /* O Returns error co
de */ | 80 opus_int silk_Decode( /* O Returns error co
de */ |
78 void* decState, /* I/O State
*/ | 81 void* decState, /* I/O State
*/ |
79 silk_DecControlStruct* decControl, /* I/O Control Structur
e */ | 82 silk_DecControlStruct* decControl, /* I/O Control Structur
e */ |
80 opus_int lostFlag, /* I 0: no loss, 1 lo
ss, 2 decode fec */ | 83 opus_int lostFlag, /* I 0: no loss, 1 lo
ss, 2 decode fec */ |
81 opus_int newPacketFlag, /* I Indicates first
decoder call for this packet */ | 84 opus_int newPacketFlag, /* I Indicates first
decoder call for this packet */ |
82 ec_dec *psRangeDec, /* I/O Compressor data
structure */ | 85 ec_dec *psRangeDec, /* I/O Compressor data
structure */ |
83 opus_int16 *samplesOut, /* O Decoded output s
peech vector */ | 86 opus_int16 *samplesOut, /* O Decoded output s
peech vector */ |
84 opus_int32 *nSamplesOut /* O Number of sample
s decoded */ | 87 opus_int32 *nSamplesOut /* O Number of sample
s decoded */ |
85 ) | 88 ) |
86 { | 89 { |
87 opus_int i, n, decode_only_middle = 0, ret = SILK_NO_ERROR; | 90 opus_int i, n, decode_only_middle = 0, ret = SILK_NO_ERROR; |
88 opus_int32 nSamplesOutDec, LBRR_symbol; | 91 opus_int32 nSamplesOutDec, LBRR_symbol; |
89 opus_int16 *samplesOut1_tmp[ 2 ]; | 92 opus_int16 *samplesOut1_tmp[ 2 ]; |
90 VARDECL( opus_int16, samplesOut1_tmp_storage ); | 93 VARDECL( opus_int16, samplesOut1_tmp_storage ); |
91 VARDECL( opus_int16, samplesOut2_tmp ); | 94 VARDECL( opus_int16, samplesOut2_tmp ); |
92 opus_int32 MS_pred_Q13[ 2 ] = { 0 }; | 95 opus_int32 MS_pred_Q13[ 2 ] = { 0 }; |
93 opus_int16 *resample_out_ptr; | 96 opus_int16 *resample_out_ptr; |
94 silk_decoder *psDec = ( silk_decoder * )decState; | 97 silk_decoder *psDec = ( silk_decoder * )decState; |
95 silk_decoder_state *channel_state = psDec->channel_state; | 98 silk_decoder_state *channel_state = psDec->channel_state; |
96 opus_int has_side; | 99 opus_int has_side; |
97 opus_int stereo_to_mono; | 100 opus_int stereo_to_mono; |
98 SAVE_STACK; | 101 SAVE_STACK; |
99 | 102 |
| 103 silk_assert( decControl->nChannelsInternal == 1 || decControl->nChannelsInte
rnal == 2 ); |
| 104 |
100 /**********************************/ | 105 /**********************************/ |
101 /* Test if first frame in payload */ | 106 /* Test if first frame in payload */ |
102 /**********************************/ | 107 /**********************************/ |
103 if( newPacketFlag ) { | 108 if( newPacketFlag ) { |
104 for( n = 0; n < decControl->nChannelsInternal; n++ ) { | 109 for( n = 0; n < decControl->nChannelsInternal; n++ ) { |
105 channel_state[ n ].nFramesDecoded = 0; /* Used to count frames in p
acket */ | 110 channel_state[ n ].nFramesDecoded = 0; /* Used to count frames in p
acket */ |
106 } | 111 } |
107 } | 112 } |
108 | 113 |
109 /* If Mono -> Stereo transition in bitstream: init state of second channel *
/ | 114 /* If Mono -> Stereo transition in bitstream: init state of second channel *
/ |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 Silk_TOC->inbandFECFlag = flags & 1; | 388 Silk_TOC->inbandFECFlag = flags & 1; |
384 for( i = nFramesPerPayload - 1; i >= 0 ; i-- ) { | 389 for( i = nFramesPerPayload - 1; i >= 0 ; i-- ) { |
385 flags = silk_RSHIFT( flags, 1 ); | 390 flags = silk_RSHIFT( flags, 1 ); |
386 Silk_TOC->VADFlags[ i ] = flags & 1; | 391 Silk_TOC->VADFlags[ i ] = flags & 1; |
387 Silk_TOC->VADFlag |= flags & 1; | 392 Silk_TOC->VADFlag |= flags & 1; |
388 } | 393 } |
389 | 394 |
390 return ret; | 395 return ret; |
391 } | 396 } |
392 #endif | 397 #endif |
OLD | NEW |