Permalink
Browse files

camera: add Morpho DNR support

-- Use to Morpho DNR (Digital Noise Reduction) for low-ligth conditions (under
   50lux).
-- Remove logspam

Bug: 7131846
Bug: 7138612
Change-Id: Ie8b66ddb0307ec5f779d60033eae766ed12b13ed
Signed-off-by: Iliyan Malchev <malchev@google.com>
  • Loading branch information...
insupchoi0513 authored and The Android Automerger committed Oct 1, 2012
1 parent 2e58bad commit cf96c98c5e4140d9d8d0f5b9c905ce4de3968154
View
@@ -24,6 +24,8 @@
#include <cutils/properties.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <string.h>
+#include <dlfcn.h>
#include "QCameraHAL.h"
#include "QCameraHWI.h"
@@ -282,6 +284,13 @@ QCameraHardwareInterface(int cameraId, int mode)
return;
}
mCameraState = CAMERA_STATE_READY;
+ libdnr = dlopen("libmorpho_noise_reduction.so", RTLD_NOW);
+ if (libdnr) {
+ ALOGD("Open MM camera DL libmorpho_noise_reduction loaded at %p & %p ", libdnr);
+ *(void **)&LINK_morpho_DNR_ProcessFrame = dlsym(libdnr, "LINK_mm_camera_morpho_noise_reduction");
+ }
+ else
+ ALOGE("failed to open libmorpho_noise_reduction");
ALOGI("QCameraHardwareInterface: X");
}
@@ -332,6 +341,11 @@ QCameraHardwareInterface::~QCameraHardwareInterface()
QCameraStream_Snapshot::deleteInstance (mStreamSnap);
mStreamSnap = NULL;
}
+ if (libdnr != NULL) {
+ dlclose(libdnr);
+ libdnr = NULL;
+ ALOGD("closed libmorpho_noise_reduction.so");
+ }
if (mStreamLiveSnap){
QCameraStream_Snapshot::deleteInstance (mStreamLiveSnap);
@@ -1389,7 +1403,7 @@ void QCameraHardwareInterface::releaseRecordingFrame(const void *opaque)
status_t QCameraHardwareInterface::autoFocusMoveEvent(cam_ctrl_status_t *status, app_notify_cb_t *app_cb)
{
- ALOGI("autoFocusMoveEvent: E");
+ ALOGV("autoFocusMoveEvent: E");
int ret = NO_ERROR;
isp3a_af_mode_t afMode = getAutoFocusMode(mParameters);
@@ -1412,7 +1426,7 @@ status_t QCameraHardwareInterface::autoFocusMoveEvent(cam_ctrl_status_t *status,
ALOGE("%s:Unknown AF Move Status received (%d) received",__func__,*status);
}
}
- ALOGI("autoFocusMoveEvent: X");
+ ALOGV("autoFocusMoveEvent: X");
return ret;
}
@@ -1473,7 +1487,7 @@ status_t QCameraHardwareInterface::autoFocusEvent(cam_ctrl_status_t *status, app
app_cb->argm_notify.ext2 = 0;
app_cb->argm_notify.cookie = mCallbackCookie;
- ALOGD("Auto foucs state =%d", *status);
+ ALOGV("Auto focus state =%d", *status);
if(*status==CAM_CTRL_SUCCESS) {
app_cb->argm_notify.ext1 = true;
}
View
@@ -45,6 +45,7 @@ extern "C" {
#include "QCameraStream.h"
#include "QCamera_Intf.h"
+#include "hdr/include/morpho_noise_reduction_ext.h"
//Error codes
#define NOT_FOUND -1
#define MAX_ZOOM_RATIOS 62
@@ -800,6 +801,8 @@ class QCameraHardwareInterface : public virtual RefBase {
camera_size_type* mVideoSizes;
const camera_size_type * mPictureSizesPtr;
HAL_camera_state_type_t mCameraState;
+ void *libdnr;
+ int (*LINK_morpho_DNR_ProcessFrame)(unsigned char* yuvImage, int width, int height, int y_level, int c_level);
/* Temporary - can be removed after Honeycomb*/
#ifdef USE_ION
View
30 QCameraHWI_Still.cpp 100755 → 100644
@@ -1832,6 +1832,7 @@ status_t QCameraStream_Snapshot::receiveRawPicture(mm_camera_ch_data_buf_t* recv
int buf_index = 0;
common_crop_t crop;
int rc = NO_ERROR;
+ int cur_lux_idx = 0;
camera_notify_callback notifyCb;
camera_data_callback dataCb, jpgDataCb;
@@ -1910,7 +1911,34 @@ status_t QCameraStream_Snapshot::receiveRawPicture(mm_camera_ch_data_buf_t* recv
return BAD_VALUE;
}
memcpy(frame, recvd_frame, sizeof(mm_camera_ch_data_buf_t));
-
+ rc = cam_config_get_parm(mCameraId, MM_CAMERA_PARM_LUX_IDX, &cur_lux_idx);
+
+ if (cur_lux_idx > 370) {
+ static int input_width = 0, input_height = 0;
+ static int ret = 0;
+ unsigned char *dnr_buffer;
+ input_width = mPictureWidth;
+ input_height = mPictureHeight;
+
+ ALOGV("%s: received frame %d * %d", __func__, input_width, input_height);
+ {
+ dnr_buffer = (uint8_t *)malloc(input_width*input_height*3/2);
+ if (dnr_buffer == NULL)
+ ALOGV("dnr_buffer alloc fail");
+ ALOGV("dnr_buffer allocated size : %d", input_width*input_height*3/2);
+ memcpy(dnr_buffer, (uint8_t *)frame->snapshot.main.frame->buffer, input_width*input_height*3/2);
+ ALOGV("dnr_buffer memcpy completed.");
+ }
+ ALOGV("[DNR] DNR Processing Start.... %d * %d\n", mPictureWidth, mPictureHeight);
+ ret = NO_ERROR;
+ if (mHalCamCtrl->LINK_morpho_DNR_ProcessFrame)
+ ret = (int)mHalCamCtrl->LINK_morpho_DNR_ProcessFrame(dnr_buffer, mPictureWidth, mPictureHeight, 1, 1); //bright->normal->dark
+ ALOGV("[DNR] DNR Processing result.... ret = %d\n", ret);
+ memcpy((uint8_t *)recvd_frame->snapshot.main.frame->buffer, (uint8_t *)dnr_buffer, mPictureWidth*mPictureHeight*3/2);
+ ALOGV("[DNR] DNR Processing END....\n");
+ if(dnr_buffer)
+ free(dnr_buffer);
+ }
//mStopCallbackLock.lock();
// only in ZSL mode and Wavelet Denoise is enabled, we will send frame to deamon to do WDN
View
@@ -470,6 +470,7 @@ typedef enum {
#ifdef FAST_AF
MM_CAMERA_PARM_CAF_TYPE,
#endif
+ MM_CAMERA_PARM_LUX_IDX,
MM_CAMERA_PARM_MAX
} mm_camera_parm_type_t;
@@ -619,6 +620,7 @@ typedef enum {
#ifdef FAST_AF
CAMERA_SET_PARM_CAF_TYPE,
#endif
+ CAMERA_GET_PARM_LUX_IDX,
CAMERA_CTRL_PARM_MAX
} cam_ctrl_type;
View
@@ -0,0 +1,23 @@
+/**
+ * @file morpho_api.h
+ * @brief API関数定義のマクロ
+ * @version 1.0.0
+ * @date Tue Sep 21 17:37:35 2010
+ *
+ * Copyright (C) 2006-2012 Morpho, Inc.
+ */
+
+#ifndef MORPHO_API_H
+#define MORPHO_API_H
+
+/**
+ * API関数を定義するときに使用.
+ * WindowsでDLLを作成する際等に書き換えることで切り替え可能
+ */
+#if defined(MORPHO_DLL) && defined(_WIN32)
+#define MORPHO_API(type) __declspec(dllexport) extern type
+#else
+#define MORPHO_API(type) extern type
+#endif
+
+#endif /* #ifndef MORPHO_API_H */
Oops, something went wrong.

0 comments on commit cf96c98

Please sign in to comment.