void melp_chn_write(struct melp_param *par) { int i, bit_cntr; unsigned int *bit_ptr; /* FEC: code additional information in redundant indeces */ fec_code(par); /* Fill bit buffer */ bit_ptr = bit_buffer; bit_cntr = 0; pack_code(par->gain_index[1],&bit_ptr,&bit_cntr,5,1); /* Toggle and write sync bit */ if (sync_bit) sync_bit = 0; else sync_bit = 1; pack_code(sync_bit,&bit_ptr,&bit_cntr,1,1); pack_code(par->gain_index[0],&bit_ptr,&bit_cntr,3,1); pack_code(par->pitch_index,&bit_ptr,&bit_cntr,PIT_BITS,1); pack_code(par->jit_index,&bit_ptr,&bit_cntr,1,1); pack_code(par->bpvc_index,&bit_ptr,&bit_cntr,NUM_BANDS-1,1); for (i = 0; i < par->msvq_stages; i++) pack_code(par->msvq_index[i],&bit_ptr,&bit_cntr,par->msvq_bits[i],1); pack_code(par->fsvq_index[0],&bit_ptr,&bit_cntr, FS_BITS,1); /* Write channel output buffer */ for (i = 0; i < NUM_CH_BITS; i++) { pack_code(bit_buffer[bit_order[i]],&par->chptr,&par->chbit, 1,CHWORDSIZE); if (i == 0) *(par->chptr) |= 0x8000; /* set beginning of frame bit */ } }
void melp_chn_write(struct quant_param *qpar, unsigned char chbuf[]) { register int16_t i; unsigned char *bit_ptr; int16_t bit_cntr; /* FEC: code additional information in redundant indeces */ fec_code(qpar); /* Fill bit buffer */ bit_ptr = bit_buffer; bit_cntr = 0; pack_code(qpar->gain_index[1], &bit_ptr, &bit_cntr, 5, 1); /* Toggle and write sync bit */ sync_bit = melpe_sub(1, sync_bit); pack_code(sync_bit, &bit_ptr, &bit_cntr, 1, 1); pack_code(qpar->gain_index[0], &bit_ptr, &bit_cntr, 3, 1); pack_code(qpar->pitch_index, &bit_ptr, &bit_cntr, PIT_BITS, 1); pack_code(qpar->jit_index[0], &bit_ptr, &bit_cntr, 1, 1); pack_code(qpar->bpvc_index[0], &bit_ptr, &bit_cntr, NUM_BANDS - 1, 1); for (i = 0; i < MSVQ_STAGES; i++) pack_code(qpar->msvq_index[i], &bit_ptr, &bit_cntr, msvq_bits[i], 1); pack_code(qpar->fsvq_index, &bit_ptr, &bit_cntr, FS_BITS, 1); /* Write channel output buffer */ qpar->chptr = chbuf; qpar->chbit = 0; for (i = 0; i < bitNum24; i++) { pack_code(bit_buffer[bit_order[i]], &qpar->chptr, &qpar->chbit, 1, chwordsize); if (i == 0) /* set beginning of frame bit */ *(qpar->chptr) |= (uint16_t) 0x8000; } }