Loading services/camera/libcameraservice/device3/Camera3OutputUtils.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -385,9 +385,8 @@ void sendCaptureResult( // Fix up result metadata to account for zoom ratio availabilities between // HAL and app. bool zoomRatioIs1 = cameraIdsWithZoom.find(states.cameraId) == cameraIdsWithZoom.end(); bool appUsesZoomRatio = !zoomRatioIs1 || useZoomRatio; res = states.zoomRatioMappers[states.cameraId].updateCaptureResult( &captureResult.mMetadata, appUsesZoomRatio); &captureResult.mMetadata, useZoomRatio, zoomRatioIs1); if (res != OK) { SET_ERR("Failed to update capture result zoom ratio metadata for frame %d: %s (%d)", frameNumber, strerror(-res), res); Loading Loading @@ -456,7 +455,8 @@ void sendCaptureResult( // Note: Physical camera continues to use SCALER_CROP_REGION to reflect // zoom levels. res = states.zoomRatioMappers[cameraId].updateCaptureResult( &physicalMetadata.mPhysicalCameraMetadata, /*appUsesZoomRatio*/ false); &physicalMetadata.mPhysicalCameraMetadata, /*zoomMethodIsRatio*/false, /*zoomRatioIs1*/false); if (res != OK) { SET_ERR("Failed to update camera %s's physical zoom ratio metadata for " "frame %d: %s(%d)", cameraId.c_str(), frameNumber, strerror(-res), res); Loading services/camera/libcameraservice/device3/ZoomRatioMapper.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,8 @@ status_t ZoomRatioMapper::updateCaptureRequest(CameraMetadata* request) { return res; } status_t ZoomRatioMapper::updateCaptureResult(CameraMetadata* result, bool useZoomRatio) { status_t ZoomRatioMapper::updateCaptureResult( CameraMetadata* result, bool zoomMethodIsRatio, bool zoomRatioIs1) { if (!mIsValid) return INVALID_OPERATION; status_t res = OK; Loading @@ -300,6 +301,8 @@ status_t ZoomRatioMapper::updateCaptureResult(CameraMetadata* result, bool useZo if (res != OK) { return res; } bool useZoomRatio = !zoomRatioIs1 || zoomMethodIsRatio; if (mHalSupportsZoomRatio && !useZoomRatio) { res = combineZoomAndCropLocked(result, true/*isResult*/, arrayWidth, arrayHeight); } else if (!mHalSupportsZoomRatio && useZoomRatio) { Loading @@ -312,6 +315,12 @@ status_t ZoomRatioMapper::updateCaptureResult(CameraMetadata* result, bool useZo } } if (flags::zoom_method()) { uint8_t zoomMethod = zoomMethodIsRatio ? ANDROID_CONTROL_ZOOM_METHOD_ZOOM_RATIO : ANDROID_CONTROL_ZOOM_METHOD_AUTO; result->update(ANDROID_CONTROL_ZOOM_METHOD, &zoomMethod, 1); } return res; } Loading services/camera/libcameraservice/device3/ZoomRatioMapper.h +3 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,9 @@ class ZoomRatioMapper : public CoordinateMapper { /** * Update capture result to handle both cropRegion and zoomRatio. */ status_t updateCaptureResult(CameraMetadata *request, bool useZoomRatio); status_t updateCaptureResult(CameraMetadata *request, bool zoomMethodIsRatio, bool zoomRatioIs1); public: // Visible for testing. Do not use concurently. void scaleCoordinates(int32_t* coordPairs, int coordCount, Loading services/camera/libcameraservice/tests/ZoomRatioTest.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -296,7 +296,8 @@ void subCropOverMaxDigitalZoomTest(bool usePreCorrectArray) { } metadata.update(ANDROID_SCALER_CROP_REGION, test2xCropRegion[index], 4); res = mapper.updateCaptureResult(&metadata, false/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false /*zoomMethodIsRatio*/, true/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_SCALER_CROP_REGION); ASSERT_EQ(entry.count, 4U); Loading Loading @@ -340,7 +341,8 @@ void subCropOverZoomRangeTest(bool usePreCorrectArray) { entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); EXPECT_NEAR(entry.data.f[0], 2.0f, kMaxAllowedRatioError); res = mapper.updateCaptureResult(&metadata, false/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false/*useZoomMethod*/, true/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); EXPECT_NEAR(entry.data.f[0], 1.0f, kMaxAllowedRatioError); Loading @@ -364,7 +366,8 @@ void subCropOverZoomRangeTest(bool usePreCorrectArray) { entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); EXPECT_NEAR(entry.data.f[0], 1.0f, kMaxAllowedRatioError); res = mapper.updateCaptureResult(&metadata, false/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false/*zoomMethodIsRatio*/, true/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_SCALER_CROP_REGION); ASSERT_EQ(entry.count, 4U); Loading Loading @@ -452,7 +455,8 @@ void subZoomOverZoomRangeTest(bool usePreCorrectArray) { entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); ASSERT_EQ(entry.data.f[0], zoomRatio); res = mapper.updateCaptureResult(&metadata, true/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false/*zoomMethodIsRatio*/, false/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_SCALER_CROP_REGION); ASSERT_EQ(entry.count, 4U); Loading Loading
services/camera/libcameraservice/device3/Camera3OutputUtils.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -385,9 +385,8 @@ void sendCaptureResult( // Fix up result metadata to account for zoom ratio availabilities between // HAL and app. bool zoomRatioIs1 = cameraIdsWithZoom.find(states.cameraId) == cameraIdsWithZoom.end(); bool appUsesZoomRatio = !zoomRatioIs1 || useZoomRatio; res = states.zoomRatioMappers[states.cameraId].updateCaptureResult( &captureResult.mMetadata, appUsesZoomRatio); &captureResult.mMetadata, useZoomRatio, zoomRatioIs1); if (res != OK) { SET_ERR("Failed to update capture result zoom ratio metadata for frame %d: %s (%d)", frameNumber, strerror(-res), res); Loading Loading @@ -456,7 +455,8 @@ void sendCaptureResult( // Note: Physical camera continues to use SCALER_CROP_REGION to reflect // zoom levels. res = states.zoomRatioMappers[cameraId].updateCaptureResult( &physicalMetadata.mPhysicalCameraMetadata, /*appUsesZoomRatio*/ false); &physicalMetadata.mPhysicalCameraMetadata, /*zoomMethodIsRatio*/false, /*zoomRatioIs1*/false); if (res != OK) { SET_ERR("Failed to update camera %s's physical zoom ratio metadata for " "frame %d: %s(%d)", cameraId.c_str(), frameNumber, strerror(-res), res); Loading
services/camera/libcameraservice/device3/ZoomRatioMapper.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,8 @@ status_t ZoomRatioMapper::updateCaptureRequest(CameraMetadata* request) { return res; } status_t ZoomRatioMapper::updateCaptureResult(CameraMetadata* result, bool useZoomRatio) { status_t ZoomRatioMapper::updateCaptureResult( CameraMetadata* result, bool zoomMethodIsRatio, bool zoomRatioIs1) { if (!mIsValid) return INVALID_OPERATION; status_t res = OK; Loading @@ -300,6 +301,8 @@ status_t ZoomRatioMapper::updateCaptureResult(CameraMetadata* result, bool useZo if (res != OK) { return res; } bool useZoomRatio = !zoomRatioIs1 || zoomMethodIsRatio; if (mHalSupportsZoomRatio && !useZoomRatio) { res = combineZoomAndCropLocked(result, true/*isResult*/, arrayWidth, arrayHeight); } else if (!mHalSupportsZoomRatio && useZoomRatio) { Loading @@ -312,6 +315,12 @@ status_t ZoomRatioMapper::updateCaptureResult(CameraMetadata* result, bool useZo } } if (flags::zoom_method()) { uint8_t zoomMethod = zoomMethodIsRatio ? ANDROID_CONTROL_ZOOM_METHOD_ZOOM_RATIO : ANDROID_CONTROL_ZOOM_METHOD_AUTO; result->update(ANDROID_CONTROL_ZOOM_METHOD, &zoomMethod, 1); } return res; } Loading
services/camera/libcameraservice/device3/ZoomRatioMapper.h +3 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,9 @@ class ZoomRatioMapper : public CoordinateMapper { /** * Update capture result to handle both cropRegion and zoomRatio. */ status_t updateCaptureResult(CameraMetadata *request, bool useZoomRatio); status_t updateCaptureResult(CameraMetadata *request, bool zoomMethodIsRatio, bool zoomRatioIs1); public: // Visible for testing. Do not use concurently. void scaleCoordinates(int32_t* coordPairs, int coordCount, Loading
services/camera/libcameraservice/tests/ZoomRatioTest.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -296,7 +296,8 @@ void subCropOverMaxDigitalZoomTest(bool usePreCorrectArray) { } metadata.update(ANDROID_SCALER_CROP_REGION, test2xCropRegion[index], 4); res = mapper.updateCaptureResult(&metadata, false/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false /*zoomMethodIsRatio*/, true/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_SCALER_CROP_REGION); ASSERT_EQ(entry.count, 4U); Loading Loading @@ -340,7 +341,8 @@ void subCropOverZoomRangeTest(bool usePreCorrectArray) { entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); EXPECT_NEAR(entry.data.f[0], 2.0f, kMaxAllowedRatioError); res = mapper.updateCaptureResult(&metadata, false/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false/*useZoomMethod*/, true/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); EXPECT_NEAR(entry.data.f[0], 1.0f, kMaxAllowedRatioError); Loading @@ -364,7 +366,8 @@ void subCropOverZoomRangeTest(bool usePreCorrectArray) { entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); EXPECT_NEAR(entry.data.f[0], 1.0f, kMaxAllowedRatioError); res = mapper.updateCaptureResult(&metadata, false/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false/*zoomMethodIsRatio*/, true/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_SCALER_CROP_REGION); ASSERT_EQ(entry.count, 4U); Loading Loading @@ -452,7 +455,8 @@ void subZoomOverZoomRangeTest(bool usePreCorrectArray) { entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO); ASSERT_EQ(entry.data.f[0], zoomRatio); res = mapper.updateCaptureResult(&metadata, true/*useZoomRatio*/); res = mapper.updateCaptureResult(&metadata, false/*zoomMethodIsRatio*/, false/*requestedZoomRatioIs1*/); ASSERT_EQ(res, OK); entry = metadata.find(ANDROID_SCALER_CROP_REGION); ASSERT_EQ(entry.count, 4U); Loading