summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/util
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2013-09-23 21:30:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-23 21:30:33 +0000
commit4c478ffe556bff91f9c7574384ab6d482c947627 (patch)
treef921d6d755b7581bfeced1fad40dddc37777508c /src/com/android/camera/util
parent283beaf677d0c3235fbb22bfd5cd8338459bed1b (diff)
parent16a35206473b5a49821edccea93bbde54c52be49 (diff)
downloadandroid_packages_apps_Snap-4c478ffe556bff91f9c7574384ab6d482c947627.tar.gz
android_packages_apps_Snap-4c478ffe556bff91f9c7574384ab6d482c947627.tar.bz2
android_packages_apps_Snap-4c478ffe556bff91f9c7574384ab6d482c947627.zip
Merge "Sort and select the preview fps range for still image." into gb-ub-photos-carlsbad
Diffstat (limited to 'src/com/android/camera/util')
-rw-r--r--src/com/android/camera/util/CameraUtil.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index fc80c5c3e..3ce19b561 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -72,6 +72,10 @@ import java.util.StringTokenizer;
public class CameraUtil {
private static final String TAG = "Util";
+ // For calculate the best fps range for still image capture.
+ private final static int MAX_PREVIEW_FPS_TIMES_1000 = 400000;
+ private final static int PREFERRED_PREVIEW_FPS_TIMES_1000 = 30000;
+
// For creating crop intents.
public static final String KEY_RETURN_DATA = "return-data";
public static final String KEY_SHOW_WHEN_LOCKED = "showWhenLocked";
@@ -746,6 +750,54 @@ public class CameraUtil {
}
}
+ /**
+ * For still image capture, we need to get the right fps range such that the
+ * camera can slow down the framerate to allow for less-noisy/dark
+ * viewfinder output in dark conditions.
+ *
+ * @param params Camera's parameters.
+ * @return null if no appropiate fps range can't be found. Otherwise, return
+ * the right range.
+ */
+ public static int[] getPhotoPreviewFpsRange(Parameters params) {
+ List<int[]> frameRates = params.getSupportedPreviewFpsRange();
+ if (frameRates.size() == 0) {
+ Log.e(TAG, "No suppoted frame rates returned!");
+ return null;
+ }
+
+ // Find the lowest min rate in supported ranges who can cover 30fps.
+ int lowestMinRate = MAX_PREVIEW_FPS_TIMES_1000;
+ for (int[] rate : frameRates) {
+ int minFps = rate[Parameters.PREVIEW_FPS_MIN_INDEX];
+ int maxFps = rate[Parameters.PREVIEW_FPS_MAX_INDEX];
+ if (maxFps >= PREFERRED_PREVIEW_FPS_TIMES_1000 &&
+ minFps <= PREFERRED_PREVIEW_FPS_TIMES_1000 &&
+ minFps < lowestMinRate) {
+ lowestMinRate = minFps;
+ }
+ }
+
+ // Find all the modes with the lowest min rate found above, the pick the
+ // one with highest max rate.
+ int resultIndex = -1;
+ int highestMaxRate = 0;
+ for (int i = 0; i < frameRates.size(); i++) {
+ int[] rate = frameRates.get(i);
+ int minFps = rate[Parameters.PREVIEW_FPS_MIN_INDEX];
+ int maxFps = rate[Parameters.PREVIEW_FPS_MAX_INDEX];
+ if (minFps == lowestMinRate && highestMaxRate < maxFps) {
+ highestMaxRate = maxFps;
+ resultIndex = i;
+ }
+ }
+
+ if (resultIndex >= 0) {
+ return frameRates.get(resultIndex);
+ }
+ Log.e(TAG, "Can't find an appropiate frame rate range!");
+ return null;
+ }
public static int[] getMaxPreviewFpsRange(Parameters params) {
List<int[]> frameRates = params.getSupportedPreviewFpsRange();