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

Commit 088308a6 authored by Zhijun He's avatar Zhijun He Committed by Android (Google) Code Review
Browse files

Merge "Camera2/3: Cleanup the jpeg buffer size calcaulation logic" into lmp-dev

parents edf10398 28c9b6f2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ status_t CallbackProcessor::updateStream(const Parameters &params) {
                callbackFormat, params.previewFormat);
        res = device->createStream(mCallbackWindow,
                params.previewWidth, params.previewHeight,
                callbackFormat, 0, &mCallbackStreamId);
                callbackFormat, &mCallbackStreamId);
        if (res != OK) {
            ALOGE("%s: Camera %d: Can't create output stream for callbacks: "
                    "%s (%d)", __FUNCTION__, mId,
+6 −9
Original line number Diff line number Diff line
@@ -73,11 +73,10 @@ status_t JpegProcessor::updateStream(const Parameters &params) {
    }

    // Find out buffer size for JPEG
    camera_metadata_ro_entry_t maxJpegSize =
            params.staticInfo(ANDROID_JPEG_MAX_SIZE);
    if (maxJpegSize.count == 0) {
        ALOGE("%s: Camera %d: Can't find ANDROID_JPEG_MAX_SIZE!",
                __FUNCTION__, mId);
    ssize_t maxJpegSize = device->getJpegBufferSize(params.pictureWidth, params.pictureHeight);
    if (maxJpegSize <= 0) {
        ALOGE("%s: Camera %d: Jpeg buffer size (%zu) is invalid ",
                __FUNCTION__, mId, maxJpegSize);
        return INVALID_OPERATION;
    }

@@ -91,8 +90,7 @@ status_t JpegProcessor::updateStream(const Parameters &params) {
        mCaptureConsumer->setName(String8("Camera2Client::CaptureConsumer"));
        mCaptureWindow = new Surface(producer);
        // Create memory for API consumption
        mCaptureHeap = new MemoryHeapBase(maxJpegSize.data.i32[0], 0,
                                       "Camera2Client::CaptureHeap");
        mCaptureHeap = new MemoryHeapBase(maxJpegSize, 0, "Camera2Client::CaptureHeap");
        if (mCaptureHeap->getSize() == 0) {
            ALOGE("%s: Camera %d: Unable to allocate memory for capture",
                    __FUNCTION__, mId);
@@ -134,8 +132,7 @@ status_t JpegProcessor::updateStream(const Parameters &params) {
        // Create stream for HAL production
        res = device->createStream(mCaptureWindow,
                params.pictureWidth, params.pictureHeight,
                HAL_PIXEL_FORMAT_BLOB, maxJpegSize.data.i32[0],
                &mCaptureStreamId);
                HAL_PIXEL_FORMAT_BLOB, &mCaptureStreamId);
        if (res != OK) {
            ALOGE("%s: Camera %d: Can't create output stream for capture: "
                    "%s (%d)", __FUNCTION__, mId,
+2 −3
Original line number Diff line number Diff line
@@ -181,8 +181,7 @@ status_t StreamingProcessor::updatePreviewStream(const Parameters &params) {
    if (mPreviewStreamId == NO_STREAM) {
        res = device->createStream(mPreviewWindow,
                params.previewWidth, params.previewHeight,
                CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, 0,
                &mPreviewStreamId);
                CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, &mPreviewStreamId);
        if (res != OK) {
            ALOGE("%s: Camera %d: Unable to create preview stream: %s (%d)",
                    __FUNCTION__, mId, strerror(-res), res);
@@ -385,7 +384,7 @@ status_t StreamingProcessor::updateRecordingStream(const Parameters &params) {
        mRecordingFrameCount = 0;
        res = device->createStream(mRecordingWindow,
                params.videoWidth, params.videoHeight,
                CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, 0, &mRecordingStreamId);
                CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, &mRecordingStreamId);
        if (res != OK) {
            ALOGE("%s: Camera %d: Can't create output stream for recording: "
                    "%s (%d)", __FUNCTION__, mId,
+1 −2
Original line number Diff line number Diff line
@@ -183,8 +183,7 @@ status_t ZslProcessor::updateStream(const Parameters &params) {
                (int)HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
        res = device->createStream(mZslWindow,
                params.fastInfo.arrayWidth, params.fastInfo.arrayHeight,
                streamType, 0,
                &mZslStreamId);
                streamType, &mZslStreamId);
        if (res != OK) {
            ALOGE("%s: Camera %d: Can't create output stream for ZSL: "
                    "%s (%d)", __FUNCTION__, mId,
+1 −17
Original line number Diff line number Diff line
@@ -384,23 +384,7 @@ status_t CameraDeviceClient::createStream(int width, int height, int format,
    // after each call, but only once we are done with all.

    int streamId = -1;
    if (format == HAL_PIXEL_FORMAT_BLOB) {
        // JPEG buffers need to be sized for maximum possible compressed size
        CameraMetadata staticInfo = mDevice->info();
        camera_metadata_entry_t entry = staticInfo.find(ANDROID_JPEG_MAX_SIZE);
        if (entry.count == 0) {
            ALOGE("%s: Camera %d: Can't find maximum JPEG size in "
                    "static metadata!", __FUNCTION__, mCameraId);
            return INVALID_OPERATION;
        }
        int32_t maxJpegSize = entry.data.i32[0];
        res = mDevice->createStream(anw, width, height, format, maxJpegSize,
                &streamId);
    } else {
        // All other streams are a known size
        res = mDevice->createStream(anw, width, height, format, /*size*/0,
                &streamId);
    }
    res = mDevice->createStream(anw, width, height, format, &streamId);

    if (res == OK) {
        mStreamMap.add(bufferProducer->asBinder(), streamId);
Loading