diff options
author | Linux Build Service Account <lnxbuild@quicinc.com> | 2017-08-30 19:47:20 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-08-30 19:47:20 -0700 |
commit | 004f8683454e374b81788fd1a13d44c4d5f35bab (patch) | |
tree | ba212c5f402f7e924ffc12cee7958cf9e8ba181f /src | |
parent | db15c114eda09196c982ae020dbb018d0d8919b1 (diff) | |
parent | b5533d51a7c97138235d29b35cec876d107aeadd (diff) | |
download | android_packages_apps_Snap-004f8683454e374b81788fd1a13d44c4d5f35bab.tar.gz android_packages_apps_Snap-004f8683454e374b81788fd1a13d44c4d5f35bab.tar.bz2 android_packages_apps_Snap-004f8683454e374b81788fd1a13d44c4d5f35bab.zip |
Merge "SnapdragonCamera: Sync LA.UM.6.4 to LA.UM.6.3"
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x] | 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 | ||||
-rw-r--r--[-rwxr-xr-x] | src/com/android/camera/CaptureUI.java | 24 | ||||
-rw-r--r-- | src/com/android/camera/MediaSaveService.java | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | 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 | ||||
-rw-r--r--[-rwxr-xr-x] | src/com/android/camera/ui/Camera2FaceView.java | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | 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, 523 insertions, 401 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index ea4bc03ba..f679e26c3 100755..100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -639,14 +639,8 @@ 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); @@ -1651,7 +1645,8 @@ public class CameraActivity extends Activity SETTING_LIST_WIDTH_1 = lower / 2 + offset; SETTING_LIST_WIDTH_2 = lower / 2 - offset; registerSDcardMountedReceiver(); - mAutoTestEnabled = SystemProperties.getBoolean("camera.ui.auto_test", false); + + mAutoTestEnabled = PersistUtil.isAutoTestEnabled(); if (mAutoTestEnabled) { registerAutoTestReceiver(); diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index e0141ed11..541c65704 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -38,6 +38,7 @@ 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; @@ -338,6 +339,10 @@ 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 @@ -977,6 +982,8 @@ public class CameraSettings { supportedAdvancedFeatures)) { removePreference(group, chromaFlash.getKey()); } + //remove chromaFlash + removePreference(group, chromaFlash.getKey()); } if (sceneMode != null) { @@ -1037,7 +1044,7 @@ public class CameraSettings { removePreference(group, cameraHdrPlus.getKey()); } - if (SystemProperties.getBoolean("persist.env.camera.saveinsd", false)) { + if (PersistUtil.isSaveInSdEnabled()) { 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 46a822e67..5b029df86 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -89,7 +89,6 @@ 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; @@ -1028,7 +1027,6 @@ public class CaptureModule implements CameraModule, PhotoController, if(id == getMainCameraId()) { mCurrentSession = cameraCaptureSession; } - initializePreviewConfiguration(id); setDisplayOrientation(); updateFaceDetection(); @@ -1047,17 +1045,18 @@ 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 @@ -1271,12 +1270,11 @@ public class CaptureModule implements CameraModule, PhotoController, mJpegImageData = data; } - public void showCapturedReview(final byte[] jpegData, final int orientation, - final boolean mirror) { + public void showCapturedReview(final byte[] jpegData, final int orientation) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { - mUI.showCapturedImageForReview(jpegData, orientation, mirror); + mUI.showCapturedImageForReview(jpegData, orientation); } }); } @@ -1309,11 +1307,7 @@ public class CaptureModule implements CameraModule, PhotoController, if (takeZSLPicture(BAYER_ID)) { return; } -/* take picture directly for now*/ - captureStillPicture(BAYER_ID); - mState[BAYER_ID] = STATE_PICTURE_TAKEN; - -//todo lockFocus(BAYER_ID); + lockFocus(BAYER_ID); break; case MONO_MODE: lockFocus(MONO_ID); @@ -1323,11 +1317,7 @@ public class CaptureModule implements CameraModule, PhotoController, if (takeZSLPicture(FRONT_ID)) { return; } -/* take picture directly for now*/ - captureStillPicture(FRONT_ID); - mState[FRONT_ID] = STATE_PICTURE_TAKEN; - -//todo lockFocus(FRONT_ID); + lockFocus(FRONT_ID); } } } @@ -1480,173 +1470,175 @@ 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; } - final boolean csEnabled = isClearSightOn(); - CaptureRequest.Builder captureBuilder; + CaptureRequest.Builder captureBuilder = + mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE); - 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 { - Log.d(TAG, "CONTROL_ENABLE_ZSL is disabled."); + }else{ 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); - 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 + VendorTagUtil.setCdsMode(captureBuilder, 2);// CDS 0-OFF, 1-ON, 2-AUTO applySettingsForCapture(captureBuilder, id); - if(csEnabled) { - applySettingsForLockExposure(captureBuilder, id); - checkAndPlayShutterSound(id); - ClearSightImageProcessor.getInstance().capture( - id==BAYER_ID, mCaptureSession[id], captureBuilder, mCaptureCallbackHandler); + if(isClearSightOn()) { + captureStillPictureForClearSight(id); } else if(id == getMainCameraId() && mPostProcessor.isFilterOn()) { // Case of post filtering - 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); - } + captureStillPictureForFilter(captureBuilder, id); } else { captureBuilder.addTarget(mImageReader[id].getSurface()); if (mSaveRaw) { captureBuilder.addTarget(mRawImageReader[id].getSurface()); } mCaptureSession[id].stopRepeating(); - 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() { + captureStillPictureForLongshot(captureBuilder, id); + } else { + captureStillPictureForCommon(captureBuilder, id); + } + } + } catch (CameraAccessException e) { + Log.d(TAG, "Capture still picture has failed"); + e.printStackTrace(); + } + } - @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(); - } - }); - } - } + private void captureStillPictureForClearSight(int id) throws CameraAccessException{ + CaptureRequest.Builder captureBuilder = + ClearSightImageProcessor.getInstance().createCaptureRequest(mCameraDevice[id]); + + 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); + } + } + + 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, "captureStillPictureForLongshot onCaptureCompleted: " + id); + if (mLongshotActive) { + checkAndPlayShutterSound(id); + mActivity.runOnUiThread(new Runnable() { @Override - 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(); - } - }); - } + 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 onCaptureSequenceCompleted(CameraCaptureSession session, int - sequenceId, long frameNumber) { - Log.d(TAG, "captureStillPicture Longshot onCaptureSequenceCompleted: " + id); - mLongshotActive = false; - unlockFocus(id); + public void run() { + mUI.doShutterAnimation(); } - }, mCaptureCallbackHandler); - mActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - mUI.enableVideo(false); + }); } - }); - - } 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); + + @Override + public void onCaptureSequenceCompleted(CameraCaptureSession session, int + sequenceId, long frameNumber) { + Log.d(TAG, "captureStillPictureForLongshot onCaptureSequenceCompleted: " + id); + mLongshotActive = false; + unlockFocus(id); } - } + }, mCaptureCallbackHandler); + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mUI.enableVideo(false); } - } catch (CameraAccessException e) { - Log.d(TAG, "Capture still picture has failed"); - e.printStackTrace(); + }); + } + + 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); } } @@ -1661,12 +1653,12 @@ public class CaptureModule implements CameraModule, PhotoController, CaptureRequest.Builder captureBuilder = mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_VIDEO_SNAPSHOT); - /* todo captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, CameraUtil.getJpegRotation(id, mOrientation)); + 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(), @@ -1764,8 +1756,7 @@ public class CaptureModule implements CameraModule, PhotoController, ClearSightImageProcessor.getInstance().setCallback(this); } } else { -//todo if ((imageFormat == ImageFormat.YUV_420_888 || imageFormat == ImageFormat.PRIVATE) - if ((imageFormat == ImageFormat.PRIVATE) + if ((imageFormat == ImageFormat.YUV_420_888 || imageFormat == ImageFormat.PRIVATE) && i == getMainCameraId()) { if(mPostProcessor.isZSLEnabled()) { mImageReader[i] = ImageReader.newInstance(mSupportedMaxPictureSize.getWidth(), @@ -1801,38 +1792,19 @@ 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, - mPostProcessor.isSelfieMirrorOn()); + showCapturedReview(bytes, orientation); } else { onCaptureDone(); } @@ -1870,30 +1842,16 @@ 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(); } -/*Todo mVideoSnapshotImageReader = ImageReader.newInstance(mVideoSnapshotSize.getWidth(), - mVideoSnapshotSize.getHeight(), ImageFormat.JPEG, 2);*/ - - mVideoSnapshotImageReader = ImageReader.newInstance(3840, 2160, mChosenImageFormat, 2); - Log.e(TAG, "Image="+mChosenImageFormat); + mVideoSnapshotImageReader = ImageReader.newInstance(mVideoSnapshotSize.getWidth(), + mVideoSnapshotSize.getHeight(), ImageFormat.JPEG, 2); 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); @@ -1901,39 +1859,19 @@ public class CaptureModule implements CameraModule, PhotoController, String title = (name == null) ? null : name.title; long date = (name == null) ? -1 : name.date; - 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); + 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); } @@ -2151,6 +2089,23 @@ 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); @@ -2387,42 +2342,6 @@ 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(); @@ -2433,7 +2352,16 @@ public class CaptureModule implements CameraModule, PhotoController, width = mVideoSize.getWidth(); height = mVideoSize.getHeight(); } - mPreviewSize = checkOverridePreviewSize(width, height); + + 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); mUI.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } @@ -2474,7 +2402,7 @@ public class CaptureModule implements CameraModule, PhotoController, } else if(mPostProcessor.isFilterOn() || getFrameFilters().size() != 0 || mPostProcessor.isSelfieMirrorOn()) { mChosenImageFormat = ImageFormat.YUV_420_888; } else { - mChosenImageFormat = ImageFormat.YUV_420_888; //todo ImageFormat.JPEG; + mChosenImageFormat = ImageFormat.JPEG; } setUpCameraOutputs(mChosenImageFormat); @@ -3114,11 +3042,9 @@ public class CaptureModule implements CameraModule, PhotoController, Size[] prevSizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), SurfaceHolder.class); mSupportedMaxPictureSize = prevSizes[0]; - if (mSaveRaw == true) { - Size[] rawSize = mSettingsManager.getSupportedOutputSize(getMainCameraId(), + 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 @@ -3150,17 +3076,19 @@ public class CaptureModule implements CameraModule, PhotoController, Size[] prevSizes = mSettingsManager.getSupportedOutputSize(getMainCameraId(), MediaRecorder.class); mVideoPreviewSize = getOptimalPreviewSize(mVideoSize, prevSizes); - mVideoPreviewSize = checkOverridePreviewSize(mVideoPreviewSize.getWidth(), - mVideoPreviewSize.getHeight()); + + 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()); } private void updateVideoSnapshotSize() { - updateHFRSetting(); - mVideoSnapshotSize = mPictureSize; - mVideoSnapshotSize = getMaxPictureSizeForLiveShot(); - // if video High FrameRate > 60fps, the mVideoSnapshotSize = mVideoSize - if (mHighSpeedCapture && ((int)mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) { - mVideoSnapshotSize = mVideoSize; + mVideoSnapshotSize = mVideoSize; + if (is4kSize(mVideoSize) && is4kSize(mVideoSnapshotSize)) { + mVideoSnapshotSize = getMaxPictureSizeLessThan4k(); } Size[] thumbSizes = mSettingsManager.getSupportedThumbnailSizes(getMainCameraId()); mVideoSnapshotThumbSize = getOptimalPreviewSize(mVideoSnapshotSize, thumbSizes); // get largest thumb size @@ -3200,7 +3128,6 @@ public class CaptureModule implements CameraModule, PhotoController, mStartRecPending = true; mIsRecordingVideo = true; mMediaRecorderPausing = false; - mUI.hideUIwhileRecording(); mActivity.updateStorageSpaceAndHint(); if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) { @@ -3212,6 +3139,17 @@ 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; @@ -3227,6 +3165,7 @@ 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; @@ -3294,17 +3233,6 @@ 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; @@ -3339,17 +3267,6 @@ 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; @@ -3395,9 +3312,6 @@ 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) { @@ -4059,14 +3973,14 @@ public class CaptureModule implements CameraModule, PhotoController, if (value == null || value.equals("0")) return; int intValue = Integer.parseInt(value); - //todo request.set(CaptureModule.INSTANT_AEC_MODE, intValue); + 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); - //todo request.set(CaptureModule.SATURATION, intValue); + request.set(CaptureModule.SATURATION, intValue); } } @@ -4371,7 +4285,7 @@ public class CaptureModule implements CameraModule, PhotoController, } } - private Surface getPreviewSurfaceForSession(int id) { + public Surface getPreviewSurfaceForSession(int id) { if (isBackCamera()) { if (getCameraMode() == DUAL_MODE && id == MONO_ID) { return mUI.getMonoDummySurface(); @@ -4669,57 +4583,6 @@ 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 6ec09effd..d0b129ad9 100755..100644 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -306,8 +306,10 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mMakeupSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) { - int value = progresValue/10*10; - mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, value+""); + if ( progresValue != 0 ) { + int value = 10 + 9 * progresValue / 10; + mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, value + ""); + } } @Override public void onStartTrackingTouch(SeekBar seekBar) { @@ -484,8 +486,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, showFirstTimeHelp(); } - protected void showCapturedImageForReview(byte[] jpegData, int orientation, boolean mirror) { - mDecodeTaskForReview = new CaptureUI.DecodeImageForReview(jpegData, orientation, mirror); + protected void showCapturedImageForReview(byte[] jpegData, int orientation) { + mDecodeTaskForReview = new CaptureUI.DecodeImageForReview(jpegData, orientation); mDecodeTaskForReview.execute(); if (getCurrentIntentMode() != CaptureModule.INTENT_MODE_NORMAL) { if (mFilterMenuStatus == FILTER_MENU_ON) { @@ -1737,24 +1739,18 @@ 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, boolean mirror) { + public DecodeTask(byte[] data, int orientation) { 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 || mMirror) && (bitmap != null)) { + if ((mOrientation != 0) && (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); @@ -1768,8 +1764,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } private class DecodeImageForReview extends CaptureUI.DecodeTask { - public DecodeImageForReview(byte[] data, int orientation, boolean mirror) { - super(data, orientation, mirror); + public DecodeImageForReview(byte[] data, int orientation) { + super(data, orientation); } @Override diff --git a/src/com/android/camera/MediaSaveService.java b/src/com/android/camera/MediaSaveService.java index 6ca37b9e2..217f44f27 100644 --- a/src/com/android/camera/MediaSaveService.java +++ b/src/com/android/camera/MediaSaveService.java @@ -41,6 +41,7 @@ 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; @@ -58,7 +59,8 @@ public class MediaSaveService extends Service { // The memory limit for unsaved image is 50MB. private static final int SAVE_TASK_MEMORY_LIMIT_IN_MB = - android.os.SystemProperties.getInt("persist.camera.perf.memlimit", 60); + PersistUtil.getSaveTaskMemoryLimitInMb(); + 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 4cccf8e94..af796c6a7 100755..100644 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -1181,7 +1181,10 @@ public class SettingsManager implements ListMenu.SettingsListener { public int getHighSpeedVideoEncoderBitRate(CamcorderProfile profile, int targetRate) { int bitRate; String key = profile.videoFrameWidth+"x"+profile.videoFrameHeight+":"+targetRate; - if (CameraSettings.VIDEO_ENCODER_BITRATE.containsKey(key)) { + 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) ) { bitRate = CameraSettings.VIDEO_ENCODER_BITRATE.get(key); } else { Log.i(TAG, "No pre-defined bitrate for "+key); @@ -1394,7 +1397,9 @@ 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 b1b415acd..6b0c97732 100644 --- a/src/com/android/camera/imageprocessor/FrameProcessor.java +++ b/src/com/android/camera/imageprocessor/FrameProcessor.java @@ -401,7 +401,11 @@ public class FrameProcessor { } } else { filter.init(mSize.getWidth(), mSize.getHeight(), stride, stride); - filter.addImage(bY, bVU, 0, new Boolean(true)); + if (filter instanceof BeautificationFilter) { + filter.addImage(bY, bVU, 0, new Boolean(false)); + } else { + filter.addImage(bY, bVU, 0, new Boolean(true)); + } needToFeedSurface = true; } bY.rewind(); @@ -485,7 +489,11 @@ public class FrameProcessor { mBY.rewind(); mBVU.rewind(); mFilter.init(mWidth, mHeight, mStride, mStride); - mFilter.addImage(mBY, mBVU, 0, new Boolean(true)); + if (mFilter instanceof BeautificationFilter) { + mFilter.addImage(mBY, mBVU, 0, new Boolean(false)); + } else { + 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 6e34de96d..d70743be9 100644 --- a/src/com/android/camera/imageprocessor/PostProcessor.java +++ b/src/com/android/camera/imageprocessor/PostProcessor.java @@ -391,6 +391,7 @@ 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); } @@ -405,11 +406,13 @@ 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()); } @@ -561,17 +564,20 @@ 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) { @@ -672,6 +678,7 @@ 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)) @@ -1091,8 +1098,7 @@ public class PostProcessor{ if (mController.isQuickCapture()) { mController.onCaptureDone(); } else { - mController.showCapturedReview( - bytes, mOrientation, isSelfieMirrorOn()); + mController.showCapturedReview(bytes, mOrientation); } } mActivity.getMediaSaveService().addImage( @@ -1166,8 +1172,7 @@ public class PostProcessor{ if (mController.isQuickCapture()) { mController.onCaptureDone(); } else { - mController.showCapturedReview(bytes, - orientation, isSelfieMirrorOn()); + mController.showCapturedReview(bytes, orientation); } } else { mActivity.getMediaSaveService().addImage( @@ -1204,7 +1209,7 @@ public class PostProcessor{ return quality; } - public static class BitmapOutputStream extends ByteArrayOutputStream { + private 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 c9ecb79a2..0509b8fb5 100644 --- a/src/com/android/camera/imageprocessor/ZSLQueue.java +++ b/src/com/android/camera/imageprocessor/ZSLQueue.java @@ -42,9 +42,7 @@ import java.util.LinkedList; import java.util.NoSuchElementException; public class ZSLQueue { - 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 int mCircularBufferSize; private ImageItem[] mBuffer; private int mImageHead; private int mMetaHead; @@ -56,7 +54,7 @@ public class ZSLQueue { private static final String TAG = "ZSLQueue"; public ZSLQueue(CaptureModule module) { - mCircularBufferSize = SystemProperties.getInt(CIRCULAR_BUFFER_SIZE_PERSIST, CIRCULAR_BUFFER_SIZE_DEFAULT); + mCircularBufferSize = PersistUtil.getCircularBufferSize(); 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 607908ebf..4682e3947 100644 --- a/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java +++ b/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java @@ -32,8 +32,10 @@ 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; @@ -155,20 +157,33 @@ 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); - 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); + 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) { captureSession.capture(builder.build(), callback, handler); + waitForImage(i); } 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) { @@ -190,6 +205,41 @@ 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 3b6d10541..81be61f81 100755..100644 --- a/src/com/android/camera/ui/Camera2FaceView.java +++ b/src/com/android/camera/ui/Camera2FaceView.java @@ -151,7 +151,9 @@ 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 b617891e5..04b3664eb 100755..100644 --- a/src/com/android/camera/ui/FaceView.java +++ b/src/com/android/camera/ui/FaceView.java @@ -33,14 +33,17 @@ 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 = false; + 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); // 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 3b0d5e6ac..d6c1956d9 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 = SystemProperties.get("camera.display.umax", ""); - String lMax = SystemProperties.get("camera.display.lmax", ""); + String uMax = PersistUtil.getDisplayUMax(); + String lMax = PersistUtil.getDisplayLMax(); 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 8c1b57e98..976389ea2 100644 --- a/src/com/android/camera/util/PersistUtil.java +++ b/src/com/android/camera/util/PersistUtil.java @@ -28,20 +28,32 @@ */ 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 int PERSIST_CAMERA_PREVIEW_SIZE = - SystemProperties.getInt("persist.vendor.camera.preview.size", 0); + private static final String PERSIST_CAMERA_PREVIEW_SIZE = + SystemProperties.get("persist.vendor.camera.preview.size", ""); 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 = @@ -56,10 +68,59 @@ 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); - - 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 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 int getMemoryLimit() { return PERSIST_MEMORY_LIMIT; @@ -72,15 +133,31 @@ 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 int getCameraPreviewSize() { - return PERSIST_CAMERA_PREVIEW_SIZE; + 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 boolean getCamera2Mode() { return PERSIST_CAMERA_CAMERA2; } + public static boolean getCameraZSLDisabled() { + return PERSIST_CAMERA_ZSL; + } + public static int getCamera2Debug() { return PERSIST_CAMERA_DEBUG; } @@ -110,4 +187,115 @@ 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; + } + } |