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

Commit 0181fde7 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

Camera2/3: For still captures, use widest FPS range available.

Instead of using the application-selected preview FPS range for still
captures, select the widest FPS range advertised by the device and use
it for still captures instead, to give the HAL the widest range of exposure
values to choose from possible.

Bug: 10842868
Change-Id: I0e24f5eb713a4f8df116cd5979a84390cc0974d7
parent fbb2609f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -326,6 +326,10 @@ status_t Camera2Client::dump(int fd, const Vector<String16>& args) {
    result.appendFormat("    Video stabilization is %s\n",
            p.videoStabilization ? "enabled" : "disabled");

    result.appendFormat("    Selected still capture FPS range: %d - %d\n",
            p.fastInfo.bestStillCaptureFpsRange[0],
            p.fastInfo.bestStillCaptureFpsRange[1]);

    result.append("  Current streams:\n");
    result.appendFormat("    Preview stream ID: %d\n",
            getPreviewStreamId());
+38 −2
Original line number Diff line number Diff line
@@ -852,6 +852,33 @@ status_t Parameters::buildFastInfo() {
        arrayHeight = activeArraySize.data.i32[3];
    } else return NO_INIT;

    // We'll set the target FPS range for still captures to be as wide
    // as possible to give the HAL maximum latitude for exposure selection
    camera_metadata_ro_entry_t availableFpsRanges =
        staticInfo(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, 2);
    if (availableFpsRanges.count < 2 || availableFpsRanges.count % 2 != 0) {
        return NO_INIT;
    }

    int32_t bestStillCaptureFpsRange[2] = {
        availableFpsRanges.data.i32[0], availableFpsRanges.data.i32[1]
    };
    int32_t curRange =
            bestStillCaptureFpsRange[1] - bestStillCaptureFpsRange[0];
    for (size_t i = 2; i < availableFpsRanges.count; i += 2) {
        int32_t nextRange =
                availableFpsRanges.data.i32[i + 1] -
                availableFpsRanges.data.i32[i];
        if ( (nextRange > curRange) ||       // Maximize size of FPS range first
                (nextRange == curRange &&    // Then minimize low-end FPS
                 bestStillCaptureFpsRange[0] > availableFpsRanges.data.i32[i])) {

            bestStillCaptureFpsRange[0] = availableFpsRanges.data.i32[i];
            bestStillCaptureFpsRange[1] = availableFpsRanges.data.i32[i + 1];
            curRange = nextRange;
        }
    }

    camera_metadata_ro_entry_t availableFaceDetectModes =
        staticInfo(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, 0, 0,
                false);
@@ -971,6 +998,8 @@ status_t Parameters::buildFastInfo() {

    fastInfo.arrayWidth = arrayWidth;
    fastInfo.arrayHeight = arrayHeight;
    fastInfo.bestStillCaptureFpsRange[0] = bestStillCaptureFpsRange[0];
    fastInfo.bestStillCaptureFpsRange[1] = bestStillCaptureFpsRange[1];
    fastInfo.bestFaceDetectMode = bestFaceDetectMode;
    fastInfo.maxFaces = maxFaces;

@@ -1709,8 +1738,15 @@ status_t Parameters::updateRequest(CameraMetadata *request) const {
            &metadataMode, 1);
    if (res != OK) return res;

    camera_metadata_entry_t intent =
            request->find(ANDROID_CONTROL_CAPTURE_INTENT);
    if (intent.data.u8[0] == ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE) {
        res = request->update(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
                fastInfo.bestStillCaptureFpsRange, 2);
    } else {
        res = request->update(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
                previewFpsRange, 2);
    }
    if (res != OK) return res;

    uint8_t reqWbLock = autoWhiteBalanceLock ?
+1 −0
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ struct Parameters {
    struct DeviceInfo {
        int32_t arrayWidth;
        int32_t arrayHeight;
        int32_t bestStillCaptureFpsRange[2];
        uint8_t bestFaceDetectMode;
        int32_t maxFaces;
        struct OverrideModes {