author | jiyu.yang <jiyu.yang@amlogic.com> | 2013-11-27 11:47:39 (GMT) |
---|---|---|
committer | eric <eric.zhong@amlogic.com> | 2013-11-27 11:47:39 (GMT) |
commit | d671adb34ac9f111b9973f9b85bf2f637ba66d0d (patch) | |
tree | 06fef54822cec01b1362d94d0a882b2ce2f54464 | |
parent | 610b2b1e5435da81f0201fa3f4ecd159f77de8e9 (diff) | |
download | camera-d671adb34ac9f111b9973f9b85bf2f637ba66d0d.zip camera-d671adb34ac9f111b9973f9b85bf2f637ba66d0d.tar.gz camera-d671adb34ac9f111b9973f9b85bf2f637ba66d0d.tar.bz2 |
PD #82826:32 byte align for nv21 and yv12, remove print info
-rwxr-xr-x | V4LCameraAdapter/V4LCameraAdapter.cpp | 19 | ||||
-rwxr-xr-x | utils/util.cpp | 45 | ||||
-rwxr-xr-x | utils/util.h | 3 |
3 files changed, 64 insertions, 3 deletions
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp index 6ccefe2..4922878 100755 --- a/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -1537,9 +1537,17 @@ int V4LCameraAdapter::previewThread() } #else if ( CameraFrame::PIXEL_FMT_NV21 == mPixelFormat){ - memcpy(dest,src,frame.mLength); + if (frame.mLength == mVideoInfo->buf.length) { + memcpy(dest,src,frame.mLength); + }else{ + nv21_memcpy_align32 (dest, src, width, height); + } }else{ - yv12_adjust_memcpy(dest,src,width,height); + if (frame.mLength == mVideoInfo->buf.length) { + yv12_adjust_memcpy(dest,src,width,height); + } else { + yv12_memcpy_align32 (dest, src, width, height); + } } #endif }else{ //default case @@ -1873,7 +1881,12 @@ int V4LCameraAdapter::pictureThread() //convert yuyv to rgb24 yuyv422_to_rgb24(src,dest,width,height); #else - memcpy(dest,src,mVideoInfo->buf.length); + if (frame.mLength == mVideoInfo->buf.length) { + memcpy (dest, src, frame.mLength); + }else{ + rgb24_memcpy( dest, src, width, height); + CAMHAL_LOGVB("w*h*3=%d, mLenght=%d\n", width*height*3, mVideoInfo->buf.length); + } #endif }else if(DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT == V4L2_PIX_FMT_YUYV){ // 422I frame.mLength = width*height*2; diff --git a/utils/util.cpp b/utils/util.cpp index 652c463..069392c 100755 --- a/utils/util.cpp +++ b/utils/util.cpp @@ -322,6 +322,51 @@ void yuyv_to_yv12(unsigned char *src, unsigned char *dst, int width, int height) } } #endif +void rgb24_memcpy(unsigned char *dst, unsigned char *src, int width, int height) +{ + int stride = (width + 31) & ( ~31); + int w, h; + for (h=0; h<height; h++) + { + memcpy( dst, src, width*3); + dst += width*3; + src += stride*3; + } +} + +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; + } +} + void yv12_adjust_memcpy(unsigned char *dst, unsigned char *src, int width, int height) { //width should be an even number. diff --git a/utils/util.h b/utils/util.h index a4f2fc9..f0ab08c 100755 --- a/utils/util.h +++ b/utils/util.h @@ -9,4 +9,7 @@ void yuyv422_to_rgb24(unsigned char *buf, unsigned char *rgb, int width, int hei void yuyv422_to_nv21(unsigned char *bufsrc, unsigned char *bufdest, int width, int height); void yv12_adjust_memcpy(unsigned char *dst, unsigned char *src, int width, int height); void yuyv_to_yv12(unsigned char *src, unsigned char *dst, int width, int height); +void rgb24_memcpy(unsigned char *dst, unsigned char *src, 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); #endif /* AML_CAMERA_HARDWARE_INCLUDE_*/ |