diff options
author | Weijie Wang <weijiew@codeaurora.org> | 2017-09-02 12:11:20 +0800 |
---|---|---|
committer | Weijie Wang <weijiew@codeaurora.org> | 2017-09-02 12:11:20 +0800 |
commit | f884ef3a01cefaf71f6ff0ed059c8d356b40c17c (patch) | |
tree | b4b545a0cd632402dddc406247fcd7836b408b84 /src | |
parent | 2e0ed791732a27bb4d951bfbdaba3ddcda4e6b2c (diff) | |
download | android_packages_apps_Snap-f884ef3a01cefaf71f6ff0ed059c8d356b40c17c.tar.gz android_packages_apps_Snap-f884ef3a01cefaf71f6ff0ed059c8d356b40c17c.tar.bz2 android_packages_apps_Snap-f884ef3a01cefaf71f6ff0ed059c8d356b40c17c.zip |
Revert "SnapdragonCamera: Sync LA.UM.6.4 to LA.UM.6.3"
This reverts commit b5533d51a7c97138235d29b35cec876d107aeadd.
Change-Id: I8063422680802e25d03a374be91e884a86ad55e9
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/CameraActivity.java | 9 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 9 | ||||
-rw-r--r-- | src/com/android/camera/CaptureModule.java | 561 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/CaptureUI.java | 24 | ||||
-rw-r--r-- | src/com/android/camera/MediaSaveService.java | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/SettingsManager.java | 7 | ||||
-rw-r--r-- | src/com/android/camera/imageprocessor/FrameProcessor.java | 12 | ||||
-rw-r--r-- | src/com/android/camera/imageprocessor/PostProcessor.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/imageprocessor/ZSLQueue.java | 6 | ||||
-rw-r--r-- | src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java | 60 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/ui/Camera2FaceView.java | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/ui/FaceView.java | 7 | ||||
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/util/PersistUtil.java | 204 |
14 files changed, 401 insertions, 523 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index f679e26c3..ea4bc03ba 100644..100755 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -639,8 +639,14 @@ public class CameraActivity extends Activity View decorView = getWindow().getDecorView(); int currentSystemUIVisibility = decorView.getSystemUiVisibility(); + boolean hidePreview = SystemProperties.getBoolean("camera.ui.no_navigation_bar", false); int systemUIVisibility = DEFAULT_SYSTEM_UI_VISIBILITY; int systemUINotVisible = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN; + if (hidePreview) { + systemUIVisibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + systemUINotVisible |= (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } int newSystemUIVisibility = systemUIVisibility | (visible ? View.SYSTEM_UI_FLAG_VISIBLE : systemUINotVisible); @@ -1645,8 +1651,7 @@ public class CameraActivity extends Activity SETTING_LIST_WIDTH_1 = lower / 2 + offset; SETTING_LIST_WIDTH_2 = lower / 2 - offset; registerSDcardMountedReceiver(); - - mAutoTestEnabled = PersistUtil.isAutoTestEnabled(); + mAutoTestEnabled = SystemProperties.getBoolean("camera.ui.auto_test", false); if (mAutoTestEnabled) { registerAutoTestReceiver(); diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 541c65704..e0141ed11 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -38,7 +38,6 @@ import android.util.Log; import com.android.camera.util.ApiHelper; import com.android.camera.util.CameraUtil; import com.android.camera.util.GcamHelper; -import com.android.camera.util.PersistUtil; import org.codeaurora.snapcam.R; import org.codeaurora.snapcam.wrapper.CamcorderProfileWrapper; import org.codeaurora.snapcam.wrapper.ParametersWrapper; @@ -339,10 +338,6 @@ public class CameraSettings { VIDEO_ENCODER_BITRATE.put("1280x720:240", 72000000); VIDEO_ENCODER_BITRATE.put("720:480:120", 5200000); - //resolution, fps and encoder type - VIDEO_ENCODER_BITRATE.put("3840x2160:60:" + MediaRecorder.VideoEncoder.H264, 67200000); - VIDEO_ENCODER_BITRATE.put("3840x2160:60:" + MediaRecorder.VideoEncoder.HEVC, 50400000); - } // Following maps help find a corresponding time-lapse or high-speed quality @@ -982,8 +977,6 @@ public class CameraSettings { supportedAdvancedFeatures)) { removePreference(group, chromaFlash.getKey()); } - //remove chromaFlash - removePreference(group, chromaFlash.getKey()); } if (sceneMode != null) { @@ -1044,7 +1037,7 @@ public class CameraSettings { removePreference(group, cameraHdrPlus.getKey()); } - if (PersistUtil.isSaveInSdEnabled()) { + if (SystemProperties.getBoolean("persist.env.camera.saveinsd", false)) { final String CAMERA_SAVEPATH_SDCARD = "1"; final int CAMERA_SAVEPATH_SDCARD_IDX = 1; final int CAMERA_SAVEPATH_PHONE_IDX = 0; diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 5b029df86..46a822e67 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -89,6 +89,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.util.AttributeSet; import android.graphics.Bitmap; +import android.graphics.YuvImage; import com.android.camera.exif.ExifInterface; import com.android.camera.imageprocessor.filter.BlurbusterFilter; @@ -1027,6 +1028,7 @@ public class CaptureModule implements CameraModule, PhotoController, if(id == getMainCameraId()) { mCurrentSession = cameraCaptureSession; } + initializePreviewConfiguration(id); setDisplayOrientation(); updateFaceDetection(); @@ -1045,18 +1047,17 @@ public class CaptureModule implements CameraModule, PhotoController, mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id] .build(), mCaptureCallback, mCameraHandler); } - if (isClearSightOn()) { ClearSightImageProcessor.getInstance().onCaptureSessionConfigured(id == BAYER_ID, cameraCaptureSession); } else if (mChosenImageFormat == ImageFormat.PRIVATE && id == getMainCameraId()) { mPostProcessor.onSessionConfigured(mCameraDevice[id], mCaptureSession[id]); } - } catch (CameraAccessException e) { e.printStackTrace(); } catch(IllegalStateException e) { e.printStackTrace(); } + } @Override @@ -1270,11 +1271,12 @@ public class CaptureModule implements CameraModule, PhotoController, mJpegImageData = data; } - public void showCapturedReview(final byte[] jpegData, final int orientation) { + public void showCapturedReview(final byte[] jpegData, final int orientation, + final boolean mirror) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { - mUI.showCapturedImageForReview(jpegData, orientation); + mUI.showCapturedImageForReview(jpegData, orientation, mirror); } }); } @@ -1307,7 +1309,11 @@ public class CaptureModule implements CameraModule, PhotoController, if (takeZSLPicture(BAYER_ID)) { return; } - lockFocus(BAYER_ID); +/* take picture directly for now*/ + captureStillPicture(BAYER_ID); + mState[BAYER_ID] = STATE_PICTURE_TAKEN; + +//todo lockFocus(BAYER_ID); break; case MONO_MODE: lockFocus(MONO_ID); @@ -1317,7 +1323,11 @@ public class CaptureModule implements CameraModule, PhotoController, if (takeZSLPicture(FRONT_ID)) { return; } - lockFocus(FRONT_ID); +/* take picture directly for now*/ + captureStillPicture(FRONT_ID); + mState[FRONT_ID] = STATE_PICTURE_TAKEN; + +//todo lockFocus(FRONT_ID); } } } @@ -1470,175 +1480,173 @@ public class CaptureModule implements CameraModule, PhotoController, Log.d(TAG, "captureStillPicture " + id); mJpegImageData = null; mIsRefocus = false; + CameraCaptureSession.CaptureCallback captureCallback = new CameraCaptureSession.CaptureCallback() { + + @Override + public void onCaptureCompleted(CameraCaptureSession session, + CaptureRequest request, + TotalCaptureResult result) { + Log.d(TAG, "captureStillPicture onCaptureCompleted: " + id); + } + + @Override + public void onCaptureFailed(CameraCaptureSession session, + CaptureRequest request, + CaptureFailure result) { + Log.d(TAG, "captureStillPicture onCaptureFailed: " + id); + } + + @Override + public void onCaptureSequenceCompleted(CameraCaptureSession session, int + sequenceId, long frameNumber) { + Log.d(TAG, "captureStillPicture onCaptureSequenceCompleted: " + id); + unlockFocus(id); + } + }; try { if (null == mActivity || null == mCameraDevice[id]) { warningToast("Camera is not ready yet to take a picture."); return; } - CaptureRequest.Builder captureBuilder = - mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE); + final boolean csEnabled = isClearSightOn(); + CaptureRequest.Builder captureBuilder; + if(csEnabled) { + captureBuilder = ClearSightImageProcessor.getInstance().createCaptureRequest(mCameraDevice[id]); + } else { + captureBuilder = mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE); + } if(mSettingsManager.isZSLInHALEnabled()) { + Log.d(TAG, "CONTROL_ENABLE_ZSL is enabled."); captureBuilder.set(CaptureRequest.CONTROL_ENABLE_ZSL, true); - }else{ + } else { + Log.d(TAG, "CONTROL_ENABLE_ZSL is disabled."); captureBuilder.set(CaptureRequest.CONTROL_ENABLE_ZSL, false); } +/*todo Location location = mLocationManager.getCurrentLocation(); + if(location != null) { + // make copy so that we don't alter the saved location since we may re-use it + location = new Location(location); + // workaround for Google bug. Need to convert timestamp from ms -> sec + location.setTime(location.getTime()/1000); + captureBuilder.set(CaptureRequest.JPEG_GPS_LOCATION, location); + Log.d(TAG, "captureStillPicture gps: " + location.toString()); + } else { + Log.d(TAG, "captureStillPicture no location - getRecordLocation: " + getRecordLocation()); + } + captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, CameraUtil.getJpegRotation(id, mOrientation)); + captureBuilder.set(CaptureRequest.JPEG_THUMBNAIL_SIZE, mPictureThumbSize); + captureBuilder.set(CaptureRequest.JPEG_THUMBNAIL_QUALITY, (byte)80); +*/ + captureBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO); - applySettingsForJpegInformation(captureBuilder, id); addPreviewSurface(captureBuilder, null, id); - VendorTagUtil.setCdsMode(captureBuilder, 2);// CDS 0-OFF, 1-ON, 2-AUTO + captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode); + captureBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE); + VendorTagUtil.setCdsMode(captureBuilder, 2); // CDS 0-OFF, 1-ON, 2-AUTO applySettingsForCapture(captureBuilder, id); - if(isClearSightOn()) { - captureStillPictureForClearSight(id); + if(csEnabled) { + applySettingsForLockExposure(captureBuilder, id); + checkAndPlayShutterSound(id); + ClearSightImageProcessor.getInstance().capture( + id==BAYER_ID, mCaptureSession[id], captureBuilder, mCaptureCallbackHandler); } else if(id == getMainCameraId() && mPostProcessor.isFilterOn()) { // Case of post filtering - captureStillPictureForFilter(captureBuilder, id); - } else { + applySettingsForLockExposure(captureBuilder, id); + checkAndPlayShutterSound(id); + mCaptureSession[id].stopRepeating(); captureBuilder.addTarget(mImageReader[id].getSurface()); if (mSaveRaw) { captureBuilder.addTarget(mRawImageReader[id].getSurface()); } - mCaptureSession[id].stopRepeating(); - if (mLongshotActive) { - captureStillPictureForLongshot(captureBuilder, id); + mPostProcessor.onStartCapturing(); + if(mPostProcessor.isManualMode()) { + mPostProcessor.manualCapture(captureBuilder, mCaptureSession[id], mCaptureCallbackHandler); } else { - captureStillPictureForCommon(captureBuilder, id); + List<CaptureRequest> captureList = mPostProcessor.setRequiredImages(captureBuilder); + mCaptureSession[id].captureBurst(captureList, mPostProcessor.getCaptureCallback(), mCaptureCallbackHandler); } - } - } catch (CameraAccessException e) { - Log.d(TAG, "Capture still picture has failed"); - e.printStackTrace(); - } - } - - private void captureStillPictureForClearSight(int id) throws CameraAccessException{ - CaptureRequest.Builder captureBuilder = - ClearSightImageProcessor.getInstance().createCaptureRequest(mCameraDevice[id]); + } else { + captureBuilder.addTarget(mImageReader[id].getSurface()); + if (mSaveRaw) { + captureBuilder.addTarget(mRawImageReader[id].getSurface()); + } + mCaptureSession[id].stopRepeating(); - if(mSettingsManager.isZSLInHALEnabled()) { - captureBuilder.set(CaptureRequest.CONTROL_ENABLE_ZSL, true); - }else{ - captureBuilder.set(CaptureRequest.CONTROL_ENABLE_ZSL, false); - } - - applySettingsForJpegInformation(captureBuilder, id); - addPreviewSurface(captureBuilder, null, id); - VendorTagUtil.setCdsMode(captureBuilder, 2); // CDS 0-OFF, 1-ON, 2-AUTO - applySettingsForCapture(captureBuilder, id); - applySettingsForLockExposure(captureBuilder, id); - checkAndPlayShutterSound(id); - ClearSightImageProcessor.getInstance().capture( - id==BAYER_ID, mCaptureSession[id], captureBuilder, mCaptureCallbackHandler); - } - - private void captureStillPictureForFilter(CaptureRequest.Builder captureBuilder, int id) throws CameraAccessException{ - applySettingsForLockExposure(captureBuilder, id); - checkAndPlayShutterSound(id); - mCaptureSession[id].stopRepeating(); - captureBuilder.addTarget(mImageReader[id].getSurface()); - if (mSaveRaw) { - captureBuilder.addTarget(mRawImageReader[id].getSurface()); - } - mPostProcessor.onStartCapturing(); - if(mPostProcessor.isManualMode()) { - mPostProcessor.manualCapture(captureBuilder, mCaptureSession[id], mCaptureCallbackHandler); - } else { - List<CaptureRequest> captureList = mPostProcessor.setRequiredImages(captureBuilder); - mCaptureSession[id].captureBurst(captureList, mPostProcessor.getCaptureCallback(), mCaptureCallbackHandler); - } - } + if (mLongshotActive) { + Log.d(TAG, "captureStillPicture capture longshot " + id); + List<CaptureRequest> burstList = new ArrayList<>(); + for (int i = 0; i < PersistUtil.getLongshotShotLimit(); i++) { + burstList.add(captureBuilder.build()); + } + mCaptureSession[id].captureBurst(burstList, new + CameraCaptureSession.CaptureCallback() { - private void captureStillPictureForLongshot(CaptureRequest.Builder captureBuilder, int id) throws CameraAccessException{ - Log.d(TAG, "captureStillPictureForLongshot " + id); - List<CaptureRequest> burstList = new ArrayList<>(); - for (int i = 0; i < PersistUtil.getLongshotShotLimit(); i++) { - burstList.add(captureBuilder.build()); - } - mCaptureSession[id].captureBurst(burstList, new - CameraCaptureSession.CaptureCallback() { + @Override + public void onCaptureCompleted(CameraCaptureSession session, + CaptureRequest request, + TotalCaptureResult result) { + Log.d(TAG, "captureStillPicture Longshot onCaptureCompleted: " + id); + if (mLongshotActive) { + checkAndPlayShutterSound(id); + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mUI.doShutterAnimation(); + } + }); + } + } - @Override - public void onCaptureCompleted(CameraCaptureSession session, - CaptureRequest request, - TotalCaptureResult result) { - Log.d(TAG, "captureStillPictureForLongshot onCaptureCompleted: " + id); - if (mLongshotActive) { - checkAndPlayShutterSound(id); - mActivity.runOnUiThread(new Runnable() { @Override - public void run() { - mUI.doShutterAnimation(); + public void onCaptureFailed(CameraCaptureSession session, + CaptureRequest request, + CaptureFailure result) { + Log.d(TAG, "captureStillPicture Longshot onCaptureFailed: " + id); + if (mLongshotActive) { + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mUI.doShutterAnimation(); + } + }); + } } - }); - } - } - @Override - public void onCaptureFailed(CameraCaptureSession session, - CaptureRequest request, - CaptureFailure result) { - Log.d(TAG, "captureStillPictureForLongshot onCaptureFailed: " + id); - if (mLongshotActive) { - mActivity.runOnUiThread(new Runnable() { @Override - public void run() { - mUI.doShutterAnimation(); + public void onCaptureSequenceCompleted(CameraCaptureSession session, int + sequenceId, long frameNumber) { + Log.d(TAG, "captureStillPicture Longshot onCaptureSequenceCompleted: " + id); + mLongshotActive = false; + unlockFocus(id); } - }); + }, mCaptureCallbackHandler); + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mUI.enableVideo(false); } - } + }); - @Override - public void onCaptureSequenceCompleted(CameraCaptureSession session, int - sequenceId, long frameNumber) { - Log.d(TAG, "captureStillPictureForLongshot onCaptureSequenceCompleted: " + id); - mLongshotActive = false; - unlockFocus(id); + } else { + checkAndPlayShutterSound(id); + if(isMpoOn()) { + mCaptureStartTime = System.currentTimeMillis(); + mMpoSaveHandler.obtainMessage(MpoSaveHandler.MSG_CONFIGURE, + Long.valueOf(mCaptureStartTime)).sendToTarget(); + } +/*todo if(mChosenImageFormat == ImageFormat.YUV_420_888 || mChosenImageFormat == ImageFormat.PRIVATE) { // Case of ZSL, FrameFilter, SelfieMirror + mPostProcessor.onStartCapturing(); + mCaptureSession[id].capture(captureBuilder.build(), mPostProcessor.getCaptureCallback(), mCaptureCallbackHandler); + } else*/ { + mCaptureSession[id].capture(captureBuilder.build(), captureCallback, mCaptureCallbackHandler); } - }, mCaptureCallbackHandler); - mActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - mUI.enableVideo(false); - } - }); - } - - private void captureStillPictureForCommon(CaptureRequest.Builder captureBuilder, int id) throws CameraAccessException{ - checkAndPlayShutterSound(id); - if(isMpoOn()) { - mCaptureStartTime = System.currentTimeMillis(); - mMpoSaveHandler.obtainMessage(MpoSaveHandler.MSG_CONFIGURE, - Long.valueOf(mCaptureStartTime)).sendToTarget(); - } - if(mChosenImageFormat == ImageFormat.YUV_420_888 || mChosenImageFormat == ImageFormat.PRIVATE) { // Case of ZSL, FrameFilter, SelfieMirror - mPostProcessor.onStartCapturing(); - mCaptureSession[id].capture(captureBuilder.build(), mPostProcessor.getCaptureCallback(), mCaptureCallbackHandler); - } else { - mCaptureSession[id].capture(captureBuilder.build(), new CameraCaptureSession.CaptureCallback() { - - @Override - public void onCaptureCompleted(CameraCaptureSession session, - CaptureRequest request, - TotalCaptureResult result) { - Log.d(TAG, "captureStillPictureForCommon onCaptureCompleted: " + id); - } - - @Override - public void onCaptureFailed(CameraCaptureSession session, - CaptureRequest request, - CaptureFailure result) { - Log.d(TAG, "captureStillPictureForCommon onCaptureFailed: " + id); - } - - @Override - public void onCaptureSequenceCompleted(CameraCaptureSession session, int - sequenceId, long frameNumber) { - Log.d(TAG, "captureStillPictureForCommon onCaptureSequenceCompleted: " + id); - unlockFocus(id); } - }, mCaptureCallbackHandler); + } + } catch (CameraAccessException e) { + Log.d(TAG, "Capture still picture has failed"); + e.printStackTrace(); } } @@ -1653,12 +1661,12 @@ public class CaptureModule implements CameraModule, PhotoController, CaptureRequest.Builder captureBuilder = mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_VIDEO_SNAPSHOT); - captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, CameraUtil.getJpegRotation(id, mOrientation)); + /* todo captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, CameraUtil.getJpegRotation(id, mOrientation)); captureBuilder.set(CaptureRequest.JPEG_THUMBNAIL_SIZE, mVideoSnapshotThumbSize); captureBuilder.set(CaptureRequest.JPEG_THUMBNAIL_QUALITY, (byte)80); applyVideoSnapshot(captureBuilder, id); applyZoom(captureBuilder, id); - + */ captureBuilder.addTarget(mVideoSnapshotImageReader.getSurface()); mCurrentSession.capture(captureBuilder.build(), @@ -1756,7 +1764,8 @@ public class CaptureModule implements CameraModule, PhotoController, ClearSightImageProcessor.getInstance().setCallback(this); } } else { - if ((imageFormat == ImageFormat.YUV_420_888 || imageFormat == ImageFormat.PRIVATE) +//todo if ((imageFormat == ImageFormat.YUV_420_888 || imageFormat == ImageFormat.PRIVATE) + if ((imageFormat == ImageFormat.PRIVATE) && i == getMainCameraId()) { if(mPostProcessor.isZSLEnabled()) { mImageReader[i] = ImageReader.newInstance(mSupportedMaxPictureSize.getWidth(), @@ -1792,19 +1801,38 @@ public class CaptureModule implements CameraModule, PhotoController, String title = (name == null) ? null : name.title; long date = (name == null) ? -1 : name.date; - byte[] bytes = getJpegData(image); - if (image.getFormat() == ImageFormat.RAW10) { + byte[] bytes = getJpegData(image); mActivity.getMediaSaveService().addRawImage(bytes, title, "raw"); + } else if (image.getFormat() == ImageFormat.YUV_420_888) { + Log.d(TAG, "Bring up picture of YUV is taken and ready to process"); + int width = image.getWidth(); + int height = image.getHeight(); + int stride = image.getPlanes()[0].getRowStride(); + ByteBuffer yuvBuf = ByteBuffer.allocateDirect(stride * height*3/2); + + ByteBuffer yBuf = image.getPlanes()[0].getBuffer(); + ByteBuffer vuBuf = image.getPlanes()[2].getBuffer(); + yBuf.get(yuvBuf.array(), 0, yBuf.remaining()); + vuBuf.get(yuvBuf.array(), stride*height, vuBuf.remaining()); + byte[] bytes = nv21ToJpeg(yuvBuf, width, height, stride); + mActivity.getMediaSaveService().addImage(bytes, title, date, + null, width, height, 90, null, + mOnMediaSavedListener, mContentResolver, "jpeg"); + mActivity.updateThumbnail(bytes); + image.close(); } else { + byte[] bytes = getJpegData(image); + ExifInterface exif = Exif.getExif(bytes); int orientation = Exif.getOrientation(exif); if (mIntentMode != CaptureModule.INTENT_MODE_NORMAL) { mJpegImageData = bytes; if (!mQuickCapture) { - showCapturedReview(bytes, orientation); + showCapturedReview(bytes, orientation, + mPostProcessor.isSelfieMirrorOn()); } else { onCaptureDone(); } @@ -1842,16 +1870,30 @@ public class CaptureModule implements CameraModule, PhotoController, } } + private byte[] nv21ToJpeg(ByteBuffer byteBuffer, int width, int height, int stride) { + PostProcessor.BitmapOutputStream bos = new PostProcessor.BitmapOutputStream(1024); + YuvImage im = new YuvImage(byteBuffer.array(), ImageFormat.NV21, + width, height, new int[]{stride, stride}); + im.compressToJpeg(new Rect(0,0, width, height), 50, bos); + byte[] bytes = bos.getArray(); + return bytes; + } + private void createVideoSnapshotImageReader() { if (mVideoSnapshotImageReader != null) { mVideoSnapshotImageReader.close(); } - mVideoSnapshotImageReader = ImageReader.newInstance(mVideoSnapshotSize.getWidth(), - mVideoSnapshotSize.getHeight(), ImageFormat.JPEG, 2); +/*Todo mVideoSnapshotImageReader = ImageReader.newInstance(mVideoSnapshotSize.getWidth(), + mVideoSnapshotSize.getHeight(), ImageFormat.JPEG, 2);*/ + + mVideoSnapshotImageReader = ImageReader.newInstance(3840, 2160, mChosenImageFormat, 2); + Log.e(TAG, "Image="+mChosenImageFormat); mVideoSnapshotImageReader.setOnImageAvailableListener( new ImageReader.OnImageAvailableListener() { @Override public void onImageAvailable(ImageReader reader) { + Log.d(TAG, "Video Snapshot Image Available."); + Image image = reader.acquireNextImage(); mCaptureStartTime = System.currentTimeMillis(); mNamedImages.nameNewImage(mCaptureStartTime); @@ -1859,19 +1901,39 @@ public class CaptureModule implements CameraModule, PhotoController, String title = (name == null) ? null : name.title; long date = (name == null) ? -1 : name.date; - ByteBuffer buffer = image.getPlanes()[0].getBuffer(); - byte[] bytes = new byte[buffer.remaining()]; - buffer.get(bytes); + if (image.getFormat() == ImageFormat.YUV_420_888) { + Log.d(TAG, "Bring up picture of YUV is taken and ready to process"); + int width = image.getWidth(); + int height = image.getHeight(); + int stride = image.getPlanes()[0].getRowStride(); + ByteBuffer yuvBuf = ByteBuffer.allocateDirect(stride * height*3/2); + + ByteBuffer yBuf = image.getPlanes()[0].getBuffer(); + ByteBuffer vuBuf = image.getPlanes()[2].getBuffer(); + yBuf.get(yuvBuf.array(), 0, yBuf.remaining()); + vuBuf.get(yuvBuf.array(), stride*height, vuBuf.remaining()); + byte[] bytes = nv21ToJpeg(yuvBuf, width, height, stride); + mActivity.getMediaSaveService().addImage(bytes, title, date, + null, width, height, 90, null, + mOnMediaSavedListener, mContentResolver, "jpeg"); + mActivity.updateThumbnail(bytes); + image.close(); + } else { + + ByteBuffer buffer = image.getPlanes()[0].getBuffer(); + byte[] bytes = new byte[buffer.remaining()]; + buffer.get(bytes); - ExifInterface exif = Exif.getExif(bytes); - int orientation = Exif.getOrientation(exif); + ExifInterface exif = Exif.getExif(bytes); + int orientation = Exif.getOrientation(exif); - mActivity.getMediaSaveService().addImage(bytes, title, date, + mActivity.getMediaSaveService().addImage(bytes, title, date, null, image.getWidth(), image.getHeight(), orientation, null, mOnMediaSavedListener, mContentResolver, "jpeg"); - mActivity.updateThumbnail(bytes); - image.close(); + mActivity.updateThumbnail(bytes); + image.close(); + } } }, mImageAvailableHandler); } @@ -2089,23 +2151,6 @@ public class CaptureModule implements CameraModule, PhotoController, applyCommonSettings(builder, id); } - private void applySettingsForJpegInformation(CaptureRequest.Builder builder, int id) { - Location location = mLocationManager.getCurrentLocation(); - if(location != null) { - // make copy so that we don't alter the saved location since we may re-use it - location = new Location(location); - // workaround for Google bug. Need to convert timestamp from ms -> sec - location.setTime(location.getTime()/1000); - builder.set(CaptureRequest.JPEG_GPS_LOCATION, location); - Log.d(TAG, "gps: " + location.toString()); - } else { - Log.d(TAG, "no location - getRecordLocation: " + getRecordLocation()); - } - builder.set(CaptureRequest.JPEG_ORIENTATION, CameraUtil.getJpegRotation(id, mOrientation)); - builder.set(CaptureRequest.JPEG_THUMBNAIL_SIZE, mPictureThumbSize); - builder.set(CaptureRequest.JPEG_THUMBNAIL_QUALITY, (byte)80); - } - private void applyVideoSnapshot(CaptureRequest.Builder builder, int id) { builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO); applyColorEffect(builder); @@ -2342,6 +2387,42 @@ public class CaptureModule implements CameraModule, PhotoController, updateMaxVideoDuration(); } + private Size checkOverridePreviewSize(int cur_width, int cur_height) { + int preview_resolution = PersistUtil.getCameraPreviewSize(); + + switch (preview_resolution) { + case 1: { + cur_width = 640; + cur_height = 480; + Log.v(TAG, "Preview resolution hardcoded to 640x480"); + break; + } + case 2: { + cur_width = 720; + cur_height = 480; + Log.v(TAG, "Preview resolution hardcoded to 720x480"); + break; + } + case 3: { + cur_width = 1280; + cur_height = 720; + Log.v(TAG, "Preview resolution hardcoded to 1280x720"); + break; + } + case 4: { + cur_width = 1920; + cur_height = 1080; + Log.v(TAG, "Preview resolution hardcoded to 1920x1080"); + break; + } + default: { + Log.v(TAG, "Preview resolution as per Snapshot aspect ratio"); + break; + } + } + return new Size(cur_width, cur_height); + } + private void updatePreviewSize() { int width = mPreviewSize.getWidth(); int height = mPreviewSize.getHeight(); @@ -2352,16 +2433,7 @@ public class CaptureModule implements CameraModule, PhotoController, width = mVideoSize.getWidth(); height = mVideoSize.getHeight(); } - - Point previewSize = PersistUtil.getCameraPreviewSize(); - if (previewSize != null) { - width = previewSize.x; - height = previewSize.y; - } - - Log.d(TAG, "updatePreviewSize final preview size = " + width + ", " + height); - - mPreviewSize = new Size(width, height); + mPreviewSize = checkOverridePreviewSize(width, height); mUI.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } @@ -2402,7 +2474,7 @@ public class CaptureModule implements CameraModule, PhotoController, } else if(mPostProcessor.isFilterOn() || getFrameFilters().size() != 0 || mPostProcessor.isSelfieMirrorOn()) { mChosenImageFormat = ImageFormat.YUV_420_888; } else { - mChosenImageFormat = ImageFormat.JPEG; + mChosenImageFormat = ImageFormat.YUV_420_888; //todo ImageFormat.JPEG; } setUpCameraOutputs(mChosenImageFormat); @@ -3042,9 +3114,11 @@ public class CaptureModule implements CameraModule, PhotoController, Size[] prevSizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), SurfaceHolder.class); mSupportedMaxPictureSize = prevSizes[0]; - Size[] rawSize = mSettingsManager.getSupportedOutputSize(getMainCameraId(), + if (mSaveRaw == true) { + Size[] rawSize = mSettingsManager.getSupportedOutputSize(getMainCameraId(), ImageFormat.RAW10); - mSupportedRawPictureSize = rawSize[0]; + mSupportedRawPictureSize = rawSize[0]; + } mPreviewSize = getOptimalPreviewSize(mPictureSize, prevSizes); Size[] thumbSizes = mSettingsManager.getSupportedThumbnailSizes(getMainCameraId()); mPictureThumbSize = getOptimalPreviewSize(mPictureSize, thumbSizes); // get largest thumb size @@ -3076,19 +3150,17 @@ public class CaptureModule implements CameraModule, PhotoController, Size[] prevSizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), MediaRecorder.class); mVideoPreviewSize = getOptimalPreviewSize(mVideoSize, prevSizes); - - Point previewSize = PersistUtil.getCameraPreviewSize(); - if (previewSize != null) { - mVideoPreviewSize = new Size(previewSize.x, previewSize.y); - } - Log.d(TAG, "updatePreviewSize final preview size = " + mVideoPreviewSize.getWidth() - + ", " + mVideoPreviewSize.getHeight()); + mVideoPreviewSize = checkOverridePreviewSize(mVideoPreviewSize.getWidth(), + mVideoPreviewSize.getHeight()); } private void updateVideoSnapshotSize() { - mVideoSnapshotSize = mVideoSize; - if (is4kSize(mVideoSize) && is4kSize(mVideoSnapshotSize)) { - mVideoSnapshotSize = getMaxPictureSizeLessThan4k(); + updateHFRSetting(); + mVideoSnapshotSize = mPictureSize; + mVideoSnapshotSize = getMaxPictureSizeForLiveShot(); + // if video High FrameRate > 60fps, the mVideoSnapshotSize = mVideoSize + if (mHighSpeedCapture && ((int)mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) { + mVideoSnapshotSize = mVideoSize; } Size[] thumbSizes = mSettingsManager.getSupportedThumbnailSizes(getMainCameraId()); mVideoSnapshotThumbSize = getOptimalPreviewSize(mVideoSnapshotSize, thumbSizes); // get largest thumb size @@ -3128,6 +3200,7 @@ public class CaptureModule implements CameraModule, PhotoController, mStartRecPending = true; mIsRecordingVideo = true; mMediaRecorderPausing = false; + mUI.hideUIwhileRecording(); mActivity.updateStorageSpaceAndHint(); if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) { @@ -3139,17 +3212,6 @@ public class CaptureModule implements CameraModule, PhotoController, try { setUpMediaRecorder(cameraId); - try { - mMediaRecorder.start(); // Recording is now started - } catch (RuntimeException e) { - Toast.makeText(mActivity,"Could not start media recorder.\n " + - "Can't start video recording.", Toast.LENGTH_LONG).show(); - releaseMediaRecorder(); - releaseAudioFocus(); - mStartRecPending = false; - mIsRecordingVideo = false; - return false; - } if (mUnsupportedResolution == true ) { Log.v(TAG, "Unsupported Resolution according to target"); mStartRecPending = false; @@ -3165,7 +3227,6 @@ public class CaptureModule implements CameraModule, PhotoController, requestAudioFocus(); mUI.clearFocus(); - mUI.hideUIwhileRecording(); mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[cameraId]); mState[cameraId] = STATE_PREVIEW; mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE; @@ -3233,6 +3294,17 @@ public class CaptureModule implements CameraModule, PhotoController, + e.getMessage()); e.printStackTrace(); } + try { + mMediaRecorder.start(); // Recording is now started + } catch (RuntimeException e) { + Toast.makeText(mActivity,"Could not start media recorder.\n " + + "Can't start video recording.", Toast.LENGTH_LONG).show(); + releaseMediaRecorder(); + releaseAudioFocus(); + mStartRecPending = false; + mIsRecordingVideo = false; + return; + } mUI.clearFocus(); mUI.resetPauseButton(); mRecordingTotalTime = 0L; @@ -3267,6 +3339,17 @@ public class CaptureModule implements CameraModule, PhotoController, } catch (IllegalStateException e) { e.printStackTrace(); } + try { + mMediaRecorder.start(); // Recording is now started + } catch (RuntimeException e) { + Toast.makeText(mActivity,"Could not start media recorder.\n " + + "Can't start video recording.", Toast.LENGTH_LONG).show(); + releaseMediaRecorder(); + releaseAudioFocus(); + mStartRecPending = false; + mIsRecordingVideo = false; + return; + } mUI.clearFocus(); mUI.resetPauseButton(); mRecordingTotalTime = 0L; @@ -3312,6 +3395,9 @@ public class CaptureModule implements CameraModule, PhotoController, mHighSpeedRecordingMode = mode.equals("hsr"); mHighSpeedCaptureRate = Integer.parseInt(value.substring(3)); } + if (mHighSpeedCapture) { + mHighSpeedFPSRange = new Range(mHighSpeedCaptureRate, mHighSpeedCaptureRate); + } } private void setUpVideoCaptureRequestBuilder(CaptureRequest.Builder builder,int cameraId) { @@ -3973,14 +4059,14 @@ public class CaptureModule implements CameraModule, PhotoController, if (value == null || value.equals("0")) return; int intValue = Integer.parseInt(value); - request.set(CaptureModule.INSTANT_AEC_MODE, intValue); + //todo request.set(CaptureModule.INSTANT_AEC_MODE, intValue); } private void applySaturationLevel(CaptureRequest.Builder request) { String value = mSettingsManager.getValue(SettingsManager.KEY_SATURATION_LEVEL); if (value != null) { int intValue = Integer.parseInt(value); - request.set(CaptureModule.SATURATION, intValue); + //todo request.set(CaptureModule.SATURATION, intValue); } } @@ -4285,7 +4371,7 @@ public class CaptureModule implements CameraModule, PhotoController, } } - public Surface getPreviewSurfaceForSession(int id) { + private Surface getPreviewSurfaceForSession(int id) { if (isBackCamera()) { if (getCameraMode() == DUAL_MODE && id == MONO_ID) { return mUI.getMonoDummySurface(); @@ -4583,6 +4669,57 @@ public class CaptureModule implements CameraModule, PhotoController, return (optimalPickIndex == -1) ? null : prevSizes[optimalPickIndex]; } + private Size getMaxPictureSizeForLiveShot() { + Size[] sizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), ImageFormat.JPEG); + float ratio = (float) mVideoSize.getWidth() / mVideoSize.getHeight(); + Size optimalSize = null; + double minDiff = Double.MAX_VALUE; + for (Size size : sizes) { + // if video quality set 1080p, the mVideoSnapshotSize is biggest is 16M(16:9 and 4:3) + if (mVideoSize.getHeight() == 1080 && mVideoSize.getWidth() == 1920) { + if (size.getHeight() > 3456 || size.getWidth() > 5312) continue; + // if video quality set 4K dci or UHD, the mVideoSnapshotSize is biggest is 12M + } else if ((mVideoSize.getHeight() == 2160 && mVideoSize.getWidth() == 4096) || + (mVideoSize.getHeight() == 2160 && mVideoSize.getWidth() == 3840)){ + if (size.getHeight() > 3000 || size.getWidth() > 4000) continue; + } + + float pictureRatio = (float) size.getWidth() / size.getHeight(); + if (Math.abs(pictureRatio - ratio) > 0.01) continue; + + double heightDiff = Math.abs(size.getHeight() - mPictureSize.getHeight()); + if (heightDiff < minDiff) { + optimalSize = size; + minDiff = Math.abs(size.getHeight() - mPictureSize.getHeight()); + } else if (heightDiff == minDiff) { + // Prefer resolutions smaller-than-display when an equally close + // larger-than-display resolution is available + if (size.getHeight() < mPictureSize.getHeight()) { + optimalSize = size; + minDiff = heightDiff; + } + } + } + + // Cannot find one that matches the aspect ratio. This should not happen. + // Ignore the requirement. + if (optimalSize == null) { + Log.w(TAG, "No picture size match the aspect ratio"); + for (Size size : sizes) { + if (mVideoSize.getHeight() == 1080 && mVideoSize.getWidth() == 1920) { + if (size.getHeight() >= 3456 || size.getWidth() >= 4608) continue; + } else if ((mVideoSize.getHeight() == 2160 && mVideoSize.getWidth() == 4096) || + (mVideoSize.getHeight() == 2160 && mVideoSize.getWidth() == 3840)) { + if (size.getHeight() >= 3000 || size.getWidth() >= 4000) continue; + } + if (optimalSize == null || size.getWidth() > optimalSize.getWidth()) { + optimalSize = size; + } + } + } + return optimalSize; + } + private Size getMaxPictureSizeLessThan4k() { Size[] sizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), ImageFormat.JPEG); float ratio = (float) mVideoSize.getWidth() / mVideoSize.getHeight(); diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index d0b129ad9..6ec09effd 100644..100755 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -306,10 +306,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mMakeupSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) { - if ( progresValue != 0 ) { - int value = 10 + 9 * progresValue / 10; - mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, value + ""); - } + int value = progresValue/10*10; + mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, value+""); } @Override public void onStartTrackingTouch(SeekBar seekBar) { @@ -486,8 +484,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, showFirstTimeHelp(); } - protected void showCapturedImageForReview(byte[] jpegData, int orientation) { - mDecodeTaskForReview = new CaptureUI.DecodeImageForReview(jpegData, orientation); + protected void showCapturedImageForReview(byte[] jpegData, int orientation, boolean mirror) { + mDecodeTaskForReview = new CaptureUI.DecodeImageForReview(jpegData, orientation, mirror); mDecodeTaskForReview.execute(); if (getCurrentIntentMode() != CaptureModule.INTENT_MODE_NORMAL) { if (mFilterMenuStatus == FILTER_MENU_ON) { @@ -1739,18 +1737,24 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private class DecodeTask extends AsyncTask<Void, Void, Bitmap> { private final byte [] mData; private int mOrientation; + private boolean mMirror; - public DecodeTask(byte[] data, int orientation) { + public DecodeTask(byte[] data, int orientation, boolean mirror) { mData = data; mOrientation = orientation; + mMirror = mirror; } @Override protected Bitmap doInBackground(Void... params) { Bitmap bitmap = CameraUtil.downSample(mData, mDownSampleFactor); // Decode image in background. - if ((mOrientation != 0) && (bitmap != null)) { + if ((mOrientation != 0 || mMirror) && (bitmap != null)) { Matrix m = new Matrix(); + if (mMirror) { + // Flip horizontally + m.setScale(-1f, 1f); + } m.preRotate(mOrientation); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, false); @@ -1764,8 +1768,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } private class DecodeImageForReview extends CaptureUI.DecodeTask { - public DecodeImageForReview(byte[] data, int orientation) { - super(data, orientation); + public DecodeImageForReview(byte[] data, int orientation, boolean mirror) { + super(data, orientation, mirror); } @Override diff --git a/src/com/android/camera/MediaSaveService.java b/src/com/android/camera/MediaSaveService.java index 217f44f27..6ca37b9e2 100644 --- a/src/com/android/camera/MediaSaveService.java +++ b/src/com/android/camera/MediaSaveService.java @@ -41,7 +41,6 @@ import com.android.camera.exif.ExifInterface; import com.android.camera.mpo.MpoData; import com.android.camera.mpo.MpoImageData; import com.android.camera.mpo.MpoInterface; -import com.android.camera.util.PersistUtil; import com.android.camera.util.XmpUtil; import org.codeaurora.snapcam.filter.GDepth; @@ -59,8 +58,7 @@ public class MediaSaveService extends Service { // The memory limit for unsaved image is 50MB. private static final int SAVE_TASK_MEMORY_LIMIT_IN_MB = - PersistUtil.getSaveTaskMemoryLimitInMb(); - + android.os.SystemProperties.getInt("persist.camera.perf.memlimit", 60); private static final int SAVE_TASK_MEMORY_LIMIT = SAVE_TASK_MEMORY_LIMIT_IN_MB * 1024 * 1024; private static final String TAG = "CAM_" + MediaSaveService.class.getSimpleName(); diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index af796c6a7..4cccf8e94 100644..100755 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -1181,10 +1181,7 @@ public class SettingsManager implements ListMenu.SettingsListener { public int getHighSpeedVideoEncoderBitRate(CamcorderProfile profile, int targetRate) { int bitRate; String key = profile.videoFrameWidth+"x"+profile.videoFrameHeight+":"+targetRate; - String resolutionFpsEncoder = key + ":" + profile.videoCodec; - if (CameraSettings.VIDEO_ENCODER_BITRATE.containsKey(resolutionFpsEncoder)) { - bitRate = CameraSettings.VIDEO_ENCODER_BITRATE.get(resolutionFpsEncoder); - } else if (CameraSettings.VIDEO_ENCODER_BITRATE.containsKey(key) ) { + if (CameraSettings.VIDEO_ENCODER_BITRATE.containsKey(key)) { bitRate = CameraSettings.VIDEO_ENCODER_BITRATE.get(key); } else { Log.i(TAG, "No pre-defined bitrate for "+key); @@ -1397,9 +1394,7 @@ public class SettingsManager implements ListMenu.SettingsListener { modes.add("" + i); } } catch(NullPointerException e) { - Log.w(TAG, "Supported instant aec modes is null."); } catch(IllegalArgumentException e) { - Log.w(TAG, "Supported instant aec modes is null."); } return modes; diff --git a/src/com/android/camera/imageprocessor/FrameProcessor.java b/src/com/android/camera/imageprocessor/FrameProcessor.java index 6b0c97732..b1b415acd 100644 --- a/src/com/android/camera/imageprocessor/FrameProcessor.java +++ b/src/com/android/camera/imageprocessor/FrameProcessor.java @@ -401,11 +401,7 @@ public class FrameProcessor { } } else { filter.init(mSize.getWidth(), mSize.getHeight(), stride, stride); - if (filter instanceof BeautificationFilter) { - filter.addImage(bY, bVU, 0, new Boolean(false)); - } else { - filter.addImage(bY, bVU, 0, new Boolean(true)); - } + filter.addImage(bY, bVU, 0, new Boolean(true)); needToFeedSurface = true; } bY.rewind(); @@ -489,11 +485,7 @@ public class FrameProcessor { mBY.rewind(); mBVU.rewind(); mFilter.init(mWidth, mHeight, mStride, mStride); - if (mFilter instanceof BeautificationFilter) { - mFilter.addImage(mBY, mBVU, 0, new Boolean(false)); - } else { - mFilter.addImage(mBY, mBVU, 0, new Boolean(true)); - } + mFilter.addImage(mBY, mBVU, 0, new Boolean(true)); mMutureLock.release(); } catch (InterruptedException e) { } diff --git a/src/com/android/camera/imageprocessor/PostProcessor.java b/src/com/android/camera/imageprocessor/PostProcessor.java index d70743be9..6e34de96d 100644 --- a/src/com/android/camera/imageprocessor/PostProcessor.java +++ b/src/com/android/camera/imageprocessor/PostProcessor.java @@ -391,7 +391,6 @@ public class PostProcessor{ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { - Log.d(TAG, "onCaptureCompleted"); if(mTotalCaptureResultList.size() <= PostProcessor.MAX_REQUIRED_IMAGE_NUM) { mTotalCaptureResultList.add(result); } @@ -406,13 +405,11 @@ public class PostProcessor{ public void onCaptureFailed(CameraCaptureSession session, CaptureRequest request, CaptureFailure result) { - Log.d(TAG, "onCaptureFailed"); } @Override public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId, long frameNumber) { - Log.d(TAG, "onCaptureSequenceCompleted"); if(!isFilterOn()) { mController.unlockFocus(mController.getMainCameraId()); } @@ -564,20 +561,17 @@ public class PostProcessor{ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { - Log.d(TAG, "reprocessImage onCaptureCompleted"); } @Override public void onCaptureFailed(CameraCaptureSession session, CaptureRequest request, CaptureFailure result) { - Log.d(TAG, "reprocessImage onCaptureFailed"); } @Override public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId, long frameNumber) { - Log.d(TAG, "reprocessImage onCaptureSequenceCompleted"); } }, mHandler); } catch (CameraAccessException e) { @@ -678,7 +672,6 @@ public class PostProcessor{ mImageHandlerTask = new ImageHandlerTask(); mSaveRaw = isSaveRaw; if(setFilter(postFilterId) || isFlashModeOn || isTrackingFocusOn || isMakeupOn || isSelfieMirrorOn - || PersistUtil.getCameraZSLDisabled() || !SettingsManager.getInstance().isZSLInAppEnabled() || "enable".equals( SettingsManager.getInstance().getValue(SettingsManager.KEY_AUTO_HDR)) @@ -1098,7 +1091,8 @@ public class PostProcessor{ if (mController.isQuickCapture()) { mController.onCaptureDone(); } else { - mController.showCapturedReview(bytes, mOrientation); + mController.showCapturedReview( + bytes, mOrientation, isSelfieMirrorOn()); } } mActivity.getMediaSaveService().addImage( @@ -1172,7 +1166,8 @@ public class PostProcessor{ if (mController.isQuickCapture()) { mController.onCaptureDone(); } else { - mController.showCapturedReview(bytes, orientation); + mController.showCapturedReview(bytes, + orientation, isSelfieMirrorOn()); } } else { mActivity.getMediaSaveService().addImage( @@ -1209,7 +1204,7 @@ public class PostProcessor{ return quality; } - private class BitmapOutputStream extends ByteArrayOutputStream { + public static class BitmapOutputStream extends ByteArrayOutputStream { public BitmapOutputStream(int size) { super(size); } diff --git a/src/com/android/camera/imageprocessor/ZSLQueue.java b/src/com/android/camera/imageprocessor/ZSLQueue.java index 0509b8fb5..c9ecb79a2 100644 --- a/src/com/android/camera/imageprocessor/ZSLQueue.java +++ b/src/com/android/camera/imageprocessor/ZSLQueue.java @@ -42,7 +42,9 @@ import java.util.LinkedList; import java.util.NoSuchElementException; public class ZSLQueue { - private int mCircularBufferSize; + private static final String CIRCULAR_BUFFER_SIZE_PERSIST = "persist.camera.zsl.buffer.size"; + private static final int CIRCULAR_BUFFER_SIZE_DEFAULT = 5; + private int mCircularBufferSize = CIRCULAR_BUFFER_SIZE_DEFAULT; private ImageItem[] mBuffer; private int mImageHead; private int mMetaHead; @@ -54,7 +56,7 @@ public class ZSLQueue { private static final String TAG = "ZSLQueue"; public ZSLQueue(CaptureModule module) { - mCircularBufferSize = PersistUtil.getCircularBufferSize(); + mCircularBufferSize = SystemProperties.getInt(CIRCULAR_BUFFER_SIZE_PERSIST, CIRCULAR_BUFFER_SIZE_DEFAULT); synchronized (mLock) { mBuffer = new ImageItem[mCircularBufferSize]; mImageHead = 0; diff --git a/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java b/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java index 4682e3947..607908ebf 100644 --- a/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java +++ b/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java @@ -32,10 +32,8 @@ import android.graphics.Rect; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraCaptureSession; import android.hardware.camera2.CameraCharacteristics; -import android.hardware.camera2.CameraDevice; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.CaptureResult; -import android.hardware.camera2.TotalCaptureResult; import android.os.Handler; import android.util.Log; @@ -157,33 +155,20 @@ public class ChromaflashFilter implements ImageFilter{ for (int i = 0; i < NUM_REQUIRED_IMAGE; i++) { if (i == 0) { captureSession.capture(builder.build(), callback, handler); - waitForImage(i); } else if (i == 1) { //To change the setting builder.set(CaptureRequest.CONTROL_AE_LOCK, Boolean.FALSE); - builder.set(CaptureRequest.FLASH_MODE, - CaptureRequest.FLASH_MODE_SINGLE); captureSession.capture(builder.build(), callback, handler); waitForImage(i); } else if (i == 2) { //To change the setting - builder.set(CaptureRequest.CONTROL_AE_MODE, - CaptureRequest.CONTROL_AE_MODE_ON); - CaptureRequest.Builder AeTunningBuilder = captureSession.getDevice(). - createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); - CaptureRequest request = builder.build(); - for (CaptureRequest.Key key : request.getKeys()) { - AeTunningBuilder.set(key, request.get(key)); - } - AeTunningBuilder.addTarget(mModule.getPreviewSurfaceForSession( - mModule.getMainCameraId())); - - waitForAeBlock(AeTunningBuilder,builder,callback, - captureSession,handler,5); - } else if (i == 3) { + builder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON); + builder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_SINGLE); + builder.set(CaptureRequest.CONTROL_AE_LOCK, Boolean.TRUE); captureSession.capture(builder.build(), callback, handler); waitForImage(i); + } else if (i == 3) { + captureSession.capture(builder.build(), callback, handler); } else if (i == 4) { //To change the setting builder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF); - builder.set(CaptureRequest.CONTROL_AE_LOCK, Boolean.FALSE); captureSession.capture(builder.build(), callback, handler); waitForImage(i); } else if (i == 5) { @@ -205,41 +190,6 @@ public class ChromaflashFilter implements ImageFilter{ } } - private void waitForAeBlock(final CaptureRequest.Builder tuningBuilder, - final CaptureRequest.Builder captureBuilder, - final CameraCaptureSession.CaptureCallback callback, - final CameraCaptureSession captureSession, - final Handler handler, final int AeTunningTime) { - try{ - captureSession.capture(tuningBuilder.build(), - new CameraCaptureSession.CaptureCallback() { - private boolean mAeStateConverged = false; - - @Override - public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, - TotalCaptureResult result) { - Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE); - Log.d(TAG,"AE tunning onCaptureCompleted aeState = " + aeState); - if (aeState != null && aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) { - mAeStateConverged = true; - } - Log.d(TAG,"AE tunning completed mAeStateConverged = " + mAeStateConverged); - if(!mAeStateConverged && AeTunningTime >= 2) { - int resetTime = AeTunningTime - 1; - waitForAeBlock(tuningBuilder,captureBuilder,callback, - captureSession,handler,resetTime); - } else { - try{ - captureSession.capture(captureBuilder.build(),callback,handler); - } catch (CameraAccessException e){} - } - } - }, handler); - }catch (CameraAccessException e){ - - } - } - public static boolean isSupportedStatic() { return mIsSupported; } diff --git a/src/com/android/camera/ui/Camera2FaceView.java b/src/com/android/camera/ui/Camera2FaceView.java index 81be61f81..3b6d10541 100644..100755 --- a/src/com/android/camera/ui/Camera2FaceView.java +++ b/src/com/android/camera/ui/Camera2FaceView.java @@ -151,9 +151,7 @@ public class Camera2FaceView extends FaceView { faceBound.offset(-mCameraBound.left, -mCameraBound.top); mRect.set(faceBound); translateMatrix.mapRect(mRect); - if (LOGV) CameraUtil.dumpRect(mRect, "Original rect"); mMatrix.mapRect(mRect); - if (LOGV) CameraUtil.dumpRect(mRect, "Transformed rect"); mPaint.setColor(mColor); mRect.offset(dx, dy); diff --git a/src/com/android/camera/ui/FaceView.java b/src/com/android/camera/ui/FaceView.java index 04b3664eb..b617891e5 100644..100755 --- a/src/com/android/camera/ui/FaceView.java +++ b/src/com/android/camera/ui/FaceView.java @@ -33,17 +33,14 @@ import android.view.View; import com.android.camera.PhotoUI; import com.android.camera.util.CameraUtil; -import com.android.camera.util.PersistUtil; import org.codeaurora.snapcam.R; import org.codeaurora.snapcam.wrapper.ExtendedFaceWrapper; public class FaceView extends View implements FocusIndicator, Rotatable, PhotoUI.SurfaceTextureSizeChangedListener { - protected static final String TAG = "CAM_FaceView"; - protected final boolean LOGV = - (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_LOG) || - (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_ALL); + protected static final String TAG = "CAM FaceView"; + protected final boolean LOGV = false; // The value for android.hardware.Camera.setDisplayOrientation. protected int mDisplayOrientation; // The orientation compensation for the face indicator to make it look diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index d6c1956d9..3b0d5e6ac 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -526,8 +526,8 @@ public class CameraUtil { //For < 720p, there is no need to do any capping. //By capping the panel size, we are indirectly controlling the preview size being //chosen in getOptimalPreviewSize(). - String uMax = PersistUtil.getDisplayUMax(); - String lMax = PersistUtil.getDisplayLMax(); + String uMax = SystemProperties.get("camera.display.umax", ""); + String lMax = SystemProperties.get("camera.display.lmax", ""); if ((uMax.length() > 0) && (lMax.length() > 0)) { Log.v(TAG,"display uMax "+ uMax + " lMax " + lMax); String uMaxArr[] = uMax.split("x", 2); diff --git a/src/com/android/camera/util/PersistUtil.java b/src/com/android/camera/util/PersistUtil.java index 976389ea2..8c1b57e98 100644 --- a/src/com/android/camera/util/PersistUtil.java +++ b/src/com/android/camera/util/PersistUtil.java @@ -28,32 +28,20 @@ */ package com.android.camera.util; -import android.graphics.Point; import android.os.SystemProperties; -import android.text.TextUtils; -import android.util.Log; public class PersistUtil { - public static final int CAMERA2_DEBUG_DUMP_IMAGE = 1; - public static final int CAMERA2_DEBUG_DUMP_LOG = 2; - public static final int CAMERA2_DEBUG_DUMP_ALL = 100; - - private static final int CAMERA_SENSOR_HORIZONTAL_ALIGNED = 0; - private static final int CAMERA_SENSOR_VERTICAL_ALIGNED = 1; - private static final int PERSIST_MEMORY_LIMIT = SystemProperties.getInt("persist.vendor.camera.perf.memlimit", 60); private static final boolean PERSIST_SKIP_MEMORY_CHECK = SystemProperties.getBoolean("persist.vendor.camera.perf.skip_memck", false); private static final int PERSIST_LONGSHOT_SHOT_LIMIT = SystemProperties.getInt("persist.vendor.camera.longshot.shotnum", 50); - private static final String PERSIST_CAMERA_PREVIEW_SIZE = - SystemProperties.get("persist.vendor.camera.preview.size", ""); + private static final int PERSIST_CAMERA_PREVIEW_SIZE = + SystemProperties.getInt("persist.vendor.camera.preview.size", 0); private static final boolean PERSIST_CAMERA_CAMERA2 = SystemProperties.getBoolean("persist.vendor.camera.camera2", true); - private static final boolean PERSIST_CAMERA_ZSL = - SystemProperties.getBoolean("persist.vendor.camera.zsl.disabled", false); private static final int PERSIST_CAMERA2_DEBUG = SystemProperties.getInt("persist.vendor.camera2.debug", 0); private static final int PERSIST_CAMERA_CANCEL_TOUCHFOCUS_DELAY = @@ -68,59 +56,10 @@ public class PersistUtil { SystemProperties.get("persist.vendor.camera.stm_smooth", "0"); private static final int PERSIST_CAMERA_STILLMORE_NUM_REQUIRED_IMAGE = SystemProperties.getInt("persist.vendor.camera.stm_img_nums", 5); - private static final String PERSIST_CAMERA_CS_BRINTENSITY_KEY = - SystemProperties.get("persist.vendor.camera.sensor.brinten", "0.0"); - private static final String PERSIST_CAMERA_CS_SMOOTH_KEY = - SystemProperties.get("persist.vendor.camera.sensor.smooth", "0.5"); - private static final int PERSIST_CAMERA_SENSOR_ALIGN_KEY = - SystemProperties.getInt("persist.vendor.camera.sensor.align", - CAMERA_SENSOR_HORIZONTAL_ALIGNED); - private static final int CIRCULAR_BUFFER_SIZE_PERSIST = - SystemProperties.getInt("persist.vendor.camera.zsl.buffer.size", 5); - private static final int SAVE_TASK_MEMORY_LIMIT_IN_MB = - SystemProperties.getInt("persist.vendor.camera.perf.memlimit", 60); - private static final boolean PERSIST_CAMERA_UI_AUTO_TEST_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.ui.auto_test", false); - private static final boolean PERSIST_CAMERA_SAVE_IN_SD_ENABLED = - SystemProperties.getBoolean("persist.vendor.env.camera.saveinsd", false); - private static final boolean PERSIST_LONG_SAVE_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.longshot.save", false); - private static final boolean PERSIST_CAMERA_PREVIEW_RESTART_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.feature.restart", false); - private static final boolean PERSIST_CAPTURE_ANIMATION_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.capture.animate", true); - private static final boolean PERSIST_SKIP_MEM_CHECK_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.perf.skip_memck", false); - private static final boolean PERSIST_ZZHDR_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.zzhdr.enable", false); - private static final int PERSIST_PREVIEW_SIZE = - SystemProperties.getInt("persist.vendor.camera.preview.size", 0); - private static final long PERSIST_TIMESTAMP_LIMIT = - SystemProperties.getLong("persist.vendor.camera.cs.threshold", 10); - private static final int PERSIST_BURST_COUNT = - SystemProperties.getInt("persist.vendor.camera.cs.burstcount", 4); - private static final boolean PERSIST_DUMP_FRAMES_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.cs.dumpframes", false); - private static final boolean PERSIST_DUMP_YUV_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.cs.dumpyuv", false); - private static final int PERSIST_CS_TIMEOUT = - SystemProperties.getInt("persist.vendor.camera.cs.timeout", 300); - private static final boolean PERSIST_DUMP_DEPTH_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.cs.dumpdepth", false); - private static final boolean PERSIST_DISABLE_QCOM_MISC_SETTING = - SystemProperties.getBoolean("persist.vendor.camera.qcom.misc.disable", false); - private static final int PREVIEW_FLIP_VALUE = - SystemProperties.getInt("persist.vendor.debug.camera.preview.flip", 0); - private static final int PERSIST_VIDEO_FLIP_VALUE = - SystemProperties.getInt("persist.vendor.debug.camera.video.flip", 0); - private static final int PERSIST_PICTURE_FLIP_VALUE = - SystemProperties.getInt("persist.vendor.debug.camera.picture.flip", 0); - private static final boolean PERSIST_YV_12_FORMAT_ENABLED = - SystemProperties.getBoolean("persist.vendor.camera.debug.camera.yv12", false); - private static final String PERSIST_DISPLAY_UMAX = - SystemProperties.get("persist.vendor.camera.display.umax", ""); - private static final String PERSIST_DISPLAY_LMAX = - SystemProperties.get("persist.vendor.camera.display.lmax", ""); + + public static final int CAMERA2_DEBUG_DUMP_IMAGE = 1; + public static final int CAMERA2_DEBUG_DUMP_LOG = 2; + public static final int CAMERA2_DEBUG_DUMP_ALL = 100; public static int getMemoryLimit() { return PERSIST_MEMORY_LIMIT; @@ -133,31 +72,15 @@ public class PersistUtil { public static int getLongshotShotLimit() { return PERSIST_LONGSHOT_SHOT_LIMIT; } - public static int getLongshotShotLimit(int defaultValue) { - return SystemProperties.getInt("persist.vendor.camera.longshot.shotnum", defaultValue); - } - public static Point getCameraPreviewSize() { - Point result = null; - if (PERSIST_CAMERA_PREVIEW_SIZE != null) { - String[] sourceStrArray = PERSIST_CAMERA_PREVIEW_SIZE.split("x"); - if (sourceStrArray != null && sourceStrArray.length >= 2) { - result = new Point(); - result.x = Integer.parseInt(sourceStrArray[0]); - result.y = Integer.parseInt(sourceStrArray[1]); - } - } - return result; + public static int getCameraPreviewSize() { + return PERSIST_CAMERA_PREVIEW_SIZE; } public static boolean getCamera2Mode() { return PERSIST_CAMERA_CAMERA2; } - public static boolean getCameraZSLDisabled() { - return PERSIST_CAMERA_ZSL; - } - public static int getCamera2Debug() { return PERSIST_CAMERA_DEBUG; } @@ -187,115 +110,4 @@ public class PersistUtil { public static int getCancelTouchFocusDelay() { return PERSIST_CAMERA_CANCEL_TOUCHFOCUS_DELAY; } - - public static float getDualCameraBrIntensity() { - return Float.parseFloat(PERSIST_CAMERA_CS_BRINTENSITY_KEY); - } - - public static float getDualCameraSmoothingIntensity() { - return Float.parseFloat(PERSIST_CAMERA_CS_SMOOTH_KEY); - } - - public static boolean getDualCameraSensorAlign() { - return PERSIST_CAMERA_SENSOR_ALIGN_KEY == CAMERA_SENSOR_VERTICAL_ALIGNED; - } - - public static int getCircularBufferSize(){ - return CIRCULAR_BUFFER_SIZE_PERSIST; - } - - public static int getSaveTaskMemoryLimitInMb(){ - return SAVE_TASK_MEMORY_LIMIT_IN_MB; - } - - public static boolean isAutoTestEnabled(){ - return PERSIST_CAMERA_UI_AUTO_TEST_ENABLED; - } - - public static boolean isSaveInSdEnabled(){ - return PERSIST_CAMERA_SAVE_IN_SD_ENABLED; - } - - public static boolean isLongSaveEnabled(){ - return PERSIST_LONG_SAVE_ENABLED; - } - - public static boolean isPreviewRestartEnabled(){ - return PERSIST_CAMERA_PREVIEW_RESTART_ENABLED; - } - - public static boolean isCaptureAnimationEnabled(){ - return PERSIST_CAPTURE_ANIMATION_ENABLED; - } - - public static boolean isSkipMemoryCheckEnabled(){ - return PERSIST_SKIP_MEM_CHECK_ENABLED; - } - - public static boolean isZzhdrEnabled(){ - return PERSIST_ZZHDR_ENABLED; - } - - public static int getPreviewSize(){ - //Read Preview Resolution from adb command - //value: 0(default) - Default value as per snapshot aspect ratio - //value: 1 - 640x480 - //value: 2 - 720x480 - //value: 3 - 1280x720 - //value: 4 - 1920x1080 - return PERSIST_PREVIEW_SIZE; - } - - public static long getTimestampLimit(){ - return PERSIST_TIMESTAMP_LIMIT; - } - - public static int getImageToBurst(){ - return PERSIST_BURST_COUNT; - } - - public static boolean isDumpFramesEnabled(){ - return PERSIST_DUMP_FRAMES_ENABLED; - } - - public static boolean isDumpYUVEnabled(){ - return PERSIST_DUMP_YUV_ENABLED; - } - - public static int getClearSightTimeout(){ - return PERSIST_CS_TIMEOUT; - } - - public static boolean isDumpDepthEnabled() { - return PERSIST_DUMP_DEPTH_ENABLED; - } - - public static boolean isDisableQcomMiscSetting(){ - return PERSIST_DISABLE_QCOM_MISC_SETTING; - } - - public static int getPreviewFlip() { - return PREVIEW_FLIP_VALUE; - } - - public static int getVideoFlip() { - return PERSIST_VIDEO_FLIP_VALUE; - } - - public static int getPictureFlip() { - return PERSIST_PICTURE_FLIP_VALUE; - } - - public static boolean isYv12FormatEnable() { - return PERSIST_YV_12_FORMAT_ENABLED; - } - - public static String getDisplayUMax() { - return PERSIST_DISPLAY_UMAX; - } - - public static String getDisplayLMax() { - return PERSIST_DISPLAY_LMAX; - } - } |