I want to use function written in C in an Android app. The function is taken from here. I've learned some basics of android NDK, I can manage to use the function in my Java source, but the application freezes when I call it, than I have to wait until android offers me to kill the app.
The JNI signature is this:
JNIEXPORT void JNICALL Java_pda_lupa_callbacks_MySurfaceCallback_NativeYuv2rgb
(JNIEnv *env, jclass clazz,
jbyteArray imageIn, jint widthIn, jint heightIn,
jobject imageOut, jint widthOut, jint heightOut) {
jbyte *cImageIn = (*env)->GetByteArrayElements(env, imageIn, NULL);
jbyte *cImageOut = (jbyte*)(*env)->GetDirectBufferAddress(env, imageOut);
toRGB565((unsigned short*)cImageIn, widthIn, heightIn, (unsigned int*)cImageOut, widthOut, heightOut);
(*env)->ReleaseByteArrayElements(env, imageIn, cImageIn, JNI_ABORT);
}
Then I load it in Java like this:
static {
System.loadLibrary("rgb");
}
public native void NativeYuv2rgb(byte[] imageIn, int widthIn, int heightIn,
java.nio.Buffer imageOut, int widthOut, int heightOut);
And when I call it, app freezes (I don't get any error):
NativeYuv2rgb(this.cameraFrame, this.prevX, this.prevY,
this.rgb, this.prevX, this.prevY);
I guess I might use wrong variable types for the imageIn and imageOut, but I don't know...
Thanks for your help!
edit: This is output from GDB:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 4731]
0x8083f0b0 in ?? ()