diff options
author | Jack Yoo <jyoo@codeaurora.org> | 2016-10-12 11:13:33 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-10-20 11:25:03 -0700 |
commit | d48b19dc07840224e7434661c4c5e8ec1a78a67d (patch) | |
tree | 7ede241a612188147562d5bdc56117c3a496637a | |
parent | e5638a1b4697191588438be133102f61b67a3985 (diff) | |
download | android_packages_apps_Snap-d48b19dc07840224e7434661c4c5e8ec1a78a67d.tar.gz android_packages_apps_Snap-d48b19dc07840224e7434661c4c5e8ec1a78a67d.tar.bz2 android_packages_apps_Snap-d48b19dc07840224e7434661c4c5e8ec1a78a67d.zip |
SnapdragonCamera: Blurbuster filter
Adding blurbuster filter to the post processor
Change-Id: I2958a2b1b0df834c4cb5b921e49d21d2e20c8377
CRs-Fixed: 1080317
-rw-r--r-- | res/drawable-hdpi/blur_buster.png | bin | 0 -> 2079 bytes | |||
-rw-r--r-- | res/drawable-hdpi/ic_settings_selfiemirror.png | bin | 1463 -> 0 bytes | |||
-rw-r--r-- | res/drawable-hdpi/seekbar_hide.png | bin | 0 -> 515 bytes | |||
-rw-r--r-- | res/drawable-hdpi/seekbar_show.png | bin | 0 -> 457 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_settings_selfiemirror.png | bin | 2319 -> 0 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/ic_settings_selfiemirror.png | bin | 3219 -> 0 bytes | |||
-rw-r--r-- | res/drawable/ic_settings_selfiemirror.png | bin | 0 -> 2153 bytes | |||
-rw-r--r-- | res/layout/one_ui_layout.xml | 9 | ||||
-rw-r--r-- | res/values/camera2arrays.xml | 3 | ||||
-rw-r--r-- | res/values/qcomstrings.xml | 1 | ||||
-rw-r--r-- | src/com/android/camera/CaptureModule.java | 3 | ||||
-rw-r--r-- | src/com/android/camera/CaptureUI.java | 9 | ||||
-rw-r--r-- | src/com/android/camera/SettingsManager.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/imageprocessor/PostProcessor.java | 7 | ||||
-rw-r--r-- | src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java | 165 |
15 files changed, 192 insertions, 9 deletions
diff --git a/res/drawable-hdpi/blur_buster.png b/res/drawable-hdpi/blur_buster.png Binary files differnew file mode 100644 index 000000000..3c9818728 --- /dev/null +++ b/res/drawable-hdpi/blur_buster.png diff --git a/res/drawable-hdpi/ic_settings_selfiemirror.png b/res/drawable-hdpi/ic_settings_selfiemirror.png Binary files differdeleted file mode 100644 index 870093c57..000000000 --- a/res/drawable-hdpi/ic_settings_selfiemirror.png +++ /dev/null diff --git a/res/drawable-hdpi/seekbar_hide.png b/res/drawable-hdpi/seekbar_hide.png Binary files differnew file mode 100644 index 000000000..a8a3788c3 --- /dev/null +++ b/res/drawable-hdpi/seekbar_hide.png diff --git a/res/drawable-hdpi/seekbar_show.png b/res/drawable-hdpi/seekbar_show.png Binary files differnew file mode 100644 index 000000000..ed84408a1 --- /dev/null +++ b/res/drawable-hdpi/seekbar_show.png diff --git a/res/drawable-xhdpi/ic_settings_selfiemirror.png b/res/drawable-xhdpi/ic_settings_selfiemirror.png Binary files differdeleted file mode 100644 index 692476577..000000000 --- a/res/drawable-xhdpi/ic_settings_selfiemirror.png +++ /dev/null diff --git a/res/drawable-xxhdpi/ic_settings_selfiemirror.png b/res/drawable-xxhdpi/ic_settings_selfiemirror.png Binary files differdeleted file mode 100644 index 988d95866..000000000 --- a/res/drawable-xxhdpi/ic_settings_selfiemirror.png +++ /dev/null diff --git a/res/drawable/ic_settings_selfiemirror.png b/res/drawable/ic_settings_selfiemirror.png Binary files differnew file mode 100644 index 000000000..7d99f5c2c --- /dev/null +++ b/res/drawable/ic_settings_selfiemirror.png diff --git a/res/layout/one_ui_layout.xml b/res/layout/one_ui_layout.xml index e8162197a..2a87b6cd2 100644 --- a/res/layout/one_ui_layout.xml +++ b/res/layout/one_ui_layout.xml @@ -90,12 +90,13 @@ android:layout_height="wrap_content" android:id="@+id/makeup_seekbar_layout" android:visibility="gone"> - <Button + <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:id="@+id/seekbar_toggle" - android:text="@string/makeup_seekbar_low"> - </Button> + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:id="@+id/seekbar_toggle"> + </ImageView> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml index 438d1389a..b1c3a5b7c 100644 --- a/res/values/camera2arrays.xml +++ b/res/values/camera2arrays.xml @@ -153,6 +153,7 @@ <item>-1</item> <item>103</item> <item>105</item> + <item>106</item> <item>104</item> </string-array> @@ -176,6 +177,7 @@ <item>@string/pref_camera_scenemode_entry_asd</item> <item>@string/pref_camera_scenemode_entry_bestpicture</item> <item>@string/pref_camera_scenemode_entry_chromaflash</item> + <item>@string/pref_camera_scenemode_entry_blurbuster</item> <item>@string/pref_camera_scenemode_entry_panorama</item> </string-array> @@ -198,6 +200,7 @@ <item>@drawable/ic_scene_mode_smartauto</item> <item>@drawable/pick_the_best_photo</item> <item>@drawable/chroma_flash</item> + <item>@drawable/blur_buster</item> <item>@drawable/scene_panorama</item> </array> diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml index 72fab56e0..64bd8127a 100644 --- a/res/values/qcomstrings.xml +++ b/res/values/qcomstrings.xml @@ -1025,6 +1025,7 @@ <string name="pref_camera2_trackingfocus_title" translatable="true">Tracking Focus</string> <string name="pref_camera_scenemode_entry_bestpicture" translatable="true">BestPicture</string> <string name="pref_camera_scenemode_entry_chromaflash" translatable="true">ChromaFlash</string> + <string name="pref_camera_scenemode_entry_blurbuster" translatable="true">BlurBuster</string> <string name="pref_camera_scenemode_entry_panorama" translatable="true">Panorama</string> <string name="bestpicture_done" translatable="true">DONE</string> <string name="bestpicture_at_least_one_picture" translatable="true">At least, one picture has to be chosen.</string> diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index e81a34c6f..6c7af2a74 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -76,6 +76,7 @@ import android.widget.Toast; import com.android.camera.exif.ExifInterface; import com.android.camera.Exif; +import com.android.camera.imageprocessor.filter.BlurbusterFilter; import com.android.camera.imageprocessor.filter.ChromaflashFilter; import com.android.camera.imageprocessor.filter.ImageFilter; import com.android.camera.imageprocessor.PostProcessor; @@ -1861,6 +1862,8 @@ public class CaptureModule implements CameraModule, PhotoController, return PostProcessor.FILTER_SHARPSHOOTER; } else if (mode == SettingsManager.SCENE_MODE_CHROMAFLASH_INT && ChromaflashFilter.isSupportedStatic()) { return PostProcessor.FILTER_CHROMAFLASH; + } else if (mode == SettingsManager.SCENE_MODE_BLURBUSTER_INT && BlurbusterFilter.isSupportedStatic()) { + return PostProcessor.FILTER_BLURBUSTER; } else if (mode == SettingsManager.SCENE_MODE_UBIFOCUS_INT) { return PostProcessor.FILTER_UBIFOCUS; }// else if (mode == SettingsManager.SCENE_MODE_AUTO_INT && StillmoreFilter.isSupportedStatic()) { diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index 1710dc975..ae67007d0 100644 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -49,11 +49,9 @@ import android.view.ViewGroup; import android.view.ViewPropertyAnimator; import android.view.Window; import android.view.WindowManager; -import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; @@ -185,7 +183,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private RotateLayout mRecordingTimeRect; private PauseButton mPauseButton; private RotateImageView mMuteButton; - private Button mSeekbarToggleButton; + private ImageView mSeekbarToggleButton; int mPreviewWidth; int mPreviewHeight; @@ -250,14 +248,16 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mMakeupButton = (ImageView) mRootView.findViewById(R.id.ts_makeup_switcher); mMakeupSeekBarLayout = mRootView.findViewById(R.id.makeup_seekbar_layout); mSeekbarBody = mRootView.findViewById(R.id.seekbar_body); - mSeekbarToggleButton = (Button) mRootView.findViewById(R.id.seekbar_toggle); + mSeekbarToggleButton = (ImageView) mRootView.findViewById(R.id.seekbar_toggle); mSeekbarToggleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(mSeekbarBody.getVisibility() == View.VISIBLE) { mSeekbarBody.setVisibility(View.GONE); + mSeekbarToggleButton.setImageResource(R.drawable.seekbar_show); } else { mSeekbarBody.setVisibility(View.VISIBLE); + mSeekbarToggleButton.setImageResource(R.drawable.seekbar_hide); } } }); @@ -372,6 +372,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mMakeupSeekBar.setProgress(10); mMakeupSeekBarLayout.setVisibility(View.VISIBLE); mSeekbarBody.setVisibility(View.VISIBLE); + mSeekbarToggleButton.setImageResource(R.drawable.seekbar_hide); } else { mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, "0"); mMakeupSeekBar.setProgress(0); diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index 1a190b502..c98bb8813 100644 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -47,6 +47,7 @@ import android.util.Size; import com.android.camera.imageprocessor.filter.BeautificationFilter; import com.android.camera.imageprocessor.filter.BestpictureFilter; +import com.android.camera.imageprocessor.filter.BlurbusterFilter; import com.android.camera.imageprocessor.filter.ChromaflashFilter; import com.android.camera.imageprocessor.filter.OptizoomFilter; import com.android.camera.imageprocessor.filter.TrackingFocusFrameListener; @@ -84,6 +85,7 @@ public class SettingsManager implements ListMenu.SettingsListener { public static final int SCENE_MODE_BESTPICTURE_INT = 103; public static final int SCENE_MODE_PANORAMA_INT = 104; public static final int SCENE_MODE_CHROMAFLASH_INT = 105; + public static final int SCENE_MODE_BLURBUSTER_INT = 106; public static final String SCENE_MODE_DUAL_STRING = "100"; public static final String KEY_CAMERA_SAVEPATH = "pref_camera2_savepath_key"; public static final String KEY_RECORD_LOCATION = "pref_camera2_recordlocation_key"; @@ -675,6 +677,7 @@ public class SettingsManager implements ListMenu.SettingsListener { if (!mIsFrontCameraPresent || !isFacingFront(mCameraId)) { removePreference(mPreferenceGroup, KEY_SELFIE_FLASH); + removePreference(mPreferenceGroup, KEY_SELFIEMIRROR); } } @@ -1059,6 +1062,7 @@ public class SettingsManager implements ListMenu.SettingsListener { if (BestpictureFilter.isSupportedStatic() && cameraId == CaptureModule.BAYER_ID) modes.add(SCENE_MODE_BESTPICTURE_INT + ""); if (PanoCaptureProcessView.isSupportedStatic() && cameraId == CaptureModule.BAYER_ID) modes.add(SCENE_MODE_PANORAMA_INT + ""); if (ChromaflashFilter.isSupportedStatic() && cameraId == CaptureModule.BAYER_ID) modes.add(SCENE_MODE_CHROMAFLASH_INT + ""); + if (BlurbusterFilter.isSupportedStatic()) modes.add(SCENE_MODE_BLURBUSTER_INT + ""); for (int mode : sceneModes) { modes.add("" + mode); } diff --git a/src/com/android/camera/imageprocessor/PostProcessor.java b/src/com/android/camera/imageprocessor/PostProcessor.java index 228c0816f..82467acaa 100644 --- a/src/com/android/camera/imageprocessor/PostProcessor.java +++ b/src/com/android/camera/imageprocessor/PostProcessor.java @@ -61,6 +61,7 @@ import com.android.camera.SettingsManager; import com.android.camera.exif.ExifInterface; import com.android.camera.exif.Rational; import com.android.camera.imageprocessor.filter.BestpictureFilter; +import com.android.camera.imageprocessor.filter.BlurbusterFilter; import com.android.camera.imageprocessor.filter.ChromaflashFilter; import com.android.camera.imageprocessor.filter.OptizoomFilter; import com.android.camera.imageprocessor.filter.SharpshooterFilter; @@ -94,7 +95,8 @@ public class PostProcessor{ public static final int FILTER_STILLMORE = 4; public static final int FILTER_BESTPICTURE = 5; public static final int FILTER_CHROMAFLASH = 6; - public static final int FILTER_MAX = 7; + public static final int FILTER_BLURBUSTER = 7; + public static final int FILTER_MAX = 8; //BestPicture requires 10 which is the biggest among filters public static final int MAX_REQUIRED_IMAGE_NUM = 11; @@ -588,6 +590,9 @@ public class PostProcessor{ case FILTER_STILLMORE: mFilter = new StillmoreFilter(mController); break; + case FILTER_BLURBUSTER: + mFilter = new BlurbusterFilter(mController); + break; case FILTER_BESTPICTURE: mFilter = new BestpictureFilter(mController, mActivity, this); break; diff --git a/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java b/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java new file mode 100644 index 000000000..2ac8fdc0e --- /dev/null +++ b/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java @@ -0,0 +1,165 @@ +/* +Copyright (c) 2016, The Linux Foundation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of The Linux Foundation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.android.camera.imageprocessor.filter; + +import android.graphics.Rect; +import android.hardware.camera2.CameraCaptureSession; +import android.hardware.camera2.CaptureRequest; +import android.os.Handler; +import android.util.Log; + +import com.android.camera.CaptureModule; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +public class BlurbusterFilter implements ImageFilter{ + public static final int NUM_REQUIRED_IMAGE = 5; + private int mWidth; + private int mHeight; + private int mStrideY; + private int mStrideVU; + private static String TAG = "BlurbusterFilter"; + private static final boolean DEBUG = false; + private static boolean mIsSupported = false; + private ByteBuffer mOutBuf; + private CaptureModule mModule; + + private static void Log(String msg) { + if(DEBUG) { + Log.d(TAG, msg); + } + } + + public BlurbusterFilter(CaptureModule module) { + mModule = module; + } + + @Override + public List<CaptureRequest> setRequiredImages(CaptureRequest.Builder builder) { + List<CaptureRequest> list = new ArrayList<CaptureRequest>(); + for(int i=0; i < NUM_REQUIRED_IMAGE; i++) { + list.add(builder.build()); + } + return list; + } + + @Override + public String getStringName() { + return TAG; + } + + @Override + public int getNumRequiredImage() { + return NUM_REQUIRED_IMAGE; + } + + @Override + public void init(int width, int height, int strideY, int strideVU) { + Log("init"); + mWidth = width/2*2; + mHeight = height/2*2; + mStrideY = strideY/2*2; + mStrideVU = strideVU/2*2; + mOutBuf = ByteBuffer.allocate(mStrideY*mHeight*3/2); + Log("width: "+mWidth+" height: "+mHeight+" strideY: "+mStrideY+" strideVU: "+mStrideVU); + nativeInit(mWidth, mHeight, mStrideY, mStrideVU, NUM_REQUIRED_IMAGE); + } + + @Override + public void deinit() { + Log("deinit"); + mOutBuf = null; + nativeDeinit(); + } + + @Override + public void addImage(ByteBuffer bY, ByteBuffer bVU, int imageNum, Object param) { + Log("addImage"); + int yActualSize = bY.remaining(); + int vuActualSize = bVU.remaining(); + int status = nativeAddImage(bY, bVU, yActualSize, vuActualSize, imageNum); + if(status != 0) { + Log.e(TAG, "Fail to add image"); + } + } + + @Override + public ResultImage processImage() { + Log("processImage "); + int[] roi = new int[4]; + int status = nativeProcessImage(mOutBuf.array(),roi); + Log("processImage done"); + if(status < 0) { //In failure case, library will return the first image as it is. + Log.w(TAG, "Fail to process the image."); + } + return new ResultImage(mOutBuf, new Rect(roi[0], roi[1], roi[0]+roi[2], roi[1] + roi[3]), mWidth, mHeight, mStrideY); + } + + @Override + public boolean isSupported() { + return mIsSupported; + } + + @Override + public boolean isFrameListener() { + return false; + } + + @Override + public boolean isManualMode() { + return false; + } + + @Override + public void manualCapture(CaptureRequest.Builder builder, CameraCaptureSession captureSession, + CameraCaptureSession.CaptureCallback callback, Handler handler) { + + } + + public static boolean isSupportedStatic() { + return mIsSupported; + } + + private native int nativeInit(int width, int height, int yStride, int vuStride, int numImages); + private native int nativeDeinit(); + private native int nativeAddImage(ByteBuffer yB, ByteBuffer vuB, int ySize, int vuSize, int imageNum); + private native int nativeProcessImage(byte[] buffer, int[] roi); + + static { + try { + System.loadLibrary("jni_blurbuster"); + mIsSupported = true; + }catch(UnsatisfiedLinkError e) { + Log.d(TAG, e.toString()); + mIsSupported = false; + } + } +} |