| 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 15 matching lines...) Expand all Loading... |
| 26 * and LP parameters. If no packet loss, update state. | 26 * and LP parameters. If no packet loss, update state. |
| 27 *---------------------------------------------------------------*/ | 27 *---------------------------------------------------------------*/ |
| 28 | 28 |
| 29 void WebRtcIlbcfix_DoThePlc( | 29 void WebRtcIlbcfix_DoThePlc( |
| 30 int16_t *PLCresidual, /* (o) concealed residual */ | 30 int16_t *PLCresidual, /* (o) concealed residual */ |
| 31 int16_t *PLClpc, /* (o) concealed LP parameters */ | 31 int16_t *PLClpc, /* (o) concealed LP parameters */ |
| 32 int16_t PLI, /* (i) packet loss indicator | 32 int16_t PLI, /* (i) packet loss indicator |
| 33 0 - no PL, 1 = PL */ | 33 0 - no PL, 1 = PL */ |
| 34 int16_t *decresidual, /* (i) decoded residual */ | 34 int16_t *decresidual, /* (i) decoded residual */ |
| 35 int16_t *lpc, /* (i) decoded LPC (only used for no PL) */ | 35 int16_t *lpc, /* (i) decoded LPC (only used for no PL) */ |
| 36 int16_t inlag, /* (i) pitch lag */ | 36 size_t inlag, /* (i) pitch lag */ |
| 37 IlbcDecoder *iLBCdec_inst | 37 IlbcDecoder *iLBCdec_inst |
| 38 /* (i/o) decoder instance */ | 38 /* (i/o) decoder instance */ |
| 39 ){ | 39 ){ |
| 40 int16_t i; | 40 size_t i; |
| 41 int32_t cross, ener, cross_comp, ener_comp = 0; | 41 int32_t cross, ener, cross_comp, ener_comp = 0; |
| 42 int32_t measure, maxMeasure, energy; | 42 int32_t measure, maxMeasure, energy; |
| 43 int16_t max, crossSquareMax, crossSquare; | 43 int16_t max, crossSquareMax, crossSquare; |
| 44 int16_t j, lag, tmp1, tmp2, randlag; | 44 size_t j, lag, randlag; |
| 45 int16_t tmp1, tmp2; |
| 45 int16_t shift1, shift2, shift3, shiftMax; | 46 int16_t shift1, shift2, shift3, shiftMax; |
| 46 int16_t scale3; | 47 int16_t scale3; |
| 47 int16_t corrLen; | 48 size_t corrLen; |
| 48 int32_t tmpW32, tmp2W32; | 49 int32_t tmpW32, tmp2W32; |
| 49 int16_t use_gain; | 50 int16_t use_gain; |
| 50 int16_t tot_gain; | 51 int16_t tot_gain; |
| 51 int16_t max_perSquare; | 52 int16_t max_perSquare; |
| 52 int16_t scale1, scale2; | 53 int16_t scale1, scale2; |
| 53 int16_t totscale; | 54 int16_t totscale; |
| 54 int32_t nom; | 55 int32_t nom; |
| 55 int16_t denom; | 56 int16_t denom; |
| 56 int16_t pitchfact; | 57 int16_t pitchfact; |
| 57 int16_t use_lag; | 58 size_t use_lag; |
| 58 int ind; | 59 int ind; |
| 59 int16_t randvec[BLOCKL_MAX]; | 60 int16_t randvec[BLOCKL_MAX]; |
| 60 | 61 |
| 61 /* Packet Loss */ | 62 /* Packet Loss */ |
| 62 if (PLI == 1) { | 63 if (PLI == 1) { |
| 63 | 64 |
| 64 (*iLBCdec_inst).consPLICount += 1; | 65 (*iLBCdec_inst).consPLICount += 1; |
| 65 | 66 |
| 66 /* if previous frame not lost, | 67 /* if previous frame not lost, |
| 67 determine pitch pred. gain */ | 68 determine pitch pred. gain */ |
| 68 | 69 |
| 69 if (iLBCdec_inst->prevPLI != 1) { | 70 if (iLBCdec_inst->prevPLI != 1) { |
| 70 | 71 |
| 71 /* Maximum 60 samples are correlated, preserve as high accuracy | 72 /* Maximum 60 samples are correlated, preserve as high accuracy |
| 72 as possible without getting overflow */ | 73 as possible without getting overflow */ |
| 73 max = WebRtcSpl_MaxAbsValueW16((*iLBCdec_inst).prevResidual, | 74 max = WebRtcSpl_MaxAbsValueW16((*iLBCdec_inst).prevResidual, |
| 74 (int16_t)iLBCdec_inst->blockl); | 75 iLBCdec_inst->blockl); |
| 75 scale3 = (WebRtcSpl_GetSizeInBits(max)<<1) - 25; | 76 scale3 = (WebRtcSpl_GetSizeInBits(max)<<1) - 25; |
| 76 if (scale3 < 0) { | 77 if (scale3 < 0) { |
| 77 scale3 = 0; | 78 scale3 = 0; |
| 78 } | 79 } |
| 79 | 80 |
| 80 /* Store scale for use when interpolating between the | 81 /* Store scale for use when interpolating between the |
| 81 * concealment and the received packet */ | 82 * concealment and the received packet */ |
| 82 iLBCdec_inst->prevScale = scale3; | 83 iLBCdec_inst->prevScale = scale3; |
| 83 | 84 |
| 84 /* Search around the previous lag +/-3 to find the | 85 /* Search around the previous lag +/-3 to find the |
| 85 best pitch period */ | 86 best pitch period */ |
| 86 lag = inlag - 3; | 87 lag = inlag - 3; |
| 87 | 88 |
| 88 /* Guard against getting outside the frame */ | 89 /* Guard against getting outside the frame */ |
| 89 corrLen = WEBRTC_SPL_MIN(60, iLBCdec_inst->blockl-(inlag+3)); | 90 corrLen = (size_t)WEBRTC_SPL_MIN(60, iLBCdec_inst->blockl-(inlag+3)); |
| 90 | 91 |
| 91 WebRtcIlbcfix_CompCorr( &cross, &ener, | 92 WebRtcIlbcfix_CompCorr( &cross, &ener, |
| 92 iLBCdec_inst->prevResidual, lag, iLBCdec_inst->blo
ckl, corrLen, scale3); | 93 iLBCdec_inst->prevResidual, lag, iLBCdec_inst->blo
ckl, corrLen, scale3); |
| 93 | 94 |
| 94 /* Normalize and store cross^2 and the number of shifts */ | 95 /* Normalize and store cross^2 and the number of shifts */ |
| 95 shiftMax = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(cross))-15; | 96 shiftMax = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(cross))-15; |
| 96 crossSquareMax = (int16_t)(( | 97 crossSquareMax = (int16_t)(( |
| 97 (int16_t)WEBRTC_SPL_SHIFT_W32(cross, -shiftMax) * | 98 (int16_t)WEBRTC_SPL_SHIFT_W32(cross, -shiftMax) * |
| 98 (int16_t)WEBRTC_SPL_SHIFT_W32(cross, -shiftMax)) >> 15); | 99 (int16_t)WEBRTC_SPL_SHIFT_W32(cross, -shiftMax)) >> 15); |
| 99 | 100 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 use_lag = 2*lag; | 228 use_lag = 2*lag; |
| 228 } | 229 } |
| 229 | 230 |
| 230 /* compute concealed residual */ | 231 /* compute concealed residual */ |
| 231 energy = 0; | 232 energy = 0; |
| 232 | 233 |
| 233 for (i=0; i<iLBCdec_inst->blockl; i++) { | 234 for (i=0; i<iLBCdec_inst->blockl; i++) { |
| 234 | 235 |
| 235 /* noise component - 52 < randlagFIX < 117 */ | 236 /* noise component - 52 < randlagFIX < 117 */ |
| 236 iLBCdec_inst->seed = (int16_t)(iLBCdec_inst->seed * 31821 + 13849); | 237 iLBCdec_inst->seed = (int16_t)(iLBCdec_inst->seed * 31821 + 13849); |
| 237 randlag = 53 + (int16_t)(iLBCdec_inst->seed & 63); | 238 randlag = 53 + (iLBCdec_inst->seed & 63); |
| 238 if (randlag > i) { | 239 if (randlag > i) { |
| 239 randvec[i] = | 240 randvec[i] = |
| 240 iLBCdec_inst->prevResidual[iLBCdec_inst->blockl + i - randlag]; | 241 iLBCdec_inst->prevResidual[iLBCdec_inst->blockl + i - randlag]; |
| 241 } else { | 242 } else { |
| 242 randvec[i] = iLBCdec_inst->prevResidual[i - randlag]; | 243 randvec[i] = iLBCdec_inst->prevResidual[i - randlag]; |
| 243 } | 244 } |
| 244 | 245 |
| 245 /* pitch repeatition component */ | 246 /* pitch repeatition component */ |
| 246 if (use_lag > i) { | 247 if (use_lag > i) { |
| 247 PLCresidual[i] = | 248 PLCresidual[i] = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 iLBCdec_inst->consPLICount = 0; | 296 iLBCdec_inst->consPLICount = 0; |
| 296 } | 297 } |
| 297 | 298 |
| 298 /* update state */ | 299 /* update state */ |
| 299 iLBCdec_inst->prevPLI = PLI; | 300 iLBCdec_inst->prevPLI = PLI; |
| 300 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevLpc, PLClpc, (LPC_FILTERORDER+1)); | 301 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevLpc, PLClpc, (LPC_FILTERORDER+1)); |
| 301 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevResidual, PLCresidual, iLBCdec_inst->b
lockl); | 302 WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevResidual, PLCresidual, iLBCdec_inst->b
lockl); |
| 302 | 303 |
| 303 return; | 304 return; |
| 304 } | 305 } |
| OLD | NEW |