summaryrefslogtreecommitdiff
authorYuxi Sun <yuxi.sun@amlogic.com>2016-11-01 09:00:41 (GMT)
committer Yuxi Sun <yuxi.sun@amlogic.com>2016-11-01 10:19:23 (GMT)
commitb757fbda74b53dd77e9f2f2c4c1402ba0f0f1218 (patch)
tree380704954709cb6dafe57dc3b0f0d74e8f35635c
parentab2d169dcfdad840a268655ec15907a33c19e4c3 (diff)
downloadcamera-b757fbda74b53dd77e9f2f2c4c1402ba0f0f1218.zip
camera-b757fbda74b53dd77e9f2f2c4c1402ba0f0f1218.tar.gz
camera-b757fbda74b53dd77e9f2f2c4c1402ba0f0f1218.tar.bz2
PD#133846 Change MJPEG decode function to fix 64bit compile problem
Discard jpeg_decode function and use ConvertToI420 then convert to nv21 Change-Id: I4923b16e4447e6ee8df6fe3f8fb06f134980a9de
Diffstat
-rw-r--r--inc/mjpeg/defs.h2
-rw-r--r--v3/Android.mk3
-rw-r--r--v3/fake-pipeline2/Sensor.cpp63
3 files changed, 55 insertions, 13 deletions
diff --git a/inc/mjpeg/defs.h b/inc/mjpeg/defs.h
index 244e125..b286a08 100644
--- a/inc/mjpeg/defs.h
+++ b/inc/mjpeg/defs.h
@@ -40,7 +40,7 @@ typedef int8_t INT8;
typedef uint8_t UINT8;
typedef int16_t INT16;
typedef uint16_t UINT16;
-//typedef int32_t INT32;
+typedef int32_t INT32;
typedef uint32_t UINT32;
typedef int64_t INT64;
typedef uint64_t UINT64;
diff --git a/v3/Android.mk b/v3/Android.mk
index 8ab9013..88475ce 100644
--- a/v3/Android.mk
+++ b/v3/Android.mk
@@ -94,7 +94,6 @@ LOCAL_C_INCLUDES += external/jpeg \
$(LOCAL_PATH)/inc \
$(call include-path-for, camera) \
$(TOP)/external/expat/lib \
- $(LOCAL_PATH)/../inc/mjpeg/ \
LOCAL_SRC_FILES := \
EmulatedCameraHal.cpp \
@@ -124,8 +123,6 @@ LOCAL_SRC_FILES := \
fake-pipeline2/camera_hw.cpp \
VendorTags.cpp \
LoadXml.cpp \
- ../mjpeg/jpegdec.c \
- ../mjpeg/colorspaces.c \
ifeq ($(TARGET_PRODUCT),vbox_x86)
LOCAL_MODULE := camera.vbox_x86
diff --git a/v3/fake-pipeline2/Sensor.cpp b/v3/fake-pipeline2/Sensor.cpp
index c8d4c56..ae69b96 100644
--- a/v3/fake-pipeline2/Sensor.cpp
+++ b/v3/fake-pipeline2/Sensor.cpp
@@ -41,11 +41,6 @@
#include <sys/time.h>
-extern "C"{
- #include "jutils.h"
-}
-
-
#define ARRAY_SIZE(x) (sizeof((x))/sizeof(((x)[0])))
namespace android {
@@ -1985,12 +1980,40 @@ void Sensor::captureRGB(uint8_t *img, uint32_t gain, uint32_t stride) {
return;
}
#if ANDROID_PLATFORM_SDK_VERSION > 23
- if (jpeg_decode(&tmp_buffer, src, width, height, V4L2_PIX_FMT_NV21) != 0) {
+ uint8_t *vBuffer = new uint8_t[width * height / 4];
+ if (vBuffer == NULL)
+ ALOGE("alloc temperary v buffer failed\n");
+ uint8_t *uBuffer = new uint8_t[width * height / 4];
+ if (uBuffer == NULL)
+ ALOGE("alloc temperary u buffer failed\n");
+
+ if (ConvertToI420(src, vinfo->picture.buf.bytesused, tmp_buffer, width, uBuffer, (width + 1) / 2,
+ vBuffer, (width + 1) / 2, 0, 0, width, height,
+ width, height, libyuv::kRotate0, libyuv::FOURCC_MJPG) != 0) {
+ DBG_LOGA("Decode MJPEG frame failed\n");
+ putback_picture_frame(vinfo);
+ usleep(5000);
+ delete vBuffer;
+ delete uBuffer;
+ } else {
+
+ uint8_t *pUVBuffer = tmp_buffer + width * height;
+ for (int i = 0; i < width * height / 4; i++) {
+ *pUVBuffer++ = *(vBuffer + i);
+ *pUVBuffer++ = *(uBuffer + i);
+ }
+
+ delete vBuffer;
+ delete uBuffer;
+ nv21_to_rgb24(tmp_buffer,img,width,height);
+ if (tmp_buffer != NULL)
+ delete [] tmp_buffer;
+ break;
+ }
#else
if (ConvertMjpegToNV21(src, vinfo->picture.buf.bytesused, tmp_buffer,
width, tmp_buffer + width * height, (width + 1) / 2, width,
height, width, height, libyuv::FOURCC_MJPG) != 0) {
-#endif
DBG_LOGA("Decode MJPEG frame failed\n");
putback_picture_frame(vinfo);
usleep(5000);
@@ -2000,6 +2023,7 @@ void Sensor::captureRGB(uint8_t *img, uint32_t gain, uint32_t stride) {
delete [] tmp_buffer;
break;
}
+#endif
} else if (vinfo->picture.format.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) {
if (vinfo->picture.buf.length == vinfo->picture.buf.bytesused) {
yuyv422_to_rgb24(src,img,width,height);
@@ -2249,16 +2273,37 @@ void Sensor::captureNV21(StreamBuffer b, uint32_t gain) {
uint32_t height = vinfo->preview.format.fmt.pix.height;
memset(mTemp_buffer, 0 , width * height * 3/2);
#if ANDROID_PLATFORM_SDK_VERSION > 23
- if (jpeg_decode(&mTemp_buffer, src, width, height, V4L2_PIX_FMT_NV21) != 0) {
+ uint8_t *vBuffer = new uint8_t[width * height / 4];
+ if (vBuffer == NULL)
+ ALOGE("alloc temperary v buffer failed\n");
+ uint8_t *uBuffer = new uint8_t[width * height / 4];
+ if (uBuffer == NULL)
+ ALOGE("alloc temperary u buffer failed\n");
+
+ if (ConvertToI420(src, vinfo->preview.buf.bytesused, mTemp_buffer, width, uBuffer, (width + 1) / 2,
+ vBuffer, (width + 1) / 2, 0, 0, width, height,
+ width, height, libyuv::kRotate0, libyuv::FOURCC_MJPG) != 0) {
+ DBG_LOGA("Decode MJPEG frame failed\n");
+ putback_frame(vinfo);
+ ALOGE("%s , %d , Decode MJPEG frame failed \n", __FUNCTION__ , __LINE__);
+ continue;
+ }
+ uint8_t *pUVBuffer = mTemp_buffer + width * height;
+ for (int i = 0; i < width * height / 4; i++) {
+ *pUVBuffer++ = *(vBuffer + i);
+ *pUVBuffer++ = *(uBuffer + i);
+ }
+ delete vBuffer;
+ delete uBuffer;
#else
if (ConvertMjpegToNV21(src, vinfo->preview.buf.bytesused, mTemp_buffer,
width, mTemp_buffer + width * height, (width + 1) / 2, width,
height, width, height, libyuv::FOURCC_MJPG) != 0) {
-#endif
putback_frame(vinfo);
ALOGE("%s , %d , Decode MJPEG frame failed \n", __FUNCTION__ , __LINE__);
continue;
}
+#endif
if ((width == b.width) && (height == b.height)) {
memcpy(b.img, mTemp_buffer, b.width * b.height * 3/2);
mKernelBuffer = b.img;