G729aCompress.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:1k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- #include "....stdafx.h"
- #include "G729aCompress.h"
- extern "C" void va_g729a_init_encoder();
- extern "C" void va_g729a_encoder(short *speech, unsigned char *bitstream);
- extern "C" void va_g729a_init_decoder();
- extern "C" void va_g729a_decoder(unsigned char *bitstream, short *synth_short, int bfi);
- #define L_FRAME_COMPRESSED 10
- #define L_FRAME 80
- #pragma comment(lib,"Client/Sound/G729a.lib")
- CG729aCompress::CG729aCompress( )
- {
- va_g729a_init_encoder();
- va_g729a_init_decoder();
- *( int * )this->compress_buffer = CCompress::G729a;
- this->type = CCompress::G729a;
- }
- CG729aCompress::~CG729aCompress()
- {
- }
- char * CG729aCompress::Compress(char* src,int * srclen )
- {
- if(!src || * srclen != SIZE_AUDIO_FRAME )
- return FALSE;
- char * now = this->compress_buffer + sizeof( int );
- for( int i = 0 ; i < SIZE_AUDIO_PACKED / 10 ; i++ )
- {
- va_g729a_encoder((short*)(src + i * 160),(BYTE*)now + i * 10);
- }
- if( srclen )
- * srclen = sizeof( int ) + SIZE_AUDIO_PACKED;
- return this->compress_buffer;
- }
- char * CG729aCompress::UnCompress(char * src,int * srclen )
- {
- * srclen -= sizeof( int );
- if( ! src || * srclen != SIZE_AUDIO_PACKED )
- return FALSE;
- src += sizeof( int );
- for( int i = 0 ; i < SIZE_AUDIO_PACKED / 10 ; i++ )
- va_g729a_decoder((BYTE*)src + i*10 ,(short*)(this->uncompress_buffer + i*160),0);
- if( srclen )
- *srclen = SIZE_AUDIO_FRAME;
- return this->uncompress_buffer;
- }