summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorsatyavaraprasad yerramsetti <satyav@codeaurora.org>2014-10-31 15:01:39 +0530
committersatyavaraprasad yerramsetti <satyav@codeaurora.org>2014-10-31 17:38:34 +0530
commitc2248d747619ddc2f2c6521e5c755961ed031767 (patch)
treedfb2dd35a0fb9a72e20e0fa593107690d1e3e0d2 /src/com
parent6c20d314ec43be447e9a2bfb17e96452d996a18b (diff)
downloadandroid_packages_apps_Snap-c2248d747619ddc2f2c6521e5c755961ed031767.tar.gz
android_packages_apps_Snap-c2248d747619ddc2f2c6521e5c755961ed031767.tar.bz2
android_packages_apps_Snap-c2248d747619ddc2f2c6521e5c755961ed031767.zip
SnapdragonCamera: Add OptimalJpegThumbnailSize selction logic in APP.
- Set a jpegthumbnail size that is closest to the Picture height and has the right aspect ratio. - Earlier this logic was implemented in HAL but due to CTS2 testJpegExif failure, moving this to APP CRs-Fixed: 748114 Change-Id: Ia2c97bf8cec7198ee291e63c3be9bbe5fb18b3b7
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/PhotoModule.java14
-rwxr-xr-xsrc/com/android/camera/VideoModule.java13
-rw-r--r--src/com/android/camera/util/CameraUtil.java32
3 files changed, 59 insertions, 0 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index cefdeaea6..f7b2e4945 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -3102,6 +3102,20 @@ public class PhotoModule
}
Log.v(TAG, "Preview size is " + optimalSize.width + "x" + optimalSize.height);
+ size = mParameters.getPictureSize();
+
+ // Set jpegthumbnail size
+ // Set a jpegthumbnail size that is closest to the Picture height and has
+ // the right aspect ratio.
+ List<Size> supported = mParameters.getSupportedJpegThumbnailSizes();
+ optimalSize = CameraUtil.getOptimalJpegThumbnailSize(supported,
+ (double) size.width / size.height);
+ original = mParameters.getJpegThumbnailSize();
+ if (!original.equals(optimalSize)) {
+ mParameters.setJpegThumbnailSize(optimalSize.width, optimalSize.height);
+ }
+
+ Log.v(TAG, "Thumbnail size is " + optimalSize.width + "x" + optimalSize.height);
// Since changing scene mode may change supported values, set scene mode
// first. HDR is a scene mode. To promote it in UI, it is stored in a
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 651a3e3a6..eace13fa4 100755
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -2303,6 +2303,19 @@ public class VideoModule implements CameraModule,
Log.v(TAG, "Video snapshot size is " + optimalSize.width + "x" +
optimalSize.height);
+ // Set jpegthumbnail size
+ // Set a jpegthumbnail size that is closest to the Picture height and has
+ // the right aspect ratio.
+ Size size = mParameters.getPictureSize();
+ List<Size> sizes = mParameters.getSupportedJpegThumbnailSizes();
+ optimalSize = CameraUtil.getOptimalJpegThumbnailSize(sizes,
+ (double) size.width / size.height);
+ original = mParameters.getJpegThumbnailSize();
+ if (!original.equals(optimalSize)) {
+ mParameters.setJpegThumbnailSize(optimalSize.width, optimalSize.height);
+ }
+ Log.v(TAG, "Thumbnail size is " + optimalSize.width + "x" + optimalSize.height);
+
// Set JPEG quality.
int jpegQuality = CameraProfile.getJpegEncodingQualityParameter(mCameraId,
CameraProfile.QUALITY_HIGH);
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index cfddf957e..4cfc211bc 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -567,6 +567,38 @@ public class CameraUtil {
return optimalSize;
}
+
+ // Returns the largest thumbnail size which matches the given aspect ratio.
+ public static Size getOptimalJpegThumbnailSize(
+ 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 thumbnail 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, ";");