📄 g711codec.cxx
字号:
/*
* g711codec.cxx
*
* Open Phone Abstraction Library (OPAL)
* Formally known as the Open H323 project.
*
* Copyright (c) 2001 Equivalence Pty. Ltd.
*
* 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 Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Log: g711codec.cxx,v $
* Revision 1.1 2006/06/26 03:02:34 joegenbaclor
* I have decided to include the latest development realease of OPAL tagged Deimos Devel 1 (June 8 2006) as inegrated classes to opensipstack to avoid future version conflicts due to the fast pace in OPAL development. This move is also aimed to reduce the size of projects using OPAL componets such as the soon to be relased OpenSIPPhone.
*
* Revision 2.4 2005/08/28 07:59:17 rjongbloed
* Converted OpalTranscoder to use factory, requiring sme changes in making sure
* OpalMediaFormat instances are initialised before use.
*
* Revision 2.3 2002/11/20 04:53:16 robertj
* Included optimisations for G.711 and G.726 codecs, thanks Ted Szoczei
*
* Revision 2.2 2002/03/15 03:07:25 robertj
* Added static access to internal conversion functions.
*
* Revision 2.1 2001/08/01 05:04:14 robertj
* Changes to allow control of linking software transcoders, use macros
* to force linking.
*
*/
#include <ptlib.h>
#ifdef __GNUC__
#pragma implementation "g711codec.h"
#endif
#include <codec/g711codec.h>
#define new PNEW
extern "C" {
int ulaw2linear(int u_val);
int linear2ulaw(int pcm_val);
int alaw2linear(int u_val);
int linear2alaw(int pcm_val);
};
///////////////////////////////////////////////////////////////////////////////
Opal_G711_uLaw_PCM::Opal_G711_uLaw_PCM()
: OpalStreamedTranscoder(OpalG711_ULAW_64K, OpalPCM16, 8, 16, 160)
{
PTRACE(3, "Codec\tG711-uLaw-64k decoder created");
}
int Opal_G711_uLaw_PCM::ConvertOne(int sample) const
{
return ulaw2linear(sample);
}
int Opal_G711_uLaw_PCM::ConvertSample(int sample)
{
return ulaw2linear(sample);
}
///////////////////////////////////////////////////////////////////////////////
Opal_PCM_G711_uLaw::Opal_PCM_G711_uLaw()
: OpalStreamedTranscoder(OpalPCM16, OpalG711_ULAW_64K, 16, 8, 160)
{
PTRACE(3, "Codec\tG711-uLaw-64k encoder created");
}
int Opal_PCM_G711_uLaw::ConvertOne(int sample) const
{
return linear2ulaw(sample);
}
int Opal_PCM_G711_uLaw::ConvertSample(int sample)
{
return linear2ulaw(sample);
}
///////////////////////////////////////////////////////////////////////////////
Opal_G711_ALaw_PCM::Opal_G711_ALaw_PCM()
: OpalStreamedTranscoder(OpalG711_ALAW_64K, OpalPCM16, 8, 16, 160)
{
PTRACE(3, "Codec\tG711-ALaw-64k decoder created");
}
int Opal_G711_ALaw_PCM::ConvertOne(int sample) const
{
return alaw2linear(sample);
}
int Opal_G711_ALaw_PCM::ConvertSample(int sample)
{
return alaw2linear(sample);
}
///////////////////////////////////////////////////////////////////////////////
Opal_PCM_G711_ALaw::Opal_PCM_G711_ALaw()
: OpalStreamedTranscoder(OpalPCM16, OpalG711_ALAW_64K, 16, 8, 160)
{
PTRACE(3, "Codec\tG711-ALaw-64k encoder created");
}
int Opal_PCM_G711_ALaw::ConvertOne(int sample) const
{
return linear2alaw(sample);
}
int Opal_PCM_G711_ALaw::ConvertSample(int sample)
{
return linear2alaw(sample);
}
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -