summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-05-09 18:35:53 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-21 18:45:51 -0700
commit1fea7d5bb3dd45caf29e90be2e9eae2646567a10 (patch)
treebd3059bba91264f649251456ce06789e38667818 /src/com
parent67f8bccf87818e7ea124fa733c56894030ee5951 (diff)
downloadandroid_packages_apps_Snap-1fea7d5bb3dd45caf29e90be2e9eae2646567a10.zip
android_packages_apps_Snap-1fea7d5bb3dd45caf29e90be2e9eae2646567a10.tar.gz
android_packages_apps_Snap-1fea7d5bb3dd45caf29e90be2e9eae2646567a10.tar.bz2
SnapdragonCamera: Enable jpeg encoding via reprocess
Enable JPEG encoding via reprocess request for ClearSight routine. Add support for dumping images in NV21 format using persist.camera.cs.dumpyuv CRs-Fixed: 993611 Change-Id: I51ff59ec45bb37059a16197186a9f90bc52554f1
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/CaptureModule.java55
-rw-r--r--src/com/android/camera/MediaSaveService.java59
2 files changed, 32 insertions, 82 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 6bb1695..90e1794 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -750,12 +750,11 @@ public class CaptureModule implements CameraModule, PhotoController,
} else {
// No Clearsight
captureBuilder = mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
-
- // Orientation
- int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
- captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
}
+ // Orientation
+ int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
+ captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
captureBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
captureBuilder.addTarget(getPreviewSurface(id));
captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
@@ -855,7 +854,8 @@ public class CaptureModule implements CameraModule, PhotoController,
Size largest = Collections.max(
Arrays.asList(map.getOutputSizes(ImageFormat.YUV_420_888)),
new CompareSizesByArea());
- ClearSightImageProcessor.getInstance().init(largest.getWidth(), largest.getHeight(), mActivity);
+ ClearSightImageProcessor.getInstance().init(
+ largest.getWidth(), largest.getHeight(), mActivity, mOnMediaSavedListener);
ClearSightImageProcessor.getInstance().setCallback(this);
} else {
// No Clearsight
@@ -1345,6 +1345,10 @@ public class CaptureModule implements CameraModule, PhotoController,
public void onMediaSaveServiceConnected(MediaSaveService s) {
if (mFirstTimeInitialized) {
s.setListener(this);
+ ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CLEARSIGHT);
+ if(pref.getValue().equals(mActivity.getString(R.string.pref_camera_clearsight_value_on))) {
+ ClearSightImageProcessor.getInstance().setMediaSaveService(s);
+ }
}
}
@@ -1655,18 +1659,8 @@ public class CaptureModule implements CameraModule, PhotoController,
}
@Override
- public void onClearSightSuccess(ClearsightImage csImage, YuvImage bayer, YuvImage mono) {
- Log.d(TAG, "reprocess - processClearSight success");
- mNamedImages.nameNewImage(System.currentTimeMillis());
- NamedEntity name = mNamedImages.getNextNameEntity();
- String title = (name == null) ? null : name.title;
- long date = (name == null) ? -1 : name.date;
-
- mActivity.getMediaSaveService().addMpoImage(
- csImage, bayer, mono, null, null, title,
- date, null, 0, mOnMediaSavedListener, mContentResolver,
- "jpeg");
-
+ public void onClearSightSuccess() {
+ Log.d(TAG, "onClearSightSuccess");
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -1680,21 +1674,8 @@ public class CaptureModule implements CameraModule, PhotoController,
}
@Override
- public void onClearSightFailure(YuvImage bayer, YuvImage mono) {
- if(bayer != null && mono != null) {
- Log.d(TAG, "reprocess - processClearSight fail");
- mNamedImages.nameNewImage(System.currentTimeMillis());
- NamedEntity name = mNamedImages.getNextNameEntity();
- String title = (name == null) ? null : name.title;
- long date = (name == null) ? -1 : name.date;
-
- Log.d(TAG, "reprocess - saving with bayer + mono mpo");
-
- mActivity.getMediaSaveService().addMpoImage(null,
- bayer, mono, null, null, title, date, null, 0,
- mOnMediaSavedListener, mContentResolver, "jpeg");
- }
-
+ public void onClearSightFailure() {
+ Log.d(TAG, "onClearSightFailure");
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -1706,14 +1687,4 @@ public class CaptureModule implements CameraModule, PhotoController,
unlockFocus(BAYER_ID);
unlockFocus(MONO_ID);
}
-
- @Override
- public CameraCaptureSession onReprocess(boolean bayer) {
- return mCaptureSession[bayer?BAYER_ID:MONO_ID];
- }
-
- @Override
- public MediaSaveService getMediaSaveService() {
- return mActivity.getMediaSaveService();
- }
}
diff --git a/src/com/android/camera/MediaSaveService.java b/src/com/android/camera/MediaSaveService.java
index 3c5dbe5..58ebc11 100644
--- a/src/com/android/camera/MediaSaveService.java
+++ b/src/com/android/camera/MediaSaveService.java
@@ -16,7 +16,6 @@
package com.android.camera;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.ByteOrder;
@@ -25,9 +24,6 @@ import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.graphics.BitmapFactory;
-import android.graphics.Rect;
-import android.graphics.YuvImage;
-import android.hardware.camera2.TotalCaptureResult;
import android.location.Location;
import android.net.Uri;
import android.os.AsyncTask;
@@ -36,13 +32,7 @@ import android.os.IBinder;
import android.provider.MediaStore.Video;
import android.util.Log;
-import com.android.camera.PhotoModule;
import com.android.camera.exif.ExifInterface;
-
-import java.io.File;
-
-import org.codeaurora.snapcam.filter.ClearSightNativeEngine.ClearsightImage;
-
import com.android.camera.mpo.MpoData;
import com.android.camera.mpo.MpoImageData;
import com.android.camera.mpo.MpoInterface;
@@ -99,9 +89,9 @@ public class MediaSaveService extends Service {
return (mMemoryUse >= SAVE_TASK_MEMORY_LIMIT);
}
- public void addMpoImage(final ClearsightImage csImage,
- final YuvImage bayerImg, final YuvImage monoImg,
- TotalCaptureResult bayerResult, TotalCaptureResult monoResult,
+ public void addMpoImage(final byte[] csImage,
+ final byte[] bayerImg, final byte[] monoImg,
+ int width, int height,
String title, long date, Location loc, int orientation,
OnMediaSavedListener l, ContentResolver resolver,
String pictureFormat) {
@@ -111,12 +101,12 @@ public class MediaSaveService extends Service {
}
MpoSaveTask t = new MpoSaveTask(csImage, bayerImg, monoImg,
- bayerResult, monoResult, title, date, loc, orientation, l,
+ width, height, title, date, loc, orientation, l,
resolver, pictureFormat);
long size = (csImage == null ? 0
- : csImage.getDataLength())
- + bayerImg.getYuvData().length + monoImg.getYuvData().length;
+ : csImage.length)
+ + bayerImg.length + monoImg.length;
mMemoryUse += size;
if (isQueueFull()) {
onQueueFull();
@@ -179,23 +169,20 @@ public class MediaSaveService extends Service {
}
private class MpoSaveTask extends AsyncTask<Void, Void, Uri> {
- private ClearsightImage csImage;
- private YuvImage bayerImage;
- private YuvImage monoImage;
+ private byte[] csImage;
+ private byte[] bayerImage;
+ private byte[] monoImage;
private String title;
private long date;
private Location loc;
private int width, height;
private int orientation;
- private TotalCaptureResult bayerResult;
- private TotalCaptureResult monoResult;
private ContentResolver resolver;
private OnMediaSavedListener listener;
private String pictureFormat;
- public MpoSaveTask(ClearsightImage csImage, YuvImage bayerImg,
- YuvImage monoImg, TotalCaptureResult bayerResult,
- TotalCaptureResult monoResult, String title, long date,
+ public MpoSaveTask(byte[] csImage, byte[] bayerImg,
+ byte[] monoImg, int width, int height, String title, long date,
Location loc, int orientation, OnMediaSavedListener listener,
ContentResolver resolver, String pictureFormat) {
this.csImage = csImage;
@@ -204,11 +191,9 @@ public class MediaSaveService extends Service {
this.title = title;
this.date = date;
this.loc = loc;
- this.width = bayerImg.getWidth();
- this.height = bayerImg.getHeight();
+ this.width = width;
+ this.height = height;
this.orientation = orientation;
- this.bayerResult = bayerResult;
- this.monoResult = monoResult;
this.resolver = resolver;
this.listener = listener;
this.pictureFormat = pictureFormat;
@@ -218,23 +203,17 @@ public class MediaSaveService extends Service {
protected Uri doInBackground(Void... v) {
// encode jpeg and add exif for all images
MpoData mpo = new MpoData();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- bayerImage.compressToJpeg(new Rect(0, 0, bayerImage.getWidth(),
- bayerImage.getHeight()), 100, baos);
- MpoImageData bayer = new MpoImageData(baos.toByteArray(),
+ MpoImageData bayer = new MpoImageData(bayerImage,
ByteOrder.BIG_ENDIAN);
- baos.reset();
- monoImage.compressToJpeg(new Rect(0, 0, monoImage.getWidth(),
- monoImage.getHeight()), 100, baos);
- MpoImageData mono = new MpoImageData(baos.toByteArray(),
+ MpoImageData mono = new MpoImageData(monoImage,
ByteOrder.BIG_ENDIAN);
if (csImage == null) {
mpo.addAuxiliaryMpoImage(mono);
mpo.setPrimaryMpoImage(bayer);
} else {
- MpoImageData cs = new MpoImageData(csImage.compressToJpeg(),
+ MpoImageData cs = new MpoImageData(csImage,
ByteOrder.BIG_ENDIAN);
mpo.addAuxiliaryMpoImage(bayer);
@@ -260,9 +239,9 @@ public class MediaSaveService extends Service {
listener.onMediaSaved(uri);
boolean previouslyFull = isQueueFull();
long size = (csImage == null ? 0
- : csImage.getDataLength())
- + bayerImage.getYuvData().length
- + monoImage.getYuvData().length;
+ : csImage.length)
+ + bayerImage.length
+ + monoImage.length;
mMemoryUse -= size;
if (isQueueFull() != previouslyFull)
onQueueAvailable();