author | Guosong Zhou <guosong.zhou@amlogic.com> | 2015-01-29 11:35:51 (GMT) |
---|---|---|
committer | Guosong Zhou <guosong.zhou@amlogic.com> | 2015-01-29 12:11:59 (GMT) |
commit | 1f6589589dd0da80a5763ec047ba0ce3fc00ab0f (patch) | |
tree | 6187d92d0e62674c5645b0c900ba52efa8780137 | |
parent | b16271acf212cfa28a29bf912f26801458e8b40a (diff) | |
download | camera-1f6589589dd0da80a5763ec047ba0ce3fc00ab0f.zip camera-1f6589589dd0da80a5763ec047ba0ce3fc00ab0f.tar.gz camera-1f6589589dd0da80a5763ec047ba0ce3fc00ab0f.tar.bz2 |
add qcif resolution for cts
Change-Id: I5b76c1190edd56976f8a867d5bffbf58f38b1ba7
Signed-off-by: Guosong Zhou <guosong.zhou@amlogic.com>
-rwxr-xr-x | v3/fake-pipeline2/Sensor.cpp | 12 | ||||
-rwxr-xr-x | v3/fake-pipeline2/util.c | 52 | ||||
-rwxr-xr-x | v3/fake-pipeline2/util.h | 2 |
3 files changed, 54 insertions, 12 deletions
diff --git a/v3/fake-pipeline2/Sensor.cpp b/v3/fake-pipeline2/Sensor.cpp index 09818d6..68a76be 100755 --- a/v3/fake-pipeline2/Sensor.cpp +++ b/v3/fake-pipeline2/Sensor.cpp @@ -2021,7 +2021,11 @@ void Sensor::captureNV21(StreamBuffer b, uint32_t gain) { continue; } if (vinfo->preview.format.fmt.pix.pixelformat == V4L2_PIX_FMT_NV21) { - memcpy(b.img, src, vinfo->preview.buf.length); + if (vinfo->preview.buf.length == b.width * b.height * 3/2) { + memcpy(b.img, src, vinfo->preview.buf.length); + } else { + nv21_memcpy_align32 (b.img, src, b.width, b.height); + } mKernelBuffer = src; } else if (vinfo->preview.format.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) { int width = vinfo->preview.format.fmt.pix.width; @@ -2189,7 +2193,11 @@ void Sensor::captureYV12(StreamBuffer b, uint32_t gain) { continue; } if (vinfo->preview.format.fmt.pix.pixelformat == V4L2_PIX_FMT_YVU420) { - memcpy(b.img, src, vinfo->preview.buf.length); + if (vinfo->preview.buf.length == b.width * b.height * 3/2) { + memcpy(b.img, src, vinfo->preview.buf.length); + } else { + yv12_memcpy_align32 (b.img, src, b.width, b.height); + } } else if (vinfo->preview.format.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) { int width = vinfo->preview.format.fmt.pix.width; int height = vinfo->preview.format.fmt.pix.height; 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;
+ }
+}
+
diff --git a/v3/fake-pipeline2/util.h b/v3/fake-pipeline2/util.h index 18969a8..16ef745 100755 --- a/v3/fake-pipeline2/util.h +++ b/v3/fake-pipeline2/util.h @@ -7,6 +7,8 @@ extern "C" { void yuyv422_to_rgb24(unsigned char *buf, unsigned char *rgb, int width, int height);
void nv21_to_rgb24(unsigned char *buf, unsigned char *rgb, int width, int height);
+void nv21_memcpy_align32(unsigned char *dst, unsigned char *src, int width, int height);
+void yv12_memcpy_align32(unsigned char *dst, unsigned char *src, int width, int height);
#ifdef __cplusplus
}
|