Just FYI, I got the same code to work using arrays, which is
surprisingly fast still but inconsistent. I'm seeing about a 3ms
processing time using arrays but every 10 or so times it jumps to
10-15ms. Not sure what's causing that.
Here's my working arrays version:
void Java_com_myproject_MyClass_interpolate2( JNIEnv* env,
jobject thiz, jintArray verts1, jintArray verts2,
jintArray out, jint mix, jint count) {
int i;
jint vArray1[count];
jint vArray2[count];
jint outBuf[count];
(*env)->GetIntArrayRegion(env, verts1, 0, count, vArray1);
(*env)->GetIntArrayRegion(env, verts2, 0, count, vArray2);
(*env)->GetIntArrayRegion(env, out, 0, count, outBuf);
for (i = 0; i < count; i++) {
outBuf[i] = vArray1[i] + ((jint) (((jlong) (vArray2[i] - vArray1
[i]) * (jlong) mix) >> 16));
}
(*env)->SetIntArrayRegion(env, out, 0, count, outBuf);
}
So now I'm feeling confident that if I can get the direct int buffers
to work, I'll be golden on this and have it running at 3ms or less
consistently for my largest data set. This makes me love that we have
the NDK right now.
Can anyone take a stab at what I'm doing wrong with the IntBuffer
method?
Thanks!