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

Commit f8d6a2a8 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6108108 from 1bd7d377 to rvc-release

Change-Id: I1636f0be2d9a74b11bc9a23708c311919a2000ab
parents 5cc4c1b2 1bd7d377
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
// #define LOG_NDEBUG 0

#define LOG_TAG "Camera2-Metadata"
#define ATRACE_TAG ATRACE_TAG_CAMERA
#include <utils/Log.h>
#include <utils/Trace.h>
#include <utils/Errors.h>

#include <binder/Parcel.h>
@@ -38,11 +40,13 @@ CameraMetadata::CameraMetadata() :
CameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity) :
        mLocked(false)
{
    ATRACE_CALL();
    mBuffer = allocate_camera_metadata(entryCapacity, dataCapacity);
}

CameraMetadata::CameraMetadata(const CameraMetadata &other) :
        mLocked(false) {
    ATRACE_CALL();
    mBuffer = clone_camera_metadata(other.mBuffer);
}

@@ -104,6 +108,7 @@ camera_metadata_t* CameraMetadata::release() {
}

void CameraMetadata::clear() {
    ATRACE_CALL();
    if (mLocked) {
        ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
        return;
@@ -115,6 +120,7 @@ void CameraMetadata::clear() {
}

void CameraMetadata::acquire(camera_metadata_t *buffer) {
    ATRACE_CALL();
    if (mLocked) {
        ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
        return;
@@ -128,6 +134,7 @@ void CameraMetadata::acquire(camera_metadata_t *buffer) {
}

void CameraMetadata::acquire(CameraMetadata &other) {
    ATRACE_CALL();
    if (mLocked) {
        ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
        return;
@@ -136,10 +143,12 @@ void CameraMetadata::acquire(CameraMetadata &other) {
}

status_t CameraMetadata::append(const CameraMetadata &other) {
    ATRACE_CALL();
    return append(other.mBuffer);
}

status_t CameraMetadata::append(const camera_metadata_t* other) {
    ATRACE_CALL();
    if (mLocked) {
        ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
        return INVALID_OPERATION;
@@ -161,6 +170,7 @@ bool CameraMetadata::isEmpty() const {
}

status_t CameraMetadata::sort() {
    ATRACE_CALL();
    if (mLocked) {
        ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
        return INVALID_OPERATION;
@@ -291,6 +301,7 @@ status_t CameraMetadata::update(const camera_metadata_ro_entry &entry) {

status_t CameraMetadata::updateImpl(uint32_t tag, const void *data,
        size_t data_count) {
    ATRACE_CALL();
    status_t res;
    if (mLocked) {
        ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
@@ -348,11 +359,13 @@ status_t CameraMetadata::updateImpl(uint32_t tag, const void *data,
}

bool CameraMetadata::exists(uint32_t tag) const {
    ATRACE_CALL();
    camera_metadata_ro_entry entry;
    return find_camera_metadata_ro_entry(mBuffer, tag, &entry) == 0;
}

camera_metadata_entry_t CameraMetadata::find(uint32_t tag) {
    ATRACE_CALL();
    status_t res;
    camera_metadata_entry entry;
    if (mLocked) {
@@ -369,6 +382,7 @@ camera_metadata_entry_t CameraMetadata::find(uint32_t tag) {
}

camera_metadata_ro_entry_t CameraMetadata::find(uint32_t tag) const {
    ATRACE_CALL();
    status_t res;
    camera_metadata_ro_entry entry;
    res = find_camera_metadata_ro_entry(mBuffer, tag, &entry);
@@ -380,6 +394,7 @@ camera_metadata_ro_entry_t CameraMetadata::find(uint32_t tag) const {
}

status_t CameraMetadata::erase(uint32_t tag) {
    ATRACE_CALL();
    camera_metadata_entry_t entry;
    status_t res;
    if (mLocked) {
@@ -410,6 +425,7 @@ status_t CameraMetadata::erase(uint32_t tag) {

status_t CameraMetadata::removePermissionEntries(metadata_vendor_id_t vendorId,
        std::vector<int32_t> *tagsRemoved) {
    ATRACE_CALL();
    uint32_t tagCount = 0;
    std::vector<uint32_t> tagsToRemove;

@@ -486,6 +502,7 @@ void CameraMetadata::dump(int fd, int verbosity, int indentation) const {
}

status_t CameraMetadata::resizeIfNeeded(size_t extraEntries, size_t extraData) {
    ATRACE_CALL();
    if (mBuffer == NULL) {
        mBuffer = allocate_camera_metadata(extraEntries * 2, extraData * 2);
        if (mBuffer == NULL) {
@@ -525,7 +542,7 @@ status_t CameraMetadata::resizeIfNeeded(size_t extraEntries, size_t extraData) {

status_t CameraMetadata::readFromParcel(const Parcel& data,
                                        camera_metadata_t** out) {

    ATRACE_CALL();
    status_t err = OK;

    camera_metadata_t* metadata = NULL;
@@ -616,6 +633,7 @@ status_t CameraMetadata::readFromParcel(const Parcel& data,

status_t CameraMetadata::writeToParcel(Parcel& data,
                                       const camera_metadata_t* metadata) {
    ATRACE_CALL();
    status_t res = OK;

    /**
@@ -710,7 +728,7 @@ status_t CameraMetadata::writeToParcel(Parcel& data,
}

status_t CameraMetadata::readFromParcel(const Parcel *parcel) {

    ATRACE_CALL();
    ALOGV("%s: parcel = %p", __FUNCTION__, parcel);

    status_t res = OK;
@@ -742,7 +760,7 @@ status_t CameraMetadata::readFromParcel(const Parcel *parcel) {
}

status_t CameraMetadata::writeToParcel(Parcel *parcel) const {

    ATRACE_CALL();
    ALOGV("%s: parcel = %p", __FUNCTION__, parcel);

    if (parcel == NULL) {
@@ -771,7 +789,7 @@ void CameraMetadata::swap(CameraMetadata& other) {

status_t CameraMetadata::getTagFromName(const char *name,
        const VendorTagDescriptor* vTags, uint32_t *tag) {

    ATRACE_CALL();
    if (name == nullptr || tag == nullptr) return BAD_VALUE;

    size_t nameLength = strlen(name);
+7 −0
Original line number Diff line number Diff line
@@ -2112,6 +2112,13 @@ CameraProviderManager::ProviderInfo::DeviceInfo3::DeviceInfo3(const std::string&
                        CameraProviderManager::statusToString(status), status);
                return;
            }

            res = camera3::ZoomRatioMapper::overrideZoomRatioTags(
                    &mPhysicalCameraCharacteristics[id], &mSupportNativeZoomRatio);
            if (OK != res) {
                ALOGE("%s: Unable to override zoomRatio related tags: %s (%d)",
                        __FUNCTION__, strerror(-res), res);
            }
        }
    }

+2 −12
Original line number Diff line number Diff line
@@ -161,14 +161,9 @@ status_t Camera3Device::initialize(sp<CameraProviderManager> manager, const Stri
                }
            }

            res = mZoomRatioMappers[physicalId].initZoomRatioTags(
            mZoomRatioMappers[physicalId] = ZoomRatioMapper(
                    &mPhysicalDeviceInfoMap[physicalId],
                    mSupportNativeZoomRatio, usePrecorrectArray);
            if (res != OK) {
                SET_ERR_L("Failed to initialize camera %s's zoomRatio tags: %s (%d)",
                        physicalId.c_str(), strerror(-res), res);
                return res;
            }
        }
    }

@@ -353,13 +348,8 @@ status_t Camera3Device::initializeCommonLocked() {
        }
    }

    res = mZoomRatioMappers[mId.c_str()].initZoomRatioTags(&mDeviceInfo,
    mZoomRatioMappers[mId.c_str()] = ZoomRatioMapper(&mDeviceInfo,
            mSupportNativeZoomRatio, usePrecorrectArray);
    if (res != OK) {
        SET_ERR_L("Failed to initialize zoomRatio tags: %s (%d)",
                strerror(-res), res);
        return res;
    }

    return OK;
}
+8 −10
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ namespace android {

namespace camera3 {

ZoomRatioMapper::ZoomRatioMapper() : mHalSupportsZoomRatio(false) {
}

status_t ZoomRatioMapper::initZoomRatioInTemplate(CameraMetadata *request) {
    camera_metadata_entry_t entry;
@@ -117,19 +115,17 @@ status_t ZoomRatioMapper::overrideZoomRatioTags(
    return OK;
}

status_t ZoomRatioMapper::initZoomRatioTags(const CameraMetadata* deviceInfo,
ZoomRatioMapper::ZoomRatioMapper(const CameraMetadata* deviceInfo,
        bool supportNativeZoomRatio, bool usePrecorrectArray) {
    std::lock_guard<std::mutex> lock(mMutex);

    camera_metadata_ro_entry_t entry;

    entry = deviceInfo->find(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE);
    if (entry.count != 4) return BAD_VALUE;
    if (entry.count != 4) return;
    int32_t arrayW = entry.data.i32[2];
    int32_t arrayH = entry.data.i32[3];

    entry = deviceInfo->find(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE);
    if (entry.count != 4) return BAD_VALUE;
    if (entry.count != 4) return;
    int32_t activeW = entry.data.i32[2];
    int32_t activeH = entry.data.i32[3];

@@ -144,11 +140,12 @@ status_t ZoomRatioMapper::initZoomRatioTags(const CameraMetadata* deviceInfo,

    ALOGV("%s: array size: %d x %d, mHalSupportsZoomRatio %d",
            __FUNCTION__, mArrayWidth, mArrayHeight, mHalSupportsZoomRatio);
    return OK;
    mIsValid = true;
}

status_t ZoomRatioMapper::updateCaptureRequest(CameraMetadata* request) {
    std::lock_guard<std::mutex> lock(mMutex);
    if (!mIsValid) return INVALID_OPERATION;

    status_t res = OK;
    bool zoomRatioIs1 = true;
    camera_metadata_entry_t entry;
@@ -174,7 +171,8 @@ status_t ZoomRatioMapper::updateCaptureRequest(CameraMetadata* request) {
}

status_t ZoomRatioMapper::updateCaptureResult(CameraMetadata* result, bool requestedZoomRatioIs1) {
    std::lock_guard<std::mutex> lock(mMutex);
    if (!mIsValid) return INVALID_OPERATION;

    status_t res = OK;

    if (mHalSupportsZoomRatio && requestedZoomRatioIs1) {
+6 −15
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#include <utils/Errors.h>
#include <array>
#include <mutex>

#include "camera/CameraMetadata.h"
#include "device3/CoordinateMapper.h"
@@ -36,7 +35,9 @@ namespace camera3 {
 */
class ZoomRatioMapper : private CoordinateMapper {
  public:
    ZoomRatioMapper();
    ZoomRatioMapper() = default;
    ZoomRatioMapper(const CameraMetadata *deviceInfo,
            bool supportNativeZoomRatio, bool usePrecorrectArray);
    ZoomRatioMapper(const ZoomRatioMapper& other) :
            mHalSupportsZoomRatio(other.mHalSupportsZoomRatio),
            mArrayWidth(other.mArrayWidth), mArrayHeight(other.mArrayHeight) {}
@@ -52,16 +53,6 @@ class ZoomRatioMapper : private CoordinateMapper {
    static status_t overrideZoomRatioTags(
            CameraMetadata* deviceInfo, bool* supportNativeZoomRatio);

    /**
     * Initialize zoom ratio mapper with static metadata.
     *
     * Note:
     * This function may modify the static metadata with zoomRatio related
     * tags.
     */
    status_t initZoomRatioTags(const CameraMetadata *deviceInfo,
            bool supportNativeZoomRatio, bool usePrecorrectArray);

    /**
     * Update capture request to handle both cropRegion and zoomRatio.
     */
@@ -82,16 +73,16 @@ class ZoomRatioMapper : private CoordinateMapper {
    void scaleCoordinates(int32_t* coordPairs, int coordCount,
            float scaleRatio, ClampMode clamp);

    bool isValid() { return mIsValid; }
  private:
    // const after construction
    bool mHalSupportsZoomRatio;

    // active array / pre-correction array dimension
    int32_t mArrayWidth, mArrayHeight;

    mutable std::mutex mMutex;
    bool mIsValid = false;

    float deriveZoomRatio(const CameraMetadata* metadata);

    void scaleRects(int32_t* rects, int rectCount, float scaleRatio);

    status_t separateZoomFromCropLocked(CameraMetadata* metadata, bool isResult);
Loading