diff options
Diffstat (limited to 'camera/QCamera2/HAL3/QCamera3CropRegionMapper.cpp')
-rw-r--r-- | camera/QCamera2/HAL3/QCamera3CropRegionMapper.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/camera/QCamera2/HAL3/QCamera3CropRegionMapper.cpp b/camera/QCamera2/HAL3/QCamera3CropRegionMapper.cpp index 94a398b..4d6d8b2 100644 --- a/camera/QCamera2/HAL3/QCamera3CropRegionMapper.cpp +++ b/camera/QCamera2/HAL3/QCamera3CropRegionMapper.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2016, 2020, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,6 +34,7 @@ // Camera dependencies #include "QCamera3CropRegionMapper.h" #include "QCamera3HWI.h" +#include "math.h" extern "C" { #include "mm_camera_dbg.h" @@ -159,16 +160,23 @@ void QCamera3CropRegionMapper::toActiveArray(int32_t& crop_left, int32_t& crop_t void QCamera3CropRegionMapper::toSensor(int32_t& crop_left, int32_t& crop_top, int32_t& crop_width, int32_t& crop_height) { + float tmpLeft, tmpTop, tmpWidth, tmpHeight; + if (mSensorW == 0 || mSensorH == 0 || mActiveArrayW == 0 || mActiveArrayH == 0) { LOGE("sensor/active array sizes are not initialized!"); return; } - crop_left = crop_left * mSensorW / mActiveArrayW; - crop_top = crop_top * mSensorH / mActiveArrayH; - crop_width = crop_width * mSensorW / mActiveArrayW; - crop_height = crop_height * mSensorH / mActiveArrayH; + tmpLeft = (float)crop_left * mSensorW / mActiveArrayW; + tmpTop = (float)crop_top * mSensorH / mActiveArrayH; + tmpWidth = (float)crop_width * mSensorW / mActiveArrayW; + tmpHeight = (float)crop_height * mSensorH / mActiveArrayH; + + crop_left = ceil(tmpLeft); + crop_top = ceil(tmpTop); + crop_width = ceil(tmpWidth); + crop_height = ceil(tmpHeight); LOGD("before bounding left %d, top %d, width %d, height %d", crop_left, crop_top, crop_width, crop_height); |