-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hello-jni: add README and packaging metadata #2
Conversation
@@ -0,0 +1,59 @@ | |||
Hello JNI | |||
========= | |||
This sample show how to call Native C++ code from a Android Java activity using JNI. Note this require a preview build of Android Studio and the experimental version Android Gradle plugin, see the [Pre-requisites](#pre-requisites) and [Getting Started](#getting-started) instructions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: shows how to call Native C++ code from Android Java Activity using JNI. Note this requires
^ ^ ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
hello-jni: add README and packaging metadata
The U and V planes are swapped [here](https://github.com/android/ndk-samples/blob/main/camera/basic/src/main/cpp/image_reader.cpp#L257): AImage_getPlaneData(image, 0, &yPixel, &yLen); AImage_getPlaneData(image, 1, &vPixel, &vLen); AImage_getPlaneData(image, 2, &uPixel, &uLen); According to [the docs](https://developer.android.com/ndk/reference/group/media#group___media_1gga9c3dace30485a0f28163a882a5d65a19aea9797f9b5db5d26a2055a43d8491890): > The order of planes is guaranteed such that plane #0 is always Y, plane #1 is always U (Cb), and plane #2 is always V (Cr). This works out because [the function YUV2RGB](https://github.com/android/ndk-samples/blob/main/camera/basic/src/main/cpp/image_reader.cpp#L193) actually encodes BGRA, not RGBA: return 0xff000000 | (nR << 16) | (nG << 8) | nB; (Swapping U and V is equivalent to swapping R and B.)
/cc @hak @ggfan