Esempio n. 1
0
static void dec_process(MSFilter *f){
	DecState *s=(DecState*)f->data;
	int nbytes = 0;
	mblk_t *im;
	mblk_t *om;
	const int frsz= BV16_FRAME_SIZE * 2 * 4;
	int i,frames;

	while((im=ms_queue_get(f->inputs[0]))!=NULL){
		om=allocb(frsz,0);

		nbytes=msgdsize(im);
		frames = nbytes/(BV16_CODE_SIZE * 2);
		
		//ms_error("read bv16 data, size %d, frame %d",msgdsize(im),frames);

		for(i=0;i<frames;i++){

			if (mblk_get_precious_flag(im)) { //¶ª°üÒþ±Î
				bv16_fillin(s->dec, (int16_t *) om->b_wptr, BV16_CODE_SIZE);
			} else {
				bv16_decode(s->dec, (int16_t *) om->b_wptr, (uint8_t *) im->b_rptr, BV16_CODE_SIZE);
			}
			im->b_rptr += 10;
			om->b_wptr += 80;
		}
	
		ms_queue_put(f->outputs[0],om);
		freemsg(im);
	}
		
}
Esempio n. 2
0
static switch_status_t switch_bv16_decode(switch_codec_t *codec,
										  switch_codec_t *other_codec,
										  void *encoded_data,
										  uint32_t encoded_data_len,
										  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
										  unsigned int *flag)
{
	struct bv16_context *context = codec->private_info;

	if (!context) {
		return SWITCH_STATUS_FALSE;
	}

	if ((*flag & SFF_PLC)) {
		*decoded_data_len = (2 * bv16_fillin(context->decoder_object, (int16_t *) decoded_data, encoded_data_len));
	} else {
		*decoded_data_len = (2 * bv16_decode(context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
	}

	return SWITCH_STATUS_SUCCESS;
}