diff options
author | Jason Sams <jsams@google.com> | 2013-11-13 18:46:36 -0800 |
---|---|---|
committer | Jason Sams <jsams@google.com> | 2013-11-25 16:37:44 -0800 |
commit | ab84c3968abce348c212bc9d466c534bc2a03cd6 (patch) | |
tree | b5e8c5cadda859158b821f057a60a6de3fa161af | |
parent | 013ee925cef494eb0b12118803e842ac8f22c4c1 (diff) | |
download | rs-ab84c3968abce348c212bc9d466c534bc2a03cd6.tar.gz |
More IP cleanup.
Rename all .fs to .rs
Switch most kernels to new style.
Change-Id: I07643cd1a2c650ef7d2a6fbc17da09246c50125a
21 files changed, 167 insertions, 203 deletions
diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/colorcube.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/colorcube.rs index c0d6ace0..a501ee63 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/colorcube.rs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/colorcube.rs @@ -32,15 +32,10 @@ void setCube(rs_allocation c) { float4 m = (float4)(1.f / 255.f) * convert_float4(gDims - 1); gCoordMul = convert_int4(m * (float4)0x10000); - - rsDebug("dims", gDims); - rsDebug("gCoordMul", gCoordMul); } -void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { - //rsDebug("root", in); - - int4 baseCoord = convert_int4(*in) * gCoordMul; +uchar4 __attribute__((kernel)) root(uchar4 in) { + int4 baseCoord = convert_int4(in) * gCoordMul; int4 coord1 = baseCoord >> (int4)16; int4 coord2 = min(coord1 + 1, gDims - 1); @@ -67,23 +62,8 @@ void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { uint4 v = ((z0 * weight1.z) + (z1 * weight2.z)) >> (uint4)16; uint4 v2 = (v + 0x7f) >> (uint4)8; - *out = convert_uchar4(v2); - out->a = 0xff; - - #if 0 - if (in->r != out->r) { - rsDebug("dr", in->r - out->r); - //rsDebug("in", convert_int4(*in)); - //rsDebug("coord1", coord1); - //rsDebug("coord2", coord2); - //rsDebug("weight1", weight1); - //rsDebug("weight2", weight2); - //rsDebug("yz00", yz00); - //rsDebug("z0", z0); - //rsDebug("v", v); - //rsDebug("v2", v2); - //rsDebug("out", convert_int4(*out)); - } - #endif + uchar4 o = convert_uchar4(v2); + o.a = 0xff; + return o; } diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/colormatrix.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/colormatrix.rs index 86fb2482..86fb2482 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/colormatrix.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/colormatrix.rs diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/contrast.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/contrast.rs index ef6fd635..06c18023 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/contrast.rs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/contrast.rs @@ -25,8 +25,10 @@ void setBright(float v) { brightC = 127.f - brightM * 127.f; } -void contrast(const uchar4 *in, uchar4 *out) -{ - float3 v = convert_float3(in->rgb) * brightM + brightC; - out->rgb = convert_uchar3(clamp(v, 0.f, 255.f)); +uchar4 __attribute__((kernel)) contrast(uchar4 in) { + float3 v = convert_float3(in.rgb) * brightM + brightC; + uchar4 o; + o.rgb = convert_uchar3(clamp(v, 0.f, 255.f)); + o.a = 0xff; + return o; } diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.fs deleted file mode 100644 index 4f8b4d80..00000000 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.fs +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ip.rsh" - -int32_t gWidth; -int32_t gHeight; -rs_allocation gIn; - -float gCoeffs[9]; - -uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { - uint32_t x1 = min((int32_t)x+1, gWidth-1); - uint32_t x2 = max((int32_t)x-1, 0); - uint32_t y1 = min((int32_t)y+1, gHeight-1); - uint32_t y2 = max((int32_t)y-1, 0); - - float4 result; - - float4 p00 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y1)); - float4 p01 = convert_float4(rsGetElementAt_uchar4(gIn, x, y1)); - float4 p02 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y1)); - float4 p10 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y)); - float4 p11 = convert_float4(rsGetElementAt_uchar4(gIn, x, y)); - float4 p12 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y)); - float4 p20 = convert_float4(rsGetElementAt_uchar4(gIn, x1, y2)); - float4 p21 = convert_float4(rsGetElementAt_uchar4(gIn, x, y2)); - float4 p22 = convert_float4(rsGetElementAt_uchar4(gIn, x2, y2)); - - result = p00 * gCoeffs[0]; - result += p01 * gCoeffs[1]; - result += p02 * gCoeffs[2]; - result += p10 * gCoeffs[3]; - result += p11 * gCoeffs[4]; - result += p12 * gCoeffs[5]; - result += p20 * gCoeffs[6]; - result += p21 * gCoeffs[7]; - result += p22 * gCoeffs[8]; - - result = clamp(result, 0.f, 255.f); - return convert_uchar4(result); -} - - diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.rs new file mode 100644 index 00000000..1b1cf3fb --- /dev/null +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve3x3.rs @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ip.rsh" +#pragma rs_fp_relaxed + +int32_t gWidth; +int32_t gHeight; +rs_allocation gIn; + +float gCoeffs[9]; + +uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { + uint32_t x1 = min((int32_t)x+1, gWidth-1); + uint32_t x2 = max((int32_t)x-1, 0); + uint32_t y1 = min((int32_t)y+1, gHeight-1); + uint32_t y2 = max((int32_t)y-1, 0); + + float4 sum = convert_float4(rsGetElementAt_uchar4(gIn, x1, y1)) * gCoeffs[0]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x, y1)) * gCoeffs[1]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x2, y1)) * gCoeffs[2]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x1, y)) * gCoeffs[3]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x, y)) * gCoeffs[4]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x2, y)) * gCoeffs[5]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x1, y2)) * gCoeffs[6]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x, y2)) * gCoeffs[7]; + sum += convert_float4(rsGetElementAt_uchar4(gIn, x2, y2)) * gCoeffs[8]; + + sum = clamp(sum, 0.f, 255.f); + return convert_uchar4(sum); +} + + diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.fs deleted file mode 100644 index 922a5930..00000000 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.fs +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ip.rsh" - -int32_t gWidth; -int32_t gHeight; -rs_allocation gIn; - -float gCoeffs[25]; - -uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { - uint32_t x0 = max((int32_t)x-2, 0); - uint32_t x1 = max((int32_t)x-1, 0); - uint32_t x2 = x; - uint32_t x3 = min((int32_t)x+1, gWidth-1); - uint32_t x4 = min((int32_t)x+2, gWidth-1); - - uint32_t y0 = max((int32_t)y-2, 0); - uint32_t y1 = max((int32_t)y-1, 0); - uint32_t y2 = y; - uint32_t y3 = min((int32_t)y+1, gHeight-1); - uint32_t y4 = min((int32_t)y+2, gHeight-1); - - float4 p0 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y0)) * gCoeffs[0] - + convert_float4(rsGetElementAt_uchar4(gIn, x1, y0)) * gCoeffs[1] - + convert_float4(rsGetElementAt_uchar4(gIn, x2, y0)) * gCoeffs[2] - + convert_float4(rsGetElementAt_uchar4(gIn, x3, y0)) * gCoeffs[3] - + convert_float4(rsGetElementAt_uchar4(gIn, x4, y0)) * gCoeffs[4]; - - float4 p1 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y1)) * gCoeffs[5] - + convert_float4(rsGetElementAt_uchar4(gIn, x1, y1)) * gCoeffs[6] - + convert_float4(rsGetElementAt_uchar4(gIn, x2, y1)) * gCoeffs[7] - + convert_float4(rsGetElementAt_uchar4(gIn, x3, y1)) * gCoeffs[8] - + convert_float4(rsGetElementAt_uchar4(gIn, x4, y1)) * gCoeffs[9]; - - float4 p2 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y2)) * gCoeffs[10] - + convert_float4(rsGetElementAt_uchar4(gIn, x1, y2)) * gCoeffs[11] - + convert_float4(rsGetElementAt_uchar4(gIn, x2, y2)) * gCoeffs[12] - + convert_float4(rsGetElementAt_uchar4(gIn, x3, y2)) * gCoeffs[13] - + convert_float4(rsGetElementAt_uchar4(gIn, x4, y2)) * gCoeffs[14]; - - float4 p3 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y3)) * gCoeffs[15] - + convert_float4(rsGetElementAt_uchar4(gIn, x1, y3)) * gCoeffs[16] - + convert_float4(rsGetElementAt_uchar4(gIn, x2, y3)) * gCoeffs[17] - + convert_float4(rsGetElementAt_uchar4(gIn, x3, y3)) * gCoeffs[18] - + convert_float4(rsGetElementAt_uchar4(gIn, x4, y3)) * gCoeffs[19]; - - float4 p4 = convert_float4(rsGetElementAt_uchar4(gIn, x0, y4)) * gCoeffs[20] - + convert_float4(rsGetElementAt_uchar4(gIn, x1, y4)) * gCoeffs[21] - + convert_float4(rsGetElementAt_uchar4(gIn, x2, y4)) * gCoeffs[22] - + convert_float4(rsGetElementAt_uchar4(gIn, x3, y4)) * gCoeffs[23] - + convert_float4(rsGetElementAt_uchar4(gIn, x4, y4)) * gCoeffs[24]; - - p0 = clamp(p0 + p1 + p2 + p3 + p4, 0.f, 255.f); - return convert_uchar4(p0); -} - - diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.rs new file mode 100644 index 00000000..ed8461bd --- /dev/null +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/convolve5x5.rs @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ip.rsh" +#pragma rs_fp_relaxed + +int32_t gWidth; +int32_t gHeight; +rs_allocation gIn; + +float gCoeffs[25]; + +uchar4 __attribute__((kernel)) root(uint32_t x, uint32_t y) { + uint32_t x0 = max((int32_t)x-2, 0); + uint32_t x1 = max((int32_t)x-1, 0); + uint32_t x2 = x; + uint32_t x3 = min((int32_t)x+1, gWidth-1); + uint32_t x4 = min((int32_t)x+2, gWidth-1); + + uint32_t y0 = max((int32_t)y-2, 0); + uint32_t y1 = max((int32_t)y-1, 0); + uint32_t y2 = y; + uint32_t y3 = min((int32_t)y+1, gHeight-1); + uint32_t y4 = min((int32_t)y+2, gHeight-1); + + float4 sum = convert_float4(rsGetElementAt_uchar4(gIn, x0, y0)) * gCoeffs[0] + + convert_float4(rsGetElementAt_uchar4(gIn, x1, y0)) * gCoeffs[1] + + convert_float4(rsGetElementAt_uchar4(gIn, x2, y0)) * gCoeffs[2] + + convert_float4(rsGetElementAt_uchar4(gIn, x3, y0)) * gCoeffs[3] + + convert_float4(rsGetElementAt_uchar4(gIn, x4, y0)) * gCoeffs[4] + + + convert_float4(rsGetElementAt_uchar4(gIn, x0, y1)) * gCoeffs[5] + + convert_float4(rsGetElementAt_uchar4(gIn, x1, y1)) * gCoeffs[6] + + convert_float4(rsGetElementAt_uchar4(gIn, x2, y1)) * gCoeffs[7] + + convert_float4(rsGetElementAt_uchar4(gIn, x3, y1)) * gCoeffs[8] + + convert_float4(rsGetElementAt_uchar4(gIn, x4, y1)) * gCoeffs[9] + + + convert_float4(rsGetElementAt_uchar4(gIn, x0, y2)) * gCoeffs[10] + + convert_float4(rsGetElementAt_uchar4(gIn, x1, y2)) * gCoeffs[11] + + convert_float4(rsGetElementAt_uchar4(gIn, x2, y2)) * gCoeffs[12] + + convert_float4(rsGetElementAt_uchar4(gIn, x3, y2)) * gCoeffs[13] + + convert_float4(rsGetElementAt_uchar4(gIn, x4, y2)) * gCoeffs[14] + + + convert_float4(rsGetElementAt_uchar4(gIn, x0, y3)) * gCoeffs[15] + + convert_float4(rsGetElementAt_uchar4(gIn, x1, y3)) * gCoeffs[16] + + convert_float4(rsGetElementAt_uchar4(gIn, x2, y3)) * gCoeffs[17] + + convert_float4(rsGetElementAt_uchar4(gIn, x3, y3)) * gCoeffs[18] + + convert_float4(rsGetElementAt_uchar4(gIn, x4, y3)) * gCoeffs[19] + + + convert_float4(rsGetElementAt_uchar4(gIn, x0, y4)) * gCoeffs[20] + + convert_float4(rsGetElementAt_uchar4(gIn, x1, y4)) * gCoeffs[21] + + convert_float4(rsGetElementAt_uchar4(gIn, x2, y4)) * gCoeffs[22] + + convert_float4(rsGetElementAt_uchar4(gIn, x3, y4)) * gCoeffs[23] + + convert_float4(rsGetElementAt_uchar4(gIn, x4, y4)) * gCoeffs[24]; + + return convert_uchar4(clamp(sum, 0.f, 255.f)); +} + + diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/copy.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/copy.rs index 65958748..b69f2dfe 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/copy.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/copy.rs @@ -15,6 +15,7 @@ */ #include "ip.rsh" +#pragma rs_fp_relaxed uchar4 __attribute__((kernel)) root(uchar4 v_in) { return v_in; diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye.rsh b/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye.rsh index 2eacb7d4..fb95005a 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye.rsh +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye.rsh @@ -33,7 +33,7 @@ void init_filter(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y, axis_scale.y = (float)dim_y / (float)dim_x; else axis_scale.x = (float)dim_x / (float)dim_y; - + const float bound2 = 0.25f * (axis_scale.x*axis_scale.x + axis_scale.y*axis_scale.y); const float bound = sqrt(bound2); const float radius = 1.15f * bound; diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_relaxed.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_relaxed.rs index ed69ff46..ed69ff46 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_relaxed.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_approx_relaxed.rs diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_relaxed.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_relaxed.rs index f986b5df..31646c40 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_relaxed.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/fisheye_relaxed.rs @@ -15,6 +15,7 @@ */ #include "ip.rsh" +#pragma rs_fp_relaxed #include "fisheye.rsh" diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/grain.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/grain.rs index 2e62cd7f..2e62cd7f 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/grain.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/grain.rs diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/greyscale.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/greyscale.rs index 4e13072c..4e13072c 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/greyscale.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/greyscale.rs diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels.rsh b/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels.rsh index e289906b..b864493f 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels.rsh +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels.rsh @@ -21,7 +21,7 @@ float outWMinOutB; float overInWMinInB; rs_matrix3x3 colorMat; -uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root(uchar4 in) { uchar4 out; float3 pixel = convert_float4(in).rgb; pixel = rsMatrixMultiply(&colorMat, pixel); @@ -34,7 +34,7 @@ uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) { return out; } -uchar4 __attribute__((kernel)) root4(uchar4 in, uint32_t x, uint32_t y) { +uchar4 __attribute__((kernel)) root4(uchar4 in) { float4 pixel = convert_float4(in); pixel.rgb = rsMatrixMultiply(&colorMat, pixel.rgb); pixel = clamp(pixel, 0.f, 255.f); diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels_relaxed.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels_relaxed.rs index 28596ba4..c0bc4b7c 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels_relaxed.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/levels_relaxed.rs @@ -15,6 +15,7 @@ */ #include "ip.rsh" +#pragma rs_fp_relaxed #include "levels.rsh" diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs index 107fd3a5..2f061047 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs @@ -183,9 +183,9 @@ void prepareShadows(float scale) { } } -void shadowsKernel(const uchar4 *in, uchar4 *out) { - ushort3 hsv = rgb2hsv(*in); +uchar4 __attribute__((kernel)) shadowsKernel(uchar4 in) { + ushort3 hsv = rgb2hsv(in); float v = (fastevalPoly(poly, 5, hsv.x * (1.f / 4080.f)) * 4080.f); hsv.x = (unsigned short) clamp(v, 0.f, 4080.f); - *out = hsv2rgb(hsv); + return hsv2rgb(hsv); } diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/threshold.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/threshold.rs index 0b2c2e86..d30a87b5 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/threshold.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/threshold.rs @@ -15,7 +15,7 @@ */ #include "ip.rsh" - +#pragma rs_fp_relaxed int height; int width; 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() { diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_relaxed.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_relaxed.rs index 00cbbc4d..00cbbc4d 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_relaxed.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_approx_relaxed.rs diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_relaxed.fs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_relaxed.rs index 8202c5c1..262d516b 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_relaxed.fs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/vignette_relaxed.rs @@ -15,6 +15,7 @@ */ #include "ip.rsh" +#pragma rs_fp_relaxed #include "vignette.rsh" diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/wbalance.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/wbalance.rs index b5ab14ff..c8036409 100644 --- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/wbalance.rs +++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/wbalance.rs @@ -23,9 +23,7 @@ rs_allocation histogramSource; uint32_t histogramHeight; uint32_t histogramWidth; -static float scaleR; -static float scaleG; -static float scaleB; +static float3 scale; static uchar4 estimateWhite() { @@ -115,28 +113,19 @@ void prepareWhiteBalance() { int maximum = max(estimation.r, max(estimation.g, estimation.b)); float avg = (minimum + maximum) / 2.f; - scaleR = avg/estimation.r; - scaleG = avg/estimation.g; - scaleB = avg/estimation.b; - -} - -static unsigned char contrastClamp(int c) -{ - int N = 255; - c &= ~(c >> 31); - c -= N; - c &= (c >> 31); - c += N; - return (unsigned char) c; + scale.r = avg/estimation.r; + scale.g = avg/estimation.g; + scale.b = avg/estimation.b; } -void whiteBalanceKernel(const uchar4 *in, uchar4 *out) { - float Rc = in->r*scaleR; - float Gc = in->g*scaleG; - float Bc = in->b*scaleB; +uchar4 __attribute__((kernel)) whiteBalanceKernel(uchar4 in) { + float3 t = convert_float3(in.rgb); + t *= scale; + t = min(t, 255.f); - out->r = contrastClamp(Rc); - out->g = contrastClamp(Gc); - out->b = contrastClamp(Bc); + uchar4 out; + out.rgb = convert_uchar3(t); + out.a = 255; + return out; } + |