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 #include "cng_helpfuns.h" 12 13 #include "signal_processing_library.h" 14 #include "webrtc/typedefs.h" 15 #include "webrtc_cng.h" 16 17 /* Values in |k| are Q15, and |a| Q12. */ 18 void WebRtcCng_K2a16(int16_t* k, int useOrder, int16_t* a) { 19 int16_t any[WEBRTC_SPL_MAX_LPC_ORDER + 1]; 20 int16_t *aptr, *aptr2, *anyptr; 21 const int16_t *kptr; 22 int m, i; 23 24 kptr = k; 25 *a = 4096; /* i.e., (Word16_MAX >> 3) + 1 */ 26 *any = *a; 27 a[1] = (*k + 4) >> 3; 28 for (m = 1; m < useOrder; m++) { 29 kptr++; 30 aptr = a; 31 aptr++; 32 aptr2 = &a[m]; 33 anyptr = any; 34 anyptr++; 35 36 any[m + 1] = (*kptr + 4) >> 3; 37 for (i = 0; i < m; i++) { 38 *anyptr++ = (*aptr++) + 39 (int16_t)((((int32_t)(*aptr2--) * (int32_t) * kptr) + 16384) >> 15); 40 } 41 42 aptr = a; 43 anyptr = any; 44 for (i = 0; i < (m + 2); i++) { 45 *aptr++ = *anyptr++; 46 } 47 } 48 } 49