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

Commit 4146f9b6 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Android Git Automerger
Browse files

am 515fd6b7: am 4327df2a: Merge "Camera: Allocate correctly-sized buffers for...

am 515fd6b7: am 4327df2a: Merge "Camera: Allocate correctly-sized buffers for DEPTH_POINT_CLOUD" into mnc-dev

* commit '515fd6b7':
  Camera: Allocate correctly-sized buffers for DEPTH_POINT_CLOUD
parents fb5d2674 515fd6b7
Loading
Loading
Loading
Loading
+30 −7
Original line number Original line Diff line number Diff line
@@ -370,7 +370,7 @@ ssize_t Camera3Device::getJpegBufferSize(uint32_t width, uint32_t height) const
    // Get max jpeg size (area-wise).
    // Get max jpeg size (area-wise).
    Size maxJpegResolution = getMaxJpegResolution();
    Size maxJpegResolution = getMaxJpegResolution();
    if (maxJpegResolution.width == 0) {
    if (maxJpegResolution.width == 0) {
        ALOGE("%s: Camera %d: Can't find find valid available jpeg sizes in static metadata!",
        ALOGE("%s: Camera %d: Can't find valid available jpeg sizes in static metadata!",
                __FUNCTION__, mId);
                __FUNCTION__, mId);
        return BAD_VALUE;
        return BAD_VALUE;
    }
    }
@@ -397,6 +397,21 @@ ssize_t Camera3Device::getJpegBufferSize(uint32_t width, uint32_t height) const
    return jpegBufferSize;
    return jpegBufferSize;
}
}


ssize_t Camera3Device::getPointCloudBufferSize() const {
    const int FLOATS_PER_POINT=4;
    camera_metadata_ro_entry maxPointCount = mDeviceInfo.find(ANDROID_DEPTH_MAX_DEPTH_SAMPLES);
    if (maxPointCount.count == 0) {
        ALOGE("%s: Camera %d: Can't find maximum depth point cloud size in static metadata!",
                __FUNCTION__, mId);
        return BAD_VALUE;
    }
    ssize_t maxBytesForPointCloud = sizeof(android_depth_points) +
            maxPointCount.data.i32[0] * sizeof(float) * FLOATS_PER_POINT;
    return maxBytesForPointCloud;
}



status_t Camera3Device::dump(int fd, const Vector<String16> &args) {
status_t Camera3Device::dump(int fd, const Vector<String16> &args) {
    ATRACE_CALL();
    ATRACE_CALL();
    (void)args;
    (void)args;
@@ -865,14 +880,22 @@ status_t Camera3Device::createStream(sp<Surface> consumer,


    sp<Camera3OutputStream> newStream;
    sp<Camera3OutputStream> newStream;
    if (format == HAL_PIXEL_FORMAT_BLOB) {
    if (format == HAL_PIXEL_FORMAT_BLOB) {
        ssize_t jpegBufferSize = getJpegBufferSize(width, height);
        ssize_t blobBufferSize;
        if (jpegBufferSize <= 0) {
        if (dataSpace != HAL_DATASPACE_DEPTH) {
            SET_ERR_L("Invalid jpeg buffer size %zd", jpegBufferSize);
            blobBufferSize = getJpegBufferSize(width, height);
            if (blobBufferSize <= 0) {
                SET_ERR_L("Invalid jpeg buffer size %zd", blobBufferSize);
                return BAD_VALUE;
                return BAD_VALUE;
            }
            }

        } else {
            blobBufferSize = getPointCloudBufferSize();
            if (blobBufferSize <= 0) {
                SET_ERR_L("Invalid point cloud buffer size %zd", blobBufferSize);
                return BAD_VALUE;
            }
        }
        newStream = new Camera3OutputStream(mNextStreamId, consumer,
        newStream = new Camera3OutputStream(mNextStreamId, consumer,
                width, height, jpegBufferSize, format, dataSpace, rotation);
                width, height, blobBufferSize, format, dataSpace, rotation);
    } else {
    } else {
        newStream = new Camera3OutputStream(mNextStreamId, consumer,
        newStream = new Camera3OutputStream(mNextStreamId, consumer,
                width, height, format, dataSpace, rotation);
                width, height, format, dataSpace, rotation);
+1 −0
Original line number Original line Diff line number Diff line
@@ -146,6 +146,7 @@ class Camera3Device :
    virtual uint32_t getDeviceVersion();
    virtual uint32_t getDeviceVersion();


    virtual ssize_t getJpegBufferSize(uint32_t width, uint32_t height) const;
    virtual ssize_t getJpegBufferSize(uint32_t width, uint32_t height) const;
    ssize_t getPointCloudBufferSize() const;


    // Methods called by subclasses
    // Methods called by subclasses
    void             notifyStatus(bool idle); // updates from StatusTracker
    void             notifyStatus(bool idle); // updates from StatusTracker