diff options
Diffstat (limited to 'rs/rotator.rs')
-rw-r--r-- | rs/rotator.rs | 24 |
1 files changed, 20 insertions, 4 deletions
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 |