summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/util
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2013-09-23 11:35:36 -0700
committerztenghui <ztenghui@google.com>2013-09-23 13:44:56 -0700
commit16a35206473b5a49821edccea93bbde54c52be49 (patch)
tree1301c8d3e6b48f958ead40aa57389c99514176b5 /src/com/android/camera/util
parentaa8744284864cda5570e8dfa4eccc2747cee52dc (diff)
downloadandroid_packages_apps_Snap-16a35206473b5a49821edccea93bbde54c52be49.tar.gz
android_packages_apps_Snap-16a35206473b5a49821edccea93bbde54c52be49.tar.bz2
android_packages_apps_Snap-16a35206473b5a49821edccea93bbde54c52be49.zip
Sort and select the preview fps range for still image.
bug:10842868 Change-Id: Ic7d64aead7fd877e2c404d22ce42fd2d3566e57b
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 bb72ba70c..2c9a0597d 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();