summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]rs/rotator.rs20
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/imageprocessor/FrameProcessor.java9
2 files changed, 21 insertions, 8 deletions
diff --git a/rs/rotator.rs b/rs/rotator.rs
index 5a27e00f7..2c57951d6 100644..100755
--- a/rs/rotator.rs
+++ b/rs/rotator.rs
@@ -35,32 +35,42 @@ rs_allocation gIn;
uint32_t width;
uint32_t height;
uint32_t pad;
-bool gFlip;
+uint32_t degree;
uchar __attribute__((kernel)) rotate90andMerge(uint32_t x, uint32_t y) {
uchar yValue = rsGetElementAt_uchar(gIn, x + y*width);
- if(gFlip) {
+ if(degree == 180) {
if(x >= width - pad)
return (uchar)0;
rsSetElementAt_uchar(gOut, yValue, (width-1-x-pad)*height + height - 1 - y);
- } else {
+ } else if (degree == 90) {
rsSetElementAt_uchar(gOut, yValue, x*height + height - 1 - y);
+ } else if (degree == 270) {
+ if(x >= width - pad)
+ return (uchar)0;
+ rsSetElementAt_uchar(gOut, yValue, (width-1-x-pad)*height + y);
}
+
if(x%2 == 0 && y%2 == 0) {
uint32_t ySize = width*height;
uint32_t index = ySize + x + ((y/2) * width);
uchar vValue = rsGetElementAt_uchar(gIn, index);
uchar uValue = rsGetElementAt_uchar(gIn, index + 1);
- if(gFlip) {
+ if(degree == 180) {
if(x >= width - pad)
return (uchar)0;
rsSetElementAt_uchar(gOut, uValue, ySize + (width-2-x-pad)/2*height + height - 1 - y);
rsSetElementAt_uchar(gOut, vValue, ySize + (width-2-x-pad)/2*height + height - 1 - y - 1);
- } else {
+ } else if (degree == 90) {
rsSetElementAt_uchar(gOut, uValue, ySize + x/2*height + height - 1 - y);
rsSetElementAt_uchar(gOut, vValue, ySize + x/2*height + height - 1 - y - 1);
+ } else if (degree == 270) {
+ if(x >= (width - pad))
+ return (uchar)0;
+ rsSetElementAt_uchar(gOut, uValue, ySize + (width-1-x-pad)/2*height + y -1);
+ rsSetElementAt_uchar(gOut, vValue, ySize + (width-1-x-pad)/2*height + y);
}
}
return (uchar)0;
diff --git a/src/com/android/camera/imageprocessor/FrameProcessor.java b/src/com/android/camera/imageprocessor/FrameProcessor.java
index a2ae18c1c..5dc50c4e5 100644..100755
--- a/src/com/android/camera/imageprocessor/FrameProcessor.java
+++ b/src/com/android/camera/imageprocessor/FrameProcessor.java
@@ -40,6 +40,7 @@ import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.Type;
+import android.util.Log;
import android.util.Size;
import android.view.Surface;
import android.widget.Toast;
@@ -155,10 +156,12 @@ public class FrameProcessor {
mRsRotator.set_width(width);
mRsRotator.set_height(height);
mRsRotator.set_pad(stridePad);
- if(mModule.getMainCameraCharacteristics() != null &&
- mModule.getMainCameraCharacteristics().get(CameraCharacteristics.SENSOR_ORIENTATION) == 270) {
- mRsRotator.set_gFlip(true);
+ int degree = 90;
+ if(mModule.getMainCameraCharacteristics() != null) {
+ degree = mModule.getMainCameraCharacteristics().
+ get(CameraCharacteristics.SENSOR_ORIENTATION);
}
+ mRsRotator.set_degree(degree);
mRsYuvToRGB.set_gIn(mProcessAllocation);
mRsYuvToRGB.set_width(height);
mRsYuvToRGB.set_height(width);