Merge "Camera: Increase MAX_EXIF_TABLE_ENTRIES to 17" into klp-dev
diff --git a/QCamera2/HAL3/QCamera3HWI.cpp b/QCamera2/HAL3/QCamera3HWI.cpp
index 9fbfa86..da8282f 100644
--- a/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/QCamera2/HAL3/QCamera3HWI.cpp
@@ -48,7 +48,6 @@
namespace qcamera {
#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define DATA_PTR(MEM_OBJ,INDEX) MEM_OBJ->getPtr( INDEX )
cam_capability_t *gCamCapability[MM_CAMERA_MAX_NUM_SENSORS];
@@ -2250,17 +2249,18 @@
}
/*===========================================================================
- * FUNCTION : intersectWithRegions
+ * FUNCTION : convertFromRegions
*
- * DESCRIPTION: helper method to intersect an existing region with new region
+ * DESCRIPTION: helper method to convert from array to cam_rect_t
*
* PARAMETERS :
- * @roi : roi to be intersected
- * @settings : camera_metadata_t structure containing setting
- * @tag : metadata tag to intersect with roi
+ * @rect : cam_rect_t struct to convert
+ * @region : int32_t destination array
+ * @weight : if we are converting from cam_area_t, weight is valid
+ * else weight = -1
*
*==========================================================================*/
-void QCamera3HardwareInterface::intersectWithRegions(cam_area_t* roi,
+void QCamera3HardwareInterface::convertFromRegions(cam_area_t* roi,
const camera_metadata_t *settings,
uint32_t tag){
CameraMetadata frame_settings;
@@ -2269,19 +2269,15 @@
int32_t y_min = frame_settings.find(tag).data.i32[1];
int32_t x_max = frame_settings.find(tag).data.i32[2];
int32_t y_max = frame_settings.find(tag).data.i32[3];
- int32_t weight = frame_settings.find(tag).data.i32[4];
-
- if (weight > 0) {
- roi->rect.left = MAX(x_min, roi->rect.left);
- roi->rect.top = MAX(y_min, roi->rect.top);
- roi->rect.width = MIN(x_max - x_min, roi->rect.width);
- roi->rect.height = MIN(y_max - y_min, roi->rect.height);
- roi->weight = weight;
- }
+ roi->weight = frame_settings.find(tag).data.i32[4];
+ roi->rect.left = x_min;
+ roi->rect.top = y_min;
+ roi->rect.width = x_max - x_min;
+ roi->rect.height = y_max - y_min;
}
/*===========================================================================
- * FUNCTION : convertFromCropRegion
+ * FUNCTION : resetIfNeededROI
*
* DESCRIPTION: helper method to reset the roi if it is greater than scaler
* crop region
@@ -2292,14 +2288,34 @@
*
*
*==========================================================================*/
-void QCamera3HardwareInterface::convertFromCropRegion(cam_area_t* roi,
+bool QCamera3HardwareInterface::resetIfNeededROI(cam_area_t* roi,
const cam_crop_region_t* scalerCropRegion)
{
- roi->weight = 1;
- roi->rect.left = scalerCropRegion->left;
- roi->rect.top = scalerCropRegion->top;
- roi->rect.width = scalerCropRegion->width;
- roi->rect.height = scalerCropRegion->height;
+ int32_t roi_x_max = roi->rect.width + roi->rect.left;
+ int32_t roi_y_max = roi->rect.height + roi->rect.top;
+ int32_t crop_x_max = scalerCropRegion->width + scalerCropRegion->left;
+ int32_t crop_y_max = scalerCropRegion->height + scalerCropRegion->top;
+ if ((roi_x_max < scalerCropRegion->left) ||
+ (roi_y_max < scalerCropRegion->top) ||
+ (roi->rect.left > crop_x_max) ||
+ (roi->rect.top > crop_y_max)){
+ return false;
+ }
+ if (roi->rect.left < scalerCropRegion->left) {
+ roi->rect.left = scalerCropRegion->left;
+ }
+ if (roi->rect.top < scalerCropRegion->top) {
+ roi->rect.top = scalerCropRegion->top;
+ }
+ if (roi_x_max > crop_x_max) {
+ roi_x_max = crop_x_max;
+ }
+ if (roi_y_max > crop_y_max) {
+ roi_y_max = crop_y_max;
+ }
+ roi->rect.width = roi_x_max - roi->rect.left;
+ roi->rect.height = roi_y_max - roi->rect.top;
+ return true;
}
/*===========================================================================
@@ -3774,10 +3790,7 @@
}
cam_crop_region_t scalerCropRegion;
- scalerCropRegion.left = 0;
- scalerCropRegion.top = 0;
- scalerCropRegion.width = gCamCapability[mCameraId]->active_array_size.width;
- scalerCropRegion.height = gCamCapability[mCameraId]->active_array_size.height;
+ bool scalerCropSet = false;
if (frame_settings.exists(ANDROID_SCALER_CROP_REGION)) {
scalerCropRegion.left =
frame_settings.find(ANDROID_SCALER_CROP_REGION).data.i32[0];
@@ -3790,6 +3803,7 @@
rc = AddSetParmEntryToBatch(mParameters,
CAM_INTF_META_SCALER_CROP_REGION,
sizeof(scalerCropRegion), &scalerCropRegion);
+ scalerCropSet = true;
}
if (frame_settings.exists(ANDROID_SENSOR_EXPOSURE_TIME)) {
@@ -3949,32 +3963,44 @@
sizeof(lensShadingMapMode), &lensShadingMapMode);
}
- cam_area_t roi;
- convertFromCropRegion(&roi, &scalerCropRegion);
if (frame_settings.exists(ANDROID_CONTROL_AE_REGIONS)) {
- intersectWithRegions(&roi, request->settings, ANDROID_CONTROL_AE_REGIONS);
+ cam_area_t roi;
+ bool reset = true;
+ convertFromRegions(&roi, request->settings, ANDROID_CONTROL_AE_REGIONS);
+ if (scalerCropSet) {
+ reset = resetIfNeededROI(&roi, &scalerCropRegion);
+ }
+ if (reset) {
+ rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AEC_ROI,
+ sizeof(roi), &roi);
+ }
}
- rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AEC_ROI,
- sizeof(roi), &roi);
- convertFromCropRegion(&roi, &scalerCropRegion);
if (frame_settings.exists(ANDROID_CONTROL_AF_REGIONS)) {
- intersectWithRegions(&roi, request->settings, ANDROID_CONTROL_AF_REGIONS);
+ cam_area_t roi;
+ bool reset = true;
+ convertFromRegions(&roi, request->settings, ANDROID_CONTROL_AF_REGIONS);
+ if (scalerCropSet) {
+ reset = resetIfNeededROI(&roi, &scalerCropRegion);
+ }
+ if (reset) {
+ rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AF_ROI,
+ sizeof(roi), &roi);
+ }
}
- rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AF_ROI,
- sizeof(roi), &roi);
- roi.rect.left = 0;
- roi.rect.top = 0;
- roi.rect.width = gCamCapability[mCameraId]->active_array_size.width;
- roi.rect.height = gCamCapability[mCameraId]->active_array_size.height;
- roi.weight = 1;
if (frame_settings.exists(ANDROID_CONTROL_AWB_REGIONS)) {
- intersectWithRegions(&roi, request->settings, ANDROID_CONTROL_AWB_REGIONS);
+ cam_area_t roi;
+ bool reset = true;
+ convertFromRegions(&roi, request->settings, ANDROID_CONTROL_AWB_REGIONS);
+ if (scalerCropSet) {
+ reset = resetIfNeededROI(&roi, &scalerCropRegion);
+ }
+ if (reset) {
+ rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AWB_REGIONS,
+ sizeof(roi), &roi);
+ }
}
- rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AWB_REGIONS,
- sizeof(roi), &roi);
-
return rc;
}
diff --git a/QCamera2/HAL3/QCamera3HWI.h b/QCamera2/HAL3/QCamera3HWI.h
index 76ee19d..aa441fd 100755
--- a/QCamera2/HAL3/QCamera3HWI.h
+++ b/QCamera2/HAL3/QCamera3HWI.h
@@ -103,9 +103,9 @@
static void makeOverridesList(cam_scene_mode_overrides_t* overridesTable, uint8_t size,
uint8_t* overridesList, uint8_t* supported_indexes, int camera_id);
static void convertToRegions(cam_rect_t rect, int32_t* region, int weight);
- static void intersectWithRegions(cam_area_t* roi, const camera_metadata_t *settings,
+ static void convertFromRegions(cam_area_t* roi, const camera_metadata_t *settings,
uint32_t tag);
- static void convertFromCropRegion(cam_area_t* roi, const cam_crop_region_t* scalerCropRegion);
+ static bool resetIfNeededROI(cam_area_t* roi, const cam_crop_region_t* scalerCropRegion);
static void convertLandmarks(cam_face_detection_info_t face, int32_t* landmarks);
static void postproc_channel_cb_routine(mm_camera_super_buf_t *recvd_frame,
void *userdata);