diff options
author | junjiez <junjiez@codeaurora.org> | 2018-01-03 15:50:19 +0800 |
---|---|---|
committer | junjiez <junjiez@codeaurora.org> | 2018-01-03 17:08:29 +0800 |
commit | de13f75685ff6aeba7b608c891d66e852c69d4a1 (patch) | |
tree | ded3c18b7a4259c552b89b39eeac21df10884398 /src/com/android/camera/imageprocessor/filter | |
parent | 728682a5ef9e0f53f8d21501de1bde104269f923 (diff) | |
download | android_packages_apps_Snap-de13f75685ff6aeba7b608c891d66e852c69d4a1.tar.gz android_packages_apps_Snap-de13f75685ff6aeba7b608c891d66e852c69d4a1.tar.bz2 android_packages_apps_Snap-de13f75685ff6aeba7b608c891d66e852c69d4a1.zip |
SnapdragonCamera:wrong Ubifocus image
When one the images failed to be registered
in Ubifocus, the result image maybe wrong.
Return original image when register failed.
CRs-Fixed: 2164702
Change-Id: Iff2726e01ba647041618247d9b930853ffca125e
Diffstat (limited to 'src/com/android/camera/imageprocessor/filter')
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/imageprocessor/filter/UbifocusFilter.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java b/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java index d29f29f80..25c167034 100644..100755 --- a/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java +++ b/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java @@ -76,10 +76,12 @@ public class UbifocusFilter implements ImageFilter { private Object mClosingLock = new Object(); private PostProcessor mPostProcessor; private ImageFilter.ResultImage mUbifocusResultImage; + private ImageFilter.ResultImage mOriginImage; final String[] NAMES = {"00.jpg", "01.jpg", "02.jpg", "03.jpg", "04.jpg", "DepthMapImage.y", "AllFocusImage.jpg"}; private int mSavedCount = 0; + private boolean mRegistSuccess = true; private static void Log(String msg) { if (DEBUG) { @@ -136,11 +138,13 @@ public class UbifocusFilter implements ImageFilter { mModule.setRefocusLastTaken(false); mOrientation = CameraUtil.getJpegRotation(mModule.getMainCameraId(), mModule.getDisplayOrientation()); mSavedCount = 0; + mRegistSuccess = true; } int yActualSize = bY.remaining(); int vuActualSize = bVU.remaining(); if(nativeAddImage(bY, bVU, yActualSize, vuActualSize, imageNum) < 0) { Log.e(TAG, "Fail to add image"); + mRegistSuccess = false; } new Thread() { public void run() { @@ -149,6 +153,8 @@ public class UbifocusFilter implements ImageFilter { return; } byte[] bytes = getYUVBytes(bY, bVU, imageNum); + if (imageNum == 0) + mOriginImage = mUbifocusResultImage; saveToPrivateFile(imageNum, bytes); mSavedCount++; } @@ -162,7 +168,7 @@ public class UbifocusFilter implements ImageFilter { int[] roi = new int[4]; int[] depthMapSize = new int[2]; int status = nativeProcessImage(mOutBuf.array(), roi, depthMapSize); - if(status < 0) { //In failure case, library will return the first image as it is. + if(status < 0 || !mRegistSuccess) { //In failure case, library will return the first image as it is. Log.w(TAG, "Fail to process the "+getStringName()); } else { byte[] depthMapBuf = new byte[depthMapSize[0] * depthMapSize[1] + META_BYTES_SIZE]; @@ -177,7 +183,12 @@ public class UbifocusFilter implements ImageFilter { } catch (Exception e) { } } - ResultImage result = new ResultImage(mOutBuf, new Rect(roi[0], roi[1], roi[0]+roi[2], roi[1] + roi[3]), mWidth, mHeight, mStrideY); + ResultImage result; + if (!mRegistSuccess) { + result = mOriginImage; + } else { + result = new ResultImage(mOutBuf, new Rect(roi[0], roi[1], roi[0]+roi[2], roi[1] + roi[3]), mWidth, mHeight, mStrideY); + } Log("processImage done"); return result; } |