OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

g711a1_plc.h
Go to the documentation of this file.
1 /*
2 * g711a1_plc.h
3 *
4 * packet loss concealment algorithm is based on the ITU recommendation
5 * G.711 Appendix I.
6 *
7 * Copyright (c) 2008 Christian Hoene, University of Tuebingen, Germany
8 *
9 * The contents of this file are subject to the Mozilla Public License
10 * Version 1.0 (the "License"); you may not use this file except in
11 * compliance with the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
13 *
14 * Software distributed under the License is distributed on an "AS IS"
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16 * the License for the specific language governing rights and limitations
17 * under the License.
18 *
19 * The Initial Developer of the Original Code is Christian Hoene
20 * based on the code given in ITU-T Recommendation G.711 Appendix I (09/99)
21 * "A high quality low-complexity algorithm for packet loss concealment with G.711"
22 * Approved in 1999-09, www.itu.int.
23 *
24 * Contributor(s): ______________________________________.
25 *
26 * $Revision: 24499 $
27 * $Author: rjongbloed $
28 * $Date: 2010-06-15 04:29:05 -0500 (Tue, 15 Jun 2010) $
29 */
30
31 #ifndef OPAL_CODEC_G711A1_PLC_H
32 #define OPAL_CODEC_G711A1_PLC_H
33
34 #ifndef SBC_DISABLE_PTLIB
35 #include <opal/buildopts.h>
36 #endif
37
38 #if OPAL_G711PLC
39
40 #include <string.h>
41
46 class OpalG711_PLC
47 {
48 private:
49 enum modes {
50 LOSS_PERIOD1=10,
51 LOSS_PERIOD2start=20,
52 LOSS_PERIOD2overlap=21,
53 LOSS_PERIOD2=22,
54 LOSS_PERIOD3=30,
55 TRANSITION=40,
56 NOLOSS=0
57 };
58
59 int conceal_count;
61 short * transition_buf;
63 int hist_len;
64 int pitch_overlapmax;
66 short * hist_buf;
67 short * tmp_buf;
69 short * conceal_overlapbuf;
71 double * pitch_buf;
72 double * pitch_lastq;
74 int pitch_min;
75 int pitch_max;
77 struct channel_counters {
78 enum modes mode;
79 int conceal_count;
80 int transition_len;
81 int transition_count;
83 int pitch_overlap;
84 int pitch_offset;
85 int pitch;
86 int pitch_blen;
87 } *channel;
88
89 int rate;
90 int channels;
92 int ms2samples(int ms) const
93 {
94 return ms*rate/1000;
95 }
96
97
98 public:
99 OpalG711_PLC(int rate=8000, int channels=1, double pitch_low=66.6, double pitch_high=200);
100 ~OpalG711_PLC();
101
102 void dofe(short *s, int size);
103 void addtohistory(short *s, int size);
104 int getAlgDelay() const { return pitch_overlapmax; };
105 void drop(short *s, int size);
107 private:
108 void scalespeech(short *inout, int c, int sz, bool decay=true) const;
109 void getfespeech(short *out, int c, int sz);
110 void hist_savespeech(short *s, int size);
111 int findpitch(int c);
112 void overlapadd(double *l, double *r, double *o, int c, int cnt) const;
113 void overlapadds(short *l, short *r, short *o, int c, int cnt) const;
114 void overlapaddatend(short *s, short *f, int c, int start, int end, int count) const;
115 void convertsf(short *f, double *t, int c, int cnt) const;
116 void convertfs(double *f, short *t, int c, int cnt) const;
117
118 inline void copy(double *f, double *t, int cnt) const { memmove(t,f,cnt*channels*sizeof(double)); };
119 inline void copy(short *f, short *t, int cnt) const { memmove(t,f,cnt*channels*sizeof(short)); };
120
121 int dofe_partly(short *out, int c, int size);
122 };
123
124
125 #endif // OPAL_G711PLC
126
127 #endif // OPAL_CODEC_G711A1_PLC_H