g711a1_plc.h
Go to the documentation of this file.
/*
* g711a1_plc.h
*
* packet loss concealment algorithm is based on the ITU recommendation
* G.711 Appendix I.
*
* Copyright (c) 2008 Christian Hoene, University of Tuebingen, Germany
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Initial Developer of the Original Code is Christian Hoene
* based on the code given in ITU-T Recommendation G.711 Appendix I (09/99)
* "A high quality low-complexity algorithm for packet loss concealment with G.711"
* Approved in 1999-09, www.itu.int.
*
* Contributor(s): ______________________________________.
*
* $Revision: 24499 $
* $Author: rjongbloed $
* $Date: 2010-06-15 04:29:05 -0500 (Tue, 15 Jun 2010) $
*/
#ifndef OPAL_CODEC_G711A1_PLC_H
#define OPAL_CODEC_G711A1_PLC_H
#ifndef SBC_DISABLE_PTLIB
#include <opal/buildopts.h>
#endif
#if OPAL_G711PLC
#include <string.h>
class OpalG711_PLC
{
private:
enum modes {
LOSS_PERIOD1=10,
LOSS_PERIOD2start=20,
LOSS_PERIOD2overlap=21,
LOSS_PERIOD2=22,
LOSS_PERIOD3=30,
TRANSITION=40,
NOLOSS=0
};
int conceal_count;
short * transition_buf;
int hist_len;
int pitch_overlapmax;
short * hist_buf;
short * tmp_buf;
short * conceal_overlapbuf;
double * pitch_buf;
double * pitch_lastq;
int pitch_min;
int pitch_max;
struct channel_counters {
enum modes mode;
int conceal_count;
int transition_len;
int transition_count;
int pitch_overlap;
int pitch_offset;
int pitch;
int pitch_blen;
} *channel;
int rate;
int channels;
int ms2samples(int ms) const
{
return ms*rate/1000;
}
public:
OpalG711_PLC(int rate=8000, int channels=1, double pitch_low=66.6, double pitch_high=200);
~OpalG711_PLC();
void dofe(short *s, int size);
void addtohistory(short *s, int size);
int getAlgDelay() const { return pitch_overlapmax; };
void drop(short *s, int size);
private:
void scalespeech(short *inout, int c, int sz, bool decay=true) const;
void getfespeech(short *out, int c, int sz);
void hist_savespeech(short *s, int size);
int findpitch(int c);
void overlapadd(double *l, double *r, double *o, int c, int cnt) const;
void overlapadds(short *l, short *r, short *o, int c, int cnt) const;
void overlapaddatend(short *s, short *f, int c, int start, int end, int count) const;
void convertsf(short *f, double *t, int c, int cnt) const;
void convertfs(double *f, short *t, int c, int cnt) const;
inline void copy(double *f, double *t, int cnt) const { memmove(t,f,cnt*channels*sizeof(double)); };
inline void copy(short *f, short *t, int cnt) const { memmove(t,f,cnt*channels*sizeof(short)); };
int dofe_partly(short *out, int c, int size);
};
#endif // OPAL_G711PLC
#endif // OPAL_CODEC_G711A1_PLC_H
OpalG711_PLC
Definition: g711a1_plc.h:46
OpalG711_PLC::OpalG711_PLC
OpalG711_PLC(int rate=8000, int channels=1, double pitch_low=66.6, double pitch_high=200)
buildopts.h
OpalG711_PLC::drop
void drop(short *s, int size)
OpalG711_PLC::addtohistory
void addtohistory(short *s, int size)
OpalG711_PLC::dofe
void dofe(short *s, int size)
OpalG711_PLC::~OpalG711_PLC
~OpalG711_PLC()
OpalG711_PLC::getAlgDelay
int getAlgDelay() const
Definition: g711a1_plc.h:104