Exemplo n.º 1
0
int DecodeVoicePCM(int codec, void* pBufIn, int nLenIn, void* pBufOut, int nLenOut)
{
    struct g72x_state	state;
    int					dec_bits;

	XBUFFER				xbin;
	XBUFFER				xbout;

	unsigned int		nSavePackData = 0;
	int					nSavePackBit  = 0;
    unsigned char		nUnpackEncData;

	switch (codec)
	{
		case G723_24 : dec_bits = 3; break;
		case G721_32 : dec_bits = 4; break;
		case G723_40 : dec_bits = 5; break;
		default : return 0;
	}

    g72x_init_state(&state);

	SetXBuffer(xbin , (unsigned char*) pBufIn , nLenIn , nLenIn, 0);
	SetXBuffer(xbout, (unsigned char*) pBufOut, nLenOut, 0     , 0);

    while (UnpackInput(nSavePackData, nSavePackBit, xbin, nUnpackEncData, dec_bits) >= 0)
    {
		int nUnpackSourceData;

		switch (codec)
		{
			case G723_24 : nUnpackSourceData = g723_24_decoder(nUnpackEncData, AUDIO_ENCODING_LINEAR, &state); break;
			case G721_32 : nUnpackSourceData = g721_decoder   (nUnpackEncData, AUDIO_ENCODING_LINEAR, &state); break;
			case G723_40 : nUnpackSourceData = g723_40_decoder(nUnpackEncData, AUDIO_ENCODING_LINEAR, &state); break;
		}

		AddXBufferShort(xbout, nUnpackSourceData);
    }

    return xbout.nLen;
}
Exemplo n.º 2
0
WORD FAR PASCAL G23A05toG16 (_segment _sBufSeg, BYTBASPTR pcSrcBuf,
                WORD FAR *lpusBytCnt, GENBASPTR psDstBuf, 
                WORD usRsv001, LPITCB lpITC)
{
    G2XBLK  gbG2X = lpITC->gbG2X;       /* Init G721 interface block    */
    WORD    usBit = lpITC->usBitOff;
    WORD    usByt = lpITC->usBytOff;
    WORD    usi;

    /********************************************************************/
    /********************************************************************/
// modify to accept bit offset from previous pass
    usi = *lpusBytCnt;
    while (usi) {
        if (usBit < BITCNT) {
            usByt |= (*_sBufSeg:>pcSrcBuf++ << usBit);
            usBit += BYTSIZ;
            usi--;
        }
        *_sBufSeg:>psDstBuf++ = g723_40_decoder (usByt & 0xf, 0, &gbG2X);
        usByt >>= BITCNT;
        usBit  -= BITCNT;
    }