SWIGEXPORT jlong JNICALL Java_com_morlunk_jumble_audio_celt11_CELT11JNI_celt_1encoder_1init(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jintArray jarg4) { jlong jresult = 0 ; CELTEncoder *arg1 = (CELTEncoder *) 0 ; int arg2 ; int arg3 ; int *arg4 = (int *) 0 ; int temp4 ; CELTEncoder *result = 0 ; (void)jenv; (void)jcls; arg1 = *(CELTEncoder **)&jarg1; arg2 = (int)jarg2; arg3 = (int)jarg3; { if (!jarg4) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); return 0; } if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); return 0; } temp4 = (int)0; arg4 = &temp4; } result = (CELTEncoder *)celt_encoder_init(arg1,arg2,arg3,arg4); *(CELTEncoder **)&jresult = result; { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); } return jresult; }
OpusEncoder *opus_encoder_init(OpusEncoder* st, int Fs, int channels) { void *silk_enc; CELTEncoder *celt_enc; int err; int ret, silkEncSizeBytes, celtEncSizeBytes; memset(st, 0, sizeof(OpusEncoder)); /* Create SILK encoder */ ret = silk_Get_Encoder_Size( &silkEncSizeBytes ); if( ret ) return NULL; silkEncSizeBytes = align(silkEncSizeBytes); celtEncSizeBytes = celt_encoder_get_size(channels); st->silk_enc_offset = align(sizeof(OpusEncoder)); st->celt_enc_offset = st->silk_enc_offset+silkEncSizeBytes; silk_enc = (char*)st+st->silk_enc_offset; celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset); st->stream_channels = st->channels = channels; st->Fs = Fs; ret = silk_InitEncoder( silk_enc, &st->silk_mode ); if( ret ) goto failure; /* default SILK parameters */ st->silk_mode.nChannelsAPI = channels; st->silk_mode.nChannelsInternal = channels; st->silk_mode.API_sampleRate = st->Fs; st->silk_mode.maxInternalSampleRate = 16000; st->silk_mode.minInternalSampleRate = 8000; st->silk_mode.desiredInternalSampleRate = 16000; st->silk_mode.payloadSize_ms = 20; st->silk_mode.bitRate = 25000; st->silk_mode.packetLossPercentage = 0; st->silk_mode.complexity = 10; st->silk_mode.useInBandFEC = 0; st->silk_mode.useDTX = 0; st->silk_mode.useCBR = 0; /* Create CELT encoder */ /* Initialize CELT encoder */ celt_encoder_init(celt_enc, Fs, channels, &err); if (err != CELT_OK) goto failure; celt_encoder_ctl(celt_enc, CELT_SET_SIGNALLING(0)); st->mode = MODE_HYBRID; st->bandwidth = BANDWIDTH_FULLBAND; st->use_vbr = 0; st->user_bitrate_bps = OPUS_BITRATE_AUTO; st->bitrate_bps = 3000+Fs*channels; st->user_mode = OPUS_MODE_AUTO; st->user_bandwidth = BANDWIDTH_AUTO; st->voice_ratio = 90; st->first = 1; st->encoder_buffer = st->Fs/100; st->delay_compensation = st->Fs/400; if (st->Fs > 16000) st->delay_compensation += 10; return st; failure: free(st); return NULL; }