summaryrefslogtreecommitdiff
path: root/java/tests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs
diff options
context:
space:
mode:
Diffstat (limited to 'java/tests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs')
-rw-r--r--java/tests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs
index b82e1d34..7fa295e8 100644
--- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs
+++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/vibrance.rs
@@ -25,13 +25,10 @@ static const float Bf = 0.114f;
static float Vib = 0.f;
-void vibranceKernel(const uchar4 *in, uchar4 *out) {
-
- float R, G, B;
-
- int r = in->r;
- int g = in->g;
- int b = in->b;
+uchar4 __attribute__((kernel)) vibranceKernel(uchar4 in) {
+ int r = in.r;
+ int g = in.g;
+ int b = in.b;
float red = (r-max(g, b)) * (1.f / 256.f);
float S = (float)(Vib/(1+native_exp(-red*3)))+1;
float MS = 1.0f - S;
@@ -39,18 +36,21 @@ void vibranceKernel(const uchar4 *in, uchar4 *out) {
float Gt = Gf * MS;
float Bt = Bf * MS;
int t = (r + g) >> 1;
- R = r;
- G = g;
- B = b;
+
+ float R = r;
+ float G = g;
+ float B = b;
float Rc = R * (Rt + S) + G * Gt + B * Bt;
float Gc = R * Rt + G * (Gt + S) + B * Bt;
float Bc = R * Rt + G * Gt + B * (Bt + S);
- out->r = rsClamp(Rc, 0, 255);
- out->g = rsClamp(Gc, 0, 255);
- out->b = rsClamp(Bc, 0, 255);
-
+ uchar4 o;
+ o.r = rsClamp(Rc, 0, 255);
+ o.g = rsClamp(Gc, 0, 255);
+ o.b = rsClamp(Bc, 0, 255);
+ o.a = 0xff;
+ return o;
}
void prepareVibrance() {