Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b79f10f authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Automerger Merge Worker
Browse files

Merge "legacy camera api: Enable zsl if preview frame rate is supported." into...

Merge "legacy camera api: Enable zsl if preview frame rate is supported." into sc-dev am: 84b903b0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/14526042

Change-Id: I733055791c2a0edb4aa372bc451e2be1360ef5d2
parents d553ef07 84b903b0
Loading
Loading
Loading
Loading
+31 −4
Original line number Diff line number Diff line
@@ -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 @@ status_t Parameters::buildFastInfo(CameraDeviceBase *device) {
            }
        }
        fastInfo.maxZslSize = maxPrivInputSize;
        fastInfo.usedZslSize = maxPrivInputSize;
    } else {
        fastInfo.maxZslSize = {0, 0};
    }
@@ -2047,12 +2049,33 @@ status_t Parameters::set(const String8& paramString) {

    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 @@ int64_t Parameters::getJpegStreamMinFrameDurationNs(Parameters::Size size) {
    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;
+6 −0
Original line number Diff line number Diff line
@@ -248,6 +248,7 @@ struct Parameters {
        bool useFlexibleYuv;
        Size maxJpegSize;
        Size maxZslSize;
        Size usedZslSize;
        bool supportsPreferredConfigs;
    } fastInfo;

@@ -426,6 +427,11 @@ private:
    // 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);
+4 −4
Original line number Diff line number Diff line
@@ -235,8 +235,8 @@ status_t ZslProcessor::updateStream(const Parameters &params) {
    }

    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 @@ status_t ZslProcessor::updateStream(const Parameters &params) {
        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) {