niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | /****************************************************************** |
| 12 | |
| 13 | iLBC Speech Coder ANSI-C Source Code |
| 14 | |
| 15 | WebRtcIlbcfix_SimpleInterpolateLsf.c |
| 16 | |
| 17 | ******************************************************************/ |
| 18 | |
Timothy Gu | 3111783 | 2020-12-19 06:25:57 | [diff] [blame] | 19 | #include "modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h" |
| 20 | |
Mirko Bonadei | 06c2aa9 | 2018-02-01 14:11:41 | [diff] [blame] | 21 | #include "modules/audio_coding/codecs/ilbc/bw_expand.h" |
| 22 | #include "modules/audio_coding/codecs/ilbc/constants.h" |
Timothy Gu | 3111783 | 2020-12-19 06:25:57 | [diff] [blame] | 23 | #include "modules/audio_coding/codecs/ilbc/defines.h" |
| 24 | #include "modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 25 | |
| 26 | /*----------------------------------------------------------------* |
| 27 | * lsf interpolator (subrutine to LPCencode) |
| 28 | *---------------------------------------------------------------*/ |
| 29 | |
| 30 | void WebRtcIlbcfix_SimpleInterpolateLsf( |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 31 | int16_t *syntdenum, /* (o) the synthesis filter denominator |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 32 | resulting from the quantized |
| 33 | interpolated lsf Q12 */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 34 | int16_t *weightdenum, /* (o) the weighting filter denominator |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 35 | resulting from the unquantized |
| 36 | interpolated lsf Q12 */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 37 | int16_t *lsf, /* (i) the unquantized lsf coefficients Q13 */ |
| 38 | int16_t *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */ |
| 39 | int16_t *lsfold, /* (i) the unquantized lsf coefficients of |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 40 | the previous signal frame Q13 */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 41 | int16_t *lsfdeqold, /* (i) the dequantized lsf coefficients of the |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 42 | previous signal frame Q13 */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 43 | int16_t length, /* (i) should equate FILTERORDER */ |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 | [diff] [blame] | 44 | IlbcEncoder *iLBCenc_inst |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 45 | /* (i/o) the encoder state structure */ |
| 46 | ) { |
Peter Kasting | dce40cf | 2015-08-24 21:52:23 | [diff] [blame] | 47 | size_t i; |
| 48 | int pos, lp_length; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 49 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 50 | int16_t *lsf2, *lsfdeq2; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 51 | /* Stack based */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 52 | int16_t lp[LPC_FILTERORDER + 1]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 53 | |
| 54 | lsf2 = lsf + length; |
| 55 | lsfdeq2 = lsfdeq + length; |
| 56 | lp_length = length + 1; |
| 57 | |
| 58 | if (iLBCenc_inst->mode==30) { |
| 59 | /* subframe 1: Interpolation between old and first set of |
| 60 | lsf coefficients */ |
| 61 | |
| 62 | /* Calculate Analysis/Syntehsis filter from quantized LSF */ |
turajs@google.com | ac55f7b | 2011-08-26 16:02:16 | [diff] [blame] | 63 | WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, |
| 64 | WebRtcIlbcfix_kLsfWeight30ms[0], |
| 65 | length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 66 | WEBRTC_SPL_MEMCPY_W16(syntdenum, lp, lp_length); |
| 67 | |
| 68 | /* Calculate Weighting filter from quantized LSF */ |
turajs@google.com | ac55f7b | 2011-08-26 16:02:16 | [diff] [blame] | 69 | WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, |
| 70 | WebRtcIlbcfix_kLsfWeight30ms[0], |
| 71 | length); |
| 72 | WebRtcIlbcfix_BwExpand(weightdenum, lp, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 73 | (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, |
| 74 | (int16_t)lp_length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 75 | |
| 76 | /* subframe 2 to 6: Interpolation between first and second |
| 77 | set of lsf coefficients */ |
| 78 | |
| 79 | pos = lp_length; |
| 80 | for (i = 1; i < iLBCenc_inst->nsub; i++) { |
| 81 | |
| 82 | /* Calculate Analysis/Syntehsis filter from quantized LSF */ |
turajs@google.com | ac55f7b | 2011-08-26 16:02:16 | [diff] [blame] | 83 | WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeq, lsfdeq2, |
| 84 | WebRtcIlbcfix_kLsfWeight30ms[i], |
| 85 | length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 86 | WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); |
| 87 | |
| 88 | /* Calculate Weighting filter from quantized LSF */ |
turajs@google.com | ac55f7b | 2011-08-26 16:02:16 | [diff] [blame] | 89 | WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsf, lsf2, |
| 90 | WebRtcIlbcfix_kLsfWeight30ms[i], |
| 91 | length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 92 | WebRtcIlbcfix_BwExpand(weightdenum + pos, lp, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 93 | (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, |
| 94 | (int16_t)lp_length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 95 | |
| 96 | pos += lp_length; |
| 97 | } |
| 98 | |
| 99 | /* update memory */ |
| 100 | |
| 101 | WEBRTC_SPL_MEMCPY_W16(lsfold, lsf2, length); |
| 102 | WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq2, length); |
| 103 | |
| 104 | } else { /* iLBCenc_inst->mode==20 */ |
| 105 | pos = 0; |
| 106 | for (i = 0; i < iLBCenc_inst->nsub; i++) { |
| 107 | |
| 108 | /* Calculate Analysis/Syntehsis filter from quantized LSF */ |
turajs@google.com | ac55f7b | 2011-08-26 16:02:16 | [diff] [blame] | 109 | WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, |
| 110 | WebRtcIlbcfix_kLsfWeight20ms[i], |
| 111 | length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 112 | WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); |
| 113 | |
| 114 | /* Calculate Weighting filter from quantized LSF */ |
turajs@google.com | ac55f7b | 2011-08-26 16:02:16 | [diff] [blame] | 115 | WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, |
| 116 | WebRtcIlbcfix_kLsfWeight20ms[i], |
| 117 | length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 118 | WebRtcIlbcfix_BwExpand(weightdenum+pos, lp, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 119 | (int16_t*)WebRtcIlbcfix_kLpcChirpWeightDenum, |
| 120 | (int16_t)lp_length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 121 | |
| 122 | pos += lp_length; |
| 123 | } |
| 124 | |
| 125 | /* update memory */ |
| 126 | |
| 127 | WEBRTC_SPL_MEMCPY_W16(lsfold, lsf, length); |
| 128 | WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq, length); |
| 129 | |
| 130 | } |
| 131 | |
| 132 | return; |
| 133 | } |