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

Commit a1530f1b authored by Zhijun He's avatar Zhijun He
Browse files

Camera3: Update ZSL post-processing tags

Update ZSL processing tags according the still capture template
Also cache the request template to avoid extra cost of querying
into HAL every time.

Bug: 17463102
Change-Id: I2eeffefb0a4131c99a85dd3e4484cc6f0f025efa
parent 2b9530a7
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -244,6 +244,46 @@ int ZslProcessor3::getStreamId() const {
    return mZslStreamId;
}

status_t ZslProcessor3::updateRequestWithDefaultStillRequest(CameraMetadata &request) const {
    sp<Camera2Client> client = mClient.promote();
    if (client == 0) {
        ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
        return INVALID_OPERATION;
    }
    sp<Camera3Device> device =
        static_cast<Camera3Device*>(client->getCameraDevice().get());
    if (device == 0) {
        ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId);
        return INVALID_OPERATION;
    }

    CameraMetadata stillTemplate;
    device->createDefaultRequest(CAMERA3_TEMPLATE_STILL_CAPTURE, &stillTemplate);

    // Find some of the post-processing tags, and assign the value from template to the request.
    // Only check the aberration mode and noise reduction mode for now, as they are very important
    // for image quality.
    uint32_t postProcessingTags[] = {
            ANDROID_NOISE_REDUCTION_MODE,
            ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
            ANDROID_COLOR_CORRECTION_MODE,
            ANDROID_TONEMAP_MODE,
            ANDROID_SHADING_MODE,
            ANDROID_HOT_PIXEL_MODE,
            ANDROID_EDGE_MODE
    };

    camera_metadata_entry_t entry;
    for (size_t i = 0; i < sizeof(postProcessingTags) / sizeof(uint32_t); i++) {
        entry = stillTemplate.find(postProcessingTags[i]);
        if (entry.count > 0) {
            request.update(postProcessingTags[i], entry.data.u8, 1);
        }
    }

    return OK;
}

status_t ZslProcessor3::pushToReprocess(int32_t requestId) {
    ALOGV("%s: Send in reprocess request with id %d",
            __FUNCTION__, requestId);
@@ -369,6 +409,13 @@ status_t ZslProcessor3::pushToReprocess(int32_t requestId) {
            }
        }

        // Update post-processing settings
        res = updateRequestWithDefaultStillRequest(request);
        if (res != OK) {
            ALOGW("%s: Unable to update post-processing tags, the reprocessed image quality "
                    "may be compromised", __FUNCTION__);
        }

        mLatestCapturedRequest = request;
        res = client->getCameraDevice()->capture(request);
        if (res != OK ) {
+3 −0
Original line number Diff line number Diff line
@@ -135,6 +135,9 @@ class ZslProcessor3 :
    nsecs_t getCandidateTimestampLocked(size_t* metadataIdx) const;

    bool isFixedFocusMode(uint8_t afMode) const;

    // Update the post-processing metadata with the default still capture request template
    status_t updateRequestWithDefaultStillRequest(CameraMetadata &request) const;
};


+6 −0
Original line number Diff line number Diff line
@@ -1044,6 +1044,11 @@ status_t Camera3Device::createDefaultRequest(int templateId,
            return INVALID_OPERATION;
    }

    if (!mRequestTemplateCache[templateId].isEmpty()) {
        *request = mRequestTemplateCache[templateId];
        return OK;
    }

    const camera_metadata_t *rawRequest;
    ATRACE_BEGIN("camera3->construct_default_request_settings");
    rawRequest = mHal3Device->ops->construct_default_request_settings(
@@ -1055,6 +1060,7 @@ status_t Camera3Device::createDefaultRequest(int templateId,
        return DEAD_OBJECT;
    }
    *request = rawRequest;
    mRequestTemplateCache[templateId] = rawRequest;

    return OK;
}
+2 −0
Original line number Diff line number Diff line
@@ -174,6 +174,8 @@ class Camera3Device :

    CameraMetadata             mDeviceInfo;

    CameraMetadata             mRequestTemplateCache[CAMERA3_TEMPLATE_COUNT];

    uint32_t                   mDeviceVersion;

    enum Status {