~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/iCBConstruct.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
 
       iCBConstruct.c
7
 
 
8
 
       Copyright (C) The Internet Society (2004).
9
 
       All Rights Reserved.
10
 
 
11
 
   ******************************************************************/
12
 
 
13
 
   #include <math.h>
14
 
 
15
 
   #include "iLBC_define.h"
16
 
   #include "gainquant.h"
17
 
   #include "getCBvec.h"
18
 
 
19
 
   /*----------------------------------------------------------------*
20
 
    *  Convert the codebook indexes to make the search easier
21
 
    *---------------------------------------------------------------*/
22
 
 
23
 
 
24
 
 
25
 
 
26
 
 
27
 
 
28
 
   void index_conv_enc(
29
 
       int *index          /* (i/o) Codebook indexes */
30
 
   ){
31
 
       int k;
32
 
 
33
 
       for (k=1; k<CB_NSTAGES; k++) {
34
 
 
35
 
           if ((index[k]>=108)&&(index[k]<172)) {
36
 
               index[k]-=64;
37
 
           } else if (index[k]>=236) {
38
 
               index[k]-=128;
39
 
           } else {
40
 
               /* ERROR */
41
 
           }
42
 
       }
43
 
   }
44
 
 
45
 
   void index_conv_dec(
46
 
       int *index          /* (i/o) Codebook indexes */
47
 
   ){
48
 
       int k;
49
 
 
50
 
       for (k=1; k<CB_NSTAGES; k++) {
51
 
 
52
 
           if ((index[k]>=44)&&(index[k]<108)) {
53
 
               index[k]+=64;
54
 
           } else if ((index[k]>=108)&&(index[k]<128)) {
55
 
               index[k]+=128;
56
 
           } else {
57
 
               /* ERROR */
58
 
           }
59
 
       }
60
 
   }
61
 
 
62
 
   /*----------------------------------------------------------------*
63
 
    *  Construct decoded vector from codebook and gains.
64
 
    *---------------------------------------------------------------*/
65
 
 
66
 
   void iCBConstruct(
67
 
       float *decvector,   /* (o) Decoded vector */
68
 
       int *index,         /* (i) Codebook indices */
69
 
       int *gain_index,/* (i) Gain quantization indices */
70
 
       float *mem,         /* (i) Buffer for codevector construction */
71
 
       int lMem,           /* (i) Length of buffer */
72
 
       int veclen,         /* (i) Length of vector */
73
 
       int nStages         /* (i) Number of codebook stages */
74
 
   ){
75
 
       int j,k;
76
 
 
77
 
 
78
 
 
79
 
 
80
 
 
81
 
       float gain[CB_NSTAGES];
82
 
       float cbvec[SUBL];
83
 
 
84
 
       /* gain de-quantization */
85
 
 
86
 
       gain[0] = gaindequant(gain_index[0], 1.0, 32);
87
 
       if (nStages > 1) {
88
 
           gain[1] = gaindequant(gain_index[1],
89
 
               (float)fabs(gain[0]), 16);
90
 
       }
91
 
       if (nStages > 2) {
92
 
           gain[2] = gaindequant(gain_index[2],
93
 
               (float)fabs(gain[1]), 8);
94
 
       }
95
 
 
96
 
       /* codebook vector construction and construction of
97
 
       total vector */
98
 
 
99
 
       getCBvec(cbvec, mem, index[0], lMem, veclen);
100
 
       for (j=0;j<veclen;j++){
101
 
           decvector[j] = gain[0]*cbvec[j];
102
 
       }
103
 
       if (nStages > 1) {
104
 
           for (k=1; k<nStages; k++) {
105
 
               getCBvec(cbvec, mem, index[k], lMem, veclen);
106
 
               for (j=0;j<veclen;j++) {
107
 
                   decvector[j] += gain[k]*cbvec[j];
108
 
               }
109
 
           }
110
 
       }
111
 
   }