summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2011-11-04 11:59:19 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2011-11-04 11:59:19 +0000
commit3300723ee68dfb28871fcf30864d2f73946ab660 (patch)
tree578ea8ee0bc5285ae6f0bfcbe8b08d1a84a94b22 /src
parentc661613fc809c9623327408d052221f81dac0dfd (diff)
parent93b9c8aca92b2a6a651c562c71b8c414458c1419 (diff)
downloadLegacyCamera-3300723ee68dfb28871fcf30864d2f73946ab660.zip
LegacyCamera-3300723ee68dfb28871fcf30864d2f73946ab660.tar.gz
LegacyCamera-3300723ee68dfb28871fcf30864d2f73946ab660.tar.bz2
am 93b9c8ac: Merge "5554028: Select video snapshot resolution based on the video recording aspect ratio." into ics-mr0
* commit '93b9c8aca92b2a6a651c562c71b8c414458c1419': 5554028: Select video snapshot resolution based on the video recording aspect ratio.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Util.java31
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java21
2 files changed, 43 insertions, 9 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 21d97c3..ba8a4f7 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -413,6 +413,37 @@ public class Util {
return optimalSize;
}
+ // Returns the largest picture size which matches the given aspect ratio.
+ public static Size getOptimalVideoSnapshotPictureSize(
+ List<Size> sizes, double targetRatio) {
+ // Use a very small tolerance because we want an exact match.
+ final double ASPECT_TOLERANCE = 0.001;
+ if (sizes == null) return null;
+
+ Size optimalSize = null;
+
+ // Try to find a size matches aspect ratio and has the largest width
+ for (Size size : sizes) {
+ double ratio = (double) size.width / size.height;
+ if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
+ if (optimalSize == null || size.width > optimalSize.width) {
+ optimalSize = size;
+ }
+ }
+
+ // 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 (optimalSize == null || size.width > optimalSize.width) {
+ optimalSize = size;
+ }
+ }
+ }
+ return optimalSize;
+ }
+
public static void dumpParameters(Parameters parameters) {
String flattened = parameters.flatten();
StringTokenizer tokenizer = new StringTokenizer(flattened, ";");
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 2cc07a5..0b946c4 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -1914,15 +1914,18 @@ public class VideoCamera extends ActivityBase
}
// Set picture size.
- String pictureSize = mPreferences.getString(
- CameraSettings.KEY_PICTURE_SIZE, null);
- if (pictureSize == null) {
- CameraSettings.initialCameraPictureSize(this, mParameters);
- } else {
- List<Size> supported = mParameters.getSupportedPictureSizes();
- CameraSettings.setCameraPictureSize(
- pictureSize, supported, mParameters);
- }
+ // The logic here is different from the logic in still-mode camera.
+ // There we determine the preview size based on the picture size, but
+ // here we determine the picture size based on the preview size.
+ List<Size> supported = mParameters.getSupportedPictureSizes();
+ Size optimalSize = Util.getOptimalVideoSnapshotPictureSize(supported,
+ (double) mDesiredPreviewWidth / mDesiredPreviewHeight);
+ Size original = mParameters.getPictureSize();
+ if (!original.equals(optimalSize)) {
+ mParameters.setPictureSize(optimalSize.width, optimalSize.height);
+ }
+ Log.v(TAG, "Video snapshot size is " + optimalSize.width + "x" +
+ optimalSize.height);
// Set JPEG quality.
int jpegQuality = CameraProfile.getJpegEncodingQualityParameter(mCameraId,