Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/webrtc/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 1.9 KB
Line 
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_Lsf2Lsp.c
16
17******************************************************************/
18
19#include "defines.h"
20#include "constants.h"
21
22/*----------------------------------------------------------------*
23 *  conversion from lsf to lsp coefficients
24 *---------------------------------------------------------------*/
25
26void WebRtcIlbcfix_Lsf2Lsp(
27    int16_t *lsf, /* (i) lsf in Q13 values between 0 and pi */
28    int16_t *lsp, /* (o) lsp in Q15 values between -1 and 1 */
29    int16_t m  /* (i) number of coefficients */
30                           ) {
31  int16_t i, k;
32  int16_t diff; /* difference, which is used for the
33                           linear approximation (Q8) */
34  int16_t freq; /* normalized frequency in Q15 (0..1) */
35  int32_t tmpW32;
36
37  for(i=0; i<m; i++)
38  {
39    freq = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(lsf[i], 20861, 15);
40    /* 20861: 1.0/(2.0*PI) in Q17 */
41    /*
42       Upper 8 bits give the index k and
43       Lower 8 bits give the difference, which needs
44       to be approximated linearly
45    */
46    k = WEBRTC_SPL_RSHIFT_W16(freq, 8);
47    diff = (freq&0x00ff);
48
49    /* Guard against getting outside table */
50
51    if (k>63) {
52      k = 63;
53    }
54
55    /* Calculate linear approximation */
56    tmpW32 = WEBRTC_SPL_MUL_16_16(WebRtcIlbcfix_kCosDerivative[k], diff);
57    lsp[i] = WebRtcIlbcfix_kCos[k]+(int16_t)(WEBRTC_SPL_RSHIFT_W32(tmpW32, 12));
58  }
59
60  return;
61}
Note: See TracBrowser for help on using the repository browser.