static int lin16tog722_new(struct ast_trans_pvt *pvt) { struct g722_encoder_pvt *tmp = pvt->pvt; g722_encode_init(&tmp->g722, 64000, 0); return 0; }
/*! \brief init a new instance of g722_encoder_pvt. */ static int lintog722_new(struct ast_trans_pvt *pvt) { struct g722_encoder_pvt *tmp = pvt->pvt; g722_encode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); return 0; }
static struct cw_translator_pvt *lintog722_new(void) { struct g722_encoder_pvt *tmp; if ((tmp = malloc(sizeof (struct g722_encoder_pvt))) == NULL) return NULL; memset(tmp, 0, sizeof(*tmp)); g722_encode_init(&(tmp->g722_state), 64000, G722_PACKED); localusecnt++; cw_update_use_count(); return (struct cw_translator_pvt *) tmp; }
int CTG722::encodeFrame(short *pIn,unsigned char *pOut) { if(!estate){ estate=g722_encode_init(NULL,BPS,iSampleRate==8000?G722_SAMPLE_RATE_8000|G722_PACKED:G722_PACKED); if(!estate)return 0; } // for(int i=0;i<iCodecFrameSizeDec/2;i++)pIn[i]>>=1; int r=g722_encode((g722_encode_state_t*)estate,pOut,pIn,iCodecFrameSizeDec/2); //printf(" re=%d %d\n",r,iCodecFrameSizeEnc); //iCodecFrameSizeEnc=r; return r; }
long G722NB_create(const char* format_parameters, amci_codec_fmt_info_t* format_description) { G722State* gs; gs = (G722State*) calloc(1, sizeof(G722State)); if (!gs) { ERROR("error allocating memory for G722 codec state\n"); return 0; } if (!g722_encode_init(&gs->encode_state, 64000, #if SYSTEM_SAMPLERATE >=16000 0 #else G722_SAMPLE_RATE_8000 #endif )) { ERROR("error initializing G722 encoder\n"); free(gs); return 0; } if (!g722_decode_init(&gs->decode_state, 64000, #if SYSTEM_SAMPLERATE >=16000 0 #else G722_SAMPLE_RATE_8000 #endif )) { ERROR("error initializing G722 decoder\n"); free(gs); return 0; } format_description[0].id = AMCI_FMT_FRAME_LENGTH; format_description[0].value = 20; format_description[1].id = AMCI_FMT_FRAME_SIZE; #if SYSTEM_SAMPLERATE >=16000 format_description[1].value = 320; /* 20 ms at 16khz */ #else format_description[1].value = 160; #endif format_description[2].id = 0; return (long)gs; }
static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings) { uint32_t encoding, decoding; struct g722_context *context = NULL; encoding = (flags & SWITCH_CODEC_FLAG_ENCODE); decoding = (flags & SWITCH_CODEC_FLAG_DECODE); if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) { return SWITCH_STATUS_FALSE; } else { if (encoding) { context->encoder_object = g722_encode_init(context->encoder_object, 64000, G722_PACKED); } if (decoding) { context->decoder_object = g722_decode_init(context->decoder_object, 64000, G722_PACKED); } } codec->private_info = context; return SWITCH_STATUS_SUCCESS; }
JNIEXPORT jlong JNICALL Java_org_jitsi_impl_neomedia_codec_audio_g722_JNIEncoder_g722_1encoder_1open (JNIEnv *jniEnv, jclass clazz) { return (jlong) (intptr_t) g722_encode_init(NULL, 64000, 0); }