summaryrefslogtreecommitdiff
Diffstat
-rwxr-xr-xv3/fake-pipeline2/Sensor.cpp12
-rwxr-xr-xv3/fake-pipeline2/util.c52
-rwxr-xr-xv3/fake-pipeline2/util.h2
3 files changed, 54 insertions, 12 deletions
diff --git a/v3/fake-pipeline2/util.c b/v3/fake-pipeline2/util.c
index 1314d7c..690f853 100755
--- a/v3/fake-pipeline2/util.c
+++ b/v3/fake-pipeline2/util.c
@@ -18,7 +18,7 @@ static inline void yuv_to_rgb24(unsigned char y,unsigned char u,unsigned char v,
g = g > 255 ? 255 : g < 0 ? 0 : g;
b = b > 255 ? 255 : b < 0 ? 0 : b;
- rgb24 = (int)((r <<16) | (g << 8)| b);
+ rgb24 = (int)((r << 16) | (g << 8)| b);
*rgb = (unsigned char)r;
rgb++;
@@ -34,7 +34,7 @@ void yuyv422_to_rgb24(unsigned char *buf, unsigned char *rgb, int width, int hei
blocks = (width * height) * 2;
- for (y = 0,z=0; y < blocks; y+=4,z+=6) {
+ for (y = 0,z = 0; y < blocks; y += 4,z += 6) {
unsigned char Y1, Y2, U, V;
Y1 = buf[y + 0];
@@ -49,25 +49,57 @@ void yuyv422_to_rgb24(unsigned char *buf, unsigned char *rgb, int width, int hei
void nv21_to_rgb24(unsigned char *buf, unsigned char *rgb, int width, int height)
{
- int x,y,z=0;
+ int x,y,z = 0;
int h,w;
int blocks;
unsigned char Y1, Y2, U, V;
blocks = (width * height) * 2;
- for(h=0, z=0; h< height; h+=2){
- for (y = 0; y < width*2; y+=2) {
+ for (h = 0, z = 0; h < height; h += 2) {
+ for (y = 0; y < width * 2; y += 2) {
- Y1 = buf[ h*width + y + 0];
- V = buf[ blocks/2 + h*width/2 + y%width + 0 ];
- Y2 = buf[ h*width + y + 1];
- U = buf[ blocks/2 + h*width/2 + y%width + 1 ];
+ Y1 = buf[ h * width + y + 0];
+ V = buf[ blocks/2 + h * width/2 + y % width + 0 ];
+ Y2 = buf[ h * width + y + 1];
+ U = buf[ blocks/2 + h * width/2 + y % width + 1 ];
yuv_to_rgb24(Y1, U, V, &rgb[z]);
yuv_to_rgb24(Y2, U, V, &rgb[z + 3]);
- z+=6;
+ z += 6;
}
}
}
+void nv21_memcpy_align32(unsigned char *dst, unsigned char *src, int width, int height)
+{
+ int stride = (width + 31) & ( ~31);
+ int w, h;
+ for (h = 0; h < height* 3/2; h++)
+ {
+ memcpy( dst, src, width);
+ dst += width;
+ src += stride;
+ }
+}
+
+void yv12_memcpy_align32(unsigned char *dst, unsigned char *src, int width, int height)
+{
+ int new_width = (width + 63) & ( ~63);
+ int stride;
+ int w, h;
+ for (h = 0; h < height; h++)
+ {
+ memcpy( dst, src, width);
+ dst += width;
+ src += new_width;
+ }
+ stride = ALIGN( width/2, 16);
+ for (h = 0; h < height; h++)
+ {
+ memcpy( dst, src, width/2);
+ dst += stride;
+ src += new_width/2;
+ }
+}
+