From 7d80bdb6ca1db08ecd29389ac7f263ecff6c5b70 Mon Sep 17 00:00:00 2001 From: Jack Yoo Date: Wed, 13 Jul 2016 14:49:22 -0700 Subject: SnapdragonCamera: Selfie Mirror mode Selfie mirror menu for front camera1. Change-Id: I2e6845c9e25481106f51772b5d3dfd0a971a2be7 CRs-Fixed: 1050663 --- jni/image_util_jni.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'jni') diff --git a/jni/image_util_jni.cpp b/jni/image_util_jni.cpp index 2297f9164..a4779b3d7 100644 --- a/jni/image_util_jni.cpp +++ b/jni/image_util_jni.cpp @@ -44,6 +44,8 @@ JNIEXPORT jint JNICALL Java_com_android_camera_imageprocessor_FrameProcessor_nat jint imageWidth, jint imageHeight, jint degree, jobjectArray outBuf); JNIEXPORT jint JNICALL Java_com_android_camera_imageprocessor_FrameProcessor_nativeNV21toRgb( JNIEnv *env, jobject thiz, jobjectArray yvuBuf, jobjectArray rgbBuf, jint width, jint height); +JNIEXPORT jint JNICALL Java_com_android_camera_imageprocessor_PostProcessor_nativeFlipVerticalNV21( + JNIEnv* env, jobject thiz, jbyteArray yvuBytes, jint width, jint height); #ifdef __cplusplus } #endif @@ -150,4 +152,32 @@ jint JNICALL Java_com_android_camera_imageprocessor_FrameProcessor_nativeNV21toR } } return 0; +} + +jint JNICALL Java_com_android_camera_imageprocessor_PostProcessor_nativeFlipVerticalNV21( + JNIEnv* env, jobject thiz, jbyteArray yvuBytes, jint width, jint height) +{ + jbyte* imageDataNV21Array = env->GetByteArrayElements(yvuBytes, NULL); + uint8_t *buf = (uint8_t *)imageDataNV21Array; + int ysize = width * height; + uint8_t temp1, temp2; + for(int x=0; x < width; x++) { + for(int y=0; y < height/2; y++) { + temp1 = buf[y*width + x]; + buf[y*width + x] = buf[(height-1-y)*width + x]; + buf[(height-1-y)*width + x] = temp1; + } + } + for(int x=0; x < width; x+=2) { + for(int y=0; y < height/4; y++) { + temp1 = buf[ysize + y*width + x]; + temp2 = buf[ysize + y*width + x + 1]; + buf[ysize + y*width + x] = buf[ysize + (height/2-1-y)*width + x]; + buf[ysize + y*width + x + 1] = buf[ysize + (height/2-1-y)*width + x + 1]; + buf[ysize + (height/2-1-y)*width + x] = temp1; + buf[ysize + (height/2-1-y)*width + x + 1] = temp2; + } + } + env->ReleaseByteArrayElements(yvuBytes, imageDataNV21Array, JNI_ABORT); + return 0; } \ No newline at end of file -- cgit v1.2.3