diff options
author | Alex Ray <aray@google.com> | 2013-05-07 14:31:02 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2013-05-07 15:28:34 -0700 |
commit | 4ad015003cbab4ee6889b803225648c76a156193 (patch) | |
tree | 0e01e99a6dfa7c442b1005e8e81cbe065adc6993 /services | |
parent | 84e391686d7eced293913d1d7993721224ee0ba1 (diff) | |
download | frameworks_av-4ad015003cbab4ee6889b803225648c76a156193.zip frameworks_av-4ad015003cbab4ee6889b803225648c76a156193.tar.gz frameworks_av-4ad015003cbab4ee6889b803225648c76a156193.tar.bz2 |
Camera2: FoV quirk crop regions
Bug: 8484377
Change-Id: I5ffcc20b68dc92b502acc9898e57f12cadb92848
Diffstat (limited to 'services')
-rw-r--r-- | services/camera/libcameraservice/camera2/Parameters.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp index b26cd09..b3d0984 100644 --- a/services/camera/libcameraservice/camera2/Parameters.cpp +++ b/services/camera/libcameraservice/camera2/Parameters.cpp @@ -2524,27 +2524,24 @@ status_t Parameters::calculatePictureFovs(float *horizFov, float *vertFov) * stream cropping. */ if (quirks.meteringCropRegion) { - /** - * All streams are the same in height, so narrower aspect ratios will - * get cropped on the sides. First find the largest (widest) aspect - * ratio, then calculate the crop of the still FOV based on that. - */ - float cropAspect = arrayAspect; - float aspects[] = { - stillAspect, - static_cast<float>(previewWidth) / previewHeight, - static_cast<float>(videoWidth) / videoHeight - }; - for (size_t i = 0; i < sizeof(aspects)/sizeof(aspects[0]); i++) { - if (cropAspect < aspects[i]) cropAspect = aspects[i]; + // Use max of preview and video as first crop + float previewAspect = static_cast<float>(previewWidth) / previewHeight; + float videoAspect = static_cast<float>(videoWidth) / videoHeight; + if (videoAspect > previewAspect) { + previewAspect = videoAspect; + } + // First crop sensor to preview aspect ratio + if (arrayAspect < previewAspect) { + vertCropFactor = arrayAspect / previewAspect; + } else { + horizCropFactor = previewAspect / arrayAspect; + } + // Second crop to still aspect ratio + if (stillAspect < previewAspect) { + horizCropFactor *= stillAspect / previewAspect; + } else { + vertCropFactor *= previewAspect / stillAspect; } - ALOGV("Widest crop aspect: %f", cropAspect); - // Horizontal crop of still is done based on fitting in the widest - // aspect ratio - horizCropFactor = stillAspect / cropAspect; - // Vertical crop is a function of the array aspect ratio and the - // widest aspect ratio. - vertCropFactor = arrayAspect / cropAspect; } else { /** * Crop are just a function of just the still/array relative aspect |