~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/third_party/ilbc/LPCdecode.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
   /******************************************************************
3
 
 
4
 
       iLBC Speech Coder ANSI-C Source Code
5
 
 
6
 
       LPC_decode.c
7
 
 
8
 
       Copyright (C) The Internet Society (2004).
9
 
       All Rights Reserved.
10
 
 
11
 
   ******************************************************************/
12
 
 
13
 
   #include <math.h>
14
 
   #include <string.h>
15
 
 
16
 
   #include "helpfun.h"
17
 
   #include "lsf.h"
18
 
   #include "iLBC_define.h"
19
 
   #include "constants.h"
20
 
 
21
 
   /*---------------------------------------------------------------*
22
 
    *  interpolation of lsf coefficients for the decoder
23
 
    *--------------------------------------------------------------*/
24
 
 
25
 
   void LSFinterpolate2a_dec(
26
 
       float *a,           /* (o) lpc coefficients for a sub-frame */
27
 
       float *lsf1,    /* (i) first lsf coefficient vector */
28
 
       float *lsf2,    /* (i) second lsf coefficient vector */
29
 
       float coef,         /* (i) interpolation weight */
30
 
       int length          /* (i) length of lsf vectors */
31
 
   ){
32
 
       float  lsftmp[LPC_FILTERORDER];
33
 
 
34
 
       interpolate(lsftmp, lsf1, lsf2, coef, length);
35
 
       lsf2a(a, lsftmp);
36
 
   }
37
 
 
38
 
   /*---------------------------------------------------------------*
39
 
    *  obtain dequantized lsf coefficients from quantization index
40
 
    *--------------------------------------------------------------*/
41
 
 
42
 
   void SimplelsfDEQ(
43
 
       float *lsfdeq,    /* (o) dequantized lsf coefficients */
44
 
       int *index,         /* (i) quantization index */
45
 
       int lpc_n           /* (i) number of LPCs */
46
 
   ){
47
 
       int i, j, pos, cb_pos;
48
 
 
49
 
 
50
 
 
51
 
 
52
 
 
53
 
       /* decode first LSF */
54
 
 
55
 
       pos = 0;
56
 
       cb_pos = 0;
57
 
       for (i = 0; i < LSF_NSPLIT; i++) {
58
 
           for (j = 0; j < dim_lsfCbTbl[i]; j++) {
59
 
               lsfdeq[pos + j] = lsfCbTbl[cb_pos +
60
 
                   (long)(index[i])*dim_lsfCbTbl[i] + j];
61
 
           }
62
 
           pos += dim_lsfCbTbl[i];
63
 
           cb_pos += size_lsfCbTbl[i]*dim_lsfCbTbl[i];
64
 
       }
65
 
 
66
 
       if (lpc_n>1) {
67
 
 
68
 
           /* decode last LSF */
69
 
 
70
 
           pos = 0;
71
 
           cb_pos = 0;
72
 
           for (i = 0; i < LSF_NSPLIT; i++) {
73
 
               for (j = 0; j < dim_lsfCbTbl[i]; j++) {
74
 
                   lsfdeq[LPC_FILTERORDER + pos + j] =
75
 
                       lsfCbTbl[cb_pos +
76
 
                       (long)(index[LSF_NSPLIT + i])*
77
 
                       dim_lsfCbTbl[i] + j];
78
 
               }
79
 
               pos += dim_lsfCbTbl[i];
80
 
               cb_pos += size_lsfCbTbl[i]*dim_lsfCbTbl[i];
81
 
           }
82
 
       }
83
 
   }
84
 
 
85
 
   /*----------------------------------------------------------------*
86
 
    *  obtain synthesis and weighting filters form lsf coefficients
87
 
    *---------------------------------------------------------------*/
88
 
 
89
 
   void DecoderInterpolateLSF(
90
 
       float *syntdenum, /* (o) synthesis filter coefficients */
91
 
       float *weightdenum, /* (o) weighting denumerator
92
 
                                  coefficients */
93
 
       float *lsfdeq,       /* (i) dequantized lsf coefficients */
94
 
       int length,         /* (i) length of lsf coefficient vector */
95
 
       iLBC_Dec_Inst_t *iLBCdec_inst
96
 
                           /* (i) the decoder state structure */
97
 
   ){
98
 
       int    i, pos, lp_length;
99
 
       float  lp[LPC_FILTERORDER + 1], *lsfdeq2;
100
 
 
101
 
 
102
 
 
103
 
 
104
 
 
105
 
 
106
 
       lsfdeq2 = lsfdeq + length;
107
 
       lp_length = length + 1;
108
 
 
109
 
       if (iLBCdec_inst->mode==30) {
110
 
           /* sub-frame 1: Interpolation between old and first */
111
 
 
112
 
           LSFinterpolate2a_dec(lp, iLBCdec_inst->lsfdeqold, lsfdeq,
113
 
               lsf_weightTbl_30ms[0], length);
114
 
           memcpy(syntdenum,lp,lp_length*sizeof(float));
115
 
           bwexpand(weightdenum, lp, LPC_CHIRP_WEIGHTDENUM,
116
 
               lp_length);
117
 
 
118
 
           /* sub-frames 2 to 6: interpolation between first
119
 
              and last LSF */
120
 
 
121
 
           pos = lp_length;
122
 
           for (i = 1; i < 6; i++) {
123
 
               LSFinterpolate2a_dec(lp, lsfdeq, lsfdeq2,
124
 
                   lsf_weightTbl_30ms[i], length);
125
 
               memcpy(syntdenum + pos,lp,lp_length*sizeof(float));
126
 
               bwexpand(weightdenum + pos, lp,
127
 
                   LPC_CHIRP_WEIGHTDENUM, lp_length);
128
 
               pos += lp_length;
129
 
           }
130
 
       }
131
 
       else {
132
 
           pos = 0;
133
 
           for (i = 0; i < iLBCdec_inst->nsub; i++) {
134
 
               LSFinterpolate2a_dec(lp, iLBCdec_inst->lsfdeqold,
135
 
                   lsfdeq, lsf_weightTbl_20ms[i], length);
136
 
               memcpy(syntdenum+pos,lp,lp_length*sizeof(float));
137
 
               bwexpand(weightdenum+pos, lp, LPC_CHIRP_WEIGHTDENUM,
138
 
                   lp_length);
139
 
               pos += lp_length;
140
 
           }
141
 
       }
142
 
 
143
 
       /* update memory */
144
 
 
145
 
       if (iLBCdec_inst->mode==30)
146
 
           memcpy(iLBCdec_inst->lsfdeqold, lsfdeq2,
147
 
                       length*sizeof(float));
148
 
       else
149
 
           memcpy(iLBCdec_inst->lsfdeqold, lsfdeq,
150
 
                       length*sizeof(float));
151
 
 
152
 
   }