git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2453 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2006-08-30 16:31:35 +00:00
parent 7de2d07626
commit b4005e094d
2 changed files with 10 additions and 11 deletions

View File

@ -46,7 +46,7 @@ Flag UseVx = True;
enum Crate WrkRate = Rate63;
static const char modname[] = "mod_g723";
static const char modname[] = "mod_g723_1";
struct g723_context {
struct cod_state encoder_object;

View File

@ -43,6 +43,7 @@ typedef struct {
uint8_t bits_per_frame;
uint8_t bits;
uint8_t bbits;
uint8_t ecount;
uint8_t d_bits;
uint8_t d_bbits;
uint8_t dcount;
@ -131,12 +132,15 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
int edata = encoder(*ddp, AUDIO_ENCODING_LINEAR, context);
handle->ecount++;
if (!handle->bbits) {
*handle->ptr = edata;
} else if ((handle->bbits + handle->bits_per_frame) <= BITS_IN_A_BYTE) {
*handle->ptr <<= handle->bits_per_frame;
*handle->ptr |= edata;
printf ("WTF %d\n", BITS_IN_A_BYTE - (handle->bits_per_frame * handle->ecount));
*handle->ptr += (edata << (BITS_IN_A_BYTE - (handle->bits_per_frame * handle->ecount)));
handle->ecount = 0;
} else {
int remain, next, rdata, ndata;
@ -145,16 +149,11 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
rdata = edata;
ndata = edata;
rdata >>= remain;
*handle->ptr <<= remain;
*handle->ptr |= rdata;
handle->ptr++;
ndata &= (1 << next) - 1;
*handle->ptr += (edata << remain);
*handle->ptr = ndata;
handle->bbits = 0;
handle->ecount = 0;
}
handle->bits += handle->bits_per_frame;
handle->bbits += handle->bits_per_frame;