diff options
-rw-r--r-- | src/main/java/com/morlunk/jumble/Constants.java | 35 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/JumbleService.java | 5 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/audio/AudioInput.java | 39 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/audio/AudioOutputSpeech.java | 78 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/audio/javacpp/CELT11.java | 34 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/audio/javacpp/CELT7.java | 27 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/audio/javacpp/Opus.java | 10 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/audio/javacpp/Speex.java | 26 | ||||
-rw-r--r-- | src/main/jni/Android.mk | 4 | ||||
-rw-r--r-- | src/main/jni/celt11.cpp | 352 | ||||
-rw-r--r-- | src/main/jni/celt7.cpp | 1179 | ||||
-rw-r--r-- | src/main/jni/opus.cpp | 414 | ||||
-rw-r--r-- | src/main/jni/speex.cpp | 353 | ||||
-rwxr-xr-x | src/main/libs/armeabi/libcelt11.so | bin | 70832 -> 156912 bytes | |||
-rwxr-xr-x | src/main/libs/armeabi/libcelt7.so | bin | 62640 -> 144624 bytes | |||
-rwxr-xr-x | src/main/libs/armeabi/libopus.so | bin | 292080 -> 292080 bytes | |||
-rwxr-xr-x | src/main/libs/armeabi/libspeex.so | bin | 211604 -> 211604 bytes |
17 files changed, 2004 insertions, 552 deletions
diff --git a/src/main/java/com/morlunk/jumble/Constants.java b/src/main/java/com/morlunk/jumble/Constants.java index 67dcaa6..b2190ab 100644 --- a/src/main/java/com/morlunk/jumble/Constants.java +++ b/src/main/java/com/morlunk/jumble/Constants.java @@ -16,31 +16,34 @@ package com.morlunk.jumble; +import com.googlecode.javacpp.IntPointer; +import com.googlecode.javacpp.Loader; +import com.googlecode.javacpp.Pointer; import com.morlunk.jumble.audio.Audio; +import com.morlunk.jumble.audio.javacpp.CELT11; +import com.morlunk.jumble.audio.javacpp.CELT7; public class Constants { - /** Set dynamically by JNI calls. */ public static int CELT_11_VERSION ; /** Set dynamically by JNI calls. */ public static int CELT_7_VERSION; static { - // Load CELT bitstream versions from JNI. TODO clean me with renamed types for version -// int[] error = new int[1]; -// com.morlunk.jumble.audio.celt11.SWIGTYPE_p_CELTMode celt11Mode = CELT11.celt_mode_create(Audio.SAMPLE_RATE, Audio.FRAME_SIZE, error); -// com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTMode celt7Mode = CELT7.celt_mode_create(Audio.SAMPLE_RATE, Audio.FRAME_SIZE, error); -// -// int[] celt11Version = new int[1]; -// int[] celt7Version = new int[1]; -// -// CELT11.celt_mode_info(celt11Mode, CELT11Constants.CELT_GET_BITSTREAM_VERSION, celt11Version); -// CELT7.celt_mode_info(celt7Mode, CELT7Constants.CELT_GET_BITSTREAM_VERSION, celt7Version); -// CELT11.celt_mode_destroy(celt11Mode); -// CELT7.celt_mode_destroy(celt7Mode); -// -// CELT_11_VERSION = celt11Version[0]; -// CELT_7_VERSION = celt7Version[0]; + // Load CELT bitstream versions from JNI. + Pointer celt11Mode = CELT11.celt_mode_create(Audio.SAMPLE_RATE, Audio.FRAME_SIZE, null); + Pointer celt7Mode = CELT7.celt_mode_create(Audio.SAMPLE_RATE, Audio.FRAME_SIZE, null); + + IntPointer celt11Version = new IntPointer(); + IntPointer celt7Version = new IntPointer(); + + CELT11.celt_mode_info(celt11Mode, CELT11.CELT_GET_BITSTREAM_VERSION, celt11Version); + CELT7.celt_mode_info(celt7Mode, CELT7.CELT_GET_BITSTREAM_VERSION, celt7Version); + CELT11.celt_mode_destroy(celt11Mode); + CELT7.celt_mode_destroy(celt7Mode); + + CELT_11_VERSION = celt11Version.get(); + CELT_7_VERSION = celt7Version.get(); } public static final int PROTOCOL_MAJOR = 1; diff --git a/src/main/java/com/morlunk/jumble/JumbleService.java b/src/main/java/com/morlunk/jumble/JumbleService.java index aba134e..16e867b 100644 --- a/src/main/java/com/morlunk/jumble/JumbleService.java +++ b/src/main/java/com/morlunk/jumble/JumbleService.java @@ -243,12 +243,12 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon @Override public void requestBanList() throws RemoteException { - + // TODO } @Override public void requestUserList() throws RemoteException { - + // TODO } @Override @@ -605,7 +605,6 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon runnable.run(mObservers.getBroadcastItem(i)); } catch (RemoteException e) { e.printStackTrace(); - // TODO handle this error } } mObservers.finishBroadcast(); diff --git a/src/main/java/com/morlunk/jumble/audio/AudioInput.java b/src/main/java/com/morlunk/jumble/audio/AudioInput.java index e9be7fb..d9aaebb 100644 --- a/src/main/java/com/morlunk/jumble/audio/AudioInput.java +++ b/src/main/java/com/morlunk/jumble/audio/AudioInput.java @@ -18,6 +18,7 @@ package com.morlunk.jumble.audio; import android.media.AudioFormat; import android.media.AudioRecord; +import android.media.AudioTrack; import android.media.MediaRecorder; import android.util.Log; @@ -47,6 +48,8 @@ public class AudioInput extends JumbleMessageHandler.Stub implements Runnable { public void onFrameEncoded(byte[] data, int length, JumbleUDPMessageType messageType); } + public static final int[] SAMPLE_RATES = { 48000, 44100, 22050, 160000, 11025, 8000 }; + public static final int SPEEX_RESAMPLE_QUALITY = 3; public static final int OPUS_MAX_BYTES = 512; // Opus specifies 4000 bytes as a recommended value for encoding, but the official mumble project uses 512. private Pointer mOpusEncoder;; @@ -54,15 +57,17 @@ public class AudioInput extends JumbleMessageHandler.Stub implements Runnable { // private com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTMode mCELTAlphaMode; // private com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTEncoder mCELTAlphaEncoder; private Speex.SpeexPreprocessState mPreprocessState; + private Speex.SpeexResampler mResampler; private AudioInputListener mListener; private int mTransmitMode = Constants.TRANSMIT_PUSH_TO_TALK; private AudioRecord mAudioRecord; private int mMinBufferSize; - private int mInputSampleRate = 48000; //44100; FIXME + private int mInputSampleRate = -1; private int mFrameSize = Audio.FRAME_SIZE; - private int mFramesPerPacket = 2; + private int mMicFrameSize = Audio.FRAME_SIZE; + private int mFramesPerPacket = 6; // Temporary encoder state private final short[] mOpusBuffer = new short[mFrameSize*mFramesPerPacket]; @@ -88,8 +93,24 @@ public class AudioInput extends JumbleMessageHandler.Stub implements Runnable { switchCodec(codec); configurePreprocessState(); - // TODO support input resampling. We can't expect 48000hz on all android devices. - int reportedMinBufferSize = AudioRecord.getMinBufferSize(Audio.SAMPLE_RATE, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); + // Use the highest sample rate we can get. TODO make this an option in settings. + for(int rate : SAMPLE_RATES) { + if(AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT) > 0) { + mInputSampleRate = rate; + break; + } + } + if(mInputSampleRate != -1) { + Log.d(Constants.TAG, "Initialized AudioInput with sample rate "+mInputSampleRate); + if(mInputSampleRate != Audio.SAMPLE_RATE) { + mResampler = new Speex.SpeexResampler(1, mInputSampleRate, Audio.SAMPLE_RATE, SPEEX_RESAMPLE_QUALITY); + mMicFrameSize = (mFrameSize * mInputSampleRate)/Audio.SAMPLE_RATE; + } + } else { + throw new RuntimeException("Device does not support any compatible input sampling rates!"); + } + + int reportedMinBufferSize = AudioRecord.getMinBufferSize(mInputSampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); mMinBufferSize = Math.max(reportedMinBufferSize, mFrameSize); mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, mInputSampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, mMinBufferSize); } @@ -205,16 +226,22 @@ public class AudioInput extends JumbleMessageHandler.Stub implements Runnable { if(mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) return; + final short[] audioData = new short[mFrameSize]; + final short[] resampleBuffer = new short[mMicFrameSize]; // We loop when the 'recording' instance var is true instead of checking audio record state because we want to always cleanly shutdown. while(mRecording) { - int shortsRead = mAudioRecord.read(audioData, 0, mFrameSize); + int shortsRead = mAudioRecord.read(mResampler != null ? resampleBuffer : audioData, 0, mResampler != null ? mMicFrameSize : mFrameSize); if(shortsRead > 0) { int len; boolean encoded = false; mFrameCounter++; + // Resample if necessary + if(mResampler != null) + mResampler.resample(resampleBuffer, audioData); + boolean talking = true; if(mTransmitMode == Constants.TRANSMIT_VOICE_ACTIVITY) { @@ -310,6 +337,8 @@ public class AudioInput extends JumbleMessageHandler.Stub implements Runnable { Opus.opus_encoder_destroy(mOpusEncoder); if(mPreprocessState != null) mPreprocessState.destroy(); + if(mResampler != null) + mResampler.destroy(); } @Override diff --git a/src/main/java/com/morlunk/jumble/audio/AudioOutputSpeech.java b/src/main/java/com/morlunk/jumble/audio/AudioOutputSpeech.java index 107ef7b..5d2c85e 100644 --- a/src/main/java/com/morlunk/jumble/audio/AudioOutputSpeech.java +++ b/src/main/java/com/morlunk/jumble/audio/AudioOutputSpeech.java @@ -21,6 +21,8 @@ import com.googlecode.javacpp.FloatPointer; import com.googlecode.javacpp.IntPointer; import com.googlecode.javacpp.Loader; import com.googlecode.javacpp.Pointer; +import com.morlunk.jumble.audio.javacpp.CELT11; +import com.morlunk.jumble.audio.javacpp.CELT7; import com.morlunk.jumble.audio.javacpp.Opus; import com.morlunk.jumble.audio.javacpp.Speex; import com.morlunk.jumble.model.User; @@ -40,14 +42,10 @@ public class AudioOutputSpeech { public void onTalkStateUpdated(int session, User.TalkState state); } - // Native audio pointers -// private com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTDecoder mCELTAlphaDecoder; -// private com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTMode mCELTAlphaMode; -// private com.morlunk.jumble.audio.celt11.SWIGTYPE_p_CELTDecoder mCELTBetaDecoder; -// private SWIGTYPE_p_void mSpeexDecoder; -// private SpeexBits mSpeexBits; - private Pointer mOpusDecoder; + private Pointer mCELTBetaDecoder; + private Pointer mCELTAlphaMode; + private Pointer mCELTAlphaDecoder; private Speex.JitterBuffer mJitterBuffer; private int mSession; @@ -58,11 +56,10 @@ public class AudioOutputSpeech { private float[] mBuffer; private Queue<BytePointer> mFrames = new ConcurrentLinkedQueue<BytePointer>(); private int mMissCount = 0; - private int mMissedFrames = 0; private float mAverageAvailable = 0; private boolean mHasTerminator = false; private boolean mLastAlive = true; - private int mBufferOffset, mBufferFilled, mLastConsume = 0; + private int mBufferFilled, mLastConsume = 0; private int ucFlags; private TalkStateListener mTalkStateListener; @@ -83,16 +80,16 @@ public class AudioOutputSpeech { // mSpeexDecoder = Speex.speex_decoder_init(Speex.getSpeex_uwb_mode()); // Speex.speex_decoder_ctl(mSpeexDecoder, SpeexConstants.SPEEX_SET_ENH, new int[] { 1 }); // break; -// case UDPVoiceCELTBeta: -// mCELTBetaDecoder = CELT11.celt_decoder_create(Audio.SAMPLE_RATE, 1, error); -// break; -// case UDPVoiceCELTAlpha: -// mCELTAlphaMode = CELT7.celt_mode_create(Audio.SAMPLE_RATE, Audio.FRAME_SIZE, error); -// mCELTAlphaDecoder = CELT7.celt_decoder_create(mCELTAlphaMode, 1, error); -// break; + case UDPVoiceCELTBeta: + mCELTBetaDecoder = CELT11.celt_decoder_create(Audio.SAMPLE_RATE, 1, null); + break; + case UDPVoiceCELTAlpha: + mCELTAlphaMode = CELT7.celt_mode_create(Audio.SAMPLE_RATE, Audio.FRAME_SIZE, null); + mCELTAlphaDecoder = CELT7.celt_decoder_create(mCELTAlphaMode, 1, null); + break; } - mBuffer = new float[mAudioBufferSize*2]; // Leave room for an extra frame in the buffer- TODO fix. + mBuffer = new float[mAudioBufferSize*2]; // Leave room for an extra frame in the buffer, this saves buffer resize operations at runtime normally. mJitterBuffer = new Speex.JitterBuffer(Audio.FRAME_SIZE); IntPointer margin = new IntPointer(1); margin.put(10 * Audio.FRAME_SIZE); @@ -152,7 +149,7 @@ public class AudioOutputSpeech { while(mBufferFilled < num) { int decodedSamples = Audio.FRAME_SIZE; - //resizeBuffer(mBufferFilled + mAudioBufferSize); TODO reimplement resize + resizeBuffer(mBufferFilled + mAudioBufferSize); if(!mLastAlive) out.fill(0); @@ -236,16 +233,16 @@ public class AudioOutputSpeech { BytePointer data = mFrames.poll(); if(mCodec == JumbleUDPMessageType.UDPVoiceCELTAlpha) { -// CELT7.celt_decode_float(mCELTAlphaDecoder, -// data, -// data.length, -// out); + CELT7.celt_decode_float(mCELTAlphaDecoder, + data, + data.capacity(), + out); } else if(mCodec == JumbleUDPMessageType.UDPVoiceCELTBeta) { -// CELT11.celt_decode_float(mCELTBetaDecoder, -// data, -// data.length, -// out, -// Audio.FRAME_SIZE); + CELT11.celt_decode_float(mCELTBetaDecoder, + data, + data.capacity(), + out, + Audio.FRAME_SIZE); } else if(mCodec == JumbleUDPMessageType.UDPVoiceOpus) { decodedSamples = Opus.opus_decode_float(mOpusDecoder, data, @@ -275,11 +272,11 @@ public class AudioOutputSpeech { if(mFrames.isEmpty() && mHasTerminator) nextAlive = false; } else { -// if(mCodec == JumbleUDPMessageType.UDPVoiceCELTAlpha) -// CELT7.celt_decode_float(mCELTAlphaDecoder, null, 0, out); -// else if(mCodec == JumbleUDPMessageType.UDPVoiceCELTBeta) -// CELT11.celt_decode_float(mCELTBetaDecoder, null, 0, out, Audio.FRAME_SIZE); - /*else*/ if(mCodec == JumbleUDPMessageType.UDPVoiceOpus) + if(mCodec == JumbleUDPMessageType.UDPVoiceCELTAlpha) + CELT7.celt_decode_float(mCELTAlphaDecoder, null, 0, out); + else if(mCodec == JumbleUDPMessageType.UDPVoiceCELTBeta) + CELT11.celt_decode_float(mCELTBetaDecoder, null, 0, out, Audio.FRAME_SIZE); + else if(mCodec == JumbleUDPMessageType.UDPVoiceOpus) decodedSamples = Opus.opus_decode_float(mOpusDecoder, null, 0, out, Audio.FRAME_SIZE, 0); // else { // Speex.speex_decode(mSpeexDecoder, null, out); @@ -329,9 +326,8 @@ public class AudioOutputSpeech { if(newSize > mBuffer.length) { float[] n = new float[newSize]; if(mBuffer != null) - System.arraycopy(mBuffer, 0, n, 0, mAudioBufferSize); + System.arraycopy(mBuffer, 0, n, 0, mBuffer.length); mBuffer = n; - mAudioBufferSize = newSize; } } @@ -354,18 +350,16 @@ public class AudioOutputSpeech { public void destroy() { if(mOpusDecoder != null) Opus.opus_decoder_destroy(mOpusDecoder); -// if(mCELTBetaDecoder != null) -// CELT11.celt_decoder_destroy(mCELTBetaDecoder); -// if(mCELTAlphaMode != null) -// CELT7.celt_mode_destroy(mCELTAlphaMode); -// if(mCELTAlphaDecoder != null) -// CELT7.celt_decoder_destroy(mCELTAlphaDecoder); + if(mCELTBetaDecoder != null) + CELT11.celt_decoder_destroy(mCELTBetaDecoder); + if(mCELTAlphaMode != null) + CELT7.celt_mode_destroy(mCELTAlphaMode); + if(mCELTAlphaDecoder != null) + CELT7.celt_decoder_destroy(mCELTAlphaDecoder); // if(mSpeexBits != null) // Speex.speex_bits_destroy(mSpeexBits); // if(mSpeexDecoder != null) // Speex.speex_decoder_destroy(mSpeexDecoder); -// if(mJitterBuffer != null) -// Speex.jitter_buffer_destroy(mJitterBuffer); mJitterBuffer.destroy(); } } diff --git a/src/main/java/com/morlunk/jumble/audio/javacpp/CELT11.java b/src/main/java/com/morlunk/jumble/audio/javacpp/CELT11.java index bab4cee..c5753ed 100644 --- a/src/main/java/com/morlunk/jumble/audio/javacpp/CELT11.java +++ b/src/main/java/com/morlunk/jumble/audio/javacpp/CELT11.java @@ -16,8 +16,14 @@ package com.morlunk.jumble.audio.javacpp; +import com.googlecode.javacpp.BytePointer; +import com.googlecode.javacpp.FloatPointer; import com.googlecode.javacpp.IntPointer; +import com.googlecode.javacpp.Loader; import com.googlecode.javacpp.Pointer; +import com.googlecode.javacpp.ShortPointer; +import com.googlecode.javacpp.annotation.Cast; +import com.googlecode.javacpp.annotation.NoDeallocator; import com.googlecode.javacpp.annotation.Platform; /** @@ -26,21 +32,19 @@ import com.googlecode.javacpp.annotation.Platform; @Platform(library="celt11", cinclude={"<celt.h>","<celt_types.h>"}) public class CELT11 { - public static class Decoder { + public static final int CELT_GET_BITSTREAM_VERSION = 2000; - private Pointer mNativeDecoder; - private int mError; - - public Decoder(int sampleRate, int channels) { - IntPointer error = new IntPointer(1); - mNativeDecoder = celt_decoder_init(sampleRate, channels, error); - mError = error.get(); - } - - public int getError() { - return mError; - } + static { + Loader.load(); } - private static native Pointer celt_decoder_init(int sampleRate, int channels, IntPointer error); -} + public static native @NoDeallocator Pointer celt_mode_create(int sampleRate, int frameSize, IntPointer error); + public static native int celt_mode_info(@Cast("const CELTMode*") Pointer mode, int request, IntPointer value); + public static native void celt_mode_destroy(@Cast("CELTMode*") Pointer mode); + + public static native @NoDeallocator Pointer celt_decoder_create(int sampleRate, int channels, IntPointer error); + public static native int celt_decode(@Cast("CELTDecoder*") Pointer st, @Cast("const unsigned char*") BytePointer data, int len, ShortPointer pcm, int frameSize); + public static native int celt_decode_float(@Cast("CELTDecoder*") Pointer st, @Cast("const unsigned char*") BytePointer data, int len, FloatPointer pcm, int frameSize); + public static native int celt_decoder_ctl(@Cast("CELTDecoder*") Pointer st, int request, Pointer val); + public static native void celt_decoder_destroy(@Cast("CELTDecoder*") Pointer st); +}
\ No newline at end of file diff --git a/src/main/java/com/morlunk/jumble/audio/javacpp/CELT7.java b/src/main/java/com/morlunk/jumble/audio/javacpp/CELT7.java index 7032cf8..383e4df 100644 --- a/src/main/java/com/morlunk/jumble/audio/javacpp/CELT7.java +++ b/src/main/java/com/morlunk/jumble/audio/javacpp/CELT7.java @@ -16,8 +16,35 @@ package com.morlunk.jumble.audio.javacpp; +import com.googlecode.javacpp.BytePointer; +import com.googlecode.javacpp.FloatPointer; +import com.googlecode.javacpp.IntPointer; +import com.googlecode.javacpp.Loader; +import com.googlecode.javacpp.Pointer; +import com.googlecode.javacpp.ShortPointer; +import com.googlecode.javacpp.annotation.Cast; +import com.googlecode.javacpp.annotation.NoDeallocator; +import com.googlecode.javacpp.annotation.Platform; + /** * Created by andrew on 20/10/13. */ +@Platform(library="celt7", cinclude={"<celt.h>","<celt_types.h>"}) public class CELT7 { + + public static final int CELT_GET_BITSTREAM_VERSION = 2000; + + static { + Loader.load(); + } + + public static native @NoDeallocator Pointer celt_mode_create(int sampleRate, int frameSize, IntPointer error); + public static native int celt_mode_info(@Cast("const CELTMode*") Pointer mode, int request, IntPointer value); + public static native void celt_mode_destroy(@Cast("CELTMode*") Pointer mode); + + public static native @NoDeallocator Pointer celt_decoder_create(@Cast("CELTMode*") Pointer mode, int channels, IntPointer error); + public static native int celt_decode(@Cast("CELTDecoder*") Pointer st, @Cast("const unsigned char*") BytePointer data, int len, ShortPointer pcm); + public static native int celt_decode_float(@Cast("CELTDecoder*") Pointer st, @Cast("const unsigned char*") BytePointer data, int len, FloatPointer pcm); + public static native int celt_decoder_ctl(@Cast("CELTDecoder*") Pointer st, int request, Pointer val); + public static native void celt_decoder_destroy(@Cast("CELTDecoder*") Pointer st); } diff --git a/src/main/java/com/morlunk/jumble/audio/javacpp/Opus.java b/src/main/java/com/morlunk/jumble/audio/javacpp/Opus.java index b71bddd..72d284e 100644 --- a/src/main/java/com/morlunk/jumble/audio/javacpp/Opus.java +++ b/src/main/java/com/morlunk/jumble/audio/javacpp/Opus.java @@ -43,16 +43,6 @@ public class Opus { Loader.load(); } -// TODO work on an oo decoder wrapper -// public static class Decoder { -// private Pointer mNativeDecoder; -// -// public Decoder(int frameSize, int channels) { -// IntPointer error = new IntPointer(1); -// mNativeDecoder = opus_decoder_create(frameSize, channels, error); -// } -// } - public static native int opus_decoder_get_size(int channels); public static native @NoDeallocator Pointer opus_decoder_create(int fs, int channels, IntPointer error); public static native int opus_decoder_init(@Cast("OpusDecoder*") Pointer st, int fs, int channels); diff --git a/src/main/java/com/morlunk/jumble/audio/javacpp/Speex.java b/src/main/java/com/morlunk/jumble/audio/javacpp/Speex.java index 05936f2..3ba0018 100644 --- a/src/main/java/com/morlunk/jumble/audio/javacpp/Speex.java +++ b/src/main/java/com/morlunk/jumble/audio/javacpp/Speex.java @@ -32,7 +32,7 @@ import com.googlecode.javacpp.annotation.Platform; * JavaCPP interface for Speex JNI. * Created by andrew on 18/10/13. */ -@Platform(library="speex", link="speex", cinclude={"<speex/speex.h>","<speex/speex_types.h>","<speex/speex_jitter.h>", "<speex/speex_preprocess.h>"}) +@Platform(library="speex", link="speex", cinclude={"<speex/speex.h>","<speex/speex_types.h>","<speex/speex_jitter.h>", "<speex/speex_preprocess.h>", "<speex/speex_resampler.h>"}) public class Speex { static { @@ -125,7 +125,7 @@ public class Speex { } - public static class SpeexPreprocessState extends Pointer { + public static class SpeexPreprocessState { public static final int SPEEX_PREPROCESS_SET_DENOISE = 0; public static final int SPEEX_PREPROCESS_GET_DENOISE = 1; @@ -189,6 +189,28 @@ public class Speex { } + public static class SpeexResampler { + private Pointer mNativeState; + + public SpeexResampler(int channels, int inSampleRate, int outSampleRate, int quality) { + mNativeState = speex_resampler_init(channels, inSampleRate, outSampleRate, quality, null); + } + + public void resample(short[] in, short[] out) { + speex_resampler_process_int(mNativeState, 0, in, new int[] { in.length }, out, new int[] { out.length }); + } + + public void destroy() { + speex_resampler_destroy(mNativeState); + } + + } + + // Resampler + private static native Pointer speex_resampler_init(int channels, int inSampleRate, int outSampleRate, int quality, IntPointer error); + private static native int speex_resampler_process_int(@Cast("SpeexResamplerState*") Pointer state, int channelIndex, @Cast("short*") short[] in, @Cast("unsigned int*") int[] inLen, @Cast("short*") short[] out, @Cast("unsigned int*") int[] outLen); + private static native void speex_resampler_destroy(@Cast("SpeexResamplerState*") Pointer state); + // Jitter buffer private static native Pointer jitter_buffer_init(int tick); private static native void jitter_buffer_reset(@Cast("JitterBuffer*") Pointer jitterBuffer); diff --git a/src/main/jni/Android.mk b/src/main/jni/Android.mk index 8af2e28..eda36f8 100644 --- a/src/main/jni/Android.mk +++ b/src/main/jni/Android.mk @@ -40,7 +40,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_PATH := $(ROOT)/celt-0.11.0-src/libcelt LOCAL_MODULE := libcelt11 -LOCAL_SRC_FILES := bands.c celt.c cwrs.c entcode.c entdec.c entenc.c header.c kiss_fft.c laplace.c mathops.c mdct.c modes.c pitch.c plc.c quant_bands.c rate.c vq.c # ../../celt-0.11.0-build/celt_wrap.c +LOCAL_SRC_FILES := bands.c celt.c cwrs.c entcode.c entdec.c entenc.c header.c kiss_fft.c laplace.c mathops.c mdct.c modes.c pitch.c plc.c quant_bands.c rate.c vq.c $(ROOT)/celt11.cpp LOCAL_C_INCLUDES := $(ROOT)/celt-0.11.0-src/libcelt/ LOCAL_CFLAGS := -I$(ROOT)/celt-0.11.0-build -DHAVE_CONFIG_H -fvisibility=hidden LOCAL_CPP_FEATURES := exceptions @@ -50,7 +50,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_PATH := $(ROOT)/celt-0.7.0-src/libcelt LOCAL_MODULE := libcelt7 -LOCAL_SRC_FILES := bands.c celt.c cwrs.c entcode.c entdec.c entenc.c header.c kiss_fft.c kiss_fftr.c laplace.c mdct.c modes.c pitch.c psy.c quant_bands.c rangedec.c rangeenc.c rate.c vq.c # ../../celt-0.7.0-build/celt_wrap.c +LOCAL_SRC_FILES := bands.c celt.c cwrs.c entcode.c entdec.c entenc.c header.c kiss_fft.c kiss_fftr.c laplace.c mdct.c modes.c pitch.c psy.c quant_bands.c rangedec.c rangeenc.c rate.c vq.c $(ROOT)/celt7.cpp LOCAL_C_INCLUDES := $(ROOT)/celt-0.7.0-src/libcelt/ LOCAL_CFLAGS := -I$(ROOT)/celt-0.7.0-build -DHAVE_CONFIG_H -fvisibility=hidden LOCAL_CPP_FEATURES := exceptions diff --git a/src/main/jni/celt11.cpp b/src/main/jni/celt11.cpp index d3e772a..dae13a9 100644 --- a/src/main/jni/celt11.cpp +++ b/src/main/jni/celt11.cpp @@ -274,6 +274,14 @@ JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_00024NativeDeallocato +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0); + void* rptr = ptr0; + jint rcapacity = 1; + env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(rptr)); + env->SetIntField(obj, JavaCPP_limitFID, rcapacity); + env->SetIntField(obj, JavaCPP_capacityFID, rcapacity); +} JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_asDirectBuffer(JNIEnv* env, jobject obj) { char* ptr = (char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -375,28 +383,8 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_memset(JNIEnv* env } return rarg; } -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) { - char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0); - void* rptr = ptr0; - jint rcapacity = 1; - env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(rptr)); - env->SetIntField(obj, JavaCPP_limitFID, rcapacity); - env->SetIntField(obj, JavaCPP_capacityFID, rcapacity); -} -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 3))) { - return; - } - signed char* rptr = new (std::nothrow) signed char[arg0]; - jint rcapacity = arg0; - jvalue args[3]; - args[0].j = ptr_to_jlong(rptr); - args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray); - env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); -} -JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -404,12 +392,13 @@ JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* e } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - jbyte rarg = 0; - signed char rvalue = ptr[arg0]; - rarg = (jbyte)rvalue; + signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { +JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -417,10 +406,9 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNI } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); - jobject rarg = obj; - memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + jbyte rarg = 0; + signed char rvalue = ptr[arg0]; + rarg = (jbyte)rvalue; return rarg; } JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put__IB(JNIEnv* env, jobject obj, jint arg0, jbyte arg1) { @@ -449,19 +437,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put___3BII(JNI if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 4))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 3))) { return; } - short* rptr = new (std::nothrow) short[arg0]; + signed char* rptr = new (std::nothrow) signed char[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jshort JNICALL Java_com_googlecode_javacpp_ShortPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -489,7 +477,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_get___3SII(JN if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEnv* env, jobject obj, jint arg0, jshort arg1) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -497,13 +485,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JN } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEnv* env, jobject obj, jint arg0, jshort arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -511,23 +497,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEn } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 5))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 4))) { return; } - int* rptr = new (std::nothrow) int[arg0]; + short* rptr = new (std::nothrow) short[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jint JNICALL Java_com_googlecode_javacpp_IntPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -581,19 +569,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_IntPointer_put__II(JNIEnv* ptr[arg0] = arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 6))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 5))) { return; } - jlong* rptr = new (std::nothrow) jlong[arg0]; + int* rptr = new (std::nothrow) int[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_LongPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -621,7 +609,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_get___3JII(JNI if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -629,13 +617,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNI } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -643,23 +629,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 7))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 6))) { return; } - float* rptr = new (std::nothrow) float[arg0]; + jlong* rptr = new (std::nothrow) jlong[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jfloat JNICALL Java_com_googlecode_javacpp_FloatPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -687,7 +675,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_get___3FII(JN if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEnv* env, jobject obj, jint arg0, jfloat arg1) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -695,13 +683,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JN } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEnv* env, jobject obj, jint arg0, jfloat arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -709,23 +695,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEn } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 8))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 7))) { return; } - double* rptr = new (std::nothrow) double[arg0]; + float* rptr = new (std::nothrow) float[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jdouble JNICALL Java_com_googlecode_javacpp_DoublePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -753,7 +741,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_get___3DII(J if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIEnv* env, jobject obj, jint arg0, jdouble arg1) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -761,13 +749,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(J } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIEnv* env, jobject obj, jint arg0, jdouble arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -775,23 +761,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIE } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 9))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 8))) { return; } - unsigned short* rptr = new (std::nothrow) unsigned short[arg0]; + double* rptr = new (std::nothrow) double[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jchar JNICALL Java_com_googlecode_javacpp_CharPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -845,19 +833,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CharPointer_put__IC(JNIEnv ptr[arg0] = arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 10))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 9))) { return; } - void** rptr = new (std::nothrow) void*[arg0]; + unsigned short* rptr = new (std::nothrow) unsigned short[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_get(JNIEnv* env, jobject obj, jint arg0) { void** ptr = (void**)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -890,19 +878,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_put(JNIEnv* ptr[arg0] = ptr1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 11))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 10))) { return; } - bool* rptr = new (std::nothrow) bool[arg0]; + void** rptr = new (std::nothrow) void*[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jboolean JNICALL Java_com_googlecode_javacpp_BoolPointer_get(JNIEnv* env, jobject obj, jint arg0) { bool* ptr = (bool*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -928,19 +916,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BoolPointer_put(JNIEnv* en ptr[arg0] = (bool)arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 12))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 11))) { return; } - long* rptr = new (std::nothrow) long[arg0]; + bool* rptr = new (std::nothrow) bool[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_CLongPointer_get(JNIEnv* env, jobject obj, jint arg0) { long* ptr = (long*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -966,19 +954,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CLongPointer_put(JNIEnv* e ptr[arg0] = (long)arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 13))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 12))) { return; } - size_t* rptr = new (std::nothrow) size_t[arg0]; + long* rptr = new (std::nothrow) long[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_SizeTPointer_get(JNIEnv* env, jobject obj, jint arg0) { size_t* ptr = (size_t*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -1004,8 +992,114 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_SizeTPointer_put(JNIEnv* e ptr[arg0] = (size_t)arg1; return rarg; } +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 13))) { + return; + } + size_t* rptr = new (std::nothrow) size_t[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1mode_1create(JNIEnv* env, jclass cls, jint arg0, jint arg1, jobject arg2) { + int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jobject rarg = NULL; + void* rptr; + jthrowable exc = NULL; + try { + rptr = celt_mode_create(arg0, arg1, ptr2); + if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1decoder_1ctl(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jobject arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + char* ptr2 = arg2 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_decoder_ctl((CELTDecoder*)ptr0, arg1, ptr2); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1decoder_1destroy(JNIEnv* env, jclass cls, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jthrowable exc = NULL; + try { + celt_decoder_destroy((CELTDecoder*)ptr0); + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1mode_1info(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jobject arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_mode_info((const CELTMode*)ptr0, arg1, ptr2); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1mode_1destroy(JNIEnv* env, jclass cls, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jthrowable exc = NULL; + try { + celt_mode_destroy((CELTMode*)ptr0); + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } -JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1decoder_1init(JNIEnv* env, jclass cls, jint arg0, jint arg1, jobject arg2) { + if (exc != NULL) { + env->Throw(exc); + } +} +JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1decoder_1create(JNIEnv* env, jclass cls, jint arg0, jint arg1, jobject arg2) { int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); ptr2 += position2; @@ -1013,7 +1107,7 @@ JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1dec void* rptr; jthrowable exc = NULL; try { - rptr = celt_decoder_init(arg0, arg1, ptr2); + rptr = celt_decoder_create(arg0, arg1, ptr2); if (rptr != NULL) { rarg = env->AllocObject(JavaCPP_getClass(env, 1)); env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); @@ -1027,6 +1121,54 @@ JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1dec } return rarg; } +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1decode(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + short* ptr3 = arg3 == NULL ? NULL : (short*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); + jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); + ptr3 += position3; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_decode((CELTDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3, arg4); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT11_celt_1decode_1float(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + float* ptr3 = arg3 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); + jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); + ptr3 += position3; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_decode_float((CELTDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3, arg4); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} } diff --git a/src/main/jni/celt7.cpp b/src/main/jni/celt7.cpp new file mode 100644 index 0000000..ef1f102 --- /dev/null +++ b/src/main/jni/celt7.cpp @@ -0,0 +1,1179 @@ +/* DO NOT EDIT THIS FILE - IT IS MACHINE GENERATED */ + + +#ifdef __APPLE__ + #define _JAVASOFT_JNI_MD_H_ + + #define JNIEXPORT __attribute__((visibility("default"))) + #define JNIIMPORT + #define JNICALL + + typedef int jint; + typedef long long jlong; + typedef signed char jbyte; +#endif +#ifdef _WIN32 + #define _JAVASOFT_JNI_MD_H_ + + #define JNIEXPORT __declspec(dllexport) + #define JNIIMPORT __declspec(dllimport) + #define JNICALL __stdcall + + typedef int jint; + typedef long long jlong; + typedef signed char jbyte; +#endif +#include <jni.h> +#ifdef ANDROID + #include <android/log.h> + #define NewWeakGlobalRef(obj) NewGlobalRef(obj) + #define DeleteWeakGlobalRef(obj) DeleteGlobalRef(obj) +#endif + +#include <stddef.h> +#ifndef _WIN32 + #include <stdint.h> +#endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <exception> +#include <new> + +#define jlong_to_ptr(a) ((void*)(uintptr_t)(a)) +#define ptr_to_jlong(a) ((jlong)(uintptr_t)(a)) + +#if defined(_MSC_VER) + #define JavaCPP_noinline __declspec(noinline) + #define JavaCPP_hidden /* hidden by default */ +#elif defined(__GNUC__) + #define JavaCPP_noinline __attribute__((noinline)) + #define JavaCPP_hidden __attribute__((visibility("hidden"))) +#else + #define JavaCPP_noinline + #define JavaCPP_hidden +#endif + +extern "C" { +#include <celt.h> +#include <celt_types.h> +} + +static JavaVM* JavaCPP_vm = NULL; +static const char* JavaCPP_classNames[15] = { + "com/googlecode/javacpp/Loader", + "com/googlecode/javacpp/Pointer", + "java/lang/NullPointerException", + "com/googlecode/javacpp/BytePointer", + "com/googlecode/javacpp/ShortPointer", + "com/googlecode/javacpp/IntPointer", + "com/googlecode/javacpp/LongPointer", + "com/googlecode/javacpp/FloatPointer", + "com/googlecode/javacpp/DoublePointer", + "com/googlecode/javacpp/CharPointer", + "com/googlecode/javacpp/PointerPointer", + "com/googlecode/javacpp/BoolPointer", + "com/googlecode/javacpp/CLongPointer", + "com/googlecode/javacpp/SizeTPointer", + "java/lang/RuntimeException" }; +static jclass JavaCPP_classes[15] = { NULL }; +static jmethodID JavaCPP_initMID = NULL; +static jfieldID JavaCPP_addressFID = NULL; +static jfieldID JavaCPP_positionFID = NULL; +static jfieldID JavaCPP_limitFID = NULL; +static jfieldID JavaCPP_capacityFID = NULL; + +static inline void JavaCPP_log(const char* fmt, ...) { + va_list ap; + va_start(ap, fmt); +#ifdef ANDROID + __android_log_vprint(ANDROID_LOG_ERROR, "javacpp", fmt, ap); +#else + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); +#endif + va_end(ap); +} + +static JavaCPP_noinline jclass JavaCPP_getClass(JNIEnv* env, int i) { + if (JavaCPP_classes[i] == NULL && env->PushLocalFrame(1) == 0) { + jclass cls = env->FindClass(JavaCPP_classNames[i]); + if (cls == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error loading class %s.", JavaCPP_classNames[i]); + return NULL; + } + JavaCPP_classes[i] = (jclass)env->NewWeakGlobalRef(cls); + if (JavaCPP_classes[i] == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error creating global reference of class %s.", JavaCPP_classNames[i]); + return NULL; + } + env->PopLocalFrame(NULL); + } + return JavaCPP_classes[i]; +} + +class JavaCPP_hidden JavaCPP_exception : public std::exception { +public: + JavaCPP_exception(const char* str) throw() { + if (str == NULL) { + strcpy(msg, "Unknown exception."); + } else { + strncpy(msg, str, sizeof(msg)); + msg[sizeof(msg) - 1] = 0; + } + } + virtual const char* what() const throw() { return msg; } + char msg[1024]; +}; + +static JavaCPP_noinline jthrowable JavaCPP_handleException(JNIEnv* env, int i) { + jstring str = NULL; + try { + throw; + } catch (std::exception& e) { + str = env->NewStringUTF(e.what()); + } catch (...) { + str = env->NewStringUTF("Unknown exception."); + } + jclass cls = JavaCPP_getClass(env, i); + jmethodID mid = env->GetMethodID(cls, "<init>", "(Ljava/lang/String;)V"); + if (mid == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error getting constructor ID of %s.", JavaCPP_classNames[i]); + return NULL; + } else { + return (jthrowable)env->NewObject(cls, mid, str); + } +} + + + +static void JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray(signed char* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray(short* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray(int* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray(jlong* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray(float* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray(double* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray(unsigned short* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray(void** p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray(bool* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray(long* p) { delete[] p; } +static void JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray(size_t* p) { delete[] p; } + +extern "C" { + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK) { + JavaCPP_log("Could not get JNIEnv for JNI_VERSION_1_6 inside JNI_OnLoad()."); + return JNI_ERR; + } + if (JavaCPP_vm == vm) { + return env->GetVersion(); + } + JavaCPP_vm = vm; + const char* members[15][1] = { + { }, + { "sizeof" }, + { }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { "sizeof" }, + { } }; + int offsets[15][1] = { + { }, + { sizeof(void*) }, + { }, + { sizeof(signed char) }, + { sizeof(short) }, + { sizeof(int) }, + { sizeof(jlong) }, + { sizeof(float) }, + { sizeof(double) }, + { sizeof(unsigned short) }, + { sizeof(void*) }, + { sizeof(bool) }, + { sizeof(long) }, + { sizeof(size_t) }, + { } }; + int memberOffsetSizes[15] = { 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }; + jmethodID putMemberOffsetMID = env->GetStaticMethodID(JavaCPP_getClass(env, 0), "putMemberOffset", "(Ljava/lang/String;Ljava/lang/String;I)V"); + if (putMemberOffsetMID == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error getting method ID of Loader.putMemberOffset()."); + return JNI_ERR; + } + for (int i = 0; i < 15 && !env->ExceptionCheck(); i++) { + for (int j = 0; j < memberOffsetSizes[i] && !env->ExceptionCheck(); j++) { + if (env->PushLocalFrame(2) == 0) { + jvalue args[3]; + args[0].l = env->NewStringUTF(JavaCPP_classNames[i]); + args[1].l = env->NewStringUTF(members[i][j]); + args[2].i = offsets[i][j]; + env->CallStaticVoidMethodA(JavaCPP_getClass(env, 0), putMemberOffsetMID, args); + env->PopLocalFrame(NULL); + } + } + } + JavaCPP_initMID = env->GetMethodID(JavaCPP_getClass(env, 1), "init", "(JIJ)V"); + if (JavaCPP_initMID == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error getting method ID of Pointer.init()."); + return JNI_ERR; + } + JavaCPP_addressFID = env->GetFieldID(JavaCPP_getClass(env, 1), "address", "J"); + if (JavaCPP_addressFID == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error getting field ID of Pointer.address."); + return JNI_ERR; + } + JavaCPP_positionFID = env->GetFieldID(JavaCPP_getClass(env, 1), "position", "I"); + if (JavaCPP_positionFID == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error getting field ID of Pointer.position."); + return JNI_ERR; + } + JavaCPP_limitFID = env->GetFieldID(JavaCPP_getClass(env, 1), "limit", "I"); + if (JavaCPP_limitFID == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error getting field ID of Pointer.limit."); + return JNI_ERR; + } + JavaCPP_capacityFID = env->GetFieldID(JavaCPP_getClass(env, 1), "capacity", "I"); + if (JavaCPP_capacityFID == NULL || env->ExceptionCheck()) { + JavaCPP_log("Error getting field ID of Pointer.capacity."); + return JNI_ERR; + } + return env->GetVersion(); +} + + +JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK) { + JavaCPP_log("Could not get JNIEnv for JNI_VERSION_1_6 inside JNI_OnUnLoad()."); + return; + } + for (int i = 0; i < 15; i++) { + env->DeleteWeakGlobalRef(JavaCPP_classes[i]); + JavaCPP_classes[i] = NULL; + } + JavaCPP_vm = NULL; +} + +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_00024NativeDeallocator_deallocate(JNIEnv* env, jobject obj, jlong arg0, jlong arg1) { + void* allocatedAddress = jlong_to_ptr(arg0); + void (*deallocatorAddress)(void*) = (void(*)(void*))jlong_to_ptr(arg1); + if (deallocatorAddress != NULL && allocatedAddress != NULL) { + (*deallocatorAddress)(allocatedAddress); + } + +} + + + +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0); + void* rptr = ptr0; + jint rcapacity = 1; + env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(rptr)); + env->SetIntField(obj, JavaCPP_limitFID, rcapacity); + env->SetIntField(obj, JavaCPP_capacityFID, rcapacity); +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_asDirectBuffer(JNIEnv* env, jobject obj) { + char* ptr = (char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jint size = env->GetIntField(obj, JavaCPP_limitFID); + size -= position; + jobject rarg = NULL; + char* rptr; + rptr = ptr; + jint rcapacity = size; + if (rptr != NULL) { + rarg = env->NewDirectByteBuffer(rptr, rcapacity); + } + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_memchr(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jlong arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jobject rarg = NULL; + void* rptr; + rptr = memchr(ptr0, arg1, arg2); + if (rptr == ptr0) { + rarg = arg0; + } else if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + return rarg; +} +JNIEXPORT jint JNICALL Java_com_googlecode_javacpp_Pointer_memcmp(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + jint rarg = 0; + int rvalue = memcmp(ptr0, ptr1, arg2); + rarg = (jint)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_memcpy(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + jobject rarg = NULL; + void* rptr; + rptr = memcpy(ptr0, ptr1, arg2); + if (rptr == ptr0) { + rarg = arg0; + } else if (rptr == ptr1) { + rarg = arg1; + } else if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_memmove(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jlong arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + jobject rarg = NULL; + void* rptr; + rptr = memmove(ptr0, ptr1, arg2); + if (rptr == ptr0) { + rarg = arg0; + } else if (rptr == ptr1) { + rarg = arg1; + } else if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_memset(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jlong arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jobject rarg = NULL; + void* rptr; + rptr = memset(ptr0, arg1, arg2); + if (rptr == ptr0) { + rarg = arg0; + } else if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + return rarg; +} + +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { + signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { + signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jbyte rarg = 0; + signed char rvalue = ptr[arg0]; + rarg = (jbyte)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put__IB(JNIEnv* env, jobject obj, jint arg0, jbyte arg1) { + signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = arg1; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { + signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 3))) { + return; + } + signed char* rptr = new (std::nothrow) signed char[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jshort JNICALL Java_com_googlecode_javacpp_ShortPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { + short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jshort rarg = 0; + short rvalue = ptr[arg0]; + rarg = (jshort)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_get___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { + short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEnv* env, jobject obj, jint arg0, jshort arg1) { + short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = arg1; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { + short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 4))) { + return; + } + short* rptr = new (std::nothrow) short[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jint JNICALL Java_com_googlecode_javacpp_IntPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { + int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jint rarg = 0; + int rvalue = ptr[arg0]; + rarg = (jint)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_IntPointer_get___3III(JNIEnv* env, jobject obj, jintArray arg0, jint arg1, jint arg2) { + int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + int* ptr0 = arg0 == NULL ? NULL : (jint*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_IntPointer_put___3III(JNIEnv* env, jobject obj, jintArray arg0, jint arg1, jint arg2) { + int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + int* ptr0 = arg0 == NULL ? NULL : (jint*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_IntPointer_put__II(JNIEnv* env, jobject obj, jint arg0, jint arg1) { + int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = arg1; + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 5))) { + return; + } + int* rptr = new (std::nothrow) int[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_LongPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { + jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jlong rarg = 0; + jlong rvalue = ptr[arg0]; + rarg = (jlong)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_get___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { + jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { + jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = arg1; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { + jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 6))) { + return; + } + jlong* rptr = new (std::nothrow) jlong[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jfloat JNICALL Java_com_googlecode_javacpp_FloatPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { + float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jfloat rarg = 0; + float rvalue = ptr[arg0]; + rarg = (jfloat)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_get___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { + float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEnv* env, jobject obj, jint arg0, jfloat arg1) { + float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = arg1; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { + float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 7))) { + return; + } + float* rptr = new (std::nothrow) float[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jdouble JNICALL Java_com_googlecode_javacpp_DoublePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { + double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jdouble rarg = 0; + double rvalue = ptr[arg0]; + rarg = (jdouble)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_get___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { + double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIEnv* env, jobject obj, jint arg0, jdouble arg1) { + double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = arg1; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { + double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 8))) { + return; + } + double* rptr = new (std::nothrow) double[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jchar JNICALL Java_com_googlecode_javacpp_CharPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { + unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jchar rarg = 0; + unsigned short rvalue = ptr[arg0]; + rarg = (jchar)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CharPointer_get___3CII(JNIEnv* env, jobject obj, jcharArray arg0, jint arg1, jint arg2) { + unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + unsigned short* ptr0 = arg0 == NULL ? NULL : (jchar*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CharPointer_put___3CII(JNIEnv* env, jobject obj, jcharArray arg0, jint arg1, jint arg2) { + unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + unsigned short* ptr0 = arg0 == NULL ? NULL : (jchar*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CharPointer_put__IC(JNIEnv* env, jobject obj, jint arg0, jchar arg1) { + unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = arg1; + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 9))) { + return; + } + unsigned short* rptr = new (std::nothrow) unsigned short[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_get(JNIEnv* env, jobject obj, jint arg0) { + void** ptr = (void**)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = NULL; + void* rptr; + rptr = ptr[arg0]; + if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_put(JNIEnv* env, jobject obj, jint arg0, jobject arg1) { + void** ptr = (void**)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + char* ptr1 = arg1 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + jobject rarg = obj; + ptr[arg0] = ptr1; + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 10))) { + return; + } + void** rptr = new (std::nothrow) void*[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jboolean JNICALL Java_com_googlecode_javacpp_BoolPointer_get(JNIEnv* env, jobject obj, jint arg0) { + bool* ptr = (bool*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jboolean rarg = 0; + bool rvalue = (bool)ptr[arg0]; + rarg = (jboolean)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BoolPointer_put(JNIEnv* env, jobject obj, jint arg0, jboolean arg1) { + bool* ptr = (bool*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = (bool)arg1; + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 11))) { + return; + } + bool* rptr = new (std::nothrow) bool[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_CLongPointer_get(JNIEnv* env, jobject obj, jint arg0) { + long* ptr = (long*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jlong rarg = 0; + long rvalue = (long)ptr[arg0]; + rarg = (jlong)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CLongPointer_put(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { + long* ptr = (long*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = (long)arg1; + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 12))) { + return; + } + long* rptr = new (std::nothrow) long[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_SizeTPointer_get(JNIEnv* env, jobject obj, jint arg0) { + size_t* ptr = (size_t*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jlong rarg = 0; + size_t rvalue = (size_t)ptr[arg0]; + rarg = (jlong)rvalue; + return rarg; +} +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_SizeTPointer_put(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { + size_t* ptr = (size_t*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jobject rarg = obj; + ptr[arg0] = (size_t)arg1; + return rarg; +} +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 13))) { + return; + } + size_t* rptr = new (std::nothrow) size_t[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} + +JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1mode_1create(JNIEnv* env, jclass cls, jint arg0, jint arg1, jobject arg2) { + int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jobject rarg = NULL; + void* rptr; + jthrowable exc = NULL; + try { + rptr = celt_mode_create(arg0, arg1, ptr2); + if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1decoder_1ctl(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jobject arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + char* ptr2 = arg2 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_decoder_ctl((CELTDecoder*)ptr0, arg1, ptr2); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1decoder_1destroy(JNIEnv* env, jclass cls, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jthrowable exc = NULL; + try { + celt_decoder_destroy((CELTDecoder*)ptr0); + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1mode_1info(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jobject arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_mode_info((const CELTMode*)ptr0, arg1, ptr2); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1mode_1destroy(JNIEnv* env, jclass cls, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jthrowable exc = NULL; + try { + celt_mode_destroy((CELTMode*)ptr0); + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } +} +JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1decoder_1create(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jobject arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jobject rarg = NULL; + void* rptr; + jthrowable exc = NULL; + try { + rptr = celt_decoder_create((CELTMode*)ptr0, arg1, ptr2); + if (rptr == (CELTMode*)ptr0) { + rarg = arg0; + } else if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1decode(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + short* ptr3 = arg3 == NULL ? NULL : (short*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); + jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); + ptr3 += position3; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_decode((CELTDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_CELT7_celt_1decode_1float(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + float* ptr3 = arg3 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); + jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); + ptr3 += position3; + jint rarg = 0; + jthrowable exc = NULL; + try { + int rvalue = celt_decode_float((CELTDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3); + rarg = (jint)rvalue; + } catch (...) { + exc = JavaCPP_handleException(env, 14); + } + + if (exc != NULL) { + env->Throw(exc); + } + return rarg; +} + +} + diff --git a/src/main/jni/opus.cpp b/src/main/jni/opus.cpp index b39f77d..785020c 100644 --- a/src/main/jni/opus.cpp +++ b/src/main/jni/opus.cpp @@ -274,6 +274,14 @@ JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_00024NativeDeallocato +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0); + void* rptr = ptr0; + jint rcapacity = 1; + env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(rptr)); + env->SetIntField(obj, JavaCPP_limitFID, rcapacity); + env->SetIntField(obj, JavaCPP_capacityFID, rcapacity); +} JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_asDirectBuffer(JNIEnv* env, jobject obj) { char* ptr = (char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -375,28 +383,8 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_memset(JNIEnv* env } return rarg; } -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) { - char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0); - void* rptr = ptr0; - jint rcapacity = 1; - env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(rptr)); - env->SetIntField(obj, JavaCPP_limitFID, rcapacity); - env->SetIntField(obj, JavaCPP_capacityFID, rcapacity); -} -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 3))) { - return; - } - signed char* rptr = new (std::nothrow) signed char[arg0]; - jint rcapacity = arg0; - jvalue args[3]; - args[0].j = ptr_to_jlong(rptr); - args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray); - env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); -} -JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -404,12 +392,13 @@ JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* e } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - jbyte rarg = 0; - signed char rvalue = ptr[arg0]; - rarg = (jbyte)rvalue; + signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { +JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -417,10 +406,9 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNI } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); - jobject rarg = obj; - memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + jbyte rarg = 0; + signed char rvalue = ptr[arg0]; + rarg = (jbyte)rvalue; return rarg; } JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put__IB(JNIEnv* env, jobject obj, jint arg0, jbyte arg1) { @@ -449,19 +437,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put___3BII(JNI if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 4))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 3))) { return; } - short* rptr = new (std::nothrow) short[arg0]; + signed char* rptr = new (std::nothrow) signed char[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jshort JNICALL Java_com_googlecode_javacpp_ShortPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -489,7 +477,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_get___3SII(JN if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEnv* env, jobject obj, jint arg0, jshort arg1) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -497,13 +485,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JN } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEnv* env, jobject obj, jint arg0, jshort arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -511,23 +497,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEn } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 5))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 4))) { return; } - int* rptr = new (std::nothrow) int[arg0]; + short* rptr = new (std::nothrow) short[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jint JNICALL Java_com_googlecode_javacpp_IntPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -581,19 +569,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_IntPointer_put__II(JNIEnv* ptr[arg0] = arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 6))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 5))) { return; } - jlong* rptr = new (std::nothrow) jlong[arg0]; + int* rptr = new (std::nothrow) int[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_LongPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -621,7 +609,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_get___3JII(JNI if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -629,13 +617,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNI } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -643,23 +629,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 7))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 6))) { return; } - float* rptr = new (std::nothrow) float[arg0]; + jlong* rptr = new (std::nothrow) jlong[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jfloat JNICALL Java_com_googlecode_javacpp_FloatPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -687,7 +675,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_get___3FII(JN if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEnv* env, jobject obj, jint arg0, jfloat arg1) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -695,13 +683,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JN } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEnv* env, jobject obj, jint arg0, jfloat arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -709,23 +695,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEn } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 8))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 7))) { return; } - double* rptr = new (std::nothrow) double[arg0]; + float* rptr = new (std::nothrow) float[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jdouble JNICALL Java_com_googlecode_javacpp_DoublePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -753,7 +741,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_get___3DII(J if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIEnv* env, jobject obj, jint arg0, jdouble arg1) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -761,13 +749,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(J } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIEnv* env, jobject obj, jint arg0, jdouble arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -775,23 +761,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIE } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 9))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 8))) { return; } - unsigned short* rptr = new (std::nothrow) unsigned short[arg0]; + double* rptr = new (std::nothrow) double[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jchar JNICALL Java_com_googlecode_javacpp_CharPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -845,19 +833,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CharPointer_put__IC(JNIEnv ptr[arg0] = arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 10))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 9))) { return; } - void** rptr = new (std::nothrow) void*[arg0]; + unsigned short* rptr = new (std::nothrow) unsigned short[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_get(JNIEnv* env, jobject obj, jint arg0) { void** ptr = (void**)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -890,19 +878,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_put(JNIEnv* ptr[arg0] = ptr1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 11))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 10))) { return; } - bool* rptr = new (std::nothrow) bool[arg0]; + void** rptr = new (std::nothrow) void*[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jboolean JNICALL Java_com_googlecode_javacpp_BoolPointer_get(JNIEnv* env, jobject obj, jint arg0) { bool* ptr = (bool*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -928,19 +916,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BoolPointer_put(JNIEnv* en ptr[arg0] = (bool)arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 12))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 11))) { return; } - long* rptr = new (std::nothrow) long[arg0]; + bool* rptr = new (std::nothrow) bool[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_CLongPointer_get(JNIEnv* env, jobject obj, jint arg0) { long* ptr = (long*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -966,19 +954,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CLongPointer_put(JNIEnv* e ptr[arg0] = (long)arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 13))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 12))) { return; } - size_t* rptr = new (std::nothrow) size_t[arg0]; + long* rptr = new (std::nothrow) long[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_SizeTPointer_get(JNIEnv* env, jobject obj, jint arg0) { size_t* ptr = (size_t*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -1004,14 +992,34 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_SizeTPointer_put(JNIEnv* e ptr[arg0] = (size_t)arg1; return rarg; } +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 13))) { + return; + } + size_t* rptr = new (std::nothrow) size_t[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} -JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1destroy(JNIEnv* env, jclass cls, jobject arg0) { +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encode_1float(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4) { char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; + float* ptr1 = arg1 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + signed char* ptr3 = arg3 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); + jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); + ptr3 += position3; + jint rarg = 0; jthrowable exc = NULL; try { - opus_decoder_destroy((OpusDecoder*)ptr0); + int rvalue = opus_encode_float((OpusEncoder*)ptr0, (const float*)ptr1, arg2, (unsigned char*)ptr3, arg4); + rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1019,16 +1027,15 @@ JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_ if (exc != NULL) { env->Throw(exc); } + return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1bandwidth(JNIEnv* env, jclass cls, jobject arg0) { - signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1destroy(JNIEnv* env, jclass cls, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; - jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_packet_get_bandwidth((const unsigned char*)ptr0); - rarg = (jint)rvalue; + opus_encoder_destroy((OpusEncoder*)ptr0); } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1036,16 +1043,18 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1 if (exc != NULL) { env->Throw(exc); } - return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1samples_1per_1frame(JNIEnv* env, jclass cls, jobject arg0, jint arg1) { - signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1ctl(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jobject arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; + char* ptr2 = arg2 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_packet_get_samples_per_frame((const unsigned char*)ptr0, arg1); + int rvalue = opus_encoder_ctl((OpusEncoder*)ptr0, arg1, ptr2); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1056,14 +1065,11 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1 } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1nb_1channels(JNIEnv* env, jclass cls, jobject arg0) { - signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); - jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); - ptr0 += position0; +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1get_1size(JNIEnv* env, jclass cls, jint arg0) { jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_packet_get_nb_channels((const unsigned char*)ptr0); + int rvalue = opus_decoder_get_size(arg0); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1074,15 +1080,19 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1 } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1nb_1frames(JNIEnv* env, jclass cls, jobject arg0, jint arg1) { - signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); - jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); - ptr0 += position0; - jint rarg = 0; +JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1create(JNIEnv* env, jclass cls, jint arg0, jint arg1, jobject arg2) { + int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); + jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); + ptr2 += position2; + jobject rarg = NULL; + void* rptr; jthrowable exc = NULL; try { - int rvalue = opus_packet_get_nb_frames((const unsigned char*)ptr0, arg1); - rarg = (jint)rvalue; + rptr = opus_decoder_create(arg0, arg1, ptr2); + if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1092,14 +1102,14 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1 } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1nb_1samples(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jint arg2) { - signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1init(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jint arg2) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_packet_get_nb_samples((const unsigned char*)ptr0, arg1, arg2); + int rvalue = opus_decoder_init((OpusDecoder*)ptr0, arg1, arg2); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1110,11 +1120,20 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1 } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1get_1size(JNIEnv* env, jclass cls, jint arg0) { +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decode(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4, jint arg5) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + short* ptr3 = arg3 == NULL ? NULL : (short*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); + jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); + ptr3 += position3; jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_encoder_get_size(arg0); + int rvalue = opus_decode((OpusDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3, arg4, arg5); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1125,19 +1144,21 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_ } return rarg; } -JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1create(JNIEnv* env, jclass cls, jint arg0, jint arg1, jint arg2, jobject arg3) { - int* ptr3 = arg3 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decode_1float(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4, jint arg5) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); + jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); + ptr1 += position1; + float* ptr3 = arg3 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); ptr3 += position3; - jobject rarg = NULL; - void* rptr; + jint rarg = 0; jthrowable exc = NULL; try { - rptr = opus_encoder_create(arg0, arg1, arg2, ptr3); - if (rptr != NULL) { - rarg = env->AllocObject(JavaCPP_getClass(env, 1)); - env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); - } + int rvalue = opus_decode_float((OpusDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3, arg4, arg5); + rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1147,15 +1168,13 @@ JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encod } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1init(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jint arg2, jint arg3) { +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1destroy(JNIEnv* env, jclass cls, jobject arg0) { char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; - jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_encoder_init((OpusEncoder*)ptr0, arg1, arg2, arg3); - rarg = (jint)rvalue; + opus_decoder_destroy((OpusDecoder*)ptr0); } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1163,44 +1182,33 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_ if (exc != NULL) { env->Throw(exc); } - return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encode(JNIEnv* env, jclass cls, jobject arg0, jshortArray arg1, jint arg2, jbyteArray arg3, jint arg4) { - char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1bandwidth(JNIEnv* env, jclass cls, jobject arg0) { + signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; - short* ptr1 = arg1 == NULL ? NULL : env->GetShortArrayElements(arg1, NULL); - signed char* ptr3 = arg3 == NULL ? NULL : env->GetByteArrayElements(arg3, NULL); jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_encode((OpusEncoder*)ptr0, (const short*)ptr1, arg2, (unsigned char*)ptr3, arg4); + int rvalue = opus_packet_get_bandwidth((const unsigned char*)ptr0); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); } - if (arg1 != NULL) env->ReleaseShortArrayElements(arg1, (jshort*)ptr1, 0); - if (arg3 != NULL) env->ReleaseByteArrayElements(arg3, (jbyte*)ptr3, 0); if (exc != NULL) { env->Throw(exc); } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decode(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4, jint arg5) { - char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1samples_1per_1frame(JNIEnv* env, jclass cls, jobject arg0, jint arg1) { + signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; - signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); - jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); - ptr1 += position1; - short* ptr3 = arg3 == NULL ? NULL : (short*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); - jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); - ptr3 += position3; jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_decode((OpusDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3, arg4, arg5); + int rvalue = opus_packet_get_samples_per_frame((const unsigned char*)ptr0, arg1); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1211,20 +1219,14 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decode(J } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decode_1float(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4, jint arg5) { - char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1nb_1channels(JNIEnv* env, jclass cls, jobject arg0) { + signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; - signed char* ptr1 = arg1 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); - jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); - ptr1 += position1; - float* ptr3 = arg3 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); - jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); - ptr3 += position3; jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_decode_float((OpusDecoder*)ptr0, (const unsigned char*)ptr1, arg2, ptr3, arg4, arg5); + int rvalue = opus_packet_get_nb_channels((const unsigned char*)ptr0); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1235,20 +1237,14 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decode_1 } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encode_1float(JNIEnv* env, jclass cls, jobject arg0, jobject arg1, jint arg2, jobject arg3, jint arg4) { - char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1nb_1frames(JNIEnv* env, jclass cls, jobject arg0, jint arg1) { + signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; - float* ptr1 = arg1 == NULL ? NULL : (float*)jlong_to_ptr(env->GetLongField(arg1, JavaCPP_addressFID)); - jint position1 = arg1 == NULL ? 0 : env->GetIntField(arg1, JavaCPP_positionFID); - ptr1 += position1; - signed char* ptr3 = arg3 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); - jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); - ptr3 += position3; jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_encode_float((OpusEncoder*)ptr0, (const float*)ptr1, arg2, (unsigned char*)ptr3, arg4); + int rvalue = opus_packet_get_nb_frames((const unsigned char*)ptr0, arg1); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1259,13 +1255,15 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encode_1 } return rarg; } -JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1destroy(JNIEnv* env, jclass cls, jobject arg0) { - char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1packet_1get_1nb_1samples(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jint arg2) { + signed char* ptr0 = arg0 == NULL ? NULL : (signed char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; + jint rarg = 0; jthrowable exc = NULL; try { - opus_encoder_destroy((OpusEncoder*)ptr0); + int rvalue = opus_packet_get_nb_samples((const unsigned char*)ptr0, arg1, arg2); + rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1273,18 +1271,13 @@ JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_ if (exc != NULL) { env->Throw(exc); } + return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1ctl(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jobject arg2) { - char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); - jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); - ptr0 += position0; - char* ptr2 = arg2 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); - jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); - ptr2 += position2; +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1get_1size(JNIEnv* env, jclass cls, jint arg0) { jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_encoder_ctl((OpusEncoder*)ptr0, arg1, ptr2); + int rvalue = opus_encoder_get_size(arg0); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); @@ -1295,12 +1288,19 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_ } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1get_1size(JNIEnv* env, jclass cls, jint arg0) { - jint rarg = 0; +JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1create(JNIEnv* env, jclass cls, jint arg0, jint arg1, jint arg2, jobject arg3) { + int* ptr3 = arg3 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg3, JavaCPP_addressFID)); + jint position3 = arg3 == NULL ? 0 : env->GetIntField(arg3, JavaCPP_positionFID); + ptr3 += position3; + jobject rarg = NULL; + void* rptr; jthrowable exc = NULL; try { - int rvalue = opus_decoder_get_size(arg0); - rarg = (jint)rvalue; + rptr = opus_encoder_create(arg0, arg1, arg2, ptr3); + if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1310,19 +1310,15 @@ JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_ } return rarg; } -JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1create(JNIEnv* env, jclass cls, jint arg0, jint arg1, jobject arg2) { - int* ptr2 = arg2 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg2, JavaCPP_addressFID)); - jint position2 = arg2 == NULL ? 0 : env->GetIntField(arg2, JavaCPP_positionFID); - ptr2 += position2; - jobject rarg = NULL; - void* rptr; +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encoder_1init(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jint arg2, jint arg3) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jint rarg = 0; jthrowable exc = NULL; try { - rptr = opus_decoder_create(arg0, arg1, ptr2); - if (rptr != NULL) { - rarg = env->AllocObject(JavaCPP_getClass(env, 1)); - env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); - } + int rvalue = opus_encoder_init((OpusEncoder*)ptr0, arg1, arg2, arg3); + rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); } @@ -1332,19 +1328,23 @@ JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decod } return rarg; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1decoder_1init(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jint arg2) { +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Opus_opus_1encode(JNIEnv* env, jclass cls, jobject arg0, jshortArray arg1, jint arg2, jbyteArray arg3, jint arg4) { char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); ptr0 += position0; + short* ptr1 = arg1 == NULL ? NULL : env->GetShortArrayElements(arg1, NULL); + signed char* ptr3 = arg3 == NULL ? NULL : env->GetByteArrayElements(arg3, NULL); jint rarg = 0; jthrowable exc = NULL; try { - int rvalue = opus_decoder_init((OpusDecoder*)ptr0, arg1, arg2); + int rvalue = opus_encode((OpusEncoder*)ptr0, (const short*)ptr1, arg2, (unsigned char*)ptr3, arg4); rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 14); } + if (arg1 != NULL) env->ReleaseShortArrayElements(arg1, (jshort*)ptr1, 0); + if (arg3 != NULL) env->ReleaseByteArrayElements(arg3, (jbyte*)ptr3, 0); if (exc != NULL) { env->Throw(exc); } diff --git a/src/main/jni/speex.cpp b/src/main/jni/speex.cpp index a42cc45..c8c4974 100644 --- a/src/main/jni/speex.cpp +++ b/src/main/jni/speex.cpp @@ -59,6 +59,7 @@ extern "C" { #include <speex/speex_types.h> #include <speex/speex_jitter.h> #include <speex/speex_preprocess.h> +#include <speex/speex_resampler.h> } static JavaVM* JavaCPP_vm = NULL; @@ -190,7 +191,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { { "sizeof" }, { "sizeof" }, { "sizeof" }, - { "sizeof", "timestamp", "data", "sequence", "span", "len" }, + { "sizeof", "len", "timestamp", "data", "sequence", "span" }, { } }; int offsets[16][6] = { { }, @@ -207,7 +208,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { { sizeof(bool) }, { sizeof(long) }, { sizeof(size_t) }, - { sizeof(::_JitterBufferPacket), offsetof(::_JitterBufferPacket,timestamp), offsetof(::_JitterBufferPacket,data), offsetof(::_JitterBufferPacket,sequence), offsetof(::_JitterBufferPacket,span), offsetof(::_JitterBufferPacket,len) }, + { sizeof(::_JitterBufferPacket), offsetof(::_JitterBufferPacket,len), offsetof(::_JitterBufferPacket,timestamp), offsetof(::_JitterBufferPacket,data), offsetof(::_JitterBufferPacket,sequence), offsetof(::_JitterBufferPacket,span) }, { } }; int memberOffsetSizes[16] = { 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 0 }; jmethodID putMemberOffsetMID = env->GetStaticMethodID(JavaCPP_getClass(env, 0), "putMemberOffset", "(Ljava/lang/String;Ljava/lang/String;I)V"); @@ -280,6 +281,14 @@ JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_00024NativeDeallocato +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0); + void* rptr = ptr0; + jint rcapacity = 1; + env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(rptr)); + env->SetIntField(obj, JavaCPP_limitFID, rcapacity); + env->SetIntField(obj, JavaCPP_capacityFID, rcapacity); +} JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_asDirectBuffer(JNIEnv* env, jobject obj) { char* ptr = (char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -381,28 +390,8 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_Pointer_memset(JNIEnv* env } return rarg; } -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_Pointer_allocate(JNIEnv* env, jobject obj, jobject arg0) { - char* ptr0 = arg0 == NULL ? NULL : (char*)env->GetDirectBufferAddress(arg0); - void* rptr = ptr0; - jint rcapacity = 1; - env->SetLongField(obj, JavaCPP_addressFID, ptr_to_jlong(rptr)); - env->SetIntField(obj, JavaCPP_limitFID, rcapacity); - env->SetIntField(obj, JavaCPP_capacityFID, rcapacity); -} -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 3))) { - return; - } - signed char* rptr = new (std::nothrow) signed char[arg0]; - jint rcapacity = arg0; - jvalue args[3]; - args[0].j = ptr_to_jlong(rptr); - args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray); - env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); -} -JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -410,12 +399,13 @@ JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* e } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - jbyte rarg = 0; - signed char rvalue = ptr[arg0]; - rarg = (jbyte)rvalue; + signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); + jobject rarg = obj; + memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNIEnv* env, jobject obj, jbyteArray arg0, jint arg1, jint arg2) { +JNIEXPORT jbyte JNICALL Java_com_googlecode_javacpp_BytePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { signed char* ptr = (signed char*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -423,10 +413,9 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_get___3BII(JNI } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - signed char* ptr0 = arg0 == NULL ? NULL : (jbyte*)env->GetPrimitiveArrayCritical(arg0, NULL); - jobject rarg = obj; - memcpy(ptr0 + arg1, ptr, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + jbyte rarg = 0; + signed char rvalue = ptr[arg0]; + rarg = (jbyte)rvalue; return rarg; } JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put__IB(JNIEnv* env, jobject obj, jint arg0, jbyte arg1) { @@ -455,19 +444,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BytePointer_put___3BII(JNI if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 4))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BytePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 3))) { return; } - short* rptr = new (std::nothrow) short[arg0]; + signed char* rptr = new (std::nothrow) signed char[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BytePointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jshort JNICALL Java_com_googlecode_javacpp_ShortPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -495,7 +484,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_get___3SII(JN if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEnv* env, jobject obj, jint arg0, jshort arg1) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -503,13 +492,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JN } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEnv* env, jobject obj, jint arg0, jshort arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put___3SII(JNIEnv* env, jobject obj, jshortArray arg0, jint arg1, jint arg2) { short* ptr = (short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -517,23 +504,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_ShortPointer_put__IS(JNIEn } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + short* ptr0 = arg0 == NULL ? NULL : (jshort*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 5))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_ShortPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 4))) { return; } - int* rptr = new (std::nothrow) int[arg0]; + short* rptr = new (std::nothrow) short[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_ShortPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jint JNICALL Java_com_googlecode_javacpp_IntPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { int* ptr = (int*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -587,19 +576,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_IntPointer_put__II(JNIEnv* ptr[arg0] = arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 6))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_IntPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 5))) { return; } - jlong* rptr = new (std::nothrow) jlong[arg0]; + int* rptr = new (std::nothrow) int[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_IntPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_LongPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -627,7 +616,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_get___3JII(JNI if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -635,13 +624,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNI } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv* env, jobject obj, jint arg0, jlong arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put___3JII(JNIEnv* env, jobject obj, jlongArray arg0, jint arg1, jint arg2) { jlong* ptr = (jlong*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -649,23 +636,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_LongPointer_put__IJ(JNIEnv } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + jlong* ptr0 = arg0 == NULL ? NULL : (jlong*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 7))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_LongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 6))) { return; } - float* rptr = new (std::nothrow) float[arg0]; + jlong* rptr = new (std::nothrow) jlong[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_LongPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jfloat JNICALL Java_com_googlecode_javacpp_FloatPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -693,7 +682,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_get___3FII(JN if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEnv* env, jobject obj, jint arg0, jfloat arg1) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -701,13 +690,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JN } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEnv* env, jobject obj, jint arg0, jfloat arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put___3FII(JNIEnv* env, jobject obj, jfloatArray arg0, jint arg1, jint arg2) { float* ptr = (float*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -715,23 +702,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_FloatPointer_put__IF(JNIEn } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + float* ptr0 = arg0 == NULL ? NULL : (jfloat*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 8))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_FloatPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 7))) { return; } - double* rptr = new (std::nothrow) double[arg0]; + float* rptr = new (std::nothrow) float[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_FloatPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jdouble JNICALL Java_com_googlecode_javacpp_DoublePointer_get__I(JNIEnv* env, jobject obj, jint arg0) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -759,7 +748,7 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_get___3DII(J if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIEnv* env, jobject obj, jint arg0, jdouble arg1) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -767,13 +756,11 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(J } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; - double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); - if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); + ptr[arg0] = arg1; return rarg; } -JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIEnv* env, jobject obj, jint arg0, jdouble arg1) { +JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put___3DII(JNIEnv* env, jobject obj, jdoubleArray arg0, jint arg1, jint arg2) { double* ptr = (double*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); @@ -781,23 +768,25 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_DoublePointer_put__ID(JNIE } jint position = env->GetIntField(obj, JavaCPP_positionFID); ptr += position; + double* ptr0 = arg0 == NULL ? NULL : (jdouble*)env->GetPrimitiveArrayCritical(arg0, NULL); jobject rarg = obj; - ptr[arg0] = arg1; + memcpy(ptr, ptr0 + arg1, arg2 * sizeof(*ptr0)); + if (arg0 != NULL) env->ReleasePrimitiveArrayCritical(arg0, ptr0, 0); return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 9))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_DoublePointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 8))) { return; } - unsigned short* rptr = new (std::nothrow) unsigned short[arg0]; + double* rptr = new (std::nothrow) double[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_DoublePointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jchar JNICALL Java_com_googlecode_javacpp_CharPointer_get__I(JNIEnv* env, jobject obj, jint arg0) { unsigned short* ptr = (unsigned short*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -851,19 +840,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CharPointer_put__IC(JNIEnv ptr[arg0] = arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 10))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CharPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 9))) { return; } - void** rptr = new (std::nothrow) void*[arg0]; + unsigned short* rptr = new (std::nothrow) unsigned short[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CharPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_get(JNIEnv* env, jobject obj, jint arg0) { void** ptr = (void**)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -896,19 +885,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_PointerPointer_put(JNIEnv* ptr[arg0] = ptr1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 11))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_PointerPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 10))) { return; } - bool* rptr = new (std::nothrow) bool[arg0]; + void** rptr = new (std::nothrow) void*[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_PointerPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jboolean JNICALL Java_com_googlecode_javacpp_BoolPointer_get(JNIEnv* env, jobject obj, jint arg0) { bool* ptr = (bool*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -934,19 +923,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_BoolPointer_put(JNIEnv* en ptr[arg0] = (bool)arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 12))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_BoolPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 11))) { return; } - long* rptr = new (std::nothrow) long[arg0]; + bool* rptr = new (std::nothrow) bool[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_BoolPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_CLongPointer_get(JNIEnv* env, jobject obj, jint arg0) { long* ptr = (long*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -972,19 +961,19 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_CLongPointer_put(JNIEnv* e ptr[arg0] = (long)arg1; return rarg; } - -JNIEXPORT void JNICALL Java_com_googlecode_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 13))) { +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_CLongPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 12))) { return; } - size_t* rptr = new (std::nothrow) size_t[arg0]; + long* rptr = new (std::nothrow) long[arg0]; jint rcapacity = arg0; jvalue args[3]; args[0].j = ptr_to_jlong(rptr); args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray); + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_CLongPointer_deallocateArray); env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); } + JNIEXPORT jlong JNICALL Java_com_googlecode_javacpp_SizeTPointer_get(JNIEnv* env, jobject obj, jint arg0) { size_t* ptr = (size_t*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -1010,8 +999,73 @@ JNIEXPORT jobject JNICALL Java_com_googlecode_javacpp_SizeTPointer_put(JNIEnv* e ptr[arg0] = (size_t)arg1; return rarg; } +JNIEXPORT void JNICALL Java_com_googlecode_javacpp_SizeTPointer_allocateArray(JNIEnv* env, jobject obj, jint arg0) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 13))) { + return; + } + size_t* rptr = new (std::nothrow) size_t[arg0]; + jint rcapacity = arg0; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_googlecode_javacpp_SizeTPointer_deallocateArray); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); +} +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_getLength(JNIEnv* env, jobject obj) { + ::_JitterBufferPacket* ptr = (::_JitterBufferPacket*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return 0; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + jint rarg = 0; + int rvalue = ptr->len; + rarg = (jint)rvalue; + return rarg; +} +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_setLength(JNIEnv* env, jobject obj, jint arg0) { + ::_JitterBufferPacket* ptr = (::_JitterBufferPacket*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + ptr->len = arg0; +} +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_allocate(JNIEnv* env, jobject obj) { + if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 14))) { + return; + } + jthrowable exc = NULL; + try { + ::_JitterBufferPacket* rptr = new ::_JitterBufferPacket(); + jint rcapacity = 1; + jvalue args[3]; + args[0].j = ptr_to_jlong(rptr); + args[1].i = rcapacity; + args[2].j = ptr_to_jlong(&JavaCPP_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_deallocate); + env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); + } catch (...) { + exc = JavaCPP_handleException(env, 15); + } + if (exc != NULL) { + env->Throw(exc); + } +} +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_setTimestamp(JNIEnv* env, jobject obj, jint arg0) { + ::_JitterBufferPacket* ptr = (::_JitterBufferPacket*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); + if (ptr == NULL) { + env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); + return; + } + jint position = env->GetIntField(obj, JavaCPP_positionFID); + ptr += position; + ptr->timestamp = arg0; +} JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_getTimestamp(JNIEnv* env, jobject obj) { ::_JitterBufferPacket* ptr = (::_JitterBufferPacket*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); if (ptr == NULL) { @@ -1101,61 +1155,70 @@ JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBu ptr += position; ptr->sequence = arg0; } -JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_getLength(JNIEnv* env, jobject obj) { - ::_JitterBufferPacket* ptr = (::_JitterBufferPacket*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); - if (ptr == NULL) { - env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); - return 0; + +JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_speex_1resampler_1init(JNIEnv* env, jclass cls, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4) { + int* ptr4 = arg4 == NULL ? NULL : (int*)jlong_to_ptr(env->GetLongField(arg4, JavaCPP_addressFID)); + jint position4 = arg4 == NULL ? 0 : env->GetIntField(arg4, JavaCPP_positionFID); + ptr4 += position4; + jobject rarg = NULL; + void* rptr; + jthrowable exc = NULL; + try { + rptr = speex_resampler_init(arg0, arg1, arg2, arg3, ptr4); + if (rptr != NULL) { + rarg = env->AllocObject(JavaCPP_getClass(env, 1)); + env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr)); + } + } catch (...) { + exc = JavaCPP_handleException(env, 15); } - jint position = env->GetIntField(obj, JavaCPP_positionFID); - ptr += position; - jint rarg = 0; - int rvalue = ptr->len; - rarg = (jint)rvalue; - return rarg; -} -JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_setLength(JNIEnv* env, jobject obj, jint arg0) { - ::_JitterBufferPacket* ptr = (::_JitterBufferPacket*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); - if (ptr == NULL) { - env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); - return; + + if (exc != NULL) { + env->Throw(exc); } - jint position = env->GetIntField(obj, JavaCPP_positionFID); - ptr += position; - ptr->len = arg0; + return rarg; } -JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_allocate(JNIEnv* env, jobject obj) { - if (!env->IsSameObject(env->GetObjectClass(obj), JavaCPP_getClass(env, 14))) { - return; - } +JNIEXPORT jint JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_speex_1resampler_1process_1int(JNIEnv* env, jclass cls, jobject arg0, jint arg1, jshortArray arg2, jintArray arg3, jshortArray arg4, jintArray arg5) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + short* ptr2 = arg2 == NULL ? NULL : env->GetShortArrayElements(arg2, NULL); + int* ptr3 = arg3 == NULL ? NULL : env->GetIntArrayElements(arg3, NULL); + short* ptr4 = arg4 == NULL ? NULL : env->GetShortArrayElements(arg4, NULL); + int* ptr5 = arg5 == NULL ? NULL : env->GetIntArrayElements(arg5, NULL); + jint rarg = 0; jthrowable exc = NULL; try { - ::_JitterBufferPacket* rptr = new ::_JitterBufferPacket(); - jint rcapacity = 1; - jvalue args[3]; - args[0].j = ptr_to_jlong(rptr); - args[1].i = rcapacity; - args[2].j = ptr_to_jlong(&JavaCPP_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_deallocate); - env->CallNonvirtualVoidMethodA(obj, JavaCPP_getClass(env, 1), JavaCPP_initMID, args); + int rvalue = speex_resampler_process_int((SpeexResamplerState*)ptr0, arg1, (short*)ptr2, (unsigned int*)ptr3, (short*)ptr4, (unsigned int*)ptr5); + rarg = (jint)rvalue; } catch (...) { exc = JavaCPP_handleException(env, 15); } + if (arg2 != NULL) env->ReleaseShortArrayElements(arg2, (jshort*)ptr2, 0); + if (arg3 != NULL) env->ReleaseIntArrayElements(arg3, (jint*)ptr3, 0); + if (arg4 != NULL) env->ReleaseShortArrayElements(arg4, (jshort*)ptr4, 0); + if (arg5 != NULL) env->ReleaseIntArrayElements(arg5, (jint*)ptr5, 0); if (exc != NULL) { env->Throw(exc); } + return rarg; } -JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_00024JitterBufferPacket_setTimestamp(JNIEnv* env, jobject obj, jint arg0) { - ::_JitterBufferPacket* ptr = (::_JitterBufferPacket*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID)); - if (ptr == NULL) { - env->ThrowNew(JavaCPP_getClass(env, 2), "This pointer address is NULL."); - return; +JNIEXPORT void JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_speex_1resampler_1destroy(JNIEnv* env, jclass cls, jobject arg0) { + char* ptr0 = arg0 == NULL ? NULL : (char*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID)); + jint position0 = arg0 == NULL ? 0 : env->GetIntField(arg0, JavaCPP_positionFID); + ptr0 += position0; + jthrowable exc = NULL; + try { + speex_resampler_destroy((SpeexResamplerState*)ptr0); + } catch (...) { + exc = JavaCPP_handleException(env, 15); } - jint position = env->GetIntField(obj, JavaCPP_positionFID); - ptr += position; - ptr->timestamp = arg0; -} + if (exc != NULL) { + env->Throw(exc); + } +} JNIEXPORT jobject JNICALL Java_com_morlunk_jumble_audio_javacpp_Speex_jitter_1buffer_1init(JNIEnv* env, jclass cls, jint arg0) { jobject rarg = NULL; void* rptr; diff --git a/src/main/libs/armeabi/libcelt11.so b/src/main/libs/armeabi/libcelt11.so Binary files differindex 3c09d0c..ddfc482 100755 --- a/src/main/libs/armeabi/libcelt11.so +++ b/src/main/libs/armeabi/libcelt11.so diff --git a/src/main/libs/armeabi/libcelt7.so b/src/main/libs/armeabi/libcelt7.so Binary files differindex e50b738..f2b6d11 100755 --- a/src/main/libs/armeabi/libcelt7.so +++ b/src/main/libs/armeabi/libcelt7.so diff --git a/src/main/libs/armeabi/libopus.so b/src/main/libs/armeabi/libopus.so Binary files differindex ae446ca..5694d09 100755 --- a/src/main/libs/armeabi/libopus.so +++ b/src/main/libs/armeabi/libopus.so diff --git a/src/main/libs/armeabi/libspeex.so b/src/main/libs/armeabi/libspeex.so Binary files differindex ffd6531..5d3f7d2 100755 --- a/src/main/libs/armeabi/libspeex.so +++ b/src/main/libs/armeabi/libspeex.so |