From 53cd3dd1a139d495fe25d06d439bd8fd0ea1d683 Mon Sep 17 00:00:00 2001 From: Jack Yoo Date: Tue, 10 May 2016 14:11:19 -0700 Subject: SnapdragonCamera: Sharpshooter post filter Adding Sharpshooter post process filter Change-Id: I8f3c1962db437e7dfbe2973f806a3f9a26480eb7 CRs-Fixed: 1023183 --- rs/YuvToRgb.rs | 6 +++--- rs/rotator.rs | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'rs') diff --git a/rs/YuvToRgb.rs b/rs/YuvToRgb.rs index 25771c5c7..57076e979 100644 --- a/rs/YuvToRgb.rs +++ b/rs/YuvToRgb.rs @@ -41,9 +41,9 @@ uchar4 __attribute__((kernel)) nv21ToRgb(uint32_t x, uint32_t y) { int vV = (int)(rsGetElementAt_uchar(gIn, index) & 0xFF ) -128; int uV = (int)(rsGetElementAt_uchar(gIn, index+1) & 0xFF ) -128; - int r = (int) (1.164f * yV + 1.596f * vV ); - int g = (int) (1.164f * yV - 0.813f * vV - 0.391f * uV); - int b = (int) (1.164f * yV + 2.018f * uV ); + int r = (int) (yV + 1.370705f * vV ); + int g = (int) (yV - 0.698001f * vV - 0.337633f* uV); + int b = (int) (yV + 1.732446 * uV ); r = r>255? 255 : r<0 ? 0 : r; g = g>255? 255 : g<0 ? 0 : g; diff --git a/rs/rotator.rs b/rs/rotator.rs index cd9da4396..5a27e00f7 100644 --- a/rs/rotator.rs +++ b/rs/rotator.rs @@ -34,18 +34,34 @@ rs_allocation gOut; rs_allocation gIn; uint32_t width; uint32_t height; +uint32_t pad; +bool gFlip; uchar __attribute__((kernel)) rotate90andMerge(uint32_t x, uint32_t y) { uchar yValue = rsGetElementAt_uchar(gIn, x + y*width); - rsSetElementAt_uchar(gOut, yValue, x*height + height - 1 - y); - if(x%2 == 0 && y%2==1) { + if(gFlip) { + if(x >= width - pad) + return (uchar)0; + rsSetElementAt_uchar(gOut, yValue, (width-1-x-pad)*height + height - 1 - y); + } else { + rsSetElementAt_uchar(gOut, yValue, x*height + height - 1 - 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); - rsSetElementAt_uchar(gOut, vValue, ySize + x/2*height + height - 1 - y); - rsSetElementAt_uchar(gOut, uValue, ySize + x/2*height + height - 1 - y - 1); + if(gFlip) { + 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 { + rsSetElementAt_uchar(gOut, uValue, ySize + x/2*height + height - 1 - y); + rsSetElementAt_uchar(gOut, vValue, ySize + x/2*height + height - 1 - y - 1); + } } return (uchar)0; } \ No newline at end of file -- cgit v1.2.3