JNIEXPORT jint JNICALL Java_org_sipdroid_codecs_G729_decode (JNIEnv *env, jobject obj, jbyteArray encoded, jshortArray lin, jint size) { Word16 synth[BLOCK_LEN]; jbyte serial[BLOCK_LEN]; /* Serial stream */ unsigned int lin_pos = 0; jbyte i; int len=80; if (!codec_open) return 0; if(hDecoder == NULL) return 0; for (i=0; i + BITSTREAM_SIZE <= size; i=i+BITSTREAM_SIZE) { //env->GetByteArrayRegion(encoded, RTP_HDR_SIZE, size, serial); env->GetByteArrayRegion(encoded, i+RTP_HDR_SIZE, BITSTREAM_SIZE,serial); g729a_dec_process(hDecoder, (unsigned char*)serial, synth, 0); //env->SetShortArrayRegion(lin, 0, size,synth); //env->SetShortArrayRegion(lin, lin_pos, size,synth); env->SetShortArrayRegion(lin, lin_pos, len,synth); lin_pos = lin_pos + len; } return (jint)lin_pos; }
int G729CodecNative::Decode(UWord8 *bitstream, int size, Word16 *pcm) { if(!_bOpened) return false; int pcmOffset = 0; int g729Offset = 0; for (; g729Offset < size;) { memcpy(_g729Buff, bitstream + g729Offset, G729_BIT_STREAM_SIZE); g729a_dec_process(_hDecoder, _g729Buff, _speechBuff, 0); memcpy(pcm + pcmOffset, _speechBuff, PCM_BIT_STREAM_SIZE * 2); pcmOffset += PCM_BIT_STREAM_SIZE; g729Offset += G729_BIT_STREAM_SIZE; } return pcmOffset; // return true; }