| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 void WebRtcIlbcfix_Refiner( | 32 void WebRtcIlbcfix_Refiner( |
| 33 int16_t *updStartPos, /* (o) updated start point (Q-2) */ | 33 int16_t *updStartPos, /* (o) updated start point (Q-2) */ |
| 34 int16_t *idata, /* (i) original data buffer */ | 34 int16_t *idata, /* (i) original data buffer */ |
| 35 int16_t idatal, /* (i) dimension of idata */ | 35 int16_t idatal, /* (i) dimension of idata */ |
| 36 int16_t centerStartPos, /* (i) beginning center segment */ | 36 int16_t centerStartPos, /* (i) beginning center segment */ |
| 37 int16_t estSegPos, /* (i) estimated beginning other segment (Q-2) */ | 37 int16_t estSegPos, /* (i) estimated beginning other segment (Q-2) */ |
| 38 int16_t *surround, /* (i/o) The contribution from this sequence | 38 int16_t *surround, /* (i/o) The contribution from this sequence |
| 39 summed with earlier contributions */ | 39 summed with earlier contributions */ |
| 40 int16_t gain /* (i) Gain to use for this sequence */ | 40 int16_t gain /* (i) Gain to use for this sequence */ |
| 41 ){ | 41 ){ |
| 42 int16_t estSegPosRounded,searchSegStartPos,searchSegEndPos,corrdim; | 42 int16_t estSegPosRounded,searchSegStartPos,searchSegEndPos; |
| 43 int16_t tloc,tloc2,i,st,en,fraction; | 43 size_t corrdim,i; |
| 44 int16_t tloc,tloc2,st,en,fraction; |
| 44 | 45 |
| 45 int32_t maxtemp, scalefact; | 46 int32_t maxtemp, scalefact; |
| 46 int16_t *filtStatePtr, *polyPtr; | 47 int16_t *filtStatePtr, *polyPtr; |
| 47 /* Stack based */ | 48 /* Stack based */ |
| 48 int16_t filt[7]; | 49 int16_t filt[7]; |
| 49 int32_t corrVecUps[ENH_CORRDIM*ENH_UPS0]; | 50 int32_t corrVecUps[ENH_CORRDIM*ENH_UPS0]; |
| 50 int32_t corrVecTemp[ENH_CORRDIM]; | 51 int32_t corrVecTemp[ENH_CORRDIM]; |
| 51 int16_t vect[ENH_VECTL]; | 52 int16_t vect[ENH_VECTL]; |
| 52 int16_t corrVec[ENH_CORRDIM]; | 53 int16_t corrVec[ENH_CORRDIM]; |
| 53 | 54 |
| 54 /* defining array bounds */ | 55 /* defining array bounds */ |
| 55 | 56 |
| 56 estSegPosRounded = (estSegPos - 2) >> 2; | 57 estSegPosRounded = (estSegPos - 2) >> 2; |
| 57 | 58 |
| 58 searchSegStartPos=estSegPosRounded-ENH_SLOP; | 59 searchSegStartPos=estSegPosRounded-ENH_SLOP; |
| 59 | 60 |
| 60 if (searchSegStartPos<0) { | 61 if (searchSegStartPos<0) { |
| 61 searchSegStartPos=0; | 62 searchSegStartPos=0; |
| 62 } | 63 } |
| 63 searchSegEndPos=estSegPosRounded+ENH_SLOP; | 64 searchSegEndPos=estSegPosRounded+ENH_SLOP; |
| 64 | 65 |
| 65 if(searchSegEndPos+ENH_BLOCKL >= idatal) { | 66 if(searchSegEndPos+ENH_BLOCKL >= idatal) { |
| 66 searchSegEndPos=idatal-ENH_BLOCKL-1; | 67 searchSegEndPos=idatal-ENH_BLOCKL-1; |
| 67 } | 68 } |
| 68 corrdim=searchSegEndPos-searchSegStartPos+1; | 69 corrdim=(size_t)(searchSegEndPos-searchSegStartPos+1); |
| 69 | 70 |
| 70 /* compute upsampled correlation and find | 71 /* compute upsampled correlation and find |
| 71 location of max */ | 72 location of max */ |
| 72 | 73 |
| 73 WebRtcIlbcfix_MyCorr(corrVecTemp,idata+searchSegStartPos, | 74 WebRtcIlbcfix_MyCorr(corrVecTemp,idata+searchSegStartPos, |
| 74 (int16_t)(corrdim+ENH_BLOCKL-1),idata+centerStartPos,ENH_
BLOCKL); | 75 corrdim+ENH_BLOCKL-1,idata+centerStartPos,ENH_BLOCKL); |
| 75 | 76 |
| 76 /* Calculate the rescaling factor for the correlation in order to | 77 /* Calculate the rescaling factor for the correlation in order to |
| 77 put the correlation in a int16_t vector instead */ | 78 put the correlation in a int16_t vector instead */ |
| 78 maxtemp=WebRtcSpl_MaxAbsValueW32(corrVecTemp, corrdim); | 79 maxtemp=WebRtcSpl_MaxAbsValueW32(corrVecTemp, corrdim); |
| 79 | 80 |
| 80 scalefact=WebRtcSpl_GetSizeInBits(maxtemp)-15; | 81 scalefact=WebRtcSpl_GetSizeInBits(maxtemp)-15; |
| 81 | 82 |
| 82 if (scalefact>0) { | 83 if (scalefact>0) { |
| 83 for (i=0;i<corrdim;i++) { | 84 for (i=0;i<corrdim;i++) { |
| 84 corrVec[i] = (int16_t)(corrVecTemp[i] >> scalefact); | 85 corrVec[i] = (int16_t)(corrVecTemp[i] >> scalefact); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 103 bounds */ | 104 bounds */ |
| 104 *updStartPos = (int16_t)(searchSegStartPos * 4) + tloc + 4; | 105 *updStartPos = (int16_t)(searchSegStartPos * 4) + tloc + 4; |
| 105 | 106 |
| 106 tloc2 = (tloc + 3) >> 2; | 107 tloc2 = (tloc + 3) >> 2; |
| 107 | 108 |
| 108 st=searchSegStartPos+tloc2-ENH_FL0; | 109 st=searchSegStartPos+tloc2-ENH_FL0; |
| 109 | 110 |
| 110 /* initialize the vector to be filtered, stuff with zeros | 111 /* initialize the vector to be filtered, stuff with zeros |
| 111 when data is outside idata buffer */ | 112 when data is outside idata buffer */ |
| 112 if(st<0){ | 113 if(st<0){ |
| 113 WebRtcSpl_MemSetW16(vect, 0, (int16_t)(-st)); | 114 WebRtcSpl_MemSetW16(vect, 0, (size_t)(-st)); |
| 114 WEBRTC_SPL_MEMCPY_W16(&vect[-st], idata, (ENH_VECTL+st)); | 115 WEBRTC_SPL_MEMCPY_W16(&vect[-st], idata, (ENH_VECTL+st)); |
| 115 } | 116 } |
| 116 else{ | 117 else{ |
| 117 en=st+ENH_VECTL; | 118 en=st+ENH_VECTL; |
| 118 | 119 |
| 119 if(en>idatal){ | 120 if(en>idatal){ |
| 120 WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], | 121 WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], |
| 121 (ENH_VECTL-(en-idatal))); | 122 (ENH_VECTL-(en-idatal))); |
| 122 WebRtcSpl_MemSetW16(&vect[ENH_VECTL-(en-idatal)], 0, | 123 WebRtcSpl_MemSetW16(&vect[ENH_VECTL-(en-idatal)], 0, |
| 123 (int16_t)(en-idatal)); | 124 (size_t)(en-idatal)); |
| 124 } | 125 } |
| 125 else { | 126 else { |
| 126 WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL); | 127 WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL); |
| 127 } | 128 } |
| 128 } | 129 } |
| 129 /* Calculate which of the 4 fractions to use */ | 130 /* Calculate which of the 4 fractions to use */ |
| 130 fraction = (int16_t)(tloc2 * ENH_UPS0) - tloc; | 131 fraction = (int16_t)(tloc2 * ENH_UPS0) - tloc; |
| 131 | 132 |
| 132 /* compute the segment (this is actually a convolution) */ | 133 /* compute the segment (this is actually a convolution) */ |
| 133 | 134 |
| 134 filtStatePtr = filt + 6; | 135 filtStatePtr = filt + 6; |
| 135 polyPtr = (int16_t*)WebRtcIlbcfix_kEnhPolyPhaser[fraction]; | 136 polyPtr = (int16_t*)WebRtcIlbcfix_kEnhPolyPhaser[fraction]; |
| 136 for (i=0;i<7;i++) { | 137 for (i=0;i<7;i++) { |
| 137 *filtStatePtr-- = *polyPtr++; | 138 *filtStatePtr-- = *polyPtr++; |
| 138 } | 139 } |
| 139 | 140 |
| 140 WebRtcSpl_FilterMAFastQ12( | 141 WebRtcSpl_FilterMAFastQ12( |
| 141 &vect[6], vect, filt, | 142 &vect[6], vect, filt, |
| 142 ENH_FLO_MULT2_PLUS1, ENH_BLOCKL); | 143 ENH_FLO_MULT2_PLUS1, ENH_BLOCKL); |
| 143 | 144 |
| 144 /* Add the contribution from this vector (scaled with gain) to the total surro
und vector */ | 145 /* Add the contribution from this vector (scaled with gain) to the total surro
und vector */ |
| 145 WebRtcSpl_AddAffineVectorToVector( | 146 WebRtcSpl_AddAffineVectorToVector( |
| 146 surround, vect, gain, | 147 surround, vect, gain, |
| 147 (int32_t)32768, 16, ENH_BLOCKL); | 148 (int32_t)32768, 16, ENH_BLOCKL); |
| 148 | 149 |
| 149 return; | 150 return; |
| 150 } | 151 } |
| OLD | NEW |