in
public void onPreviewFrame(byte[] data, Camera camera)
we get the data in YUV format. Now for converting to RGB I have used a converter in NDK. But it is still not fast enough.
So I found this:
http://www.roman10.net/effective-color-conversion-yuv-rgb-in-android-in-assembly/
which has this NDK method:
https://github.com/roman10/roman10-android-tutorial/blob/master/colorConversion/jni/test.c
but I do not know how to change it so it would accept the YUV byte array ‘data’ and return me an RGB int array?
You must write a JNI function similar to
naGetConvertedFrame(). The new function will have the following declaration:The name of the function should reflect the name of the Java class that will declare this function as
nativemethod (see RenderView.java as example). In Roman’s example the shared library is loaded from another class, in Main.java – but thisloadLibrary()could be easily trasnferred into RenderView.java file.Your function will be similar to the original example, only it will not read a file, but rather use GetByteArrayElements() to acquire y, u, and v pointers for the convertor.