diff options
Diffstat (limited to 'src')
7 files changed, 264 insertions, 107 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 591926738..2c7b4de34 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -182,7 +182,7 @@ public class CaptureModule implements CameraModule, PhotoController, private static final int CANCEL_TOUCH_FOCUS_DELAY = PersistUtil.getCancelTouchFocusDelay(); private static final int OPEN_CAMERA = 0; private static final int CANCEL_TOUCH_FOCUS = 1; - private static final int MAX_NUM_CAM = 6; + private static final int MAX_NUM_CAM = 16; private String DEPTH_CAM_ID; private static final MeteringRectangle[] ZERO_WEIGHT_3A_REGION = new MeteringRectangle[]{ new MeteringRectangle(0, 0, 0, 0, 0)}; @@ -494,9 +494,12 @@ public class CaptureModule implements CameraModule, PhotoController, */ private ImageReader[] mImageReader = new ImageReader[MAX_NUM_CAM]; private ImageReader[] mRawImageReader = new ImageReader[MAX_NUM_CAM]; - private Surface mHeifInput; - private HeifWriter mHeifWriter; - private String mHeifPath; + private HeifWriter mInitHeifWriter; + private OutputConfiguration mHeifOutput; + private HeifImage mHeifImage; + private HeifWriter mLiveShotInitHeifWriter; + private OutputConfiguration mLiveShotOutput; + private HeifImage mLiveShotImage; private NamedImages mNamedImages; private ContentResolver mContentResolver; private byte[] mLastJpegData; @@ -1571,9 +1574,17 @@ public class CaptureModule implements CameraModule, PhotoController, if (mSaveRaw) { list.add(mRawImageReader[id].getSurface()); } + + List<OutputConfiguration> outputConfigurations = null; if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT ) { - if (mHeifWriter != null && mHeifInput != null) { - list.add(mHeifInput); + outputConfigurations = new ArrayList<OutputConfiguration>(); + if (mInitHeifWriter != null) { + for (Surface s : list) { + outputConfigurations.add(new OutputConfiguration(s)); + } + mHeifOutput = new OutputConfiguration(mInitHeifWriter.getInputSurface()); + mHeifOutput.enableSurfaceSharing(); + outputConfigurations.add(mHeifOutput); } } if(mChosenImageFormat == ImageFormat.YUV_420_888 || mChosenImageFormat == ImageFormat.PRIVATE) { @@ -1586,10 +1597,22 @@ public class CaptureModule implements CameraModule, PhotoController, mCameraDevice[id].createReprocessableCaptureSession(new InputConfiguration(mImageReader[id].getWidth(), mImageReader[id].getHeight(), mImageReader[id].getImageFormat()), list, captureSessionCallback, null); } else { - mCameraDevice[id].createCaptureSession(list, captureSessionCallback, null); + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT && + outputConfigurations != null) { + mCameraDevice[id].createCaptureSessionByOutputConfigurations(outputConfigurations, + captureSessionCallback,null); + } else { + mCameraDevice[id].createCaptureSession(list, captureSessionCallback, null); + } } } else { - mCameraDevice[id].createCaptureSession(list, captureSessionCallback, null); + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT && + outputConfigurations != null) { + mCameraDevice[id].createCaptureSessionByOutputConfigurations(outputConfigurations, + captureSessionCallback, null); + } else { + mCameraDevice[id].createCaptureSession(list, captureSessionCallback, null); + } } } else { if (surface != null) { @@ -1825,6 +1848,7 @@ public class CaptureModule implements CameraModule, PhotoController, Log.d(TAG, "takePicture"); mUI.enableShutter(false); if (mSettingsManager.isZSLInHALEnabled()&& + !isFlashOn(getMainCameraId())&& mPreviewCaptureResult.get(CaptureResult.CONTROL_AE_STATE) != CameraMetadata.CONTROL_AE_STATE_FLASH_REQUIRED) { takeZSLPictureInHAL(); @@ -2106,7 +2130,10 @@ public class CaptureModule implements CameraModule, PhotoController, mIsRefocus = false; if (isDeepZoom()) mSupportZoomCapture = false; try { - if (null == mActivity || null == mCameraDevice[id]) { + if (null == mActivity || null == mCameraDevice[id] + || !checkSessionAndBuilder(mCaptureSession[id], mPreviewRequestBuilder[id])) { + mUI.enableShutter(true); + mLongshotActive = false; warningToast("Camera is not ready yet to take a picture."); return; } @@ -2120,12 +2147,12 @@ public class CaptureModule implements CameraModule, PhotoController, captureBuilder.set(CaptureRequest.CONTROL_ENABLE_ZSL, false); } + applySettingsForJpegInformation(captureBuilder, id); + applyAFRegions(captureBuilder, id); + applyAERegions(captureBuilder, id); + applySettingsForCapture(captureBuilder, id); if (!mLongshoting) { - applySettingsForJpegInformation(captureBuilder, id); - applyAFRegions(captureBuilder, id); - applyAERegions(captureBuilder, id); VendorTagUtil.setCdsMode(captureBuilder, 2);// CDS 0-OFF, 1-ON, 2-AUTO - applySettingsForCapture(captureBuilder, id); applyCaptureMFNR(captureBuilder); } applyCaptureBurstFps(captureBuilder); @@ -2149,11 +2176,28 @@ public class CaptureModule implements CameraModule, PhotoController, } if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { - if (mHeifWriter != null && mHeifInput != null) { - captureBuilder.addTarget(mHeifInput); + long captureTime = System.currentTimeMillis(); + mNamedImages.nameNewImage(captureTime); + NamedEntity name = mNamedImages.getNextNameEntity(); + String title = (name == null) ? null : name.title; + long date = (name == null) ? -1 : name.date; + String pictureFormat = mLongshotActive? "heifs":"heif"; + String path = Storage.generateFilepath(title, pictureFormat); + String value = mSettingsManager.getValue(SettingsManager.KEY_JPEG_QUALITY); + int quality = getQualityNumber(value); + int orientation = CameraUtil.getJpegRotation(id,mOrientation); + int imageCount = mLongshotActive? MAX_IMAGEREADERS*2 : 1; + HeifWriter writer = createHEIFEncoder(path,mPictureSize.getWidth(),mPictureSize.getHeight(), + orientation,imageCount,quality); + if (writer != null) { + mHeifImage = new HeifImage(writer,path,title,date,orientation,quality); + Surface input = writer.getInputSurface(); + mHeifOutput.addSurface(input); try{ - mHeifWriter.start(); - } catch (IllegalStateException e) { + mCaptureSession[id].updateOutputConfiguration(mHeifOutput); + captureBuilder.addTarget(input); + writer.start(); + } catch (IllegalStateException | IllegalArgumentException e) { e.printStackTrace(); } } @@ -2272,6 +2316,24 @@ public class CaptureModule implements CameraModule, PhotoController, @Override public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId, long frameNumber) { + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { + if (mHeifImage != null) { + try { + mHeifOutput.removeSurface(mHeifImage.getInputSurface()); + session.updateOutputConfiguration(mHeifOutput); + mHeifImage.getWriter().stop(3000); + mHeifImage.getWriter().close(); + mActivity.getMediaSaveService().addHEIFImage(mHeifImage.getPath(), + mHeifImage.getTitle(),mHeifImage.getDate(),null,mPictureSize.getWidth(),mPictureSize.getHeight(), + mHeifImage.getOrientation(),null,mContentResolver,mOnMediaSavedListener,mHeifImage.getQuality(),"heifs"); + mHeifImage = null; + } catch (TimeoutException | IllegalStateException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } if(mLongshotActive) { captureStillPicture(getMainCameraId()); } else { @@ -2314,26 +2376,6 @@ public class CaptureModule implements CameraModule, PhotoController, CaptureRequest request, TotalCaptureResult result) { Log.d(TAG, "captureStillPictureForCommon onCaptureCompleted: " + id); - - if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { - if (mHeifWriter != null) { - try { - mHeifWriter.stop(5000); - mHeifWriter.close(); - } catch (TimeoutException | IllegalStateException e) { - Log.d(TAG,"HEIF encode error ="+e.getMessage()); - e.printStackTrace(); - } catch (Exception e) { - Log.d(TAG, e.toString()); - } - } - mActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - restartSession(false); - } - }); - } } @Override @@ -2347,6 +2389,24 @@ public class CaptureModule implements CameraModule, PhotoController, public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId, long frameNumber) { Log.d(TAG, "captureStillPictureForCommon onCaptureSequenceCompleted: " + id); + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { + if (mHeifImage != null) { + try { + mHeifOutput.removeSurface(mHeifImage.getInputSurface()); + mCaptureSession[id].updateOutputConfiguration(mHeifOutput); + mHeifImage.getWriter().stop(3000); + mHeifImage.getWriter().close(); + mActivity.getMediaSaveService().addHEIFImage(mHeifImage.getPath(), + mHeifImage.getTitle(),mHeifImage.getDate(),null,mPictureSize.getWidth(),mPictureSize.getHeight(), + mHeifImage.getOrientation(),null,mContentResolver,mOnMediaSavedListener,mHeifImage.getQuality(),"heif"); + mHeifImage = null; + } catch (TimeoutException | IllegalStateException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } if (mUI.getCurrentProMode() != ProMode.MANUAL_MODE) { unlockFocus(id); } else { @@ -2374,7 +2434,33 @@ public class CaptureModule implements CameraModule, PhotoController, applyVideoSnapshot(captureBuilder, id); applyZoom(captureBuilder, id); - captureBuilder.addTarget(mVideoSnapshotImageReader.getSurface()); + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { + long captureTime = System.currentTimeMillis(); + mNamedImages.nameNewImage(captureTime); + NamedEntity name = mNamedImages.getNextNameEntity(); + String title = (name == null) ? null : name.title; + long date = (name == null) ? -1 : name.date; + String path = Storage.generateFilepath(title, "heif"); + String value = mSettingsManager.getValue(SettingsManager.KEY_JPEG_QUALITY); + int quality = getQualityNumber(value); + int orientation = CameraUtil.getJpegRotation(id,mOrientation); + HeifWriter writer = createHEIFEncoder(path,mVideoSize.getWidth(), + mVideoSize.getHeight(),orientation,1,quality); + if (writer != null) { + mLiveShotImage = new HeifImage(writer,path,title,date,orientation,quality); + Surface input = writer.getInputSurface(); + mLiveShotOutput.addSurface(input); + try{ + mCurrentSession.updateOutputConfiguration(mLiveShotOutput); + captureBuilder.addTarget(input); + writer.start(); + } catch (IllegalStateException | IllegalArgumentException e) { + e.printStackTrace(); + } + } + } else { + captureBuilder.addTarget(mVideoSnapshotImageReader.getSurface()); + } // send snapshot stream together with preview and video stream for snapshot request // stream is the surface for the app Surface surface = getPreviewSurfaceForSession(id); @@ -2408,6 +2494,27 @@ public class CaptureModule implements CameraModule, PhotoController, public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId, long frameNumber) { Log.d(TAG, "captureVideoSnapshot onCaptureSequenceCompleted: " + id); + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { + if (mLiveShotImage != null) { + try { + mLiveShotOutput.removeSurface(mLiveShotImage.getInputSurface()); + mCurrentSession.updateOutputConfiguration(mLiveShotOutput); + mLiveShotImage.getWriter().stop(3000); + mLiveShotImage.getWriter().close(); + mActivity.getMediaSaveService().addHEIFImage(mLiveShotImage.getPath(), + mLiveShotImage.getTitle(),mLiveShotImage.getDate(), + null,mVideoSize.getWidth(),mVideoSize.getHeight(), + mLiveShotImage.getOrientation(),null, + mContentResolver,mOnMediaSavedListener, + mLiveShotImage.getQuality(),"heif"); + mLiveShotImage = null; + } catch (TimeoutException | IllegalStateException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } }, mCaptureCallbackHandler); } catch (CameraAccessException e) { @@ -2458,6 +2565,15 @@ public class CaptureModule implements CameraModule, PhotoController, CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE); try { String[] cameraIdList = manager.getCameraIdList(); + //inti heifWriter and get input surface + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { + String tmpPath = mActivity.getCacheDir().getPath() + "/" + "heif.tmp"; + if (mInitHeifWriter != null) { + mInitHeifWriter.close(); + } + mInitHeifWriter = createHEIFEncoder(tmpPath, mPictureSize.getWidth(), + mPictureSize.getHeight(), 0,1, 85); + } for (int i = 0; i < cameraIdList.length; i++) { String cameraId = cameraIdList[i]; @@ -2514,19 +2630,6 @@ public class CaptureModule implements CameraModule, PhotoController, mImageReader[i].setOnImageAvailableListener(mPostProcessor.getImageHandler(), mImageAvailableHandler); mPostProcessor.onImageReaderReady(mImageReader[i], mSupportedMaxPictureSize, mPictureSize); } else if (i == getMainCameraId()) { - if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { - long captureTime = System.currentTimeMillis(); - String title = String.valueOf(captureTime); - String path = Storage.generateFilepath(title, "heif"); - String value = mSettingsManager.getValue(SettingsManager.KEY_JPEG_QUALITY); - int quality = getQualityNumber(value); - mHeifWriter = createHEIFEncoder(path, mPictureSize.getWidth(), - mPictureSize.getHeight(), 0, quality); - if (mHeifWriter != null) { - mHeifInput = mHeifWriter.getInputSurface(); - mHeifPath = path; - } - } mImageReader[i] = ImageReader.newInstance(mPictureSize.getWidth(), mPictureSize.getHeight(), imageFormat, MAX_IMAGEREADERS); @@ -2547,6 +2650,10 @@ public class CaptureModule implements CameraModule, PhotoController, image.close(); return; } + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { + image.close(); + return; + } if (isMpoOn()) { mMpoSaveHandler.obtainMessage( MpoSaveHandler.MSG_NEW_IMG, mCamId, 0, image).sendToTarget(); @@ -2596,7 +2703,6 @@ public class CaptureModule implements CameraModule, PhotoController, mSupportedRawPictureSize.getHeight(), ImageFormat.RAW10, PersistUtil.getLongshotShotLimit()); mRawImageReader[i].setOnImageAvailableListener(listener, mImageAvailableHandler); } - } } } @@ -2608,14 +2714,14 @@ public class CaptureModule implements CameraModule, PhotoController, } } - public HeifWriter createHEIFEncoder(String path, int width, int height, - int orientation, int quality) { + public static HeifWriter createHEIFEncoder(String path, int width, int height, + int orientation, int imageCount, int quality) { HeifWriter heifWriter = null; try { HeifWriter.Builder builder = new HeifWriter.Builder(path, width, height, HeifWriter.INPUT_MODE_SURFACE); builder.setQuality(quality); - builder.setMaxImages(1); + builder.setMaxImages(imageCount); builder.setPrimaryIndex(0); builder.setRotation(orientation); builder.setGridEnabled(true); @@ -2632,6 +2738,12 @@ public class CaptureModule implements CameraModule, PhotoController, if (mVideoSnapshotImageReader != null) { mVideoSnapshotImageReader.close(); } + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) { + String tmpPath = mActivity.getCacheDir().getPath() + "/" + "liveshot_heif.tmp"; + mLiveShotInitHeifWriter = createHEIFEncoder(tmpPath,mVideoSize.getWidth(), + mVideoSize.getHeight(),0, 1,85); + return; + } mVideoSnapshotImageReader = ImageReader.newInstance(mVideoSnapshotSize.getWidth(), mVideoSnapshotSize.getHeight(), ImageFormat.JPEG, 2); mVideoSnapshotImageReader.setOnImageAvailableListener( @@ -2923,6 +3035,8 @@ public class CaptureModule implements CameraModule, PhotoController, } private void applySettingsForJpegInformation(CaptureRequest.Builder builder, int id) { + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) + return; Location location = mLocationManager.getCurrentLocation(); if(location != null) { // make copy so that we don't alter the saved location since we may re-use it @@ -3082,11 +3196,8 @@ public class CaptureModule implements CameraModule, PhotoController, if(isClearSightOn()) { ClearSightImageProcessor.getInstance().close(); } - if (mHeifWriter != null && mHeifPath != null) { - mHeifWriter.close(); - File emptyFile = new File(mHeifPath); - if (emptyFile.exists() && emptyFile.length() == 0) - emptyFile.delete(); + if (mInitHeifWriter != null) { + mInitHeifWriter.close(); } closeCamera(); resetAudioMute(); @@ -4167,7 +4278,7 @@ public class CaptureModule implements CameraModule, PhotoController, } catch (IllegalStateException e) { e.printStackTrace(); } - if (!mFrameProcessor.isFrameListnerEnabled() && !startMediaRecorder()) { + if ((!mFrameProcessor.isFrameListnerEnabled() && !startMediaRecorder()) || !mIsRecordingVideo) { mUI.showUIafterRecording(); releaseMediaRecorder(); mFrameProcessor.setVideoOutputSurface(null); @@ -4204,7 +4315,16 @@ public class CaptureModule implements CameraModule, PhotoController, List<Surface> outputSurfaces, CameraCaptureSession.StateCallback listener, Handler handler, CaptureRequest initialRequest) throws CameraAccessException { List<OutputConfiguration> outConfigurations = new ArrayList<>(outputSurfaces.size()); - outputSurfaces.add(mVideoSnapshotImageReader.getSurface()); + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT && + mLiveShotInitHeifWriter != null) { + mLiveShotOutput = new OutputConfiguration( + mLiveShotInitHeifWriter.getInputSurface()); + mLiveShotOutput.enableSurfaceSharing(); + outConfigurations.add(mLiveShotOutput); + } else { + outputSurfaces.add(mVideoSnapshotImageReader.getSurface()); + } + for (Surface surface : outputSurfaces) { outConfigurations.add(new OutputConfiguration(surface)); } @@ -4256,6 +4376,13 @@ public class CaptureModule implements CameraModule, PhotoController, for (Surface surface : outputSurfaces) { outConfigurations.add(new OutputConfiguration(surface)); } + if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT && + mLiveShotInitHeifWriter != null) { + mLiveShotOutput = new OutputConfiguration( + mLiveShotInitHeifWriter.getInputSurface()); + mLiveShotOutput .enableSurfaceSharing(); + outConfigurations.add(mLiveShotOutput); + } Method method_setSessionParameters = null; Method method_createCaptureSession = null; Object sessionConfig = null; @@ -4362,6 +4489,7 @@ public class CaptureModule implements CameraModule, PhotoController, mHighSpeedFPSRange); } + if (ApiHelper.isAndroidPOrHigher()) { if (mHighSpeedCapture && ((int) mHighSpeedFPSRange.getUpper() > NORMAL_SESSION_MAX_FPS)) { CaptureRequest initialRequest = mVideoRequestBuilder.build(); @@ -4887,7 +5015,11 @@ public class CaptureModule implements CameraModule, PhotoController, setEndOfStream(false, true); mFrameProcessor.setVideoOutputSurface(null); mFrameProcessor.onClose(); + if (mLiveShotInitHeifWriter != null) { + mLiveShotInitHeifWriter.close(); + } closePreviewSession(); + mIsRecordingVideo = false; try { mMediaRecorder.setOnErrorListener(null); mMediaRecorder.setOnInfoListener(null); @@ -4911,7 +5043,6 @@ public class CaptureModule implements CameraModule, PhotoController, mUI.showRecordingUI(false, false); mUI.enableShutter(true); - mIsRecordingVideo = false; if (mIntentMode == INTENT_MODE_VIDEO) { if (isQuickCapture()) { onRecordingDone(true); @@ -6995,6 +7126,54 @@ public class CaptureModule implements CameraModule, PhotoController, public void onRenderSurfaceDestroyed() { mRenderer = null; } + + public static class HeifImage { + private HeifWriter mWriter; + private String mPath; + private String mTitle; + private long mDate; + private int mQuality; + private int mOrientation; + private Surface mInputSurface; + + public HeifImage(HeifWriter writer,String path,String title,long date,int orientation,int quality) { + mWriter = writer; + mPath = path; + mTitle = title; + mDate = date; + mQuality = quality; + mOrientation = orientation; + mInputSurface = writer.getInputSurface(); + } + + public HeifWriter getWriter() { + return mWriter; + } + + public String getPath() { + return mPath; + } + + public String getTitle() { + return mTitle; + } + + public long getDate() { + return mDate; + } + + public int getQuality() { + return mQuality; + } + + public Surface getInputSurface(){ + return mInputSurface; + } + + public int getOrientation() { + return mOrientation; + } + } } class Camera2GraphView extends View { diff --git a/src/com/android/camera/MediaSaveService.java b/src/com/android/camera/MediaSaveService.java index 30e5d1a28..078a9c427 100755 --- a/src/com/android/camera/MediaSaveService.java +++ b/src/com/android/camera/MediaSaveService.java @@ -167,7 +167,7 @@ public class MediaSaveService extends Service { t.execute(); } - public void addHEIFImageFromJpeg(byte[] data, String title, long date, Location loc, + public void addHEIFImage(String path,String title,long date , Location loc, int width, int height, int orientation, ExifInterface exif, ContentResolver resolver, OnMediaSavedListener listener, int qualitiy, String pictureFormat) { @@ -175,12 +175,9 @@ public class MediaSaveService extends Service { Log.e(TAG, "Cannot add image when the queue is full"); return; } - HEIFImageSaveTask t = new HEIFImageSaveTask(data, title, date, loc, width, height, orientation, + HEIFImageSaveTask t = new HEIFImageSaveTask(path,title,date, loc, width, height, orientation, exif, resolver, listener, qualitiy, pictureFormat); - mMemoryUse += data.length; - if (isQueueFull()) { - onQueueFull(); - } + t.execute(); } @@ -350,7 +347,7 @@ public class MediaSaveService extends Service { } private class HEIFImageSaveTask extends AsyncTask<Void, Void, Uri> { - private byte[] data; + private String path; private String title; private long date; private Location loc; @@ -362,11 +359,11 @@ public class MediaSaveService extends Service { private int quality; private String pictureFormat; - public HEIFImageSaveTask(byte[] data, String title, long date, Location loc, + public HEIFImageSaveTask(String path, String title, long date, Location loc, int width, int height, int orientation, ExifInterface exif, ContentResolver resolver, OnMediaSavedListener listener, int quality,String pictureFormat) { - this.data = data; + this.path = path; this.title = title; this.date = date; this.loc = loc; @@ -388,15 +385,13 @@ public class MediaSaveService extends Service { @Override protected Uri doInBackground(Void... params) { return Storage.addHeifImage( - resolver,title,date,loc,orientation,exif,data, + resolver,title,date,loc,orientation,exif,path, width,height,quality,pictureFormat); } @Override protected void onPostExecute(Uri uri) { boolean previouslyFull = isQueueFull(); - mMemoryUse -= data.length; - if (isQueueFull() != previouslyFull) onQueueAvailable(); } } diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java index 82b8adcf5..1f5671c97 100755 --- a/src/com/android/camera/Storage.java +++ b/src/com/android/camera/Storage.java @@ -146,6 +146,8 @@ public class Storage { if (mimeType.equalsIgnoreCase("heif")){ values.put(ImageColumns.DISPLAY_NAME, title + ".heic"); + } else if(mimeType.equalsIgnoreCase("heifs")){ + values.put(ImageColumns.DISPLAY_NAME, title + ".heics"); } else { values.put(ImageColumns.DISPLAY_NAME, title + ".jpg"); } @@ -215,30 +217,8 @@ public class Storage { } public static Uri addHeifImage(ContentResolver resolver, String title, long date, - Location location, int orientation, ExifInterface exif, byte[] data, int width, + Location location, int orientation, ExifInterface exif, String path, int width, int height, int quality, String mimeType) { - String path = generateFilepath(title, mimeType); - Bitmap bitmap = BitmapFactory.decodeByteArray(data,0,data.length); - if (bitmap != null) { - try { - HeifWriter.Builder builder = - new HeifWriter.Builder(path,width, height,HeifWriter.INPUT_MODE_BITMAP); - builder.setQuality(quality); - builder.setMaxImages(1); - builder.setPrimaryIndex(0); - builder.setRotation(orientation); - HeifWriter heifWriter = builder.build(); - heifWriter.start(); - heifWriter.addBitmap(bitmap); - heifWriter.stop(3000); - heifWriter.close(); - } catch (IOException|IllegalStateException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - bitmap.recycle(); - } File f = new File(path); int size = 0; if (f.exists() && f.isFile()) { @@ -293,10 +273,13 @@ public class Storage { public static String generateFilepath(String title, String pictureFormat) { if (pictureFormat == null || pictureFormat.equalsIgnoreCase("jpeg") - || pictureFormat.equalsIgnoreCase("heif")) { + || pictureFormat.equalsIgnoreCase("heif") + || pictureFormat.equalsIgnoreCase("heifs")) { String suffix = ".jpg"; if (pictureFormat.equalsIgnoreCase("heif")) { suffix = ".heic"; + }else if(pictureFormat.equalsIgnoreCase("heifs")) { + suffix = ".heics"; } if (isSaveSDCard() && SDCard.instance().isWriteable()) { return SDCard.instance().getDirectory() + '/' + title + suffix; diff --git a/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java b/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java index 4ec2fe378..d8d0a3e2f 100644 --- a/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java +++ b/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java @@ -154,8 +154,8 @@ public class BlurbusterFilter implements ImageFilter{ static { try { - System.loadLibrary("jni_blurbuster"); - mIsSupported = true; + //System.loadLibrary("jni_blurbuster"); + mIsSupported = false; }catch(UnsatisfiedLinkError e) { Log.d(TAG, e.toString()); mIsSupported = false; diff --git a/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java b/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java index 4682e3947..41bd03647 100644 --- a/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java +++ b/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java @@ -252,8 +252,8 @@ public class ChromaflashFilter implements ImageFilter{ static { try { - System.loadLibrary("jni_chromaflash"); - mIsSupported = true; + //System.loadLibrary("jni_chromaflash"); + mIsSupported = false; }catch(UnsatisfiedLinkError e) { Log.d(TAG, e.toString()); mIsSupported = false; diff --git a/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java b/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java index 611949f64..f35d3be7c 100644 --- a/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java +++ b/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java @@ -179,8 +179,8 @@ public class SharpshooterFilter implements ImageFilter{ static { try { - System.loadLibrary("jni_sharpshooter"); - mIsSupported = true; + //System.loadLibrary("jni_sharpshooter"); + mIsSupported = false; }catch(UnsatisfiedLinkError e) { Log.d(TAG, e.toString()); mIsSupported = false; diff --git a/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java b/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java index 25c167034..0c588b976 100755 --- a/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java +++ b/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java @@ -327,8 +327,8 @@ public class UbifocusFilter implements ImageFilter { static { try { - System.loadLibrary("jni_ubifocus"); - mIsSupported = true; + //System.loadLibrary("jni_ubifocus"); + mIsSupported = false; }catch(UnsatisfiedLinkError e) { mIsSupported = false; } |