Merge "legacy camera api: Enable zsl if preview frame rate is supported." into sc-dev am: 84b903b0da
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/14526042
Change-Id: I733055791c2a0edb4aa372bc451e2be1360ef5d2
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
index bd2e7dc..80508e4 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
@@ -29,6 +29,7 @@
#include "Parameters.h"
#include "system/camera.h"
+#include <android-base/properties.h>
#include <android/hardware/ICamera.h>
#include <media/MediaProfiles.h>
#include <media/mediarecorder.h>
@@ -1247,6 +1248,7 @@
}
}
fastInfo.maxZslSize = maxPrivInputSize;
+ fastInfo.usedZslSize = maxPrivInputSize;
} else {
fastInfo.maxZslSize = {0, 0};
}
@@ -2047,12 +2049,33 @@
slowJpegMode = false;
Size pictureSize = { pictureWidth, pictureHeight };
- int64_t minFrameDurationNs = getJpegStreamMinFrameDurationNs(pictureSize);
- if (previewFpsRange[1] > 1e9/minFrameDurationNs + FPS_MARGIN) {
+ bool zslFrameRateSupported = false;
+ int64_t jpegMinFrameDurationNs = getJpegStreamMinFrameDurationNs(pictureSize);
+ if (previewFpsRange[1] > 1e9/jpegMinFrameDurationNs + FPS_MARGIN) {
slowJpegMode = true;
}
- if (isDeviceZslSupported || slowJpegMode ||
- property_get_bool("camera.disable_zsl_mode", false)) {
+ if (isZslReprocessPresent) {
+ unsigned int firstApiLevel =
+ android::base::GetUintProperty<unsigned int>("ro.product.first_api_level", 0);
+ Size chosenSize;
+ if ((firstApiLevel >= __ANDROID_API_S__) &&
+ !android::base::GetBoolProperty("ro.camera.enableCamera1MaxZsl", false)) {
+ chosenSize = pictureSize;
+ } else {
+ // follow old behavior of keeping max zsl size as the input / output
+ // zsl stream size
+ chosenSize = fastInfo.maxZslSize;
+ }
+ int64_t zslMinFrameDurationNs = getZslStreamMinFrameDurationNs(chosenSize);
+ if (zslMinFrameDurationNs > 0 &&
+ previewFpsRange[1] <= (1e9/zslMinFrameDurationNs + FPS_MARGIN)) {
+ zslFrameRateSupported = true;
+ fastInfo.usedZslSize = chosenSize;
+ }
+ }
+
+ if (isDeviceZslSupported || slowJpegMode || !zslFrameRateSupported ||
+ android::base::GetBoolProperty("camera.disable_zsl_mode", false)) {
allowZslMode = false;
} else {
allowZslMode = isZslReprocessPresent;
@@ -3056,6 +3079,10 @@
return getMinFrameDurationNs(size, HAL_PIXEL_FORMAT_BLOB);
}
+int64_t Parameters::getZslStreamMinFrameDurationNs(Parameters::Size size) {
+ return getMinFrameDurationNs(size, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED);
+}
+
int64_t Parameters::getMinFrameDurationNs(Parameters::Size size, int fmt) {
const int STREAM_DURATION_SIZE = 4;
const int STREAM_FORMAT_OFFSET = 0;
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h
index 02ac638..e2f8d011 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.h
+++ b/services/camera/libcameraservice/api1/client2/Parameters.h
@@ -248,6 +248,7 @@
bool useFlexibleYuv;
Size maxJpegSize;
Size maxZslSize;
+ Size usedZslSize;
bool supportsPreferredConfigs;
} fastInfo;
@@ -426,6 +427,11 @@
// return -1 if input jpeg size cannot be found in supported size list
int64_t getJpegStreamMinFrameDurationNs(Parameters::Size size);
+ // Helper function to get minimum frame duration for a
+ // IMPLEMENTATION_DEFINED stream of size 'size'
+ // return -1 if input size cannot be found in supported size list
+ int64_t getZslStreamMinFrameDurationNs(Parameters::Size size);
+
// Helper function to get minimum frame duration for a size/format combination
// return -1 if input size/format combination cannot be found.
int64_t getMinFrameDurationNs(Parameters::Size size, int format);
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
index 8e598f1..1321e6b 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
@@ -235,8 +235,8 @@
}
if (mInputStreamId == NO_STREAM) {
- res = device->createInputStream(params.fastInfo.maxZslSize.width,
- params.fastInfo.maxZslSize.height, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
+ res = device->createInputStream(params.fastInfo.usedZslSize.width,
+ params.fastInfo.usedZslSize.height, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
/*isMultiResolution*/false, &mInputStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create input stream: "
@@ -258,8 +258,8 @@
mProducer->setName(String8("Camera2-ZslRingBufferConsumer"));
sp<Surface> outSurface = new Surface(producer);
- res = device->createStream(outSurface, params.fastInfo.maxZslSize.width,
- params.fastInfo.maxZslSize.height, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
+ res = device->createStream(outSurface, params.fastInfo.usedZslSize.width,
+ params.fastInfo.usedZslSize.height, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
HAL_DATASPACE_UNKNOWN, CAMERA_STREAM_ROTATION_0, &mZslStreamId,
String8(), std::unordered_set<int32_t>{ANDROID_SENSOR_PIXEL_MODE_DEFAULT});
if (res != OK) {