📄 g729a_bits.c
字号:
#include "../Common/typedef.h"
#include "../Include/G729A_ld8a.h"
#include "../Include/G729A_tab_ld8a.h"
static Word16 G729Abin2int1 ( Word16 *bitstream, Word16 no_of_bits );
static Word16 G729Abin2int2 ( Word16 *bitstream1 ,Word16 *bitstream2, Word16 no_of_bits, Word16 valuelong);
static void G729Aint2bin(Word16 value, Word16 no_of_bits, Word16 *bitstream);
void G729Aprm2bits_ld8k(Word16 prm[], Word16 bits[])
{
Word16 i;
*bits++ = G729A_SYNC_WORD;
*bits++ = G729A_SIZE_WORD;
for (i = 0; i < G729A_PRM_SIZE; i++)
{
G729Aint2bin(prm[i], G729A_bitsno[i], bits);
bits += G729A_bitsno[i];
}
return;
}
static void G729Aint2bin(Word16 value, Word16 no_of_bits, Word16 *bitstream)
{
Word16 *pt_bitstream;
Word16 i, bit;
pt_bitstream = bitstream + no_of_bits;
for (i = 0; i < no_of_bits; i++)
{
bit = value & (Word16)0x0001;
if (bit == 0)
*--pt_bitstream = G729A_BIT_0;
else
*--pt_bitstream = G729A_BIT_1;
value >>= 1;
}
}
void G729Abits2prm_ld8k(Word16 bits[], Word16 prm[])
{
Word16 i;
Word16 bitslong;
Word16 temp;
bitslong = 16;
temp = * bits;
prm[0] = 1;
for (i = 0; i < G729A_PRM_SIZE; i++)
{
if ( G729A_bitsno [ i ] > bitslong )
{
prm [ i + 1 ] = G729Abin2int2 ( &temp, bits + 1, G729A_bitsno [ i ], bitslong );
bits ++;
bitslong = 16 + bitslong - G729A_bitsno [ i ];
}
else
{
prm [ i + 1 ] = G729Abin2int1 ( &temp, G729A_bitsno [ i ] );
bitslong = bitslong - G729A_bitsno [ i ];
}
}
}
static Word16 G729Abin2int1 ( Word16 *bitstream, Word16 no_of_bits )
{
Word32 temp;
temp = *bitstream;
temp = temp & 0x0000ffff;
temp = temp << no_of_bits;
*bitstream = (Word16) ( temp );
return (Word16) (temp >> 16);
}
static Word16 G729Abin2int2 ( Word16 *bitstream1 ,Word16 *bitstream2, Word16 no_of_bits, Word16 valuelong)
{
Word32 temp1, temp2;
temp1 = *bitstream1 & 0x0000ffff;
temp2 = *bitstream2 & 0x0000ffff;
temp1 = temp1 << no_of_bits;
temp2 = temp2 << ( no_of_bits - valuelong );
temp1 = temp1 | temp2;
*bitstream1 = (Word16) ( temp1 );
return (Word16) (temp1 >> 16);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -