Result without VAD, in cycles per sample: {{{ pcmu 12.90 pcma 13.05 gsm 1436.85 speex/16000 5577.65 speex/8000 9868.60 }}} Result with VAD, in cycles per sample: {{{ pcmu 24.47 pcma 23.95 gsm 1538.53 speex/16000 5578.68 speex/8000 10026.28 }}} Code: {{{ #include static __declspec(naked) unsigned tick(void) { __asm { rdtsc ret } } static void codec_test() { pj_str_t ci[16]; pjmedia_endpt *med_ept = pjsua_var.med_endpt; pjmedia_codec_mgr *cm; unsigned i, count; pj_status_t status; cm = pjmedia_endpt_get_codec_mgr(med_ept); ci[0] = pj_str("pcmu"); ci[1] = pj_str("pcma"); ci[2] = pj_str("gsm"); ci[3] = pj_str("speex/16000"); ci[4] = pj_str("speex/8000"); count = 5; for (i=0; ipt != 0) // continue; status = pjmedia_codec_mgr_get_default_param(cm, pci, ¶m); pj_assert(status == PJ_SUCCESS); if (pci->clock_rate == 8000) { status = pjmedia_wav_player_port_create(pool, "../bin/d8.wav", param.info.frm_ptime, PJMEDIA_FILE_NO_LOOP, 0, &wav); } else if (pci->clock_rate == 16000) { status = pjmedia_wav_player_port_create(pool, "../bin/d16.wav", param.info.frm_ptime, PJMEDIA_FILE_NO_LOOP, 0, &wav); } else if (pci->clock_rate == 32000) { status = pjmedia_wav_player_port_create(pool, "../bin/d32.wav", param.info.frm_ptime, PJMEDIA_FILE_NO_LOOP, 0, &wav); } else { continue; } pj_assert(status == PJ_SUCCESS); status = pjmedia_codec_mgr_alloc_codec(cm, pci, &codec); pj_assert(status == PJ_SUCCESS); status = codec->op->init(codec, pool); pj_assert(status == PJ_SUCCESS); param.setting.vad = 1; status = codec->op->open(codec, ¶m); pj_assert(status == PJ_SUCCESS); frame.buf = (char*)framebuf; frame.size = param.info.frm_ptime * pci->clock_rate / 1000 * 2; t = 0; totsamp = 0; while (pjmedia_port_get_frame(wav, &frame)==PJ_SUCCESS && frame.type==PJMEDIA_FRAME_TYPE_AUDIO) { char outputbuf[320]; pjmedia_frame output; unsigned t0, t1; totsamp += param.info.frm_ptime * pci->clock_rate / 1000; output.buf = outputbuf; output.size = sizeof(outputbuf); t0 = tick(); status = codec->op->encode(codec, &frame, sizeof(outputbuf), &output); t1 = tick(); pj_assert(status == PJ_SUCCESS); //if (status != PJ_SUCCESS) { // int j=0; //} t += (t1 - t0); frame.size = param.info.frm_ptime * pci->clock_rate / 1000 * 2; } pjmedia_port_destroy(wav); codec->op->close(codec); pjmedia_codec_mgr_dealloc_codec(cm, codec); pj_pool_release(pool); PJ_LOG(3,("test", "%u\t%.*s\t%3.2f", pci->clock_rate, ci[i].slen, ci[i].ptr, t * 1.0 / totsamp)); } } }}}