diff options
author | Vijay kumar Tumati <vtumati@codeaurora.org> | 2015-04-13 15:36:33 +0530 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2017-01-04 22:00:39 +0200 |
commit | 60c675810105f384952aad682243265a189f38d9 (patch) | |
tree | 17f497c14eca241984f7d9b588005860c03449b2 /src/com/android/camera/PhotoModule.java | |
parent | c0baee603dde98bc93fc70d67501fb99a3e90837 (diff) | |
download | android_packages_apps_Snap-60c675810105f384952aad682243265a189f38d9.tar.gz android_packages_apps_Snap-60c675810105f384952aad682243265a189f38d9.tar.bz2 android_packages_apps_Snap-60c675810105f384952aad682243265a189f38d9.zip |
SnapdragonCamera: Longshot with Burst Functionality.
This is a new Longshot feature where in the snapshot frames
captured at ISP is @ 3fps and output JPEG encoded rate is @ 1.2 fps.
This can be enabled by setting following setprop with
the maximum number of snapshots.
adb shell setprop persist.camera.longshot.max <max_number>
e.g.:adb shell setprop persist.camera.longshot.max 10
If the number is -1, then the existing Longshot will be used.
Main changes:
1) The number of Snapshot/Preview/Metadata buffers are increased to
make sure no frames will be dropped @ ISP and to maintain burst fps.
e.g.: For max number of 10 snapshots, Snapshot buffers are increased to 9
from existing 6.
This buffer numbers are derived considering snapshot YUV frames @ 3 fps
and JPEG encoding @ 1.2 fps.
2) Shutter will be played after receiving YUV frame instead of reprocess frame.
3) New Longshot stop command is sent after receiving all the required YUV
callbacks or releasing the shutter before reaching Max number.
4) Existing Longshot off command is sent after receiving all JPEG CB.s for the issued
TakePictures() and also shutter button will be disabled until all the JPEG
callbacks are received.
Change-Id: Id0c21aeb67245530768bf3ab859d39dea7e2bc40
Diffstat (limited to 'src/com/android/camera/PhotoModule.java')
-rwxr-xr-x | src/com/android/camera/PhotoModule.java | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 3ebc460b8..e46c323da 100755 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -128,6 +128,7 @@ public class PhotoModule private int mSnapshotMode; private int mBurstSnapNum = 1; private int mReceivedSnapNum = 0; + private int mLongshotSnapNum = 0; public boolean mFaceDetectionEnabled = false; private boolean mLgeHdrMode = false; public boolean mHistogramEnabled = false; @@ -215,6 +216,8 @@ public class PhotoModule private static final String PERSIST_CAPTURE_ANIMATION = "persist.camera.capture.animate"; private static final boolean PERSIST_SKIP_MEM_CHECK = android.os.SystemProperties.getBoolean("persist.camera.perf.skip_memck", false); + private static final String PERSIST_LONGSHOT_MAX_SNAP = "persist.camera.longshot.max"; + private static int mLongShotMaxSnap = -1; // Constant from android.hardware.Camera.Parameters private static final String KEY_PICTURE_FORMAT = "picture-format"; @@ -1065,8 +1068,17 @@ public class PhotoModule Log.e(TAG, "[KPI Perf] PROFILE_SHUTTER_LAG mShutterLag = " + mShutterLag + "ms"); synchronized(mCameraDevice) { + if (++mLongshotSnapNum >= mLongShotMaxSnap && + (mLongShotMaxSnap != -1)) { + mLongshotActive = false; + mUI.enableShutter(false); + mCameraDevice.stopLongshot(); + return; + } + if (mCameraState != LONGSHOT || !mLongshotActive) { + mCameraDevice.stopLongshot(); return; } @@ -1276,7 +1288,9 @@ public class PhotoModule @Override public void onPictureTaken(byte [] jpegData, CameraProxy camera) { mUI.stopSelfieFlash(); - mUI.enableShutter(true); + if (mCameraState != LONGSHOT) { + mUI.enableShutter(true); + } if (mUI.isPreviewCoverVisible()) { // When take picture request is sent before starting preview, onPreviewFrame() // callback doesn't happen so removing preview cover here, instead. @@ -1339,12 +1353,17 @@ public class PhotoModule Log.v(TAG, "mPictureDisplayedToJpegCallbackTime = " + mPictureDisplayedToJpegCallbackTime + "ms"); + if (isLongshotDone()) { + mCameraDevice.setLongshot(false); + } + boolean needRestartPreview = !mIsImageCaptureIntent && !mPreviewRestartSupport && (mCameraState != LONGSHOT) && (mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL) - && (mReceivedSnapNum == mBurstSnapNum); + && ((mReceivedSnapNum == mBurstSnapNum) && (mCameraState != LONGSHOT)); + needRestartPreview |= (isLongshotDone() && !mFocusManager.isZslEnabled()); needRestartPreview |= mLgeHdrMode && (mCameraState != LONGSHOT); boolean backCameraRestartPreviewOnPictureTaken = false; @@ -1371,8 +1390,8 @@ public class PhotoModule || CameraUtil.FOCUS_MODE_MW_CONTINUOUS_PICTURE.equals(mFocusManager.getFocusMode(false))) { mCameraDevice.cancelAutoFocus(); } - } else if ((mReceivedSnapNum == mBurstSnapNum) - && (mCameraState != LONGSHOT)){ + } else if (((mCameraState != LONGSHOT) && (mReceivedSnapNum == mBurstSnapNum)) + || isLongshotDone()){ mFocusManager.restartTouchFocusTimer(); if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusManager.getFocusMode(false)) || CameraUtil.FOCUS_MODE_MW_CONTINUOUS_PICTURE.equals(mFocusManager.getFocusMode(false))) { @@ -1474,7 +1493,8 @@ public class PhotoModule } } // Animate capture with real jpeg data instead of a preview frame. - if (mCameraState != LONGSHOT) { + if ((mCameraState != LONGSHOT) || + isLongshotDone()) { Size pic_size = mParameters.getPictureSize(); if ((pic_size.width <= 352) && (pic_size.height<= 288)) { mUI.setDownFactor(2); //Downsample by 2 for CIF & below @@ -1521,6 +1541,10 @@ public class PhotoModule mJpegPictureCallbackTime = 0; } + if (isLongshotDone()) { + mLongshotSnapNum = 0; + } + if (mHistogramEnabled && (mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL)) { mActivity.runOnUiThread(new Runnable() { @@ -1672,6 +1696,7 @@ public class PhotoModule } if (mCameraState == LONGSHOT) { + mLongshotSnapNum = 0; mCameraDevice.setLongshot(true); } @@ -2295,20 +2320,7 @@ public class PhotoModule synchronized(mCameraDevice) { if (mCameraState == LONGSHOT) { mLongshotActive = false; - mCameraDevice.setLongshot(false); - mUI.animateCapture(mLastJpegData); - mLastJpegData = null; - if (!mFocusManager.isZslEnabled()) { - setupPreview(); - } else { - setCameraState(IDLE); - mFocusManager.resetTouchFocus(); - if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals( - mFocusManager.getFocusMode(false))) { - mCameraDevice.cancelAutoFocus(); - } - mUI.resumeFaceDetection(); - } + mUI.enableShutter(false); } } @@ -2545,7 +2557,7 @@ public class PhotoModule private void updateRemainingPhotos() { if (mJpegFileSizeEstimation != 0) { - mRemainingPhotos = (int) + mRemainingPhotos = (int) ((mActivity.getStorageSpaceBytes() - Storage.LOW_STORAGE_THRESHOLD_BYTES) / mJpegFileSizeEstimation); } else { @@ -3006,6 +3018,10 @@ public class PhotoModule @Override public void stopPreview() { if (mCameraDevice != null && mCameraState != PREVIEW_STOPPED) { + if (mCameraState == LONGSHOT) { + mCameraDevice.setLongshot(false); + mLongshotActive = false; + } Log.v(TAG, "stopPreview"); mCameraDevice.stopPreview(); } @@ -3693,6 +3709,9 @@ public class PhotoModule !mFocusManager.isFocusCompleted()) { mUI.getFocusRing().stopFocusAnimations(); } + + mLongShotMaxSnap = SystemProperties.getInt(PERSIST_LONGSHOT_MAX_SNAP, -1); + mParameters.set("max-longshot-snap",mLongShotMaxSnap); } private int estimateJpegFileSize(final Size size, final String quality) { @@ -5044,6 +5063,10 @@ public class PhotoModule enableRecordingLocation(false); } + public boolean isLongshotDone() { + return ((mCameraState == LONGSHOT) && (mLongshotSnapNum == mReceivedSnapNum) && + !mLongshotActive); + } } /* Below is no longer needed, except to get rid of compile error |